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)
| 182 | // existing mapped addresses from the mapping, which as a result should cause |
| 183 | // discovery to reannounce the new addresses. |
| 184 | func (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 |