MCPcopy Create free account
hub / github.com/apenwarr/sshuttle / original_dst

Function original_dst

client.py:82–95  ·  view source on GitHub ↗
(sock)

Source from the content-addressed store, hash-verified

80
81
82def original_dst(sock):
83 try:
84 SO_ORIGINAL_DST = 80
85 SOCKADDR_MIN = 16
86 sockaddr_in = sock.getsockopt(socket.SOL_IP,
87 SO_ORIGINAL_DST, SOCKADDR_MIN)
88 (proto, port, a,b,c,d) = struct.unpack('!HHBBBB', sockaddr_in[:8])
89 assert(socket.htons(proto) == socket.AF_INET)
90 ip = '%d.%d.%d.%d' % (a,b,c,d)
91 return (ip,port)
92 except socket.error, e:
93 if e.args[0] == errno.ENOPROTOOPT:
94 return sock.getsockname()
95 raise
96
97
98class FirewallClient:

Callers 1

onacceptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected