MCPcopy
hub / github.com/syncthing/syncthing / RemoveMapping

Method RemoveMapping

lib/nat/service.go:184–197  ·  view source on GitHub ↗

RemoveMapping does not actually remove the mapping from the IGD, it just internally removes it which stops renewing the mapping. Also, it clears any existing mapped addresses from the mapping, which as a result should cause discovery to reannounce the new addresses.

(mapping *Mapping)

Source from the content-addressed store, hash-verified

182// existing mapped addresses from the mapping, which as a result should cause
183// discovery to reannounce the new addresses.
184func (s *Service) RemoveMapping(mapping *Mapping) {
185 s.mut.Lock()
186 defer s.mut.Unlock()
187 for i, existing := range s.mappings {
188 if existing == mapping {
189 mapping.clearAddresses()
190 last := len(s.mappings) - 1
191 s.mappings[i] = s.mappings[last]
192 s.mappings[last] = nil
193 s.mappings = s.mappings[:last]
194 return
195 }
196 }
197}
198
199// updateMapping compares the addresses of the existing mapping versus the natds
200// discovered, and removes any addresses of natds that do not exist, or tries to

Callers 3

serveMethod · 0.80
serveMethod · 0.80

Calls 2

UnlockMethod · 0.80
clearAddressesMethod · 0.45

Tested by 1