.HIDE. Add a bunch of <font>s

This commit is contained in:
Nyo 2016-06-02 19:07:33 +02:00
parent feee262ed1
commit 6c85995e53
4 changed files with 13 additions and 6 deletions

View File

@ -50,7 +50,6 @@ import traceback
class handler(requestHelper.asyncRequestHandler): class handler(requestHelper.asyncRequestHandler):
def asyncPost(self): def asyncPost(self):
glob.meme.acquire()
try: try:
# Track time if needed # Track time if needed
if glob.requestTime == True: if glob.requestTime == True:
@ -69,6 +68,7 @@ class handler(requestHelper.asyncRequestHandler):
# No token, first request. Handle login. # No token, first request. Handle login.
responseTokenString, responseData = loginEvent.handle(self) responseTokenString, responseData = loginEvent.handle(self)
else: else:
userToken = None # default value
try: try:
# This is not the first packet, send response based on client's request # This is not the first packet, send response based on client's request
# Packet start position, used to read stacked packets # Packet start position, used to read stacked packets
@ -78,8 +78,10 @@ class handler(requestHelper.asyncRequestHandler):
if requestTokenString not in glob.tokens.tokens: if requestTokenString not in glob.tokens.tokens:
raise exceptions.tokenNotFoundException() raise exceptions.tokenNotFoundException()
# Token exists, get its object # Token exists, get its object and lock it
userToken = glob.tokens.tokens[requestTokenString] userToken = glob.tokens.tokens[requestTokenString]
userToken.lock.acquire()
consoleHelper.printColored("[{}] locked".format(userToken.token), bcolors.YELLOW)
# Keep reading packets until everything has been read # Keep reading packets until everything has been read
while pos < len(requestData): while pos < len(requestData):
@ -166,6 +168,11 @@ class handler(requestHelper.asyncRequestHandler):
responseData += serverPackets.notification("Whoops! Something went wrong, please login again.") responseData += serverPackets.notification("Whoops! Something went wrong, please login again.")
consoleHelper.printColored("[!] Received packet from unknown token ({}).".format(requestTokenString), bcolors.RED) consoleHelper.printColored("[!] Received packet from unknown token ({}).".format(requestTokenString), bcolors.RED)
consoleHelper.printColored("> {} have been disconnected (invalid token)".format(requestTokenString), bcolors.YELLOW) consoleHelper.printColored("> {} have been disconnected (invalid token)".format(requestTokenString), bcolors.YELLOW)
finally:
# Unlock token
if userToken != None:
consoleHelper.printColored("[{}] unlocked".format(userToken.token), bcolors.GREEN)
userToken.lock.release()
if glob.requestTime == True: if glob.requestTime == True:
# End time # End time
@ -192,7 +199,6 @@ class handler(requestHelper.asyncRequestHandler):
discordBotHelper.sendConfidential(msg) discordBotHelper.sendConfidential(msg)
finally: finally:
self.finish() self.finish()
glob.meme.release()
def asyncGet(self): def asyncGet(self):
html = "<html><head><title>MA MAURO ESISTE?</title><style type='text/css'>body{width:30%}</style></head><body><pre>" html = "<html><head><title>MA MAURO ESISTE?</title><style type='text/css'>body{width:30%}</style></head><body><pre>"

View File

@ -5,7 +5,7 @@ from objects import channelList
from objects import matchList from objects import matchList
import threading import threading
VERSION = "0.9" VERSION = "1.2"
db = None db = None
conf = None conf = None
@ -17,4 +17,3 @@ memes = True
restarting = False restarting = False
pool = None pool = None
requestTime = False requestTime = False
meme = threading.Lock()

View File

@ -7,6 +7,7 @@ from helpers import consoleHelper
from constants import bcolors from constants import bcolors
from constants import serverPackets from constants import serverPackets
from events import logoutEvent from events import logoutEvent
import threading
class token: class token:
"""Osu Token object """Osu Token object
@ -75,6 +76,7 @@ class token:
self.rank = userHelper.getRankPrivileges(self.userID) self.rank = userHelper.getRankPrivileges(self.userID)
self.loginTime = int(time.time()) self.loginTime = int(time.time())
self.pingTime = self.loginTime self.pingTime = self.loginTime
self.lock = threading.Lock() # <-- Sync primitive
# Default variables # Default variables
self.spectators = [] self.spectators = []

2
pep.py
View File

@ -184,7 +184,7 @@ if __name__ == "__main__":
glob.requestTime = generalFunctions.stringToBool(glob.conf.config["server"]["outputrequesttime"]) glob.requestTime = generalFunctions.stringToBool(glob.conf.config["server"]["outputrequesttime"])
# Server start message and console output # Server start message and console output
discordBotHelper.sendConfidential("w00t p00t! (pep.py started)") discordBotHelper.sendConfidential("**asyncppytornadovroom** Server started!")
consoleHelper.printColored("> Tornado listening for clients on 127.0.0.1:{}...".format(serverPort), bcolors.GREEN) consoleHelper.printColored("> Tornado listening for clients on 127.0.0.1:{}...".format(serverPort), bcolors.GREEN)
# Start tornado # Start tornado