(self)
| 129 | Socks5.__init__(self, address=address) |
| 130 | |
| 131 | def state_auth_done(self): |
| 132 | # Now we can request the actual connection |
| 133 | self.append_write_buf(struct.pack('BBB', 0x05, 0x01, 0x00)) |
| 134 | # If the given destination address is an IP address, we'll |
| 135 | # use the IPv4 address request even if remote resolving was specified. |
| 136 | try: |
| 137 | self.ipaddr = socket.inet_aton(self.destination[0]) |
| 138 | self.append_write_buf(chr(0x01).encode() + self.ipaddr) |
| 139 | except socket.error: |
| 140 | # Well it's not an IP number, so it's probably a DNS name. |
| 141 | if Proxy._remote_dns: |
| 142 | # Resolve remotely |
| 143 | self.ipaddr = None |
| 144 | self.append_write_buf(chr(0x03).encode() + chr(len(self.destination[0])).encode() + self.destination[0]) |
| 145 | else: |
| 146 | # Resolve locally |
| 147 | self.ipaddr = socket.inet_aton(socket.gethostbyname(self.destination[0])) |
| 148 | self.append_write_buf(chr(0x01).encode() + self.ipaddr) |
| 149 | self.append_write_buf(struct.pack(">H", self.destination[1])) |
| 150 | self.set_state("pre_connect", length=0, expectBytes=4) |
| 151 | return True |
| 152 | |
| 153 | def state_pre_connect(self): |
| 154 | try: |
nothing calls this directly
no test coverage detected