MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / handleIncomingConnection

Method handleIncomingConnection

src/Connection/Connection.py:183–200  ·  view source on GitHub ↗
(self, sock)

Source from the content-addressed store, hash-verified

181
182 # Handle incoming connection
183 def handleIncomingConnection(self, sock):
184 self.log("Incoming connection...")
185
186 if "TCP_NODELAY" in dir(socket):
187 sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
188
189 self.type = "in"
190 if self.ip not in config.ip_local: # Clearnet: Check implicit SSL
191 try:
192 first_byte = sock.recv(1, gevent.socket.MSG_PEEK)
193 if first_byte == b"\x16":
194 self.log("Crypt in connection using implicit SSL")
195 self.sock = CryptConnection.manager.wrapSocket(self.sock, "tls-rsa", True)
196 self.sock_wrapped = True
197 self.crypt = "tls-rsa"
198 except Exception as err:
199 self.log("Socket peek error: %s" % Debug.formatException(err))
200 self.messageLoop()
201
202 def getMsgpackUnpacker(self):
203 if self.handshake and self.handshake.get("use_bin_type"):

Callers 1

Calls 3

logMethod · 0.95
messageLoopMethod · 0.95
wrapSocketMethod · 0.80

Tested by

no test coverage detected