Disallow TURN login after session close

This commit is contained in:
Jannis Mattheis
2020-10-27 10:32:28 +01:00
parent 54530cc7b5
commit 75773e9946
5 changed files with 13 additions and 6 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ func Start(conf config.Config) (*Server, error) {
split := strings.Split(conf.TurnAddress, ":")
svr := &Server{
Port: split[len(split) - 1],
Port: split[len(split)-1],
lookup: map[string]Entry{},
strictAuth: conf.TurnStrictAuth,
}
+2 -2
View File
@@ -36,14 +36,14 @@ func (e *Disconnected) Execute(rooms *Rooms, current ClientInfo) error {
if ok {
host.Write <- outgoing.EndShare(id)
}
room.closeSession(id)
room.closeSession(rooms, id)
}
if bytes.Equal(session.Host.Bytes(), current.ID.Bytes()) {
client, ok := room.Users[session.Client]
if ok {
client.Write <- outgoing.EndShare(id)
}
room.closeSession(id)
room.closeSession(rooms, id)
}
}
+1 -1
View File
@@ -33,7 +33,7 @@ func (e *StopShare) Execute(rooms *Rooms, current ClientInfo) error {
if ok {
client.Write <- outgoing.EndShare(id)
}
room.closeSession(id)
room.closeSession(rooms, id)
}
}
+5 -1
View File
@@ -88,7 +88,11 @@ func (r *Rooms) address(user *User, prefix string) string {
return fmt.Sprintf("%s:%s:%s", prefix, ip, r.turnServer.Port)
}
func (r *Room) closeSession(id xid.ID) {
func (r *Room) closeSession(rooms *Rooms, id xid.ID) {
if r.Mode == ConnectionTURN {
rooms.turnServer.Disallow(id.String() + "host")
rooms.turnServer.Disallow(id.String() + "client")
}
delete(r.Sessions, id)
sessionClosedTotal.Inc()
}
+4 -1
View File
@@ -79,7 +79,10 @@ func (r *Rooms) closeRoom(roomId string) {
return
}
usersLeftTotal.Add(float64(len(room.Users)))
sessionClosedTotal.Add(float64(len(room.Sessions)))
for id := range room.Sessions {
room.closeSession(r, id)
}
delete(r.Rooms, roomId)
roomsClosedTotal.Inc()
}