Register: kick out old session when number is taken
When a new session registers with an already-taken number, close the old connection. Prevents two devices from sharing the same number simultaneously.
This commit is contained in:
parent
22e33f0e5f
commit
ba79f81721
1 changed files with 3 additions and 0 deletions
|
|
@ -418,6 +418,9 @@ func marshalIdentityResponse(number string, certDER, caCertPEM []byte) []byte {
|
|||
func (s *Server) Register(sess call.CallSession, number string) {
|
||||
s.sessionsMu.Lock()
|
||||
defer s.sessionsMu.Unlock()
|
||||
if old, ok := s.sessions[number]; ok && old != sess {
|
||||
old.Conn().CloseWithError(0, "replaced by new session")
|
||||
}
|
||||
s.sessions[number] = sess.(*Session)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue