OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """This is a simple HTTP/FTP/SYNC/TCP/UDP/ server used for testing Chrome. | 6 """This is a simple HTTP/FTP/SYNC/TCP/UDP/ server used for testing Chrome. |
7 | 7 |
8 It supports several test URLs, as specified by the handlers in TestPageHandler. | 8 It supports several test URLs, as specified by the handlers in TestPageHandler. |
9 By default, it listens on an ephemeral port and sends the port number back to | 9 By default, it listens on an ephemeral port and sends the port number back to |
10 the originating process over a pipe. The originating process can specify an | 10 the originating process over a pipe. The originating process can specify an |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 self.port = port | 77 self.port = port |
78 self.websock_handlers = data_dir | 78 self.websock_handlers = data_dir |
79 self.scan_dir = None | 79 self.scan_dir = None |
80 self.allow_handlers_outside_root_dir = False | 80 self.allow_handlers_outside_root_dir = False |
81 self.websock_handlers_map_file = None | 81 self.websock_handlers_map_file = None |
82 self.cgi_directories = [] | 82 self.cgi_directories = [] |
83 self.is_executable_method = None | 83 self.is_executable_method = None |
84 self.allow_draft75 = False | 84 self.allow_draft75 = False |
85 self.strict = True | 85 self.strict = True |
86 | 86 |
87 # TODO(toyoshim): Support SSL and authenticates (http://crbug.com/137639) | |
88 self.use_tls = False | 87 self.use_tls = False |
89 self.private_key = None | 88 self.private_key = None |
90 self.certificate = None | 89 self.certificate = None |
90 self.tls_client_auth = False | |
91 self.tls_client_ca = None | 91 self.tls_client_ca = None |
92 self.use_basic_auth = False | 92 self.use_basic_auth = False |
93 | 93 |
94 class RecordingSSLSessionCache(object): | 94 class RecordingSSLSessionCache(object): |
95 """RecordingSSLSessionCache acts as a TLS session cache and maintains a log of | 95 """RecordingSSLSessionCache acts as a TLS session cache and maintains a log of |
96 lookups and inserts in order to test session cache behaviours.""" | 96 lookups and inserts in order to test session cache behaviours.""" |
97 | 97 |
98 def __init__(self): | 98 def __init__(self): |
99 self.log = [] | 99 self.log = [] |
100 | 100 |
(...skipping 2144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2245 server.policy_keys = options.policy_keys | 2245 server.policy_keys = options.policy_keys |
2246 server.policy_user = options.policy_user | 2246 server.policy_user = options.policy_user |
2247 server.gdata_auth_token = options.auth_token | 2247 server.gdata_auth_token = options.auth_token |
2248 elif options.server_type == SERVER_WEBSOCKET: | 2248 elif options.server_type == SERVER_WEBSOCKET: |
2249 # Launch pywebsocket via WebSocketServer. | 2249 # Launch pywebsocket via WebSocketServer. |
2250 logger = logging.getLogger() | 2250 logger = logging.getLogger() |
2251 logger.addHandler(logging.StreamHandler()) | 2251 logger.addHandler(logging.StreamHandler()) |
2252 # TODO(toyoshim): Remove following os.chdir. Currently this operation | 2252 # TODO(toyoshim): Remove following os.chdir. Currently this operation |
2253 # is required to work correctly. It should be fixed from pywebsocket side. | 2253 # is required to work correctly. It should be fixed from pywebsocket side. |
2254 os.chdir(MakeDataDir()) | 2254 os.chdir(MakeDataDir()) |
2255 server = WebSocketServer(WebSocketOptions(host, port, '.')) | 2255 websocket_options = WebSocketOptions(host, port, '.') |
2256 if options.cert_and_key_file: | |
2257 websocket_options.use_tls = True | |
2258 websocket_options.private_key = options.cert_and_key_file | |
2259 websocket_options.certificate = options.cert_and_key_file | |
2260 if options.ssl_client_auth: | |
2261 websocket_options.tls_client_auth = True | |
2262 if len(options.ssl_client_ca) != 1: | |
2263 print 'one trusted client CA file should be specified' | |
2264 return | |
Paweł Hajdan Jr.
2012/10/16 17:07:24
Those failure cases should make the server exit wi
Takashi Toyoshima
2012/10/17 01:18:42
Other paths need similar fix.
So, just leave TODO
| |
2265 if not os.path.isfile(options.ssl_client_ca[0]): | |
2266 print 'specified trusted client CA file not found: ' + \ | |
Paweł Hajdan Jr.
2012/10/16 17:07:24
nit: Use parentheses ('...' +
Takashi Toyoshima
2012/10/17 01:18:42
Done.
| |
2267 options.ssl_client_ca[0] + ' exiting...' | |
2268 return | |
2269 websocket_options.tls_client_ca = options.ssl_client_ca[0] | |
2270 server = WebSocketServer(websocket_options) | |
2256 print 'WebSocket server started on %s:%d...' % (host, server.server_port) | 2271 print 'WebSocket server started on %s:%d...' % (host, server.server_port) |
2257 server_data['port'] = server.server_port | 2272 server_data['port'] = server.server_port |
2258 elif options.server_type == SERVER_SYNC: | 2273 elif options.server_type == SERVER_SYNC: |
2259 xmpp_port = options.xmpp_port | 2274 xmpp_port = options.xmpp_port |
2260 server = SyncHTTPServer((host, port), xmpp_port, SyncPageHandler) | 2275 server = SyncHTTPServer((host, port), xmpp_port, SyncPageHandler) |
2261 print 'Sync HTTP server started on port %d...' % server.server_port | 2276 print 'Sync HTTP server started on port %d...' % server.server_port |
2262 print 'Sync XMPP server started on port %d...' % server.xmpp_port | 2277 print 'Sync XMPP server started on port %d...' % server.xmpp_port |
2263 server_data['port'] = server.server_port | 2278 server_data['port'] = server.server_port |
2264 server_data['xmpp_port'] = server.xmpp_port | 2279 server_data['xmpp_port'] = server.xmpp_port |
2265 elif options.server_type == SERVER_TCP_ECHO: | 2280 elif options.server_type == SERVER_TCP_ECHO: |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2438 dest='host', | 2453 dest='host', |
2439 help='Hostname or IP upon which the server will ' | 2454 help='Hostname or IP upon which the server will ' |
2440 'listen. Client connections will also only be ' | 2455 'listen. Client connections will also only be ' |
2441 'allowed from this address.') | 2456 'allowed from this address.') |
2442 option_parser.add_option('', '--auth-token', dest='auth_token', | 2457 option_parser.add_option('', '--auth-token', dest='auth_token', |
2443 help='Specify the auth token which should be used' | 2458 help='Specify the auth token which should be used' |
2444 'in the authorization header for GData.') | 2459 'in the authorization header for GData.') |
2445 options, args = option_parser.parse_args() | 2460 options, args = option_parser.parse_args() |
2446 | 2461 |
2447 sys.exit(main(options, args)) | 2462 sys.exit(main(options, args)) |
OLD | NEW |