-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
29 lines (25 loc) · 988 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from socketserver import ForkingTCPServer, StreamRequestHandler, ForkingMixIn
from controllers import *
class MessageHandler(StreamRequestHandler):
def handle(self):
self.writeString(
"GreyH@t Stepping into Security - Lab Server\n"
+ "v1.3\n"
+ "------------------\n"
+ "Available commands: [l[ogin], r[egister], i[nfo], h[elp], c[lear], q[uit]]\n"
)
while True:
last_command = mainmenu.MainMenu().handle(self)
if last_command == "quit" or last_command == 'q':
return
if last_command == "logout":
self.writeString("Ok. You are now logged out.\n")
def writeString(self, string):
self.wfile.write(bytes(string, "utf-8"))
if __name__ == '__main__':
server = ForkingTCPServer(("0.0.0.0", 1000), RequestHandlerClass=MessageHandler, bind_and_activate=False)
server.allow_reuse_address = True
server.server_bind()
server.server_activate()
print("Now listening on port 1000!")
server.serve_forever()