mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-25 19:39:46 +01:00
* fix(plugins): align the Python HTTP example with the repo's host-call pattern
Bind http_send with raw memory offsets like nowplaying-py does, drop
guards for fields the host always sends, and document how plugins
without a PDK call host services and which built-in HTTP APIs are
disabled.
* docs(plugins): document the private-address rules for HTTP requiredHosts
Explain in the README and manifest schema that named hosts can't reach
private addresses while IP/CIDR entries and a bare "*" can.
* docs(plugins): document the private-address rules for requiredHosts
Explain in the README and manifest schema that named hosts can't reach
private addresses while IP/CIDR entries and a bare "*" can, for both
HTTP and WebSocket. Inline the single-use HTTP isHostAllowed wrapper.
* feat(plugins): derive Default for Rust host service structs
The ndpgen client.rs template now adds Default to the derive list of host
service structs, as the capability and shared types templates already do.
Plugin authors can now set only the fields they need, for example
HTTPRequest { method, url, ..Default::default() }. The webhook-rs and
discord-rich-presence-rs examples use this form now. The golden files and
the generated nd-pdk-host crate are updated to match.
* feat(plugins): deprecate pdk.NewHTTPRequest in the Go PDK
Navidrome no longer enables extism's http_request host function, so a
request built with pdk.NewHTTPRequest always fails. ndpgen now reads a small
deprecation table and writes a Deprecated: paragraph for the listed extism
functions, in both the WASM wrapper and the native stub. Linters and IDEs
now point plugin authors to host.HTTPSend. The PDK example tests used to
teach NewHTTPRequest. They now use host.HTTPSend and host.HTTPMock.
* docs(plugins): correct requiredHosts rules for websocket and private addresses
Two statements in the plugin docs did not match the code.
The WebSocket section claimed requiredHosts behaves like HTTP. It does not:
host_httpclient.go only consults the allowlist when the list is non-empty and
otherwise falls back to allowing public addresses, while host_websocket.go
always calls isHostInAllowlist, so an absent list blocks every connection.
The HTTP section claimed a named host can never reach a private address.
checkPrivateDial scans the whole requiredHosts list, so a named host does
reach a private address when the same list also holds a covering IP or CIDR.
Reworded both, plus the matching requiredHosts descriptions in
manifest-schema.json, and regenerated manifest_gen.go.
206 lines
5.9 KiB
Go
206 lines
5.9 KiB
Go
// Code generated by ndpgen. DO NOT EDIT.
|
|
//
|
|
// This file contains wrapper functions for the extism/go-pdk package.
|
|
// For WASM builds, it provides type aliases and function wrappers that delegate
|
|
// to the real extism/go-pdk package with zero overhead.
|
|
//
|
|
//go:build wasip1
|
|
|
|
package pdk
|
|
|
|
import (
|
|
extism "github.com/extism/go-pdk"
|
|
)
|
|
|
|
// Type aliases - zero overhead, full compatibility
|
|
type HTTPMethod = extism.HTTPMethod
|
|
type HTTPRequest = extism.HTTPRequest
|
|
type HTTPRequestMeta = extism.HTTPRequestMeta
|
|
type HTTPResponse = extism.HTTPResponse
|
|
type LogLevel = extism.LogLevel
|
|
type Memory = extism.Memory
|
|
|
|
// Constants
|
|
|
|
const (
|
|
LogDebug = extism.LogDebug
|
|
LogError = extism.LogError
|
|
LogInfo = extism.LogInfo
|
|
LogTrace = extism.LogTrace
|
|
LogWarn = extism.LogWarn
|
|
)
|
|
|
|
const (
|
|
MethodConnect = extism.MethodConnect
|
|
MethodDelete = extism.MethodDelete
|
|
MethodGet = extism.MethodGet
|
|
MethodHead = extism.MethodHead
|
|
MethodOptions = extism.MethodOptions
|
|
MethodPatch = extism.MethodPatch
|
|
MethodPost = extism.MethodPost
|
|
MethodPut = extism.MethodPut
|
|
MethodTrace = extism.MethodTrace
|
|
)
|
|
|
|
// Functions
|
|
func Allocate(length int) Memory {
|
|
return extism.Allocate(length)
|
|
}
|
|
func AllocateBytes(data []byte) Memory {
|
|
return extism.AllocateBytes(data)
|
|
}
|
|
|
|
// AllocateJSON AllocateJSON allocates and saves the type `any` into Memory on the host.
|
|
func AllocateJSON(v any) (Memory, error) {
|
|
return extism.AllocateJSON(v)
|
|
}
|
|
|
|
// AllocateString AllocateString allocates and saves the UTF-8 string `data` into Memory on the host.
|
|
func AllocateString(data string) Memory {
|
|
return extism.AllocateString(data)
|
|
}
|
|
|
|
// FindMemory FindMemory finds the host memory block at the given `offset`.
|
|
func FindMemory(offset uint64) Memory {
|
|
return extism.FindMemory(offset)
|
|
}
|
|
|
|
// GetConfig GetConfig returns the config string associated with `key` (if any).
|
|
func GetConfig(key string) (string, bool) {
|
|
return extism.GetConfig(key)
|
|
}
|
|
|
|
// GetVar GetVar returns the byte slice (if any) associated with `key`.
|
|
func GetVar(key string) []byte {
|
|
return extism.GetVar(key)
|
|
}
|
|
|
|
// GetVarInt GetVarInt returns the int associated with `key` (or 0 if none).
|
|
func GetVarInt(key string) int {
|
|
return extism.GetVarInt(key)
|
|
}
|
|
|
|
// Input Input returns a slice of bytes from the host.
|
|
func Input() []byte {
|
|
return extism.Input()
|
|
}
|
|
|
|
// InputJSON InputJSON returns unmartialed JSON data from the host "input".
|
|
func InputJSON(v any) error {
|
|
return extism.InputJSON(v)
|
|
}
|
|
|
|
// InputString InputString returns the input data from the host as a UTF-8 string.
|
|
func InputString() string {
|
|
return extism.InputString()
|
|
}
|
|
|
|
// JSONFrom JSONFrom unmarshals a `Memory` block located at `offset` from the host into the provided data `v`.
|
|
func JSONFrom(offset uint64, v any) error {
|
|
return extism.JSONFrom(offset, v)
|
|
}
|
|
|
|
// Log Log logs the provided UTF-8 string `s` on the host using the provided log `level`.
|
|
func Log(level LogLevel, s string) {
|
|
extism.Log(level, s)
|
|
}
|
|
|
|
// LogMemory LogMemory logs the `memory` block on the host using the provided log `level`.
|
|
func LogMemory(level LogLevel, m Memory) {
|
|
extism.LogMemory(level, m)
|
|
}
|
|
|
|
// NewHTTPRequest NewHTTPRequest returns a new `HTTPRequest`.
|
|
//
|
|
// Deprecated: Navidrome does not enable extism's http_request host function, so every request sent this way fails. Use host.HTTPSend instead.
|
|
func NewHTTPRequest(method HTTPMethod, url string) *HTTPRequest {
|
|
return extism.NewHTTPRequest(method, url)
|
|
}
|
|
func NewMemory(offset uint64, length uint64) Memory {
|
|
return extism.NewMemory(offset, length)
|
|
}
|
|
|
|
// Output Output sends the `data` slice of bytes to the host output.
|
|
func Output(data []byte) {
|
|
extism.Output(data)
|
|
}
|
|
|
|
// OutputJSON OutputJSON marshals the provided data `v` as output to the host.
|
|
func OutputJSON(v any) error {
|
|
return extism.OutputJSON(v)
|
|
}
|
|
|
|
// OutputMemory OutputMemory sends the `mem` Memory to the host output.
|
|
func OutputMemory(mem Memory) {
|
|
extism.OutputMemory(mem)
|
|
}
|
|
|
|
// OutputString OutputString sends the UTF-8 string `s` to the host output.
|
|
func OutputString(s string) {
|
|
extism.OutputString(s)
|
|
}
|
|
|
|
// ParamBytes ParamBytes returns bytes from Extism host memory given an offset.
|
|
func ParamBytes(offset uint64) []byte {
|
|
return extism.ParamBytes(offset)
|
|
}
|
|
|
|
// ParamString ParamString returns UTF-8 string data from Extism host memory given an offset.
|
|
func ParamString(offset uint64) string {
|
|
return extism.ParamString(offset)
|
|
}
|
|
|
|
// ParamU32 ParamU32 returns a uint32 from Extism host memory given an offset.
|
|
func ParamU32(offset uint64) uint32 {
|
|
return extism.ParamU32(offset)
|
|
}
|
|
|
|
// ParamU64 ParamU64 returns a uint64 from Extism host memory given an offset.
|
|
func ParamU64(offset uint64) uint64 {
|
|
return extism.ParamU64(offset)
|
|
}
|
|
|
|
// RemoveVar RemoveVar removes (and frees) the host variable associated with `key`.
|
|
func RemoveVar(key string) {
|
|
extism.RemoveVar(key)
|
|
}
|
|
|
|
// ResultBytes ResultBytes allocates bytes and returns the offset in Extism host memory.
|
|
func ResultBytes(d []byte) uint64 {
|
|
return extism.ResultBytes(d)
|
|
}
|
|
|
|
// ResultString ResultString allocates a UTF-8 string and returns the offset in Extism host memory.
|
|
func ResultString(s string) uint64 {
|
|
return extism.ResultString(s)
|
|
}
|
|
|
|
// ResultU32 ResultU32 allocates a uint32 and returns the offset in Extism host memory.
|
|
func ResultU32(d uint32) uint64 {
|
|
return extism.ResultU32(d)
|
|
}
|
|
|
|
// ResultU64 ResultU64 allocates a uint64 and returns the offset in Extism host memory.
|
|
func ResultU64(d uint64) uint64 {
|
|
return extism.ResultU64(d)
|
|
}
|
|
|
|
// SetError SetError sets the host error string from `err`.
|
|
func SetError(err error) {
|
|
extism.SetError(err)
|
|
}
|
|
|
|
// SetErrorString SetErrorString sets the host error string from `err`.
|
|
func SetErrorString(err string) {
|
|
extism.SetErrorString(err)
|
|
}
|
|
|
|
// SetVar SetVar sets the host variable associated with `key` to the `value` byte slice.
|
|
func SetVar(key string, value []byte) {
|
|
extism.SetVar(key, value)
|
|
}
|
|
|
|
// SetVarInt SetVarInt sets the host variable associated with `key` to the `value` int.
|
|
func SetVarInt(key string, value int) {
|
|
extism.SetVarInt(key, value)
|
|
}
|