sanitize server and protocol

This commit is contained in:
ThomasV 2015-02-25 17:14:31 +01:00
parent 48838be816
commit 761871b900
1 changed files with 9 additions and 0 deletions

View File

@ -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)