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
|
### New Features
|
||||||
- Lock controls for users, globally.
|
- Lock controls for users, globally.
|
||||||
|
- Ability to set locks from config `NEKO_LOCKS=control login`.
|
||||||
|
|
||||||
### Misc
|
### Misc
|
||||||
- ARM-based images not bound to Raspberry Pi only.
|
- 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
|
- 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"]}]'
|
- 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)
|
- [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
|
## Agruments
|
||||||
|
@ -9,6 +9,7 @@ type WebSocket struct {
|
|||||||
Password string
|
Password string
|
||||||
AdminPassword string
|
AdminPassword string
|
||||||
Proxy bool
|
Proxy bool
|
||||||
|
Locks []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (WebSocket) Init(cmd *cobra.Command) error {
|
func (WebSocket) Init(cmd *cobra.Command) error {
|
||||||
@ -27,6 +28,11 @@ func (WebSocket) Init(cmd *cobra.Command) error {
|
|||||||
return err
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,4 +40,5 @@ func (s *WebSocket) Set() {
|
|||||||
s.Password = viper.GetString("password")
|
s.Password = viper.GetString("password")
|
||||||
s.AdminPassword = viper.GetString("password_admin")
|
s.AdminPassword = viper.GetString("password_admin")
|
||||||
s.Proxy = viper.GetBool("proxy")
|
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 {
|
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()
|
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{
|
return &WebSocketHandler{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
shutdown: make(chan interface{}),
|
shutdown: make(chan interface{}),
|
||||||
@ -39,7 +48,7 @@ func New(sessions types.SessionManager, remote types.RemoteManager, broadcast ty
|
|||||||
sessions: sessions,
|
sessions: sessions,
|
||||||
webrtc: webrtc,
|
webrtc: webrtc,
|
||||||
banned: make(map[string]bool),
|
banned: make(map[string]bool),
|
||||||
locked: make(map[string]string),
|
locked: locks,
|
||||||
},
|
},
|
||||||
conns: 0,
|
conns: 0,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user