Close ends all active meshes with the DERP server.
()
| 143 | |
| 144 | // Close ends all active meshes with the DERP server. |
| 145 | func (m *Mesh) Close() error { |
| 146 | m.mutex.Lock() |
| 147 | defer m.mutex.Unlock() |
| 148 | if m.isClosed() { |
| 149 | return nil |
| 150 | } |
| 151 | close(m.closed) |
| 152 | for _, cancelFunc := range m.active { |
| 153 | cancelFunc() |
| 154 | } |
| 155 | return nil |
| 156 | } |
| 157 | |
| 158 | func (m *Mesh) isClosed() bool { |
| 159 | select { |