mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-19 13:18:26 +02:00
* Simplify getting address from peer class * Improved getting caddress field in version messages * Simplified getting caddress even more * Include local address and remote address as params for peer constructor * Remove old comments from peer class
28 lines
716 B
Python
28 lines
716 B
Python
import logging
|
|
import socket
|
|
import threading
|
|
|
|
from squeaknode.core.peer_address import PeerAddress
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class PeerHandler():
|
|
"""Handles new peer connection.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
squeak_controller,
|
|
handle_connection_fn,
|
|
):
|
|
super().__init__()
|
|
self.squeak_controller = squeak_controller
|
|
self.handle_connection_fn = handle_connection_fn
|
|
|
|
def handle_connection(self, peer_socket: socket.socket, address: PeerAddress, outgoing: bool):
|
|
threading.Thread(
|
|
target=self.handle_connection_fn,
|
|
args=(self.squeak_controller, peer_socket, address, outgoing,),
|
|
).start()
|