Index: net/tools/testserver/testserver.py |
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py |
index 64619975787680a5c9a63db197cbfce70c653c8b..5d35c7d773d3da25f44d83c60ec790f18ecec874 100755 |
--- a/net/tools/testserver/testserver.py |
+++ b/net/tools/testserver/testserver.py |
@@ -64,6 +64,7 @@ SERVER_FTP = 1 |
SERVER_SYNC = 2 |
SERVER_TCP_ECHO = 3 |
SERVER_UDP_ECHO = 4 |
+SERVER_SAFEBROWSING = 5 |
# Using debug() seems to cause hangs on XP: see http://crbug.com/64515 . |
debug_output = sys.stderr |
@@ -2078,8 +2079,7 @@ def main(options, args): |
server = UDPEchoServer((host, port), UDPEchoHandler) |
print 'Echo UDP server started on port %d...' % server.server_port |
server_data['port'] = server.server_port |
- # means FTP Server |
- else: |
+ elif options.server_type == SERVER_FTP: |
my_data_dir = MakeDataDir() |
# Instantiate a dummy authorizer for managing 'virtual' users |
@@ -2103,6 +2103,19 @@ def main(options, args): |
server = pyftpdlib.ftpserver.FTPServer((host, port), ftp_handler) |
server_data['port'] = server.socket.getsockname()[1] |
print 'FTP server started on port %d...' % server_data['port'] |
+ elif options.server_type == SERVER_SAFEBROWSING: |
+ sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), |
+ '..', '..', '..', 'third_party', |
+ 'safe_browsing', 'testing')) |
+ import safebrowsing_test_server |
+ server = safebrowsing_test_server.SetupServer( |
+ options.data_dir, host, port, opt_enforce_caching=False, |
+ opt_validate_database=True) |
+ print 'Safebrowsing HTTP server started on port %d...' % server.server_port |
+ server_data['port'] = server.server_port |
+ else: |
+ print 'unknown server type', options.server_type |
+ return 1 |
# Notify the parent that we've started. (BaseServer subclasses |
# bind their sockets on construction.) |
@@ -2152,6 +2165,10 @@ if __name__ == '__main__': |
const=SERVER_UDP_ECHO, default=SERVER_HTTP, |
dest='server_type', |
help='start up a udp echo server.') |
+ option_parser.add_option('', '--safebrowsing', action='store_const', |
+ const=SERVER_SAFEBROWSING, default=SERVER_HTTP, |
+ dest='server_type', |
+ help='start up a safebrowsing test server.') |
option_parser.add_option('', '--log-to-console', action='store_const', |
const=True, default=False, |
dest='log_to_console', |