mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
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...
This commit is contained in:
parent
d1b243481b
commit
735fcbf311
16 changed files with 394 additions and 48 deletions
1
servatrice/scripts/.gitignore
vendored
Normal file
1
servatrice/scripts/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
pypb/
|
||||
10
servatrice/scripts/mk_pypb.sh
Executable file
10
servatrice/scripts/mk_pypb.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
SRC_DIR=../../common/pb/
|
||||
DST_DIR=./pypb
|
||||
|
||||
rm -rf "$DST_DIR"
|
||||
mkdir -p "$DST_DIR"
|
||||
protoc -I=$SRC_DIR --python_out=$DST_DIR $SRC_DIR/*.proto
|
||||
touch "$DST_DIR/__init__.py"
|
||||
|
||||
73
servatrice/scripts/register.py
Executable file
73
servatrice/scripts/register.py
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
#!/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"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue