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

Functions

 make_key ()
 _der_key (priv)
 _openssl (args, priv, data=b'')
 public_key (priv)
 plus_id (pk)
 signed_text (challenge, adr)
 _der_int (der, i)
 sign (priv, challenge, adr)
 _private (ip)
 address_accepted (signed_ip, from_ip, public, net_ip='', signed_port=28960, net_port=28960, public_port=None, local_ips=())
 id_keys (pk_hex, ps_hex, adr)
 connect_with_id (port, priv, adr=None, name='plusid', protocol=115, plus=123)
 status_rows (port)
 status_extra (port, name)
 status (port)
 seen_file (path)
 launch (binary, game_dir, home, port, map_name, log_path, extra=())
 make_home (home)
 stop (server)
 check_shared_seen_file (args, check)
 check_address_rule (check)
 run_cases (port, protocol, log_path, game_log, seen_path, check)
 parse_time (text)
 read_bans (path)
 run_ban_cases (port, protocol, log_path, game_log, bans_path, check)
 check_lists (args, check)
 main ()

Variables

 ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
str RCON = 'plusid_rcon'
int N = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551
str NOTICE = 'This server requires a Plus ID'
str GAMETYPE

Detailed Description

Checks the Plus ID: the connect key pair proof (docs/architecture/plus-id.md).

    python3 scripts/plusid_test.py /path/to/CoD2 [--binary bin/cod2rev_lnxded] [--protocol 118]

Minimal clients sign the connect challenge with keys made by the openssl CLI
and the server's verdict is read back with rcon plusIdStatus. The folder must
hold only the stock iwds. Exits with 0 when every check passes. The helpers
(make_key, sign, connect_with_id...) are for the other Plus ID tests.

Function Documentation

◆ _der_int()

plusid_test._der_int ( der,
i )
protected

◆ _der_key()

plusid_test._der_key ( priv)
protected
priv as an SEC1 ECPrivateKey on prime256v1, which openssl reads.

◆ _openssl()

plusid_test._openssl ( args,
priv,
data = b'' )
protected

◆ _private()

plusid_test._private ( ip)
protected
PlusId_IsPrivate: RFC 1918, loopback and link-local only (not the host's
own /24, which Sys_IsLANAddress also takes).

◆ address_accepted()

plusid_test.address_accepted ( signed_ip,
from_ip,
public,
net_ip = '',
signed_port = 28960,
net_port = 28960,
public_port = None,
local_ips = () )
The server's rule (PlusId_AddressAccepted) for the address the client
signed, branch for branch: a private address only from a private source,
even when it is net_ip; the public address with the port it names (else
net_port); net_ip with net_port; then, with net_port, a private address of
this host: 127/8 or one of its own IPs.

◆ check_address_rule()

plusid_test.check_address_rule ( check)

◆ check_lists()

plusid_test.check_lists ( args,
check )
Shared ban lists served by a local HTTP server, refreshed every minute:
five lists checked at the same refresh, then a restart with the HTTP
server down.

◆ check_shared_seen_file()

plusid_test.check_shared_seen_file ( args,
check )
Two servers with one seen file and the same ID connected 5 s to each.

◆ connect_with_id()

plusid_test.connect_with_id ( port,
priv,
adr = None,
name = 'plusid',
protocol = 115,
plus = 123 )
Connects a client that signs adr (by default 127.0.0.1:port) with priv;
returns (client, None or the server's reply). The caller closes the client.

◆ id_keys()

plusid_test.id_keys ( pk_hex,
ps_hex,
adr )

◆ launch()

plusid_test.launch ( binary,
game_dir,
home,
port,
map_name,
log_path,
extra = () )
Starts a dedicated server with the test gametype; returns the process.

◆ main()

plusid_test.main ( )

◆ make_home()

plusid_test.make_home ( home)

◆ make_key()

plusid_test.make_key ( )
A random private key, 32 bytes big-endian.

◆ parse_time()

plusid_test.parse_time ( text)

◆ plus_id()

plusid_test.plus_id ( pk)
P- and the base32 of the first 10 bytes of SHA-256(pk), in groups of 4.

◆ public_key()

plusid_test.public_key ( priv)
The compressed public point, 33 bytes.

◆ read_bans()

plusid_test.read_bans ( path)

◆ run_ban_cases()

plusid_test.run_ban_cases ( port,
protocol,
log_path,
game_log,
bans_path,
check )

◆ run_cases()

plusid_test.run_cases ( port,
protocol,
log_path,
game_log,
seen_path,
check )

◆ seen_file()

plusid_test.seen_file ( path)
{id: (first_seen, seconds)} of a seen file.

◆ sign()

plusid_test.sign ( priv,
challenge,
adr )
(pk hex, ps hex): the public key and the raw r||s signature of the signed text.

◆ signed_text()

plusid_test.signed_text ( challenge,
adr )

◆ status()

plusid_test.status ( port)
{name: id} from rcon plusIdStatus.

◆ status_extra()

plusid_test.status_extra ( port,
name )
(client number, flags) of a player in rcon plusIdStatus; flags is "-" for none.

◆ status_rows()

plusid_test.status_rows ( port)
{name: (id, playtime, first_seen_ago)} from rcon plusIdStatus, whose lines are
"num name id playtime first_seen_ago flags".

◆ stop()

plusid_test.stop ( server)

Variable Documentation

◆ GAMETYPE

str plusid_test.GAMETYPE
Initial value:
1= r"""main()
2{
3 maps\mp\gametypes\tdm::main();
4 level.plusidConnect = level.callbackPlayerConnect;
5 level.callbackPlayerConnect = ::connected;
6}
7
8connected()
9{
10 logPrint("plusid " + self getPlusId() + "\n");
11 logPrint("plusidflags " + self getPlusIdFlags() + "\n");
12 logPrint("plusidtime " + self getPlusIdPlaytime() + " " + self getPlusIdFirstSeen() + "\n");
13 self [[level.plusidConnect]]();
14}
15"""

◆ N

int plusid_test.N = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551

◆ NOTICE

str plusid_test.NOTICE = 'This server requires a Plus ID'

◆ RCON

str plusid_test.RCON = 'plusid_rcon'

◆ ROOT

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