feat(webrtc): add configurable STUN and TURN servers

Add backend config, RPC handlers, and an HTTP endpoint for WebRTC ICE servers. Replace hardcoded frontend STUN usage with server-provided ICE server configuration, and add access settings UI for STUN and TURN entries.
This commit is contained in:
Augtons
2026-05-03 16:43:29 +08:00
parent d5bfaffd86
commit f1a6c75fc0
12 changed files with 354 additions and 31 deletions

View File

@@ -21,6 +21,12 @@ type WakeOnLanDevice struct {
MacAddress string `json:"macAddress"`
}
type TurnServer struct {
URL string `json:"url"`
Username string `json:"username"`
Credential string `json:"credential"`
}
// Constants for keyboard macro limits
const (
MaxMacrosPerDevice = 25
@@ -81,6 +87,7 @@ func (m *KeyboardMacro) Validate() error {
type Config struct {
STUN string `json:"stun"`
TurnServers []TurnServer `json:"turn_servers"`
JigglerEnabled bool `json:"jiggler_enabled"`
AutoUpdateEnabled bool `json:"auto_update_enabled"`
IncludePreRelease bool `json:"include_pre_release"`
@@ -185,6 +192,7 @@ const sdConfigPath = "/mnt/sdcard/kvm_config.json"
var defaultConfig = &Config{
STUN: "stun:stun.l.google.com:19302",
TurnServers: []TurnServer{},
AutoUpdateEnabled: false, // Set a default value
ActiveExtension: "",
KeyboardMacros: []KeyboardMacro{},
@@ -299,6 +307,10 @@ func LoadConfig() {
loadedConfig.Firewall = defaultConfig.Firewall
}
if loadedConfig.TurnServers == nil {
loadedConfig.TurnServers = []TurnServer{}
}
config = &loadedConfig
logging.GetRootLogger().UpdateLogLevel(config.DefaultLogLevel)