2013-06-26 04:29:50 +02:00
|
|
|
import sys
|
|
|
|
import struct
|
|
|
|
|
|
|
|
def read():
|
|
|
|
(pkt_size,) = struct.unpack('>H', sys.stdin.read(2))
|
2017-07-31 22:51:12 +02:00
|
|
|
pkt = sys.stdin.read(pkt_size)
|
|
|
|
cmd = pkt.split(':')[0]
|
|
|
|
if cmd == 'auth':
|
|
|
|
u, s, p = pkt.split(':', 3)[1:]
|
|
|
|
if u == "wrong":
|
2016-09-23 11:30:33 +02:00
|
|
|
write(False)
|
|
|
|
else:
|
|
|
|
write(True)
|
2017-07-31 22:51:12 +02:00
|
|
|
elif cmd == 'isuser':
|
|
|
|
u, s = pkt.split(':', 2)[1:]
|
|
|
|
elif cmd == 'setpass':
|
|
|
|
u, s, p = pkt.split(':', 3)[1:]
|
2013-06-26 04:29:50 +02:00
|
|
|
write(True)
|
2017-07-31 22:51:12 +02:00
|
|
|
elif cmd == 'tryregister':
|
|
|
|
u, s, p = pkt.split(':', 3)[1:]
|
2013-06-26 04:29:50 +02:00
|
|
|
write(True)
|
2017-07-31 22:51:12 +02:00
|
|
|
elif cmd == 'removeuser':
|
|
|
|
u, s = pkt.split(':', 2)[1:]
|
2013-06-26 04:29:50 +02:00
|
|
|
write(True)
|
2017-07-31 22:51:12 +02:00
|
|
|
elif cmd == 'removeuser3':
|
|
|
|
u, s, p = pkt.split(':', 3)[1:]
|
2013-06-26 04:29:50 +02:00
|
|
|
write(True)
|
|
|
|
else:
|
|
|
|
write(False)
|
|
|
|
read()
|
|
|
|
|
|
|
|
def write(result):
|
|
|
|
if result:
|
|
|
|
sys.stdout.write('\x00\x02\x00\x01')
|
|
|
|
else:
|
|
|
|
sys.stdout.write('\x00\x02\x00\x00')
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
try:
|
|
|
|
read()
|
|
|
|
except struct.error:
|
|
|
|
pass
|