OpenCoD2-Plus
Call of Duty 2 client & server, rebuilt
Loading...
Searching...
No Matches
hostile_server_test Namespace Reference

Classes

class  AnyFile
class  FakeServer
class  Case
class  ClientRun

Functions

 captured_configstrings (game_dir, server_bin)
 set_info (info, key, value)
 info_value (info, key)
 gamestate (strings, sequence=0, raw_index=None)
 entity (w, number, fields)
 viewlocked_ps ()
 snapshot (server_time, lc=0, junk=b'', entities=(), ps_fields=None)
 server_command (sequence, text)
 download_block (block, size, count, data=b'')
 command (text)
 missing_iwd (strings, name='main/zz_hostile')
 huffman_bomb (srv, run)
 bad_lc (srv, run)
 negative_block (srv, run)
 info_response (srv, run)
 wwwdl (url, size, flags)
 http_redirect (srv, run)
 open_file_url (srv, run)
 entities (*items)
 make_cases (strings)
 run_case (case, base, binary, game_dir, timeout=120)
 main ()

Variables

 ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
str DEFAULT_BINARY = 'build/check-linux/cod2_linux'
str DEFAULT_SERVER = 'build/check-linux/cod2_lnxded'
str MAP = 'mp_toujane'
str OOB = b'\xff\xff\xff\xff'
int CHALLENGE = 0x1234567
int SERVER_ID = 77
int PROTOCOL = 118
str ACTIVE = 'Done with smoke grenades'
 SVC_GAMESTATE
 SVC_CONFIGSTRING
 SVC_BASELINE
 SVC_SERVERCOMMAND
 SVC_DOWNLOAD
 SVC_SNAPSHOT
 SVC_EOF
int EMPTY_COMMAND_SLOT = 100
int FRAGMENT_SIZE = 1300
int NO_ENTITY = 1023
int ET_PLAYER = 1
int ET_CORPSE = 2
int ET_SCRIPTMOVER = 6
str LONG_KEY = 'EXE_ERR_GET_NEWEST_DRIVERS'
str ESCAPE = f'cod2_hostile_escape_{os.getpid()}'
str LONG_NAME = 'y' * 80
str PAYLOAD = b'#!/bin/sh\n'

Detailed Description

A fake server sends a real client the messages only a hostile server sends.

    python3 scripts/hostile_server_test.py /path/to/CoD2 [--binary PATH] [--server PATH] [--case NAME]

Runs the dedicated server once to learn a real map's configstrings, stops it,
then plays a server on 127.0.0.1 itself: it answers the handshake and sends the
client a gamestate and snapshots of its own. Each case starts a new client and
sends it one malformed message. The client must not crash: it runs on or leaves
by its error path, writes no crash report, and logs the text the case expects.
The client needs a CD key in ~/.cod2/preferences: without one the test is
skipped (exit 0). It opens a window. Exits with 0 when every case holds. Set
COD2_HOSTILE_LOG to a path to keep the last client's log.

Function Documentation

◆ bad_lc()

hostile_server_test.bad_lc ( srv,
run )

◆ captured_configstrings()

hostile_server_test.captured_configstrings ( game_dir,
server_bin )
A real server's configstrings for MAP, as a client gets them.

◆ command()

hostile_server_test.command ( text)

◆ download_block()

hostile_server_test.download_block ( block,
size,
count,
data = b'' )

◆ entities()

hostile_server_test.entities ( * items)

◆ entity()

hostile_server_test.entity ( w,
number,
fields )
A delta from the zeroed baseline: only the fields in {index: (value,
bits)}, written up to the last one, from cod2snap.ENTITY_FIELDS.

◆ gamestate()

hostile_server_test.gamestate ( strings,
sequence = 0,
raw_index = None )
The configstrings; raw_index adds one with that index, for an out of
range one.

◆ http_redirect()

hostile_server_test.http_redirect ( srv,
run )
A redirect to an HTTP server that serves anything: the client writes it
under the name the server gave for the iwd.

◆ huffman_bomb()

hostile_server_test.huffman_bomb ( srv,
run )

◆ info_response()

hostile_server_test.info_response ( srv,
run )

◆ info_value()

hostile_server_test.info_value ( info,
key )

◆ main()

hostile_server_test.main ( )

◆ make_cases()

hostile_server_test.make_cases ( strings)

◆ missing_iwd()

hostile_server_test.missing_iwd ( strings,
name = 'main/zz_hostile' )
The systeminfo of a server that asks the client to download one iwd.

◆ negative_block()

hostile_server_test.negative_block ( srv,
run )

◆ open_file_url()

hostile_server_test.open_file_url ( srv,
run )

◆ run_case()

hostile_server_test.run_case ( case,
base,
binary,
game_dir,
timeout = 120 )
'' when the case holds, otherwise what went wrong.

◆ server_command()

hostile_server_test.server_command ( sequence,
text )

◆ set_info()

hostile_server_test.set_info ( info,
key,
value )

◆ snapshot()

hostile_server_test.snapshot ( server_time,
lc = 0,
junk = b'',
entities = (),
ps_fields = None )

◆ viewlocked_ps()

hostile_server_test.viewlocked_ps ( )
Only viewlocked_entNum, 60000: (playerstate lc, its bits).

◆ wwwdl()

hostile_server_test.wwwdl ( url,
size,
flags )

Variable Documentation

◆ ACTIVE

str hostile_server_test.ACTIVE = 'Done with smoke grenades'

◆ CHALLENGE

int hostile_server_test.CHALLENGE = 0x1234567

◆ DEFAULT_BINARY

str hostile_server_test.DEFAULT_BINARY = 'build/check-linux/cod2_linux'

◆ DEFAULT_SERVER

str hostile_server_test.DEFAULT_SERVER = 'build/check-linux/cod2_lnxded'

◆ EMPTY_COMMAND_SLOT

int hostile_server_test.EMPTY_COMMAND_SLOT = 100

◆ ESCAPE

str hostile_server_test.ESCAPE = f'cod2_hostile_escape_{os.getpid()}'

◆ ET_CORPSE

int hostile_server_test.ET_CORPSE = 2

◆ ET_PLAYER

int hostile_server_test.ET_PLAYER = 1

◆ ET_SCRIPTMOVER

int hostile_server_test.ET_SCRIPTMOVER = 6

◆ FRAGMENT_SIZE

int hostile_server_test.FRAGMENT_SIZE = 1300

◆ LONG_KEY

str hostile_server_test.LONG_KEY = 'EXE_ERR_GET_NEWEST_DRIVERS'

◆ LONG_NAME

str hostile_server_test.LONG_NAME = 'y' * 80

◆ MAP

str hostile_server_test.MAP = 'mp_toujane'

◆ NO_ENTITY

int hostile_server_test.NO_ENTITY = 1023

◆ OOB

str hostile_server_test.OOB = b'\xff\xff\xff\xff'

◆ PAYLOAD

str hostile_server_test.PAYLOAD = b'#!/bin/sh\n'

◆ PROTOCOL

int hostile_server_test.PROTOCOL = 118

◆ ROOT

hostile_server_test.ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

◆ SERVER_ID

int hostile_server_test.SERVER_ID = 77

◆ SVC_BASELINE

hostile_server_test.SVC_BASELINE

◆ SVC_CONFIGSTRING

hostile_server_test.SVC_CONFIGSTRING

◆ SVC_DOWNLOAD

hostile_server_test.SVC_DOWNLOAD

◆ SVC_EOF

hostile_server_test.SVC_EOF

◆ SVC_GAMESTATE

hostile_server_test.SVC_GAMESTATE

◆ SVC_SERVERCOMMAND

hostile_server_test.SVC_SERVERCOMMAND

◆ SVC_SNAPSHOT

hostile_server_test.SVC_SNAPSHOT