|
OpenCoD2-Plus
Call of Duty 2 client & server, rebuilt
|
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' |
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.
| hostile_server_test.bad_lc | ( | srv, | |
| run ) |
| hostile_server_test.captured_configstrings | ( | game_dir, | |
| server_bin ) |
A real server's configstrings for MAP, as a client gets them.
| hostile_server_test.command | ( | text | ) |
| hostile_server_test.download_block | ( | block, | |
| size, | |||
| count, | |||
| data = b'' ) |
| hostile_server_test.entities | ( | * | items | ) |
| 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.
| 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.
| 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.
| hostile_server_test.huffman_bomb | ( | srv, | |
| run ) |
| hostile_server_test.info_response | ( | srv, | |
| run ) |
| hostile_server_test.info_value | ( | info, | |
| key ) |
| hostile_server_test.main | ( | ) |
| hostile_server_test.make_cases | ( | strings | ) |
| hostile_server_test.missing_iwd | ( | strings, | |
| name = 'main/zz_hostile' ) |
The systeminfo of a server that asks the client to download one iwd.
| hostile_server_test.negative_block | ( | srv, | |
| run ) |
| hostile_server_test.open_file_url | ( | srv, | |
| run ) |
| hostile_server_test.run_case | ( | case, | |
| base, | |||
| binary, | |||
| game_dir, | |||
| timeout = 120 ) |
'' when the case holds, otherwise what went wrong.
| hostile_server_test.server_command | ( | sequence, | |
| text ) |
| hostile_server_test.set_info | ( | info, | |
| key, | |||
| value ) |
| hostile_server_test.snapshot | ( | server_time, | |
| lc = 0, | |||
| junk = b'', | |||
| entities = (), | |||
| ps_fields = None ) |
| hostile_server_test.viewlocked_ps | ( | ) |
Only viewlocked_entNum, 60000: (playerstate lc, its bits).
| hostile_server_test.wwwdl | ( | url, | |
| size, | |||
| flags ) |
| str hostile_server_test.ACTIVE = 'Done with smoke grenades' |
| int hostile_server_test.CHALLENGE = 0x1234567 |
| str hostile_server_test.DEFAULT_BINARY = 'build/check-linux/cod2_linux' |
| str hostile_server_test.DEFAULT_SERVER = 'build/check-linux/cod2_lnxded' |
| int hostile_server_test.EMPTY_COMMAND_SLOT = 100 |
| str hostile_server_test.ESCAPE = f'cod2_hostile_escape_{os.getpid()}' |
| int hostile_server_test.ET_CORPSE = 2 |
| int hostile_server_test.ET_PLAYER = 1 |
| int hostile_server_test.ET_SCRIPTMOVER = 6 |
| int hostile_server_test.FRAGMENT_SIZE = 1300 |
| str hostile_server_test.LONG_KEY = 'EXE_ERR_GET_NEWEST_DRIVERS' |
| str hostile_server_test.LONG_NAME = 'y' * 80 |
| str hostile_server_test.MAP = 'mp_toujane' |
| int hostile_server_test.NO_ENTITY = 1023 |
| str hostile_server_test.OOB = b'\xff\xff\xff\xff' |
| str hostile_server_test.PAYLOAD = b'#!/bin/sh\n' |
| int hostile_server_test.PROTOCOL = 118 |
| hostile_server_test.ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| int hostile_server_test.SERVER_ID = 77 |
| hostile_server_test.SVC_BASELINE |
| hostile_server_test.SVC_CONFIGSTRING |
| hostile_server_test.SVC_DOWNLOAD |
| hostile_server_test.SVC_EOF |
| hostile_server_test.SVC_GAMESTATE |
| hostile_server_test.SVC_SERVERCOMMAND |
| hostile_server_test.SVC_SNAPSHOT |