Snapshot unreviewed LocalMP battle work as rework baseline
Records the uncommitted battle-session work exactly as it was left (local service matchmaking, settlement, chat, native LocalMP hooks, battle gui/exe patches) so the following review and rework commits show every correction as a diff against this state. This commit is not reviewed and is known to be incomplete: in-game testing reported wrong settlement rewards, single-country teams, missing random/fixed supplement slots, misattributed hit messages and other regressions. Do not merge this branch before the rework lands.
This commit is contained in:
1 parent
aa272fc82b
commit
6a189513b0
97 files changed
+7676
-396
No files matched your search
@@ -1,14 +1,17 @@
|
||||
/**
|
||||
* The local service's one listening port. Every address in the game's network.blk points
|
||||
* here, and the network hook library sends every other connection of the
|
||||
* game here too (5.1), so connections arrive in several protocols. The first bytes of a
|
||||
* connection decide where it goes: the matching protocol (first byte 1, see
|
||||
* matching/matching-frame.ts) to the matching service; a TLS handshake (record type 0x16) is
|
||||
* answered with the local certificate and the decrypted stream goes to the HTTP server;
|
||||
* everything else (HTTP, other) goes to the HTTP server directly.
|
||||
* The local service's single listening port. Every address in the game's network.blk points
|
||||
* here, and the network hook library routes all other outbound game connections here as well.
|
||||
* The first bytes of a connection decide which protocol handler accepts it:
|
||||
* - Matching binary packet (first byte 1) -> MatchingService;
|
||||
* - Plaintext IRC handshake (`PASS` / `NICK` / `USER` / `CAP` / `PING`) -> IrcServer;
|
||||
* - TLS ClientHello (record type 0x16) -> decrypted with the local certificate, then routed
|
||||
* to IrcServer or the HTTP server based on the first decrypted bytes;
|
||||
* - Everything else -> HTTP server directly.
|
||||
*/
|
||||
import { createServer, type Server, type Socket } from 'node:net';
|
||||
import { createSecureContext, TLSSocket } from 'node:tls';
|
||||
import { startsIrcHandshake } from '../chat/irc-protocol.ts';
|
||||
import { IrcServer } from '../chat/irc-server.ts';
|
||||
import type { TlsCredentials } from './tls/tls-certificate.ts';
|
||||
import type { MatchingRequestTable } from '../matching/matching-requests.ts';
|
||||
import { MatchingService } from '../matching/matching-service.ts';
|
||||
@@ -34,6 +37,7 @@ export function createPortListener(router: Router, matchingRequests: MatchingReq
|
||||
let lastNumber = 0;
|
||||
const http = createHttpServer(router, log, (socket) => numbers.get(socket) ?? 0);
|
||||
const matching = new MatchingService(matchingRequests, log);
|
||||
const irc = new IrcServer();
|
||||
|
||||
const server = createServer((socket) => {
|
||||
lastNumber += 1;
|
||||
@@ -51,11 +55,18 @@ export function createPortListener(router: Router, matchingRequests: MatchingReq
|
||||
socket.pause();
|
||||
socket.unshift(first);
|
||||
if (startsMatchingPacket(first)) matching.accept(socket, number);
|
||||
else if (startsIrcHandshake(first)) irc.accept(socket);
|
||||
else if (first[0] === TLS_HANDSHAKE) {
|
||||
const secure = new TLSSocket(socket, { isServer: true, secureContext });
|
||||
numbers.set(secure, number);
|
||||
secure.on('error', () => socket.destroy());
|
||||
http.emit('connection', secure);
|
||||
secure.once('data', (innerFirst: Buffer) => {
|
||||
secure.pause();
|
||||
secure.unshift(innerFirst);
|
||||
if (startsIrcHandshake(innerFirst)) irc.accept(secure);
|
||||
else http.emit('connection', secure);
|
||||
process.nextTick(() => secure.resume());
|
||||
});
|
||||
} else http.emit('connection', socket);
|
||||
process.nextTick(() => socket.resume());
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user