MCPcopy
hub / github.com/dapr/dapr / TestIsCGNAT

Function TestIsCGNAT

utils/host_test.go:300–328  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

298}
299
300func TestIsCGNAT(t *testing.T) {
301 tests := []struct {
302 ip string
303 want bool
304 }{
305 // Inside 100.64.0.0/10
306 {"100.64.0.0", true},
307 {"100.64.0.1", true},
308 {"100.100.100.100", true},
309 {"100.127.255.255", true},
310
311 // Outside 100.64.0.0/10
312 {"100.63.255.255", false},
313 {"100.128.0.0", false},
314 {"10.0.0.1", false},
315 {"192.168.1.1", false},
316
317 // IPv6 → always false
318 {"2001:db8::1", false},
319 }
320
321 for _, tt := range tests {
322 t.Run(tt.ip, func(t *testing.T) {
323 ip := net.ParseIP(tt.ip)
324 require.NotNil(t, ip)
325 assert.Equal(t, tt.want, isCGNAT(ip))
326 })
327 }
328}

Callers

nothing calls this directly

Calls 3

isCGNATFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected