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

16
main.py
View file

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

View file

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