mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-08-09 23:57:36 +02:00
Client "almost" works on MacOS and maybe FreeBSD.
Basic forwarding now works on MacOS, assuming you set up ipfw correctly (ha ha). I wasted a few hours today trying to figure this out, and I'm *so very close*, but unfortunately it just didn't work. Think you can figure it out? Related changes: - don't die if iptables is unavailable - BSD uses getsockname() instead of SO_ORIGINAL_DST - non-blocking connect() returns EISCONN once it's connected - you can't setsockopt IP_TTL more than once
This commit is contained in:
6
ssnet.py
6
ssnet.py
@ -71,14 +71,17 @@ class SockWrapper:
|
||||
def try_connect(self):
|
||||
if not self.connect_to:
|
||||
return # already connected
|
||||
self.rsock.setsockopt(socket.SOL_IP, socket.IP_TTL, 42)
|
||||
self.rsock.setblocking(False)
|
||||
try:
|
||||
self.rsock.connect(self.connect_to)
|
||||
# connected successfully (Linux)
|
||||
self.connect_to = None
|
||||
except socket.error, e:
|
||||
if e.args[0] in [errno.EINPROGRESS, errno.EALREADY]:
|
||||
pass # not connected yet
|
||||
elif e.args[0] == errno.EISCONN:
|
||||
# connected successfully (BSD)
|
||||
self.connect_to = None
|
||||
elif e.args[0] in [errno.ECONNREFUSED, errno.ETIMEDOUT]:
|
||||
# a "normal" kind of error
|
||||
self.connect_to = None
|
||||
@ -387,6 +390,7 @@ class MuxWrapper(SockWrapper):
|
||||
def connect_dst(ip, port):
|
||||
debug2('Connecting to %s:%d\n' % (ip, port))
|
||||
outsock = socket.socket()
|
||||
outsock.setsockopt(socket.SOL_IP, socket.IP_TTL, 42)
|
||||
return SockWrapper(outsock, outsock,
|
||||
connect_to = (ip,port),
|
||||
peername = '%s:%d' % (ip,port))
|
||||
|
Reference in New Issue
Block a user