Converted indentation to tabs
This commit is contained in:
parent
f7811a605d
commit
a3d0820d78
1 changed files with 28 additions and 28 deletions
|
@ -4,44 +4,44 @@ import DataTypes
|
||||||
from .AsyncServer import Server
|
from .AsyncServer import Server
|
||||||
|
|
||||||
class vHandler(Server.Handler):
|
class vHandler(Server.Handler):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
Logging.info("Handler for '%s' initalised." % self.info[0])
|
Logging.info("Handler for '%s' initalised." % self.info[0])
|
||||||
self.authed = False
|
self.authed = False
|
||||||
self.users = self.kwargs.pop("users")
|
self.users = self.kwargs.pop("users")
|
||||||
|
|
||||||
def handle(self, data, type):
|
def handle(self, data, type):
|
||||||
if not self.authed:
|
if not self.authed:
|
||||||
if type == DataTypes.json:
|
if type == DataTypes.json:
|
||||||
self.auth(data)
|
self.auth(data)
|
||||||
|
|
||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
Logging.info("%s disconnected." % self.info[0])
|
Logging.info("%s disconnected." % self.info[0])
|
||||||
|
|
||||||
|
|
||||||
def auth(self, collection):
|
def auth(self, collection):
|
||||||
if "auth" in collection:
|
if "auth" in collection:
|
||||||
if "user" and "pw" in collection["auth"]:
|
if "user" and "pw" in collection["auth"]:
|
||||||
temp_user = User(collection["auth"]["user"], collection["auth"]["pw"])
|
temp_user = User(collection["auth"]["user"], collection["auth"]["pw"])
|
||||||
if temp_user in self.users:
|
if temp_user in self.users:
|
||||||
self.sock.send({"auth" : "success"})
|
self.sock.send({"auth" : "success"})
|
||||||
self.authed = True
|
self.authed = True
|
||||||
return
|
return
|
||||||
self.sock.close()
|
self.sock.close()
|
||||||
|
|
||||||
|
|
||||||
class User:
|
class User:
|
||||||
def __init__(self, username, password):
|
def __init__(self, username, password):
|
||||||
self.username = username
|
self.username = username
|
||||||
self.password = password
|
self.password = password
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if self.username == other.username and self.password == other.password:
|
if self.username == other.username and self.password == other.password:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.username
|
return self.username
|
||||||
|
|
||||||
|
|
||||||
server = Server("127.0.0.1", 1337, vHandler, {"users" : [User("test", "123")]})
|
server = Server("127.0.0.1", 1337, vHandler, {"users" : [User("test", "123")]})
|
Reference in a new issue