本文整理汇总了Python中xpra.net.protocol.Protocol.socket_type方法的典型用法代码示例。如果您正苦于以下问题:Python Protocol.socket_type方法的具体用法?Python Protocol.socket_type怎么用?Python Protocol.socket_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xpra.net.protocol.Protocol
的用法示例。
在下文中一共展示了Protocol.socket_type方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_protocol
# 需要导入模块: from xpra.net.protocol import Protocol [as 别名]
# 或者: from xpra.net.protocol.Protocol import socket_type [as 别名]
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: _new_connection
# 需要导入模块: from xpra.net.protocol import Protocol [as 别名]
# 或者: from xpra.net.protocol.Protocol import socket_type [as 别名]
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
示例3: _new_connection
# 需要导入模块: from xpra.net.protocol import Protocol [as 别名]
# 或者: from xpra.net.protocol.Protocol import socket_type [as 别名]
def _new_connection(self, listener, *args):
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" % str(peername)
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
else:
protocol.auth_class = self.auth_class
protocol.socket_type = socktype
protocol.invalid_header = self.invalid_header
protocol.receive_aliases.update(self._aliases)
protocol.start()
self.timeout_add(SOCKET_TIMEOUT * 1000, self.verify_connection_accepted, protocol)
return True