mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
add SO_KEEPALIVE
This commit is contained in:
parent
f6b606b364
commit
c7ce8a8343
@ -563,6 +563,7 @@ class TCPServer:
|
|||||||
# Only works if self.address == ""
|
# Only works if self.address == ""
|
||||||
self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
||||||
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
||||||
self.socket.setsockopt(IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
|
self.socket.setsockopt(IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
|
||||||
self.socket.bind(self.address)
|
self.socket.bind(self.address)
|
||||||
except socket.error:
|
except socket.error:
|
||||||
@ -574,6 +575,7 @@ class TCPServer:
|
|||||||
# Binding to an IPv6 socket failed, lets fall back to IPv4.
|
# Binding to an IPv6 socket failed, lets fall back to IPv4.
|
||||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
||||||
self.socket.bind(self.address)
|
self.socket.bind(self.address)
|
||||||
|
|
||||||
self.address = self.socket.getsockname()
|
self.address = self.socket.getsockname()
|
||||||
|
Loading…
Reference in New Issue
Block a user