xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #2952: udp_access_to_options.patch

File udp_access_to_options.patch, 3.7 KB (added by brief, 10 months ago)
  • src/xpra/net/udp_protocol.py

     
    5858        it parses the header and then exposes the data received via process_packet_cb.
    5959    """
    6060
    61     def __init__(self, sock, process_packet_cb):
     61    def __init__(self, sock, process_packet_cb, options):
    6262        assert sock is not None
    6363        self._closed = False
    6464        self._socket = sock
    6565        self._process_packet_cb =  process_packet_cb
     66        self._options = options
    6667        self._read_thread = start_thread(self._read_thread_loop, "read", daemon=True)
    6768
    6869    def __repr__(self):
     
    8485                    break
    8586                values = list(_header_struct.unpack_from(buf[:_header_size])) + [buf[_header_size:], bfrom]
    8687                try:
    87                     self._process_packet_cb(self, *values)
     88                    self._process_packet_cb(self, *values, self._options)
    8889                except Exception as e:
    8990                    log("_read_thread_loop() buffer=%s, from=%s", ellipsizer(buf), bfrom, exc_info=True)
    9091                    if not self._closed:
     
    554555        (servers use a single socket to talk to multiple clients,
    555556        they do not call connect() and so we have to specify the remote target every time)
    556557    """
     558   
     559    def __init__(self, sock, local, remote, target, socktype, info=None, socket_options=None):
     560        super().__init__(sock, local, remote, target, socktype, info, socket_options)
    557561
    558562    def write(self, buf):
    559563        #log("UDPSocketConnection: sending %i bytes to %s", len(buf), self.remote)
  • src/xpra/server/server_core.py

     
    888888
    889889    def _new_udp_connection(self, sock):
    890890        from xpra.net.udp_protocol import UDPListener
    891         udpl = UDPListener(sock, self.process_udp_packet)
     891        socket_options = self.socket_options.get(sock, {})
     892        udpl = UDPListener(sock, self.process_udp_packet, socket_options)
    892893        self._udp_listeners.append(udpl)
    893894
    894895    def _new_connection(self, socktype, listener, handle=0):
     
    21892190    def _process_udp_control(self, proto, packet):
    21902191        proto.process_control(*packet[1:])
    21912192
    2192     def process_udp_packet(self, udp_listener, uuid, seqno, synchronous, chunk, chunks, data, bfrom):
    2193         #log.info("process_udp_packet%s", (udp_listener, uuid, seqno, synchronous, chunk, chunks, len(data), bfrom))
     2193    def process_udp_packet(self, udp_listener, uuid, seqno, synchronous, chunk, chunks, data, bfrom, options):
     2194        #log.info("process_udp_packet%s", (udp_listener, uuid, seqno, synchronous, chunk, chunks, len(data), bfrom, options))
    21942195        protocol = self._udp_protocols.get(uuid)
    21952196        if not protocol:
    21962197            from xpra.net.udp_protocol import UDPServerProtocol, UDPSocketConnection
     
    22042205            host, port = bfrom
    22052206            sock = udp_listener._socket
    22062207            sockname = sock.getsockname()
    2207             conn = UDPSocketConnection(sock, sockname, (host, port), (host, port), socktype)
     2208            conn = UDPSocketConnection(sock, sockname, (host, port), (host, port), socktype, None, options)
    22082209            conn.timeout = SOCKET_TIMEOUT
    2209             protocol = self.do_make_protocol(socktype, conn, {}, udp_protocol_class)
     2210            protocol = self.do_make_protocol(socktype, conn, options, udp_protocol_class)
    22102211            self._udp_protocols[uuid] = protocol
    22112212        else:
    22122213            #update remote address in case the client is roaming: