fix(native): handle local HTTPS and allow shared log reads
Use the loopback service certificate for the offline HTTPS path. Retain original host names for host-based routing and allow the network log to be read while the client is running.
This commit is contained in:
1 parent
b6b6effef3
commit
ddb381d7f9
5 files changed
+65
-18
No files matched your search
@@ -5,13 +5,14 @@
|
||||
* http(s)://host[:port]/path -> http://127.0.0.1:<port>/host/path (host is a Gaijin domain or an external IP)
|
||||
* ws(s)://host[:port]/path -> ws://127.0.0.1:<port>/host/path
|
||||
* host:port -> 127.0.0.1:<port> (raw TCP endpoints: matching, chat)
|
||||
* host -> 127.0.0.1 (bare Gaijin domain, e.g. the event log host)
|
||||
*
|
||||
* Everything else (file patterns, placeholders such as "https://not.used", DNS server IPs)
|
||||
* is left as it is.
|
||||
* Bare Gaijin host names without a port (e.g. the event log host) are left as they are so the
|
||||
* client keeps their Host header and SNI; wto_ws.dll resolves them locally and sends their
|
||||
* connections to the local service port. Everything else (file patterns,
|
||||
* placeholders such as "https://not.used", DNS server IPs) is also left as it is.
|
||||
*/
|
||||
import { visitParams, type BlkBlock } from '@wto/blk';
|
||||
import { hostPort, localUrl, LOOPBACK, type LocalEndpoint } from './local-endpoint.ts';
|
||||
import { hostPort, localUrl, type LocalEndpoint } from './local-endpoint.ts';
|
||||
|
||||
export interface AddressChange {
|
||||
readonly path: string;
|
||||
@@ -47,7 +48,7 @@ export function rewriteAddress(value: string, endpoint: LocalEndpoint): string |
|
||||
}
|
||||
const hostAndPort = HOST_PORT_PATTERN.exec(value);
|
||||
if (hostAndPort) return isServerHost(hostAndPort[1]!.toLowerCase()) ? hostPort(endpoint) : null;
|
||||
return isGaijinDomain(value.toLowerCase()) ? LOOPBACK : null;
|
||||
return null;
|
||||
}
|
||||
|
||||
function isServerHost(host: string): boolean {
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
* certain (https://auth.gaijinent.com/login.php); the others are matched by name to the
|
||||
* addresses in the executable's string table.
|
||||
*
|
||||
* The host keys replace only the host name of every login-related address and keep the
|
||||
* address's port (yuplay2 YuSession::updateApiHost sets the host part). They therefore get
|
||||
* the bare loopback address: "127.0.0.1:<port>" would turn the local login URL into
|
||||
* http://127.0.0.1:<port>:<port>/..., which the game rejects as malformed.
|
||||
* The host-only keys (authHost, ssoHost, storeApiHost, authFallbackHost) are intentionally not
|
||||
* set: they replace only the host name and keep port 443, and turning the host into 127.0.0.1
|
||||
* would strip the original Host header and bypass wto_ws.dll's redirection. Leaving the Gaijin
|
||||
* host names in place lets wto_ws.dll resolve them to 127.0.0.2 and route their TLS connections
|
||||
* to the local service port with the original Host header intact.
|
||||
*/
|
||||
import { localUrl, LOOPBACK, type LocalEndpoint } from './local-endpoint.ts';
|
||||
import { localUrl, type LocalEndpoint } from './local-endpoint.ts';
|
||||
|
||||
const URL_DEFAULTS: ReadonlyArray<readonly [key: string, host: string, path: string]> = [
|
||||
['loginURL', 'auth.gaijinent.com', '/login.php'],
|
||||
@@ -23,12 +24,6 @@ const URL_DEFAULTS: ReadonlyArray<readonly [key: string, host: string, path: str
|
||||
['yupURL', 'yupmaster.gaijinent.com', '/yuitem/get_yup.php'],
|
||||
];
|
||||
|
||||
const HOST_KEYS = ['authHost', 'ssoHost', 'storeApiHost', 'authFallbackHost'];
|
||||
|
||||
export function loginOverrides(endpoint: LocalEndpoint): ReadonlyArray<readonly [key: string, value: string]> {
|
||||
return [
|
||||
...URL_DEFAULTS.map(([key, host, path]) => [key, localUrl(endpoint, host, path)] as const),
|
||||
...HOST_KEYS.map((key) => [key, LOOPBACK] as const),
|
||||
['fallbackIP', LOOPBACK],
|
||||
];
|
||||
return URL_DEFAULTS.map(([key, host, path]) => [key, localUrl(endpoint, host, path)] as const);
|
||||
}
|
||||
Reference in new issue
Block a user