commit 761871b9006085473b337df0ea563189615b8090
parent 48838be816fc897a8687e95e6f86d8c40e5a9bfc
Author: ThomasV <thomasv@gitorious>
Date: Wed, 25 Feb 2015 17:14:31 +0100
sanitize server and protocol
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/lib/network.py b/lib/network.py
@@ -96,10 +96,19 @@ class Network(threading.Thread):
self.interfaces = {}
self.queue = Queue.Queue()
self.protocol = self.config.get('protocol','s')
+ # sanitize protocol
+ if self.protocol not in 'sght': self.protocol = 's'
self.running = False
# Server for addresses and transactions
self.default_server = self.config.get('server')
+ # Sanitize default server
+ try:
+ host, port, protocol = self.default_server.split(':')
+ assert protocol == self.protocol
+ int(port)
+ except:
+ self.default_server = None
if not self.default_server:
self.default_server = pick_random_server(self.protocol)