mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-27 09:42:10 +03:00
fix(amneziawg): resolve all 3 real CI failures (typecheck/lint/codegen)
Found by checking the fork's Actions tab after the last two pushes —
the release build passed (it doesn't run these checks) but the
separate CI workflow caught three real issues:
- golangci-lint (noctx): every internal/amneziawg/manager.go exec.Command
call is now exec.CommandContext with a 30s timeout, so a hung
awg-quick/awg invocation can't block the reconcile job indefinitely
(mirrors internal/mtproto/process.go's own CommandContext usage).
- tsc --noEmit: frontend/src/schemas/client.ts's hand-maintained
InboundOptionSchema (used by the useClients hook, separate from the
auto-generated one in generated/) never got an awgServer field added
when the AmneziaWG frontend work was done — every read of
inbound.awgServer.* in amneziawgConfig.ts was typing as {}. Added
AwgServerOptionSchema, nested (not flattened like wg*) to match what
amneziawgConfig.ts already expects. Also guarded server.publicKey in
inbound-link.ts's genAmneziaWGLink against the schema's optional type.
- codegen staleness: frontend/public/openapi.json is produced by a Node
script (gen:api) this machine can't run; hand-applied the exact diff
the CI failure log already showed (amneziawg protocol enum entry,
ServerSettings schema, InboundOption.awgServer, one example payload),
verified as valid JSON.
Also confirmed independently by this run: install_amneziawg (previous
commit) installed and loaded the DKMS module successfully on both amd64
and arm64 CI runners. The two "Deploy Smoke Tests" failures are
unrelated to this change — this fork has only ever published the
dev-latest pre-release, and GitHub's /releases/latest API deliberately
excludes pre-releases, so the smoke test's no-argument install path
(which resolves "latest") has nothing to find. Not a regression; needs
an actual tagged release whenever that's wanted.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -899,7 +899,7 @@ export function genAmneziaWGLink(input: GenAmneziaWGLinkInput): string {
|
||||
const url = new URL(`amneziawg://${formatUrlHost(address)}:${port}`);
|
||||
url.username = client.privateKey ?? '';
|
||||
|
||||
if (server.publicKey.length > 0) url.searchParams.set('publickey', server.publicKey);
|
||||
if (server.publicKey && server.publicKey.length > 0) url.searchParams.set('publickey', server.publicKey);
|
||||
if ((client.allowedIPs ?? []).length > 0) {
|
||||
url.searchParams.set('address', client.allowedIPs.join(','));
|
||||
}
|
||||
|
||||
@@ -43,6 +43,32 @@ export const ClientRecordSchema = z.object({
|
||||
updatedAt: z.number().optional(),
|
||||
}).loose();
|
||||
|
||||
// AmneziaWG's server block, used by the clients page to render a
|
||||
// downloadable per-client .conf without a second round trip. Unlike
|
||||
// WireGuard's flattened wgPublicKey/wgMtu/wgDns below, this stays a nested
|
||||
// object — AmneziaWG has many more fields (the obfuscation parameter set) and
|
||||
// buildAmneziaWGClientConfig (pages/clients/amneziawgConfig.ts) already
|
||||
// expects this exact nested shape. Mirrors the backend's
|
||||
// InboundOption.AwgServer (internal/web/service/inbound.go).
|
||||
export const AwgServerOptionSchema = z.object({
|
||||
publicKey: z.string().optional(),
|
||||
mtu: z.number().optional(),
|
||||
primaryDns: z.string().optional(),
|
||||
secondaryDns: z.string().optional(),
|
||||
jc: z.number().optional(),
|
||||
jmin: z.number().optional(),
|
||||
jmax: z.number().optional(),
|
||||
s1: z.number().optional(),
|
||||
s2: z.number().optional(),
|
||||
s3: z.number().optional(),
|
||||
s4: z.number().optional(),
|
||||
h1: z.string().optional(),
|
||||
h2: z.string().optional(),
|
||||
h3: z.string().optional(),
|
||||
h4: z.string().optional(),
|
||||
i1: z.string().optional(),
|
||||
}).loose();
|
||||
|
||||
export const InboundOptionSchema = z.object({
|
||||
id: z.number(),
|
||||
remark: z.string().optional(),
|
||||
@@ -54,6 +80,7 @@ export const InboundOptionSchema = z.object({
|
||||
wgPublicKey: z.string().optional(),
|
||||
wgMtu: z.number().optional(),
|
||||
wgDns: z.string().optional(),
|
||||
awgServer: AwgServerOptionSchema.nullable().optional(),
|
||||
mtprotoDomain: z.string().optional(),
|
||||
// Hosting node id; absent/null for this panel's own inbounds (#4997).
|
||||
nodeId: z.number().nullable().optional(),
|
||||
|
||||
Reference in New Issue
Block a user