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.
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user