Repository navigation
Expand file tree
/
Copy pathstart-server.sh
More file actions
executable file
·114 lines (105 loc) · 4.89 KB
/
Copy pathstart-server.sh
File metadata and controls
executable file
·114 lines (105 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
#
# Start the private server for a client test.
#
# ./start-server.sh # 127.0.0.1:20016 — the mod's CUSTOM entry
# ./start-server.sh 0.0.0.0:20016 # listen on every interface
# ADDR=192.168.1.10:20016 ./start-server.sh
#
# Nothing here points at an official server. The LOGGED_ON record and the
# [44] redirect both carry this host's own stage-1/stage-2, and the 1a/79
# lobby offer — the one small that carries a real server address — is cut
# from the carrier (see docs/PRIVATE_SERVER.md).
#
# The client must be pointed here: install mods/custom-server-mod (it adds a
# "CUSTOM" entry at 127.0.0.1:20016) and pick that server in game.
#
# A client on ANOTHER machine needs the advertised endpoints to be this
# host's real IP, not loopback — an unspecified bind host advertises
# 127.0.0.1 by design (the ip4 record holds literals, never 0.0.0.0):
#
# S1=192.168.1.10:32850 S2=192.168.1.10:32851 \
# ./start-server.sh 192.168.1.10:20016
#
# A Steam client authenticates with a token2 and sends no username, so
# those logins land on TOKEN_ACCOUNT (default: the default account) with
# no password check. Set TOKEN_ACCOUNT= to refuse them instead.
#
# Env overrides: ADDR, S1, S2, DB, DEFS, SETTINGS (JSON lobby config),
# XMPP (chat listener), BATTLE_TEAM_SIZE, USER_NAME,
# USER_PASS, TOKEN_ACCOUNT, GARAGE_ALL, EXTRA
#
# BATTLE_TEAM_SIZE is how many players per side the matchmaker needs to form
# a battle (default 15). Set it to 0 to make ONE queued player enough: the
# client still starts in the hangar, and clicking Battle! forms a battle on
# its own, which is how the arena entry and the reconnect are exercised with
# a single client. The battle has no physics, no other tanks and no map
# logic.
#
# XMPP is the chat service the contacts list, private messages and the
# clan channel ride on. It must match `xmpp_connections` in the settings
# document, because that is the address the client dials. XMPP="" turns
# the chat layer off (the contacts UI then stays empty).
#
# GARAGE_ALL=1 seeds the default account's garage with every ownable
# vehicle the client declares (lobby.AllOwnableVehicles, generated by
# cmd/wotgarage) and raises its slot count to fit. The seed is written to
# the database, so one run is enough; it REPLACES the garage rather than
# merging, so re-running is safe and idempotent.
set -euo pipefail
cd "$(dirname "$0")"
ROOT=..
ADDR="${1:-${ADDR:-127.0.0.1:20016}}"
# Stage-1 is what the LOGGED_ON record advertises; stage-2 is the [44]
# redirect target. Both must sit in the manager window 32810-32999 or our
# own client's parseRedirectAt guard skips them.
S1="${S1:-127.0.0.1:32850}"
S2="${S2:-127.0.0.1:32851}"
DB="${DB:-$ROOT/wotserver.db}"
# The entity defs MUST be the build the client runs, not just any build:
# the property tables are what the client decodes entity data against, and
# a type that changed between builds silently shifts every field after it.
# `PUBLIC_VEHICLE_INFO.index` is UINT8 in 2.4.0.0 and UINT16 in 2.4.1, so a
# 2.4.1 client fed 2.4.0 defs reads a shifted `publicInfo` and leaves
# `compDescr` empty ("compact descriptor to XML mismatch? ('',)").
# `scripts-2.4.1/entity_defs` is the client's own tree, extracted from its
# scripts.pkg; the 2.4.0.0 tree stays as the fallback.
if [ -z "${DEFS:-}" ]; then
if [ -d "$ROOT/scripts-2.4.1/entity_defs" ]; then
DEFS="$ROOT/scripts-2.4.1/entity_defs"
else
DEFS="$ROOT/World_of_Tanks_EU/2.4.0.0/res/scripts/entity_defs"
fi
fi
# The lobby's server-settings document (the client's
# initialServerSettings). Generated from the game's own schemas by
# ../tools/gen_server_settings.py; regenerate it when the client build
# changes. An empty document is valid but the client's schema-validated
# configs then raise and the hangar app never loads.
SETTINGS="${SETTINGS:-$ROOT/wot/wotserver.settings.json}"
# The chat listener. The client dials the (host, port) pairs in the
# settings document's `xmpp_connections`, so this must be the same
# address; 127.0.0.1:5222 is what the generator writes.
XMPP="${XMPP-127.0.0.1:5222}"
PRIVKEY="$ROOT/mitm/loginapp_mitm.privkey"
PUBKEY="$ROOT/World_of_Tanks_EU/2.4.0.0/res/loginapp_wot.pubkey"
die() { printf 'start-server: %s\n' "$*" >&2; exit 1; }
for f in "$PRIVKEY" "$PUBKEY"; do
[ -e "$f" ] || die "missing $f"
done
[ -d "$DEFS" ] || die "missing defs directory $DEFS (set DEFS=...)"
printf 'start-server: LoginApp %s, stage-1 %s, stage-2 %s\n' "$ADDR" "$S1" "$S2"
printf 'start-server: point the client at %s (mods/custom-server-mod)\n' "$ADDR"
exec go run ./cmd/wotserver \
-addr "$ADDR" \
-privkey "$PRIVKEY" \
-s1 "$S1" -s2 "$S2" \
-defs "$DEFS" \
-settings "$SETTINGS" \
-xmpp "$XMPP" \
-db "$DB" \
-user "${USER_NAME:-admin@wot.test}" -pass "${USER_PASS:-admin}" \
-token-account "${TOKEN_ACCOUNT-${USER_NAME:-admin@wot.test}}" \
${GARAGE_ALL:+-garage-all} \
-battle-team-size "${BATTLE_TEAM_SIZE:-15}" \
${EXTRA:-}