push! PUSH!!

This commit is contained in:
legop3
2025-11-14 03:45:51 -05:00
parent 440325296c
commit 026ce2efac
10 changed files with 12 additions and 162 deletions
-31
View File
@@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"net"
"net/url"
"os"
"strings"
"time"
@@ -60,7 +59,6 @@ type MediaConfig struct {
WhepPort int `yaml:"whepPort" json:"-"`
WhepPath string `yaml:"whepPath" json:"-"`
LegacyPublish string `yaml:"publishUrl,omitempty" json:"-"`
BridgeWhepURL string `yaml:"-" json:"bridgeWhepUrl,omitempty"`
Manage bool `yaml:"manage"`
Service string `yaml:"service"`
HealthURL string `yaml:"healthUrl"`
@@ -143,38 +141,9 @@ func LoadConfig(path string) (*Config, error) {
scheme := "http"
cfg.Media.WhepURL = fmt.Sprintf("%s://%s:%d%s", scheme, ip, effectivePort(cfg.Media.WhepPort), path)
}
if bridge, err := buildBridgeURL(cfg.Media.WhepURL); err == nil {
cfg.Media.BridgeWhepURL = bridge
}
return &cfg, nil
}
func buildBridgeURL(src string) (string, error) {
if src == "" {
return "", errors.New("empty whep url")
}
parsed, err := url.Parse(src)
if err != nil {
return "", err
}
if parsed.Host == "" {
return "", errors.New("missing host")
}
proto := "whep"
if parsed.Scheme == "https" {
proto = "wheps"
}
path := strings.Trim(parsed.Path, "/")
if strings.HasPrefix(path, "whep/") {
path = strings.TrimPrefix(path, "whep/")
}
path = strings.Trim(path, "/")
if path == "" {
path = "rovercam"
}
return fmt.Sprintf("%s://%s/%s/whep", proto, parsed.Host, path), nil
}
func ensureLeadingSlash(path string) string {
if !strings.HasPrefix(path, "/") {
return "/" + path