mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-02 19:25:05 +03:00
feat(amneziawg): support persistent keepalive ranges (#6881)
AmneziaWG clients accept a randomised PersistentKeepalive range such as 15-25, which makes keepalive timing harder to fingerprint; the panel only stored a single number. A client's keepalive may now be a range, validated the way AmneziaWG parses it. The downloadable .conf and vpn:// profile carry the range, Clash/Mihomo output gets its lower bound, and plain WireGuard stays scalar-only. The range lives in an additive wg_keep_alive_range column, so the integer column and an older panel binary keep working after a rollback.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Base64, Wireguard } from '@/utils';
|
||||
import { effectiveMtu } from '@/lib/xray/amneziawg-obfuscation';
|
||||
import { AmneziaWGKeepAliveRangeSchema } from '@/schemas/primitives/keepalive';
|
||||
|
||||
import type { Inbound } from '@/schemas/api/inbound';
|
||||
import type { AmneziawgInboundSettings } from '@/schemas/protocols/inbound/amneziawg';
|
||||
@@ -1127,7 +1128,10 @@ export function genAmneziaWGConfig(input: GenAmneziaWGLinkInput): string {
|
||||
lines.push(`PresharedKey = ${client.preSharedKey}`);
|
||||
}
|
||||
lines.push('AllowedIPs = 0.0.0.0/0, ::/0', `Endpoint = ${address}:${port}`);
|
||||
if (typeof client.keepAlive === 'number' && client.keepAlive > 0) {
|
||||
if (typeof client.keepAlive === 'string') {
|
||||
if (!AmneziaWGKeepAliveRangeSchema.safeParse(client.keepAlive).success) return '';
|
||||
lines.push(`PersistentKeepalive = ${client.keepAlive}`);
|
||||
} else if (typeof client.keepAlive === 'number' && client.keepAlive > 0) {
|
||||
lines.push(`PersistentKeepalive = ${client.keepAlive}`);
|
||||
}
|
||||
return joinConfLines(lines);
|
||||
|
||||
Reference in New Issue
Block a user