mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
some boxes on 10.x.x.x/8 would crash
This commit is contained in:
parent
bef2e92cef
commit
060368e93d
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
@ -15,7 +15,7 @@
|
||||||
"-a",
|
"-a",
|
||||||
"ed:wark",
|
"ed:wark",
|
||||||
"-v",
|
"-v",
|
||||||
"/home/ed/inc:inc:r:aed"
|
"srv::r:aed"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,9 +2,24 @@
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import ssl
|
import ssl
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
|
try:
|
||||||
import jinja2
|
import jinja2
|
||||||
|
except ImportError:
|
||||||
|
print(
|
||||||
|
"""\033[1;31m
|
||||||
|
you do not have jinja2 installed,\033[33m
|
||||||
|
choose one of these:\033[0m
|
||||||
|
* apt install python-jinja2
|
||||||
|
* python3 -m pip install --user jinja2
|
||||||
|
* (try another python version, if you have one)
|
||||||
|
* (try copyparty.sfx instead)
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
from .__init__ import E
|
from .__init__ import E
|
||||||
from .util import Unrecv
|
from .util import Unrecv
|
||||||
|
|
|
@ -92,11 +92,23 @@ class TcpSrv(object):
|
||||||
|
|
||||||
default_route = None
|
default_route = None
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
for ip in [
|
||||||
|
"10.255.255.255",
|
||||||
|
"172.31.255.255",
|
||||||
|
"192.168.255.255",
|
||||||
|
"239.255.255.255",
|
||||||
|
# could add 1.1.1.1 as a final fallback
|
||||||
|
# but external connections is kinshi
|
||||||
|
]:
|
||||||
try:
|
try:
|
||||||
s.connect(("10.255.255.255", 1))
|
s.connect((ip, 1))
|
||||||
|
# raise OSError(13, "a")
|
||||||
default_route = s.getsockname()[0]
|
default_route = s.getsockname()[0]
|
||||||
|
break
|
||||||
except (OSError, socket.error) as ex:
|
except (OSError, socket.error) as ex:
|
||||||
if ex.errno not in [101, 10065]:
|
if ex.errno == 13:
|
||||||
|
self.log("tcpsrv", "eaccess {} (trying next)".format(ip))
|
||||||
|
elif ex.errno not in [101, 10065]:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
s.close()
|
s.close()
|
||||||
|
|
Loading…
Reference in a new issue