Commented on IP_TRANSPARENT and changed an exception type.
This commit is contained in:
parent
2d4e4eafe1
commit
3962a11575
|
@ -738,10 +738,11 @@ class TCPClient(_Connection):
|
||||||
|
|
||||||
if self.spoof_source_address:
|
if self.spoof_source_address:
|
||||||
try:
|
try:
|
||||||
|
# 19 is `IP_TRANSPARENT`, which is only available on Python 3.3+ on some OSes
|
||||||
if not connection.getsockopt(socket.SOL_IP, 19):
|
if not connection.getsockopt(socket.SOL_IP, 19):
|
||||||
connection.setsockopt(socket.SOL_IP, 19, 1)
|
connection.setsockopt(socket.SOL_IP, 19, 1)
|
||||||
except socket.error as e:
|
except socket.error as e:
|
||||||
raise exceptions.ProtocolException(
|
raise exceptions.TcpException(
|
||||||
"Failed to spoof the source address: " + e.strerror)
|
"Failed to spoof the source address: " + e.strerror)
|
||||||
if self.source_address:
|
if self.source_address:
|
||||||
connection.bind(self.source_address())
|
connection.bind(self.source_address())
|
||||||
|
|
Loading…
Reference in New Issue