Fix some style issues.

This commit is contained in:
poljar (Damir Jelić) 2018-02-01 18:02:58 +01:00
parent a7531839d1
commit b32baa65b1
2 changed files with 11 additions and 12 deletions

View file

@ -163,13 +163,13 @@ def ssl_fd_cb(server_name, file_descriptor):
def try_ssl_handshake(server): def try_ssl_handshake(server):
socket = server.socket sock = server.socket
while True: while True:
try: try:
socket.do_handshake() sock.do_handshake()
cipher = socket.cipher() cipher = sock.cipher()
cipher_message = ("{prefix}matrix: Connected using {tls}, and " cipher_message = ("{prefix}matrix: Connected using {tls}, and "
"{bit} bit {cipher} cipher suite.").format( "{bit} bit {cipher} cipher suite.").format(
prefix=W.prefix("network"), prefix=W.prefix("network"),
@ -179,7 +179,7 @@ def try_ssl_handshake(server):
W.prnt(server.server_buffer, cipher_message) W.prnt(server.server_buffer, cipher_message)
# TODO print out the certificates # TODO print out the certificates
# cert = socket.getpeercert() # cert = sock.getpeercert()
# W.prnt(server.server_buffer, pprint.pformat(cert)) # W.prnt(server.server_buffer, pprint.pformat(cert))
finalize_connection(server) finalize_connection(server)

View file

@ -304,7 +304,6 @@ def matrix_server_disconnect(server, reconnect=True):
if server.fd_hook: if server.fd_hook:
W.unhook(server.fd_hook) W.unhook(server.fd_hook)
# TODO close socket
close_socket(server.socket) close_socket(server.socket)
server.fd_hook = None server.fd_hook = None
@ -400,17 +399,17 @@ def send_or_queue(server, message):
def try_send(server, message): def try_send(server, message):
# type: (MatrixServer, bytes) -> bool # type: (MatrixServer, bytes) -> bool
socket = server.socket sock = server.socket
total_sent = 0 total_sent = 0
message_length = len(message) message_length = len(message)
while total_sent < message_length: while total_sent < message_length:
try: try:
sent = socket.send(message[total_sent:]) sent = sock.send(message[total_sent:])
except ssl.SSLWantWriteError: except ssl.SSLWantWriteError:
hook = W.hook_fd( hook = W.hook_fd(
server.socket.fileno(), server.sock.fileno(),
0, 1, 0, 0, 1, 0,
"send_cb", "send_cb",
server.name server.name