コード例 #1
0
ファイル: server_core.py プロジェクト: TianyouLi/Xpra
 def make_protocol(self, socktype, conn, frominfo=""):
     netlog.info("New %s connection received%s", socktype, frominfo)
     protocol = Protocol(self, conn, self.process_packet)
     self._potential_protocols.append(protocol)
     protocol.large_packets.append("info-response")
     protocol.challenge_sent = False
     protocol.authenticator = None
     if socktype == "tcp":
         protocol.auth_class = self.tcp_auth_class
         protocol.encryption = self.tcp_encryption
         protocol.keyfile = self.tcp_encryption_keyfile
     elif socktype == "vsock":
         protocol.auth_class = self.vsock_auth_class
         protocol.encryption = None
         protocol.keyfile = None
     else:
         protocol.auth_class = self.auth_class
         protocol.encryption = self.encryption
         protocol.keyfile = self.encryption_keyfile
     protocol.socket_type = socktype
     protocol.invalid_header = self.invalid_header
     protocol.receive_aliases.update(self._aliases)
     authlog("socktype=%s, auth class=%s, encryption=%s, keyfile=%s",
             socktype, protocol.auth_class, protocol.encryption,
             protocol.keyfile)
     if protocol.encryption and ENCRYPT_FIRST_PACKET:
         password = self.get_encryption_key(None, protocol.keyfile)
         protocol.set_cipher_in(protocol.encryption, DEFAULT_IV, password,
                                DEFAULT_SALT, DEFAULT_ITERATIONS,
                                INITIAL_PADDING)
     protocol.start()
     self.timeout_add(SOCKET_TIMEOUT * 1000,
                      self.verify_connection_accepted, protocol)
     return True
コード例 #2
0
ファイル: server_core.py プロジェクト: ljmljz/xpra
 def make_protocol(self, socktype, conn, frominfo=""):
     netlog.info("New %s connection received%s", socktype, frominfo)
     protocol = Protocol(self, conn, self.process_packet)
     self._potential_protocols.append(protocol)
     protocol.large_packets.append("info-response")
     protocol.challenge_sent = False
     protocol.authenticator = None
     if socktype=="tcp":
         protocol.auth_class = self.tcp_auth_class
         protocol.encryption = self.tcp_encryption
         protocol.keyfile = self.tcp_encryption_keyfile
     elif socktype=="vsock":
         protocol.auth_class = self.vsock_auth_class
         protocol.encryption = None
         protocol.keyfile = None
     else:
         protocol.auth_class = self.auth_class
         protocol.encryption = self.encryption
         protocol.keyfile = self.encryption_keyfile
     protocol.socket_type = socktype
     protocol.invalid_header = self.invalid_header
     protocol.receive_aliases.update(self._aliases)
     authlog("socktype=%s, auth class=%s, encryption=%s, keyfile=%s", socktype, protocol.auth_class, protocol.encryption, protocol.keyfile)
     if protocol.encryption and ENCRYPT_FIRST_PACKET:
         password = self.get_encryption_key(None, protocol.keyfile)
         protocol.set_cipher_in(protocol.encryption, DEFAULT_IV, password, DEFAULT_SALT, DEFAULT_ITERATIONS, INITIAL_PADDING)
     protocol.start()
     self.timeout_add(SOCKET_TIMEOUT*1000, self.verify_connection_accepted, protocol)
     return True
コード例 #3
0
ファイル: server_core.py プロジェクト: rudresh2319/Xpra
 def _new_connection(self, listener, *args):
     if self._closing:
         netlog.warn("ignoring new connection during shutdown")
         return False
     socktype = self.socket_types.get(listener)
     assert socktype, "cannot find socket type for %s" % listener
     sock, address = listener.accept()
     if len(self._potential_protocols) >= self._max_connections:
         netlog.error("too many connections (%s), ignoring new one",
                      len(self._potential_protocols))
         sock.close()
         return True
     try:
         peername = sock.getpeername()
     except:
         peername = str(address)
     sockname = sock.getsockname()
     target = peername or sockname
     sock.settimeout(self._socket_timeout)
     netlog(
         "new_connection(%s) sock=%s, timeout=%s, sockname=%s, address=%s, peername=%s",
         args, sock, self._socket_timeout, sockname, address, peername)
     sc = SocketConnection(sock, sockname, address, target, socktype)
     netlog("socket connection: %s", sc)
     frominfo = ""
     if peername:
         frominfo = " from %s" % pretty_socket(peername)
     elif socktype == "unix-domain":
         frominfo = " on %s" % sockname
     netlog.info("New %s connection received%s", socktype, frominfo)
     protocol = Protocol(self, sc, self.process_packet)
     self._potential_protocols.append(protocol)
     protocol.large_packets.append("info-response")
     protocol.challenge_sent = False
     protocol.authenticator = None
     if socktype == "tcp":
         protocol.auth_class = self.tcp_auth_class
         protocol.encryption = self.tcp_encryption
         protocol.keyfile = self.tcp_encryption_keyfile
     else:
         protocol.auth_class = self.auth_class
         protocol.encryption = self.encryption
         protocol.keyfile = self.encryption_keyfile
     protocol.socket_type = socktype
     protocol.invalid_header = self.invalid_header
     protocol.receive_aliases.update(self._aliases)
     authlog("socktype=%s, auth class=%s, encryption=%s, keyfile=%s",
             socktype, protocol.auth_class, protocol.encryption,
             protocol.keyfile)
     if protocol.encryption and ENCRYPT_FIRST_PACKET:
         password = self.get_encryption_key(None, protocol.keyfile)
         protocol.set_cipher_in(protocol.encryption, DEFAULT_IV, password,
                                DEFAULT_SALT, DEFAULT_ITERATIONS,
                                INITIAL_PADDING)
     protocol.start()
     self.timeout_add(SOCKET_TIMEOUT * 1000,
                      self.verify_connection_accepted, protocol)
     return True
コード例 #4
0
ファイル: server_core.py プロジェクト: svn2github/Xpra
 def _new_connection(self, listener, *args):
     if self._closing:
         netlog.warn("ignoring new connection during shutdown")
         return False
     socktype = self.socket_types.get(listener)
     assert socktype, "cannot find socket type for %s" % listener
     sock, address = listener.accept()
     if len(self._potential_protocols)>=self._max_connections:
         netlog.error("too many connections (%s), ignoring new one", len(self._potential_protocols))
         sock.close()
         return True
     try:
         peername = sock.getpeername()
     except:
         peername = str(address)
     sockname = sock.getsockname()
     target = peername or sockname
     sock.settimeout(self._socket_timeout)
     netlog("new_connection(%s) sock=%s, timeout=%s, sockname=%s, address=%s, peername=%s", args, sock, self._socket_timeout, sockname, address, peername)
     sc = SocketConnection(sock, sockname, address, target, socktype)
     netlog("socket connection: %s", sc)
     frominfo = ""
     if peername:
         frominfo = " from %s" % pretty_socket(peername)
     elif socktype=="unix-domain":
         frominfo = " on %s" % sockname
     netlog.info("New %s connection received%s", socktype, frominfo)
     protocol = Protocol(self, sc, self.process_packet)
     self._potential_protocols.append(protocol)
     protocol.large_packets.append("info-response")
     protocol.challenge_sent = False
     protocol.authenticator = None
     if socktype=="tcp":
         protocol.auth_class = self.tcp_auth_class
         protocol.encryption = self.tcp_encryption
         protocol.keyfile = self.tcp_encryption_keyfile
     else:
         protocol.auth_class = self.auth_class
         protocol.encryption = self.encryption
         protocol.keyfile = self.encryption_keyfile
     protocol.socket_type = socktype
     protocol.invalid_header = self.invalid_header
     protocol.receive_aliases.update(self._aliases)
     authlog("socktype=%s, auth class=%s, encryption=%s, keyfile=%s", socktype, protocol.auth_class, protocol.encryption, protocol.keyfile)
     if protocol.encryption and ENCRYPT_FIRST_PACKET:
         password = self.get_encryption_key(None, protocol.keyfile)
         protocol.set_cipher_in(protocol.encryption, DEFAULT_IV, password, DEFAULT_SALT, DEFAULT_ITERATIONS, INITIAL_PADDING)
     protocol.start()
     self.timeout_add(SOCKET_TIMEOUT*1000, self.verify_connection_accepted, protocol)
     return True