mirror of
https://github.com/screego/server.git
synced 2026-08-30 17:33:30 +08:00
Disallow TURN login after session close
This commit is contained in:
+1
-1
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user