35 lines
829 B
Python
Executable File
35 lines
829 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
from twisted.internet import protocol, reactor, endpoints
|
|
import bcrypt
|
|
|
|
salt = b'$2b$12$mvJMOyxLJid1jFLgaU1s0.'
|
|
|
|
def hash(inp):
|
|
return bcrypt.hashpw(inp.encode('utf-8'), salt).decode('utf-8')
|
|
|
|
|
|
|
|
actions = []
|
|
|
|
class Reply(protocol.Protocol):
|
|
def dataReceived(self, data):
|
|
output = 'ERROR:INVALID_INP'
|
|
data = data.decode('utf-8').split(':')
|
|
if len(data) > 4:
|
|
data.pop(0)
|
|
if data[0] in actions:
|
|
output = actions[data[0]](data[1:])
|
|
#output=hash(data[0])
|
|
else:
|
|
self.transport.write('LICKTHECOIN:{}\n'.format(output).encode('utf-8'))
|
|
|
|
class Factory(protocol.Factory):
|
|
def buildProtocol(self, addr):
|
|
return Reply()
|
|
|
|
endpoints.serverFromString(reactor, "tcp:13327").listen(Factory())
|
|
reactor.run()
|
|
|
|
|