Files
Cockatrice/servatrice/scripts/register.py
Gavin Bises 735fcbf311 Add first draft of protocol extension for registration
Stub for registration command handling in server

First draft of handling registration requests

WIP (will be rebased)

clean up bad imports (rebase this later)

Finish checkUserIsBanned method

Add username validity check

Check servatrice registration settings

WIP

Finish(?) server side of registration

Needs testing

Fix switch case compile failure

I have no idea why I have to do this

WIP for registration testing python script

Stub register script initial attempt

Rearrange register script

First try at sending reg

register.py sends commands correctly now

Add more debug to register.py

Pack bytes the right way - servatrice can parse py script sends now

register.py should be working now

Parse xml hack correctly

Log registration enabled settings on server start

Insert gender correctly on register

Show tcpserver error message on failed gameserver listen

Fail startup if db configured and can't be opened.

TIL qt5 comes without mysql by default in homebrew...
2015-05-22 18:55:51 +02:00

74 lines
1.6 KiB
Python
Executable File

#!/usr/bin/env python
import socket, sys, struct, time
from pypb.server_message_pb2 import ServerMessage
from pypb.session_commands_pb2 import Command_Register as Reg
from pypb.commands_pb2 import CommandContainer as Cmd
from pypb.event_server_identification_pb2 import Event_ServerIdentification as ServerId
from pypb.response_pb2 import Response
HOST = "localhost"
PORT = 4747
CMD_ID = 1
def build_reg():
global CMD_ID
cmd = Cmd()
sc = cmd.session_command.add()
reg = sc.Extensions[Reg.ext]
reg.user_name = "testUser"
reg.email = "test@example.com"
reg.password = "password"
cmd.cmd_id = CMD_ID
CMD_ID += 1
return cmd
def send(msg):
packed = struct.pack('>I', len(msg))
sock.sendall(packed)
sock.sendall(msg)
def print_resp(resp):
print "<<<"
print repr(resp)
m = ServerMessage()
m.ParseFromString(bytes(resp))
print m
def recv(sock):
print "< header"
header = sock.recv(4)
msg_size = struct.unpack('>I', header)[0]
print "< ", msg_size
raw_msg = sock.recv(msg_size)
print_resp(raw_msg)
if __name__ == "__main__":
address = (HOST, PORT)
sock = socket.socket()
print "Connecting to server ", address
sock.connect(address)
# hack for old xml clients - server expects this and discards first message
print ">>> xml hack"
xmlClientHack = Cmd().SerializeToString()
send(xmlClientHack)
print sock.recv(60)
recv(sock)
print ">>> register"
r = build_reg()
print r
msg = r.SerializeToString()
send(msg)
recv(sock)
print "Done"