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

Method state_pre_connect

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

Source from the content-addressed store, hash-verified

74 return True
75
76 def state_pre_connect(self):
77 # Get the response
78 if self.read_buf[0:1] != chr(0x05).encode():
79 self.close()
80 raise GeneralProxyError(1)
81 elif self.read_buf[1:2] != chr(0x00).encode():
82 # Connection failed
83 self.close()
84 if ord(self.read_buf[1:2])<=8:
85 raise Socks5Error(ord(self.read_buf[1:2]))
86 else:
87 raise Socks5Error(9)
88 # Get the bound address/port
89 elif self.read_buf[3:4] == chr(0x01).encode():
90 self.set_state("proxy_addr_1", length=4, expectBytes=4)
91 elif self.read_buf[3:4] == chr(0x03).encode():
92 self.set_state("proxy_addr_2_1", length=4, expectBytes=1)
93 else:
94 self.close()
95 raise GeneralProxyError(1)
96 return True
97
98 def state_proxy_addr_1(self):
99 self.boundaddr = self.read_buf[0:4]

Callers 1

state_pre_connectMethod · 0.45

Calls 5

GeneralProxyErrorClass · 0.90
set_stateMethod · 0.80
Socks5ErrorClass · 0.70
encodeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected