Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f1a6b7c
feat: add ip table endpoint decision and verify result types
originalix Jul 16, 2026
39af813
feat: add pure ip table endpoint decision with reachability-first and…
originalix Jul 16, 2026
19aaf4b
feat: reachability-first endpoint selection with fast domain failover
originalix Jul 16, 2026
95a229a
feat: coalesce concurrent ip table speed tests per domain
originalix Jul 16, 2026
f163b49
feat: adapter-level fail-open to builtin ip on domain network failures
originalix Jul 16, 2026
285b3c7
feat: structured ip table config verification with allowlist canonica…
originalix Jul 16, 2026
4a78a79
feat: persist verified config provenance and reject version rollback
originalix Jul 16, 2026
0ad6c1b
feat: fetch ip table cdn config through iptable-capable client
originalix Jul 16, 2026
7c10819
feat: server metrics for ip table failover and verify failures
originalix Jul 16, 2026
12f24d9
feat: dev settings kill switch ui for ip table failover
originalix Jul 16, 2026
8ba9fda
fix: classify transport errors per hostname and gate sni fallback by …
originalix Jul 17, 2026
459abea
fix: escalate coalesced domain-failure speed tests and guard stale se…
originalix Jul 17, 2026
6aaf609
fix: anchor config rollback protection to the active config when unve…
originalix Jul 17, 2026
4110511
fix: direct sni fallback for cdn config fetch on fresh installs
originalix Jul 17, 2026
f5544cf
fix: align failover kill switch semantics between main and bg runtimes
originalix Jul 17, 2026
ea33f98
fix: order request outcomes by start time and dedupe sni failure reports
originalix Jul 17, 2026
28a5f93
fix: unify outcome ordering in a shared start-time ledger for adapter…
originalix Jul 17, 2026
26e1f87
fix: tighten sni pre-write allowlist and preserve failover watermarks…
originalix Jul 17, 2026
153274f
fix: apply signed config verbatim with runtime pruning and per-host d…
originalix Jul 17, 2026
256c8a5
Merge branch 'x' into worktree-iptable-hardening
originalix Jul 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 72 additions & 13 deletions packages/kit-bg/src/dbs/simple/entity/SimpleDbEntityIpTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
IIpTableRemoteConfig,
IIpTableRuntime,
} from '@onekeyhq/shared/src/request/types/ipTable';
import { pruneIpTableRuntimeSelections } from '@onekeyhq/shared/src/utils/ipTableUtils';

import { SimpleDbEntityBase } from '../base/SimpleDbEntityBase';

Expand Down Expand Up @@ -60,20 +61,48 @@ export class SimpleDbEntityIpTable extends SimpleDbEntityBase<ISimpleDbIpTableDa
}

@backgroundMethod()
async saveConfig(config: IIpTableRemoteConfig): Promise<void> {
await this.setRawData((data) => ({
...data,
config,
runtime: {
...(data?.runtime ?? {
enabled: true,
lastUpdated: Date.now(),
lastRegionCheck: 0,
selections: {},
}),
async saveConfig(
config: IIpTableRemoteConfig,
verifiedMeta?: { payloadHash: string },
): Promise<void> {
await this.setRawData((data) => {
const runtime = data?.runtime ?? {
enabled: true,
lastUpdated: Date.now(),
},
}));
lastRegionCheck: 0,
selections: {},
};
// The stored config is the signed envelope verbatim, so runtime state
// pointing at endpoints the new config no longer endorses (revoked or
// rotated-out IPs) must be dropped alongside it.
const pruned = pruneIpTableRuntimeSelections({
config,
selections: runtime.selections,
lastBestIp: runtime.lastBestIp,
});
return {
...data,
config,
runtime: {
...runtime,
selections: pruned.selections,
lastBestIp: pruned.lastBestIp,
lastUpdated: Date.now(),
// Provenance of the last successfully verified config; consumed by
// rollback protection and diagnostics.
...(verifiedMeta
? {
lastVerified: {
at: Date.now(),
version: config.version,
generatedAt: config.generated_at,
payloadHash: verifiedMeta.payloadHash,
},
}
: {}),
},
};
});
}

/**
Expand Down Expand Up @@ -105,6 +134,36 @@ export class SimpleDbEntityIpTable extends SimpleDbEntityBase<ISimpleDbIpTableDa
});
}

/**
* Record the best IP measured by the latest speed test, independent of the
* final selection. Consumed by fast failover when the domain starts failing.
*/
@backgroundMethod()
async updateLastBestIp(domain: string, ip: string): Promise<void> {
await this.setRawData((data) => {
const runtime = data?.runtime ?? {
enabled: true,
lastUpdated: 0,
lastRegionCheck: 0,
selections: {},
};

return {
...data,
config: data?.config ?? null,
currentRegion: data?.currentRegion ?? 'AUTO',
runtime: {
...runtime,
lastBestIp: {
...runtime.lastBestIp,
[domain]: ip,
},
},
version: data?.version ?? 1,
};
});
}

@backgroundMethod()
async setEnabled(enabled: boolean): Promise<void> {
await this.setRawData((data) => ({
Expand Down
Loading
Loading