652c27690b
* feat(httpclient): implement HttpClient service for outbound HTTP requests in plugins Signed-off-by: Deluan <deluan@navidrome.org> * feat(httpclient): enhance SSRF protection by validating host requests against private IPs Signed-off-by: Deluan <deluan@navidrome.org> * feat(httpclient): support DELETE requests with body in HttpClient service Signed-off-by: Deluan <deluan@navidrome.org> * feat(httpclient): refactor HTTP client initialization and enhance redirect handling Signed-off-by: Deluan <deluan@navidrome.org> * refactor(http): standardize naming conventions for HTTP types and methods Signed-off-by: Deluan <deluan@navidrome.org> * refactor example plugin to use host.HTTPSend for improved error management Signed-off-by: Deluan <deluan@navidrome.org> * fix(plugins): fix IPv6 SSRF bypass and wildcard host matching Fix two bugs in the plugin HTTP/WebSocket host validation: 1. extractHostname now strips IPv6 brackets when no port is present (e.g. "[::1]" → "::1"). Previously, net.SplitHostPort failed for bracketed IPv6 without a port, leaving brackets intact. This caused net.ParseIP to return nil, bypassing the private/loopback SSRF guard. 2. matchHostPattern now treats "*" as an allow-all pattern. Previously, a bare "*" only matched via exact equality, so plugins declaring requiredHosts: ["*"] (like webhook-rs) had all requests rejected. --------- Signed-off-by: Deluan <deluan@navidrome.org>
58 lines
1.8 KiB
Go
58 lines
1.8 KiB
Go
// Code generated by ndpgen. DO NOT EDIT.
|
|
|
|
/*
|
|
Package host provides Navidrome Plugin Development Kit wrappers for Go/TinyGo plugins.
|
|
|
|
This package is auto-generated by the ndpgen tool and should not be edited manually.
|
|
|
|
# Usage
|
|
|
|
Add this module as a dependency in your plugin's go.mod:
|
|
|
|
require github.com/navidrome/navidrome/plugins/pdk/go/host v0.0.0
|
|
|
|
Then import the package in your plugin code:
|
|
|
|
import host "github.com/navidrome/navidrome/plugins/pdk/go/host"
|
|
|
|
func myPluginFunction() error {
|
|
// Use the cache service
|
|
_, err := host.CacheSetString("my_key", "my_value", 3600)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Schedule a recurring task
|
|
_, err = host.SchedulerScheduleRecurring("@every 5m", "payload", "task_id")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
# Available Services
|
|
|
|
The following host services are available:
|
|
|
|
- Artwork: provides artwork public URL generation capabilities for plugins.
|
|
- Cache: provides in-memory TTL-based caching capabilities for plugins.
|
|
- Config: provides access to plugin configuration values.
|
|
- HTTP: provides outbound HTTP request capabilities for plugins.
|
|
- KVStore: provides persistent key-value storage for plugins.
|
|
- Library: provides access to music library metadata for plugins.
|
|
- Scheduler: provides task scheduling capabilities for plugins.
|
|
- SubsonicAPI: provides access to Navidrome's Subsonic API from plugins.
|
|
- Users: provides access to user information for plugins.
|
|
- WebSocket: provides WebSocket communication capabilities for plugins.
|
|
|
|
# Building Plugins
|
|
|
|
Go plugins must be compiled to WebAssembly using TinyGo:
|
|
|
|
tinygo build -o plugin.wasm -target=wasip1 -buildmode=c-shared .
|
|
|
|
See the examples directory for complete plugin implementations.
|
|
*/
|
|
package host
|