Don't connect to private ip addresses in tor always mode

This commit is contained in:
shortcutme 2018-01-30 13:59:18 +01:00
parent c2edbb30b5
commit 566b689ca6
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -13,6 +13,7 @@ from Config import config
from Debug import Debug from Debug import Debug
from util import StreamingMsgpack from util import StreamingMsgpack
from Crypt import CryptConnection from Crypt import CryptConnection
from util import helper
class Connection(object): class Connection(object):
@ -104,6 +105,8 @@ class Connection(object):
if not self.server.tor_manager or not self.server.tor_manager.enabled: if not self.server.tor_manager or not self.server.tor_manager.enabled:
raise Exception("Can't connect to onion addresses, no Tor controller present") raise Exception("Can't connect to onion addresses, no Tor controller present")
self.sock = self.server.tor_manager.createSocket(self.ip, self.port) self.sock = self.server.tor_manager.createSocket(self.ip, self.port)
elif config.tor == "always" and helper.isPrivateIp(self.ip) and self.ip not in config.ip_local:
raise Exception("Can't connect to local IPs in Tor: always mode")
else: else:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)