IpMapper return locIP if corresponding map not set

If we only set v4 or v6 NAT1to1Mapping, then findExternalIP
will failed for the unset ip mapper, the gahter will complain
1:1 NAT mapping is enabled but no external IP is found,
cause that candidate for udp can't be gathered.
This commit is contained in:
cnderrauber
2022-09-26 11:10:21 +08:00
committed by cnderrauber
parent 93980395c8
commit 0cb77c669e
2 changed files with 13 additions and 4 deletions

View File

@@ -289,8 +289,9 @@ func TestExternalIPMapper(t *testing.T) {
assert.NoError(t, err, "should succeed")
// attempt to find IPv6 that does not exist in the map
_, err = m.findExternalIP("fe80::1")
assert.Error(t, err, "should fail")
extIP, err := m.findExternalIP("fe80::1")
assert.NoError(t, err, "should succeed")
assert.Equal(t, "fe80::1", extIP.String(), "should match")
m, err = newExternalIPMapper(CandidateTypeUnspecified, []string{
"2200::1",
@@ -298,7 +299,8 @@ func TestExternalIPMapper(t *testing.T) {
assert.NoError(t, err, "should succeed")
// attempt to find IPv4 that does not exist in the map
_, err = m.findExternalIP("10.0.0.1")
assert.Error(t, err, "should fail")
extIP, err = m.findExternalIP("10.0.0.1")
assert.NoError(t, err, "should succeed")
assert.Equal(t, "10.0.0.1", extIP.String(), "should match")
})
}