From 23ca00bba8cd1dd3cdc535717d3430964dc38dd0 Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 13 Sep 2023 23:24:56 +0000 Subject: [PATCH] support jython and graalpy --- copyparty/tcpsrv.py | 6 ++++++ copyparty/util.py | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/copyparty/tcpsrv.py b/copyparty/tcpsrv.py index e2f50c02..3eb8adc2 100644 --- a/copyparty/tcpsrv.py +++ b/copyparty/tcpsrv.py @@ -15,6 +15,7 @@ from .util import ( E_ADDR_IN_USE, E_ADDR_NOT_AVAIL, E_UNREACH, + IP6ALL, Netdev, min_ex, sunpack, @@ -254,6 +255,9 @@ class TcpSrv(object): srvs: list[socket.socket] = [] for srv in self.srv: ip, port = srv.getsockname()[:2] + if ip == IP6ALL: + ip = "::" # jython + try: srv.listen(self.args.nc) try: @@ -275,6 +279,8 @@ class TcpSrv(object): srv.close() continue + t = "\n\nERROR: could not open listening socket, probably because one of the server ports ({}) is busy on one of the requested interfaces ({}); avoid this issue by specifying a different port (-p 3939) and/or a specific interface to listen on (-i 192.168.56.1)\n" + self.log("tcpsrv", t.format(port, ip), 1) raise bound.append((ip, port)) diff --git a/copyparty/util.py b/copyparty/util.py index fdb8d096..40a090c8 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -56,6 +56,8 @@ E_ADDR_IN_USE = _ens("EADDRINUSE WSAEADDRINUSE") E_ACCESS = _ens("EACCES WSAEACCES") E_UNREACH = _ens("EHOSTUNREACH WSAEHOSTUNREACH ENETUNREACH WSAENETUNREACH") +IP6ALL = "0:0:0:0:0:0:0:0" + try: import ctypes @@ -66,7 +68,9 @@ except: try: HAVE_SQLITE3 = True - import sqlite3 # pylint: disable=unused-import # typechk + import sqlite3 + + assert hasattr(sqlite3, "connect") # graalpy except: HAVE_SQLITE3 = False