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

11
web.go
View File

@@ -168,6 +168,7 @@ func setupRouter() *gin.Engine {
protected.GET("/storage/download", handleDownloadHttp)
protected.GET("/storage/sd-download", handleSDDownloadHttp)
protected.POST("/api/rpc", handleRpcRequest)
protected.GET("/api/ice-servers", handleGetIceServers)
protected.GET("/terminal/ws", handleTerminalWS)
protected.GET("/serial/ws", handleSerialWS)
protected.GET("/video/stream", handleVideoStream)
@@ -907,6 +908,16 @@ func handleRpcRequest(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
func handleGetIceServers(c *gin.Context) {
LoadConfig()
servers, err := rpcGetIceServers()
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"iceServers": servers})
}
func handleVideoStream(c *gin.Context) {
logger.Info().Msg("HTTP video stream request received")