Enhance configuration and documentation for CIDR and IP handling. Updated config.example.yaml to include additional whitelisted IPs and new server entries. Improved GATEWAY_RUN.md to clarify CIDR and single IP usage. Implemented parseCIDROrIP function in config.go for better validation of IP formats in whitelist and trusted proxies.
Publish telemt-api gateway Docker image / test (push) Successful in 39s
Publish telemt-api gateway Docker image / build-and-push (push) Successful in 1m45s

This commit is contained in:
Denozordec
2026-03-30 00:00:49 +07:00
parent 073d2b2c09
commit e58f504395
4 changed files with 56 additions and 7 deletions
+20
View File
@@ -31,6 +31,26 @@ servers:
}
}
func TestParseCIDRorIP(t *testing.T) {
for _, tc := range []struct {
in string
want string
}{
{"87.103.241.8", "87.103.241.8/32"},
{"87.103.241.8/32", "87.103.241.8/32"},
{"10.0.0.0/8", "10.0.0.0/8"},
{"2001:db8::1", "2001:db8::1/128"},
} {
p, err := parseCIDROrIP(tc.in)
if err != nil {
t.Fatalf("%q: %v", tc.in, err)
}
if p.String() != tc.want {
t.Fatalf("%q: got %s want %s", tc.in, p, tc.want)
}
}
}
func TestValidateDuplicateAlias(t *testing.T) {
c := &Config{
Servers: []Server{