MCPcopy Create free account
hub / github.com/PasarGuard/node / Close

Method Close

backend/wireguard/manager.go:253–278  ·  view source on GitHub ↗

Close cleans up the WireGuard manager and removes the interface

()

Source from the content-addressed store, hash-verified

251
252// Close cleans up the WireGuard manager and removes the interface
253func (m *Manager) Close() error {
254 m.mu.Lock()
255 defer m.mu.Unlock()
256
257 var errs []error
258
259 client := m.client
260 m.client = nil
261
262 // Close wgctrl client
263 if client != nil {
264 if err := client.Close(); err != nil {
265 errs = append(errs, fmt.Errorf("client close: %w", err))
266 }
267 }
268
269 // Remove interface
270 if err := m.cleanupExistingInterface(); err != nil {
271 errs = append(errs, err)
272 }
273
274 if len(errs) > 0 {
275 return errors.Join(errs...)
276 }
277 return nil
278}
279
280// cleanupExistingInterface removes existing interface if it exists
281func (m *Manager) cleanupExistingInterface() error {

Callers

nothing calls this directly

Calls 2

CloseMethod · 0.65

Tested by

no test coverage detected