All checks were successful
release / build-and-upload (push) Successful in 7m2s
Dashboard Live uptimes + Recent runs from stream_sessions; overview.recent_sessions. WireGuard netns resolv.conf + missing-deps WARN. Support donations card. Agent start/stop/update, job_backoff default off, wvkey ensure/venv, phonecap retries, modhost YAML enrich, DRM SetCredentials requires keys.
77 lines
2.3 KiB
Go
77 lines
2.3 KiB
Go
package modhost
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
// enrichDescribeFromYAML fills gaps left by older module binaries that do not
|
|
// load panel/agent module.yaml (empty package breaks transparent MITM).
|
|
func enrichDescribeFromYAML(d *Describe, modDir string) {
|
|
if d == nil || strings.TrimSpace(modDir) == "" {
|
|
return
|
|
}
|
|
raw, err := os.ReadFile(filepath.Join(modDir, "module.yaml"))
|
|
if err != nil {
|
|
raw, err = os.ReadFile(filepath.Join(modDir, "module-publish.yaml"))
|
|
if err != nil {
|
|
return
|
|
}
|
|
}
|
|
var doc struct {
|
|
Package string `yaml:"package"`
|
|
LicenseURL string `yaml:"license_url"`
|
|
KeyMode string `yaml:"key_mode"`
|
|
ProxyBin string `yaml:"proxy_bin"`
|
|
CAHash string `yaml:"ca_hash"`
|
|
TransparentMITM *bool `yaml:"transparent_mitm"`
|
|
RequireWVD *bool `yaml:"require_wvd"`
|
|
Rewriter string `yaml:"rewriter"`
|
|
Channels map[string]struct {
|
|
Label string `yaml:"label"`
|
|
} `yaml:"channels"`
|
|
}
|
|
if err := yaml.Unmarshal(raw, &doc); err != nil {
|
|
return
|
|
}
|
|
if strings.TrimSpace(d.Package) == "" && strings.TrimSpace(doc.Package) != "" {
|
|
d.Package = strings.TrimSpace(doc.Package)
|
|
}
|
|
if strings.TrimSpace(d.LicenseURL) == "" && strings.TrimSpace(doc.LicenseURL) != "" {
|
|
d.LicenseURL = strings.TrimSpace(doc.LicenseURL)
|
|
}
|
|
if strings.TrimSpace(d.KeyMode) == "" && strings.TrimSpace(doc.KeyMode) != "" {
|
|
d.KeyMode = strings.TrimSpace(doc.KeyMode)
|
|
}
|
|
if strings.TrimSpace(d.ProxyBin) == "" && strings.TrimSpace(doc.ProxyBin) != "" {
|
|
d.ProxyBin = strings.TrimSpace(doc.ProxyBin)
|
|
}
|
|
if strings.TrimSpace(d.CAHash) == "" && strings.TrimSpace(doc.CAHash) != "" {
|
|
d.CAHash = strings.TrimSpace(doc.CAHash)
|
|
}
|
|
if strings.TrimSpace(d.Rewriter) == "" && strings.TrimSpace(doc.Rewriter) != "" {
|
|
d.Rewriter = strings.TrimSpace(doc.Rewriter)
|
|
}
|
|
if !d.TransparentMITM && doc.TransparentMITM != nil {
|
|
d.TransparentMITM = *doc.TransparentMITM
|
|
}
|
|
if !d.RequireWVD && doc.RequireWVD != nil {
|
|
d.RequireWVD = *doc.RequireWVD
|
|
}
|
|
if len(d.Channels) == 0 && len(doc.Channels) > 0 {
|
|
for id, ch := range doc.Channels {
|
|
label := strings.TrimSpace(ch.Label)
|
|
if label == "" {
|
|
label = id
|
|
}
|
|
d.Channels = append(d.Channels, Channel{ID: id, Label: label})
|
|
}
|
|
}
|
|
if !d.ValuesLoaded {
|
|
d.ValuesLoaded = true
|
|
d.ValuesPath = filepath.Join(modDir, "module.yaml")
|
|
}
|
|
}
|