From a95960321ad175f27a8ff4b6fe6435c7505c27ef Mon Sep 17 00:00:00 2001 From: j Date: Mon, 14 Mar 2016 14:25:51 +0100 Subject: [PATCH] dont use tor for ip hosts --- oml/tor_request.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/oml/tor_request.py b/oml/tor_request.py index 3a7cf3d..a9ae455 100644 --- a/oml/tor_request.py +++ b/oml/tor_request.py @@ -11,7 +11,7 @@ import socket import settings import state -from utils import get_service_id, get_local_ipv4 +from utils import get_service_id logger = logging.getLogger(__name__) @@ -27,11 +27,7 @@ class InvalidCertificateException(http.client.HTTPException, urllib.error.URLErr (self._service_id, self._cert_service_id, self.reason)) def is_local(host): - local_net = get_local_ipv4() - if not local_net: - return False - local_net = '.'.join(local_net.split('.')[:-1]) + '.' - return host.startswith('127.0.0.1') or host.startswith(local_net) + return len([p for p in host.split(':')[0].split('.') if p.isdigit()]) == 4 def getaddrinfo(*args): return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]