Close stops the TURN Server. It cleans up any associated state and closes all connections it is managing.
()
| 135 | // Close stops the TURN Server. |
| 136 | // It cleans up any associated state and closes all connections it is managing. |
| 137 | func (s *Server) Close() error { |
| 138 | var errors []error |
| 139 | |
| 140 | for _, cfg := range s.packetConnConfigs { |
| 141 | if err := cfg.PacketConn.Close(); err != nil { |
| 142 | errors = append(errors, err) |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | for _, cfg := range s.listenerConfigs { |
| 147 | if err := cfg.Listener.Close(); err != nil { |
| 148 | errors = append(errors, err) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | if len(errors) == 0 { |
| 153 | return nil |
| 154 | } |
| 155 | |
| 156 | err := errFailedToClose |
| 157 | for _, e := range errors { |
| 158 | err = fmt.Errorf("%s; close error (%w) ", err, e) //nolint:errorlint |
| 159 | } |
| 160 | |
| 161 | return err |
| 162 | } |
| 163 | |
| 164 | func (s *Server) readListener(l net.Listener, am *allocation.Manager) { |
| 165 | for { |