mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
implement config locks.
This commit is contained in:
parent
61fcf7f699
commit
00201af40c
@ -4,6 +4,7 @@
|
||||
|
||||
### New Features
|
||||
- Lock controls for users, globally.
|
||||
- Ability to set locks from config `NEKO_LOCKS=control login`.
|
||||
|
||||
### Misc
|
||||
- ARM-based images not bound to Raspberry Pi only.
|
||||
|
@ -65,6 +65,9 @@ NEKO_ICESERVERS:
|
||||
- Describes multiple STUN and TURN server that can be used by the ICEAgent to establish a connection with a peer
|
||||
- e.g. '[{"urls": ["turn:turn.example.com:19302", "stun:stun.example.com:19302"], "username": "name", "credential": "password"}, {"urls": ["stun:stun.example2.com:19302"]}]'
|
||||
- [More information](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer)
|
||||
NEKO_LOCKS:
|
||||
- Resources, that will be locked when starting, separated by whitespace.
|
||||
- Currently supported: control login
|
||||
```
|
||||
|
||||
## Agruments
|
||||
|
@ -9,6 +9,7 @@ type WebSocket struct {
|
||||
Password string
|
||||
AdminPassword string
|
||||
Proxy bool
|
||||
Locks []string
|
||||
}
|
||||
|
||||
func (WebSocket) Init(cmd *cobra.Command) error {
|
||||
@ -27,6 +28,11 @@ func (WebSocket) Init(cmd *cobra.Command) error {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().StringSlice("locks", []string{}, "resources, that will be locked when starting (control, login)")
|
||||
if err := viper.BindPFlag("locks", cmd.PersistentFlags().Lookup("locks")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -34,4 +40,5 @@ func (s *WebSocket) Set() {
|
||||
s.Password = viper.GetString("password")
|
||||
s.AdminPassword = viper.GetString("password_admin")
|
||||
s.Proxy = viper.GetBool("proxy")
|
||||
s.Locks = viper.GetStringSlice("locks")
|
||||
}
|
||||
|
@ -21,6 +21,15 @@ import (
|
||||
func New(sessions types.SessionManager, remote types.RemoteManager, broadcast types.BroadcastManager, webrtc types.WebRTCManager, conf *config.WebSocket) *WebSocketHandler {
|
||||
logger := log.With().Str("module", "websocket").Logger()
|
||||
|
||||
locks := make(map[string]string)
|
||||
for _, lock := range conf.Locks {
|
||||
locks[lock] = "" // empty session ID
|
||||
}
|
||||
|
||||
if len(conf.Locks) > 0 {
|
||||
logger.Info().Msgf("locked resources: %+v", conf.Locks)
|
||||
}
|
||||
|
||||
return &WebSocketHandler{
|
||||
logger: logger,
|
||||
shutdown: make(chan interface{}),
|
||||
@ -39,7 +48,7 @@ func New(sessions types.SessionManager, remote types.RemoteManager, broadcast ty
|
||||
sessions: sessions,
|
||||
webrtc: webrtc,
|
||||
banned: make(map[string]bool),
|
||||
locked: make(map[string]string),
|
||||
locked: locks,
|
||||
},
|
||||
conns: 0,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user