MCPcopy Create free account
hub / github.com/Bitmessage/PyBitmessage / state_auth_done

Method state_auth_done

src/network/socks5.py:131–151  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 3

append_write_bufMethod · 0.80
set_stateMethod · 0.80
encodeMethod · 0.45

Tested by

no test coverage detected