From 566b689ca61fde8397cdf0614163aa5e7f9a8c08 Mon Sep 17 00:00:00 2001
From: shortcutme <tamas@zeronet.io>
Date: Tue, 30 Jan 2018 13:59:18 +0100
Subject: [PATCH] Don't connect to private ip addresses in tor always mode

---
 src/Connection/Connection.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/Connection/Connection.py b/src/Connection/Connection.py
index 17865946..99ad632d 100644
--- a/src/Connection/Connection.py
+++ b/src/Connection/Connection.py
@@ -13,6 +13,7 @@ from Config import config
 from Debug import Debug
 from util import StreamingMsgpack
 from Crypt import CryptConnection
+from util import helper
 
 
 class Connection(object):
@@ -104,6 +105,8 @@ class Connection(object):
             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")
             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:
             self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)