Files
NexusGate/panel-go/redact.go
aaaamoooo 3951134940
CI / test (push) Canceled after 0s
CI / anytls-smoke (push) Canceled after 0s
feat: Go port of the panel in panel-go/ — drop-in replacement for server.js
Pure-stdlib Go implementation of the whole control plane: same
nexusgate.json schema (unknown fields preserved verbatim, explicit
null/false tri-states modeled), same HTTP API and error strings,
embedded frontend (NG_PUBLIC_DIR override), self-implemented scrypt
auth, X25519 Reality keys, panel-hosted keyStore and heartbeat
reconciliation included. Version stays 0.6.8.

Verified: Go tests 33/33 (scrypt + Reality vectors generated from
the Node implementation, subscription goldens byte-identical),
Node suite 52/52 untouched, differential E2E against the Node
panel 50/50 including two-way DB swap. See panel-go/PARITY.md
and panel-go/INSTALL-GO.md.
2026-10-20 08:21:54 +00:00

23 lines
797 B
Go

package main
// Port of lib/redact.js. The three patterns and replacements are copied
// verbatim from the JS regexes (all case-insensitive) and applied in the
// same order.
import "regexp"
var (
rePrivateKey = regexp.MustCompile(`(?i)\bPrivate\s*Key\s*:\s*[^\s,;]+`)
reAgentKey = regexp.MustCompile(`(?i)\bNG_AGENT_KEY\s*=\s*[^\s,;]+`)
reBearerToken = regexp.MustCompile(`(?i)\bBearer\s+[^\s,;]+`)
)
// RedactSecrets strips Reality private keys, agent keys and bearer tokens
// from a string before it is retained in job history or API responses.
func RedactSecrets(s string) string {
s = rePrivateKey.ReplaceAllString(s, "PrivateKey: [REDACTED]")
s = reAgentKey.ReplaceAllString(s, "NG_AGENT_KEY=[REDACTED]")
s = reBearerToken.ReplaceAllString(s, "Bearer [REDACTED]")
return s
}