diff --git a/.gitignore b/.gitignore index 15020d2..035c61e 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,6 @@ MANIFEST /3proxy.conf /.cache/ /.env/ + +# IDE +.idea diff --git a/socks.py b/socks.py index 83b1435..4b5da8a 100644 --- a/socks.py +++ b/socks.py @@ -361,7 +361,9 @@ def bind(self, *pos, **kw): self.proxy_sockname = ("0.0.0.0", 0) # Unknown def sendto(self, bytes, *args, **kwargs): - if self.type != socket.SOCK_DGRAM: + proxy_type, addr, port, rdns, username, password = self.proxy + + if self.type != socket.SOCK_DGRAM or not proxy_type: return super(socksocket, self).sendto(bytes, *args, **kwargs) if not self._proxyconn: self.bind(("", 0)) @@ -387,7 +389,9 @@ def send(self, bytes, flags=0, **kwargs): return super(socksocket, self).send(bytes, flags, **kwargs) def recvfrom(self, bufsize, flags=0): - if self.type != socket.SOCK_DGRAM: + proxy_type, addr, port, rdns, username, password = self.proxy + + if self.type != socket.SOCK_DGRAM or not proxy_type: return super(socksocket, self).recvfrom(bufsize, flags) if not self._proxyconn: self.bind(("", 0))