mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-31 07:30:32 +00:00
refactor(plugins): update newWebSocketService to use WebSocketPermission for allowed hosts
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
17d0e48a01
commit
5201f8a5eb
@ -59,11 +59,11 @@ type webSocketServiceImpl struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newWebSocketService creates a new WebSocketService for a plugin.
|
// newWebSocketService creates a new WebSocketService for a plugin.
|
||||||
func newWebSocketService(pluginName string, manager *Manager, allowedHosts []string) *webSocketServiceImpl {
|
func newWebSocketService(pluginName string, manager *Manager, permission *WebSocketPermission) *webSocketServiceImpl {
|
||||||
return &webSocketServiceImpl{
|
return &webSocketServiceImpl{
|
||||||
pluginName: pluginName,
|
pluginName: pluginName,
|
||||||
manager: manager,
|
manager: manager,
|
||||||
allowedHosts: allowedHosts,
|
allowedHosts: permission.AllowedHosts,
|
||||||
connections: make(map[string]*wsConnection),
|
connections: make(map[string]*wsConnection),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,7 +63,7 @@ var hostServices = []hostServiceEntry{
|
|||||||
registerStubs: func() []extism.HostFunction { return host.RegisterWebSocketHostFunctions(nil) },
|
registerStubs: func() []extism.HostFunction { return host.RegisterWebSocketHostFunctions(nil) },
|
||||||
create: func(ctx *serviceContext) ([]extism.HostFunction, io.Closer) {
|
create: func(ctx *serviceContext) ([]extism.HostFunction, io.Closer) {
|
||||||
perm := ctx.permissions.Websocket
|
perm := ctx.permissions.Websocket
|
||||||
service := newWebSocketService(ctx.pluginName, ctx.manager, perm.AllowedHosts)
|
service := newWebSocketService(ctx.pluginName, ctx.manager, perm)
|
||||||
return host.RegisterWebSocketHostFunctions(service), service
|
return host.RegisterWebSocketHostFunctions(service), service
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user