Skip to content

Commit bf26275

Browse files
committed
Fix autobind on IPv6
1 parent 3354ef5 commit bf26275

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

tor2web/t2w.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,11 @@ def unregisterProtocol(self, p):
11151115

11161116
def open_listening_socket(ip, port):
11171117
try:
1118-
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1118+
if isIPv6Address(ip):
1119+
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
1120+
else:
1121+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1122+
11191123
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
11201124
s.setblocking(False)
11211125
s.bind((ip, port))
@@ -1141,7 +1145,7 @@ def daemon_init(self):
11411145

11421146
i_https = i_http = 0
11431147

1144-
for ip in [ipv4, ipv6]:
1148+
for ip in [ipv6, ipv4]:
11451149
if ip is None:
11461150
continue
11471151

tor2web/utils/config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def __init__(self):
6666
self.__dict__['processes'] = 1
6767
self.__dict__['requests_per_process'] = 1000000
6868
self.__dict__['transport'] = 'BOTH'
69-
self.__dict__['listen_ipv4'] = '127.0.0.1'
70-
self.__dict__['listen_ipv6'] = None
69+
self.__dict__['listen_ipv4'] = '0.0.0.0'
70+
self.__dict__['listen_ipv6'] = '::'
7171
self.__dict__['listen_port_http'] = 80
7272
self.__dict__['listen_port_https'] = 443
7373
self.__dict__['basehost'] = 'AUTO'

0 commit comments

Comments
 (0)