Browse Source

Add option to bind to localhost.

By default the throughput server now binds to 0.0.0.0, but can be set to 127.0.0.1 using the '--localhost' option.
Steven Engler 5 years ago
parent
commit
21be2517ee
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/throughput_server.py

+ 5 - 1
src/throughput_server.py

@@ -14,9 +14,13 @@ if __name__ == '__main__':
 	parser = argparse.ArgumentParser(description='Test the network throughput (optionally through a proxy).')
 	parser.add_argument('port', type=int, help='listen on port')
 	parser.add_argument('--no-accel', action='store_true', help='don\'t use C acceleration (use pure Python)')
+	parser.add_argument('--localhost', action='store_true', help='bind to 127.0.0.1 instead of 0.0.0.0')
 	args = parser.parse_args()
 	#
-	endpoint = ('127.0.0.1', args.port)
+	if args.localhost:
+		endpoint = ('127.0.0.1', args.port)
+	else:
+		endpoint = ('0.0.0.0', args.port)
 	#
 	processes = []
 	processes_map = {}