parent
edb448a143
commit
87c3e1021e
1 changed files with 35 additions and 32 deletions
|
@ -25,7 +25,7 @@ motd_file = None
|
|||
ping_timeout = 255
|
||||
restrict_ip = ''
|
||||
def isalphanumeric(text:str, channel=False):
|
||||
alphanumericity = list("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890+=-_[]{};$%^*\\|'\",.<>?/`~" + ("#" if channel else ""))
|
||||
alphanumericity = list("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890+-_[]^\\|<>?`" + ("$%*,./~'\"{};#=" if channel else ""))
|
||||
for i in text:
|
||||
if not i in alphanumericity:
|
||||
return False
|
||||
|
@ -295,7 +295,7 @@ def session(connection, client, ip, isssl=False):
|
|||
if command == "NICK" and not finished:
|
||||
pending = text.split(" ")[1]
|
||||
if pending[0] == ":": pending = pending[1:]
|
||||
if "!" in pending or ":" in pending or "#" in pending or "*" in pending:
|
||||
if not isalphanumeric(pending):
|
||||
connection.sendall(bytes(f":{server} 432 * {pending} :Erroneus nickname\r\n","UTF-8"))
|
||||
pending = "*"
|
||||
elif pending.lower() in lower_nicks:
|
||||
|
@ -415,6 +415,7 @@ def session(connection, client, ip, isssl=False):
|
|||
channels = channels[1:]
|
||||
for channelt in channels.split(","):
|
||||
channel = channelt.strip()
|
||||
if isalphanumeric(channel, True):
|
||||
if channel.lower() in lower_chans:
|
||||
channel = lower_chans[channel.lower()]
|
||||
success = True
|
||||
|
@ -445,6 +446,8 @@ def session(connection, client, ip, isssl=False):
|
|||
connection.sendall(bytes(f":{server} 353 {pending} = {channel} :{users}\r\n","UTF-8"))
|
||||
connection.sendall(bytes(f":{server} 366 {pending} {channel} :End of /NAMES list.\r\n","UTF-8"))
|
||||
print("Successfully pre-loaded /NAMES list")
|
||||
else:
|
||||
connection.sendall(bytes(f":{server} 479 {pending} {channel} :Channel has erroneus characters\r\n","UTF-8"))
|
||||
elif command == "LIST":
|
||||
connection.sendall(bytes(f":{server} 321 {pending} Channel :Users Name\r\n","UTF-8"))
|
||||
for key, value in topic_list.items():
|
||||
|
@ -465,7 +468,7 @@ def session(connection, client, ip, isssl=False):
|
|||
else:
|
||||
pending2 = text.split(" ")[1]
|
||||
if pending2[0] == ":": pending2 = pending2[1:]
|
||||
if "!" in pending2 or ":" in pending2 or "#" in pending2 or "*" in pending2:
|
||||
if not isalphanumeric(pending2):
|
||||
connection.sendall(bytes(f":{server} 432 {pending} {pending2} :Erroneus nickname\r\n","UTF-8"))
|
||||
elif pending2.lower() in lower_nicks:
|
||||
connection.sendall(bytes(f":{server} 433 {pending} {pending2} :Nickname is already in use.\r\n","UTF-8"))
|
||||
|
|
Loading…
Add table
Reference in a new issue