Merge pull request 'TLS/SSL support for IRC connection' (#1) from ssl into master
Reviewed-on: #1
This commit is contained in:
commit
fdffef6e13
@ -7,16 +7,17 @@ def ircregister(username, password, email):
|
|||||||
d = irctokens.StatefulDecoder()
|
d = irctokens.StatefulDecoder()
|
||||||
e = irctokens.StatefulEncoder()
|
e = irctokens.StatefulEncoder()
|
||||||
s = socket.socket()
|
s = socket.socket()
|
||||||
|
securesocket = ssl.create_default_context().wrap_socket(s, server_hostname="irc.casa")
|
||||||
|
|
||||||
#connecting to the server
|
#connecting to the server
|
||||||
s.connect(("127.0.0.1", 6667))
|
securesocket.connect(("theia.psyched.dev", 6697))
|
||||||
|
|
||||||
#defining the send function with proper formatting
|
#defining the send function with proper formatting
|
||||||
def _send(line):
|
def _send(line):
|
||||||
print(f"> {line.format()}")
|
print(f"> {line.format()}")
|
||||||
e.push(line)
|
e.push(line)
|
||||||
while e.pending():
|
while e.pending():
|
||||||
e.pop(s.send(e.pending()))
|
e.pop(securesocket.send(e.pending()))
|
||||||
|
|
||||||
# registering the connection to the server
|
# registering the connection to the server
|
||||||
_send(irctokens.build("USER", [username, "0", "*", username]))
|
_send(irctokens.build("USER", [username, "0", "*", username]))
|
||||||
@ -33,7 +34,7 @@ def ircregister(username, password, email):
|
|||||||
|
|
||||||
# go through the cases
|
# go through the cases
|
||||||
while True:
|
while True:
|
||||||
lines = d.push(s.recv(1024))
|
lines = d.push(securesocket.recv(1024))
|
||||||
|
|
||||||
if lines == None: # if nothing is received from server
|
if lines == None: # if nothing is received from server
|
||||||
return "server error"
|
return "server error"
|
||||||
|
Loading…
Reference in New Issue
Block a user