MCPcopy
hub / github.com/syncthing/syncthing / TestMappingClearAddresses

Function TestMappingClearAddresses

lib/nat/structs_test.go:61–80  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestMappingClearAddresses(t *testing.T) {
62 tmpFile, err := os.CreateTemp("", "syncthing-testConfig-")
63 if err != nil {
64 t.Fatal(err)
65 }
66 w := config.Wrap(tmpFile.Name(), config.Configuration{}, protocol.LocalDeviceID, events.NoopLogger)
67 defer os.RemoveAll(tmpFile.Name())
68 tmpFile.Close()
69
70 natSvc := NewService(protocol.EmptyDeviceID, w)
71 // Mock a mapped port; avoids the need to actually map a port
72 ip := net.ParseIP("192.168.0.1")
73 m := natSvc.NewMapping(TCP, IPv4Only, ip, 1024)
74 m.extAddresses["test"] = []Address{{
75 IP: ip,
76 Port: 1024,
77 }}
78 // Now try and remove the mapped port; prior to #4829 this deadlocked
79 natSvc.RemoveMapping(m)
80}

Callers

nothing calls this directly

Calls 8

NewMappingMethod · 0.95
RemoveMappingMethod · 0.95
WrapFunction · 0.92
FatalMethod · 0.80
NewServiceFunction · 0.70
NameMethod · 0.65
RemoveAllMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected