wrapmodule(module) Attempts to replace a module's socket library with a SOCKS socket. Must set a default proxy using setdefaultproxy(...) first. This will only work on modules that import socket directly into the namespace; most of the Python Standard Library falls into this category
(module)
| 101 | _defaultproxy = (proxytype, addr, port, rdns, username, password) |
| 102 | |
| 103 | def wrapmodule(module): |
| 104 | """wrapmodule(module) |
| 105 | Attempts to replace a module's socket library with a SOCKS socket. Must set |
| 106 | a default proxy using setdefaultproxy(...) first. |
| 107 | This will only work on modules that import socket directly into the namespace; |
| 108 | most of the Python Standard Library falls into this category. |
| 109 | """ |
| 110 | if _defaultproxy != None: |
| 111 | module.socket.socket = socksocket |
| 112 | if _defaultproxy[0] == PROXY_TYPE_SOCKS4: |
| 113 | # Note: unable to prevent DNS leakage in SOCKS4 (Reference: https://security.stackexchange.com/a/171280) |
| 114 | pass |
| 115 | else: |
| 116 | module.socket.create_connection = create_connection |
| 117 | else: |
| 118 | raise GeneralProxyError((4, "no proxy specified")) |
| 119 | |
| 120 | def unwrapmodule(module): |
| 121 | module.socket.socket = _orgsocket |
nothing calls this directly
no test coverage detected
searching dependent graphs…