There was an error while loading. Please reload this page.
2 parents 15987bc + 75a9443 commit cc8c782Copy full SHA for cc8c782
1 file changed
moss-live-labs/examples/voice-agent/web/lib/tokenGuard.ts
@@ -52,7 +52,16 @@ export function warnTokenGuardMisconfig(config: TokenGuardConfig): void {
52
}
53
54
function normalizeIp(ip: string): string {
55
- return ip.trim().toLowerCase().replace(/^\[|\]$/g, "");
+ const normalized = ip.trim().toLowerCase();
56
+ const unwrapped =
57
+ normalized.startsWith("[") && normalized.endsWith("]")
58
+ ? normalized.slice(1, -1)
59
+ : normalized;
60
+ if (unwrapped.startsWith("::ffff:")) {
61
+ const v4 = unwrapped.slice("::ffff:".length);
62
+ if (isValidIpv4(v4)) return v4;
63
+ }
64
+ return unwrapped;
65
66
67
/** Valid dotted IPv4 with each octet in 0–255 (no leading junk). */
0 commit comments