feat(remote-management): add support for custom GitHub repository for panel updates
Browse filesIntroduce `panel-github-repository` in the configuration to allow specifying a custom repository for management panel assets. Update dependency versions and enhance asset URL resolution logic to support overrides.
- config.example.yaml +3 -0
- go.mod +5 -5
- go.sum +12 -12
- internal/api/server.go +2 -2
- internal/config/config.go +11 -0
- internal/managementasset/updater.go +47 -9
- internal/watcher/watcher.go +5 -0
config.example.yaml
CHANGED
|
@@ -25,6 +25,9 @@ remote-management:
|
|
| 25 |
# Disable the bundled management control panel asset download and HTTP route when true.
|
| 26 |
disable-control-panel: false
|
| 27 |
|
|
|
|
|
|
|
|
|
|
| 28 |
# Authentication directory (supports ~ for home directory)
|
| 29 |
auth-dir: "~/.cli-proxy-api"
|
| 30 |
|
|
|
|
| 25 |
# Disable the bundled management control panel asset download and HTTP route when true.
|
| 26 |
disable-control-panel: false
|
| 27 |
|
| 28 |
+
# GitHub repository for the management control panel. Accepts a repository URL or releases API URL.
|
| 29 |
+
panel-github-repository: "https://github.com/router-for-me/Cli-Proxy-API-Management-Center"
|
| 30 |
+
|
| 31 |
# Authentication directory (supports ~ for home directory)
|
| 32 |
auth-dir: "~/.cli-proxy-api"
|
| 33 |
|
go.mod
CHANGED
|
@@ -18,8 +18,8 @@ require (
|
|
| 18 |
github.com/tidwall/gjson v1.18.0
|
| 19 |
github.com/tidwall/sjson v1.2.5
|
| 20 |
github.com/tiktoken-go/tokenizer v0.7.0
|
| 21 |
-
golang.org/x/crypto v0.
|
| 22 |
-
golang.org/x/net v0.
|
| 23 |
golang.org/x/oauth2 v0.30.0
|
| 24 |
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
| 25 |
gopkg.in/yaml.v3 v3.0.1
|
|
@@ -68,9 +68,9 @@ require (
|
|
| 68 |
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
| 69 |
github.com/ugorji/go/codec v1.2.12 // indirect
|
| 70 |
golang.org/x/arch v0.8.0 // indirect
|
| 71 |
-
golang.org/x/sync v0.
|
| 72 |
-
golang.org/x/sys v0.
|
| 73 |
-
golang.org/x/text v0.
|
| 74 |
google.golang.org/protobuf v1.34.1 // indirect
|
| 75 |
gopkg.in/ini.v1 v1.67.0 // indirect
|
| 76 |
)
|
|
|
|
| 18 |
github.com/tidwall/gjson v1.18.0
|
| 19 |
github.com/tidwall/sjson v1.2.5
|
| 20 |
github.com/tiktoken-go/tokenizer v0.7.0
|
| 21 |
+
golang.org/x/crypto v0.45.0
|
| 22 |
+
golang.org/x/net v0.47.0
|
| 23 |
golang.org/x/oauth2 v0.30.0
|
| 24 |
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
| 25 |
gopkg.in/yaml.v3 v3.0.1
|
|
|
|
| 68 |
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
| 69 |
github.com/ugorji/go/codec v1.2.12 // indirect
|
| 70 |
golang.org/x/arch v0.8.0 // indirect
|
| 71 |
+
golang.org/x/sync v0.18.0 // indirect
|
| 72 |
+
golang.org/x/sys v0.38.0 // indirect
|
| 73 |
+
golang.org/x/text v0.31.0 // indirect
|
| 74 |
google.golang.org/protobuf v1.34.1 // indirect
|
| 75 |
gopkg.in/ini.v1 v1.67.0 // indirect
|
| 76 |
)
|
go.sum
CHANGED
|
@@ -160,22 +160,22 @@ github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZ
|
|
| 160 |
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
| 161 |
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
|
| 162 |
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
| 163 |
-
golang.org/x/crypto v0.
|
| 164 |
-
golang.org/x/crypto v0.
|
| 165 |
-
golang.org/x/net v0.
|
| 166 |
-
golang.org/x/net v0.
|
| 167 |
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
|
| 168 |
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
|
| 169 |
-
golang.org/x/sync v0.
|
| 170 |
-
golang.org/x/sync v0.
|
| 171 |
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 172 |
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 173 |
-
golang.org/x/sys v0.
|
| 174 |
-
golang.org/x/sys v0.
|
| 175 |
-
golang.org/x/term v0.
|
| 176 |
-
golang.org/x/term v0.
|
| 177 |
-
golang.org/x/text v0.
|
| 178 |
-
golang.org/x/text v0.
|
| 179 |
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
| 180 |
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
| 181 |
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
|
|
|
| 160 |
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
| 161 |
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
|
| 162 |
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
| 163 |
+
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
| 164 |
+
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
| 165 |
+
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
|
| 166 |
+
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
| 167 |
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
|
| 168 |
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
|
| 169 |
+
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
|
| 170 |
+
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
| 171 |
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 172 |
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 173 |
+
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
| 174 |
+
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
| 175 |
+
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
|
| 176 |
+
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
|
| 177 |
+
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
| 178 |
+
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
| 179 |
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
| 180 |
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
| 181 |
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
internal/api/server.go
CHANGED
|
@@ -609,7 +609,7 @@ func (s *Server) serveManagementControlPanel(c *gin.Context) {
|
|
| 609 |
|
| 610 |
if _, err := os.Stat(filePath); err != nil {
|
| 611 |
if os.IsNotExist(err) {
|
| 612 |
-
go managementasset.EnsureLatestManagementHTML(context.Background(), managementasset.StaticDir(s.configFilePath), cfg.ProxyURL)
|
| 613 |
c.AbortWithStatus(http.StatusNotFound)
|
| 614 |
return
|
| 615 |
}
|
|
@@ -929,7 +929,7 @@ func (s *Server) UpdateClients(cfg *config.Config) {
|
|
| 929 |
|
| 930 |
if !cfg.RemoteManagement.DisableControlPanel {
|
| 931 |
staticDir := managementasset.StaticDir(s.configFilePath)
|
| 932 |
-
go managementasset.EnsureLatestManagementHTML(context.Background(), staticDir, cfg.ProxyURL)
|
| 933 |
}
|
| 934 |
if s.mgmt != nil {
|
| 935 |
s.mgmt.SetConfig(cfg)
|
|
|
|
| 609 |
|
| 610 |
if _, err := os.Stat(filePath); err != nil {
|
| 611 |
if os.IsNotExist(err) {
|
| 612 |
+
go managementasset.EnsureLatestManagementHTML(context.Background(), managementasset.StaticDir(s.configFilePath), cfg.ProxyURL, cfg.RemoteManagement.PanelGitHubRepository)
|
| 613 |
c.AbortWithStatus(http.StatusNotFound)
|
| 614 |
return
|
| 615 |
}
|
|
|
|
| 929 |
|
| 930 |
if !cfg.RemoteManagement.DisableControlPanel {
|
| 931 |
staticDir := managementasset.StaticDir(s.configFilePath)
|
| 932 |
+
go managementasset.EnsureLatestManagementHTML(context.Background(), staticDir, cfg.ProxyURL, cfg.RemoteManagement.PanelGitHubRepository)
|
| 933 |
}
|
| 934 |
if s.mgmt != nil {
|
| 935 |
s.mgmt.SetConfig(cfg)
|
internal/config/config.go
CHANGED
|
@@ -17,6 +17,8 @@ import (
|
|
| 17 |
"gopkg.in/yaml.v3"
|
| 18 |
)
|
| 19 |
|
|
|
|
|
|
|
| 20 |
// Config represents the application's configuration, loaded from a YAML file.
|
| 21 |
type Config struct {
|
| 22 |
config.SDKConfig `yaml:",inline"`
|
|
@@ -104,6 +106,9 @@ type RemoteManagement struct {
|
|
| 104 |
SecretKey string `yaml:"secret-key"`
|
| 105 |
// DisableControlPanel skips serving and syncing the bundled management UI when true.
|
| 106 |
DisableControlPanel bool `yaml:"disable-control-panel"`
|
|
|
|
|
|
|
|
|
|
| 107 |
}
|
| 108 |
|
| 109 |
// QuotaExceeded defines the behavior when API quota limits are exceeded.
|
|
@@ -328,6 +333,7 @@ func LoadConfigOptional(configFile string, optional bool) (*Config, error) {
|
|
| 328 |
cfg.UsageStatisticsEnabled = false
|
| 329 |
cfg.DisableCooling = false
|
| 330 |
cfg.AmpCode.RestrictManagementToLocalhost = false // Default to false: API key auth is sufficient
|
|
|
|
| 331 |
if err = yaml.Unmarshal(data, &cfg); err != nil {
|
| 332 |
if optional {
|
| 333 |
// In cloud deploy mode, if YAML parsing fails, return empty config instead of error.
|
|
@@ -363,6 +369,11 @@ func LoadConfigOptional(configFile string, optional bool) (*Config, error) {
|
|
| 363 |
_ = SaveConfigPreserveCommentsUpdateNestedScalar(configFile, []string{"remote-management", "secret-key"}, hashed)
|
| 364 |
}
|
| 365 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
// Sync request authentication providers with inline API keys for backwards compatibility.
|
| 367 |
syncInlineAccessProvider(&cfg)
|
| 368 |
|
|
|
|
| 17 |
"gopkg.in/yaml.v3"
|
| 18 |
)
|
| 19 |
|
| 20 |
+
const DefaultPanelGitHubRepository = "https://github.com/router-for-me/Cli-Proxy-API-Management-Center"
|
| 21 |
+
|
| 22 |
// Config represents the application's configuration, loaded from a YAML file.
|
| 23 |
type Config struct {
|
| 24 |
config.SDKConfig `yaml:",inline"`
|
|
|
|
| 106 |
SecretKey string `yaml:"secret-key"`
|
| 107 |
// DisableControlPanel skips serving and syncing the bundled management UI when true.
|
| 108 |
DisableControlPanel bool `yaml:"disable-control-panel"`
|
| 109 |
+
// PanelGitHubRepository overrides the GitHub repository used to fetch the management panel asset.
|
| 110 |
+
// Accepts either a repository URL (https://github.com/org/repo) or an API releases endpoint.
|
| 111 |
+
PanelGitHubRepository string `yaml:"panel-github-repository"`
|
| 112 |
}
|
| 113 |
|
| 114 |
// QuotaExceeded defines the behavior when API quota limits are exceeded.
|
|
|
|
| 333 |
cfg.UsageStatisticsEnabled = false
|
| 334 |
cfg.DisableCooling = false
|
| 335 |
cfg.AmpCode.RestrictManagementToLocalhost = false // Default to false: API key auth is sufficient
|
| 336 |
+
cfg.RemoteManagement.PanelGitHubRepository = DefaultPanelGitHubRepository
|
| 337 |
if err = yaml.Unmarshal(data, &cfg); err != nil {
|
| 338 |
if optional {
|
| 339 |
// In cloud deploy mode, if YAML parsing fails, return empty config instead of error.
|
|
|
|
| 369 |
_ = SaveConfigPreserveCommentsUpdateNestedScalar(configFile, []string{"remote-management", "secret-key"}, hashed)
|
| 370 |
}
|
| 371 |
|
| 372 |
+
cfg.RemoteManagement.PanelGitHubRepository = strings.TrimSpace(cfg.RemoteManagement.PanelGitHubRepository)
|
| 373 |
+
if cfg.RemoteManagement.PanelGitHubRepository == "" {
|
| 374 |
+
cfg.RemoteManagement.PanelGitHubRepository = DefaultPanelGitHubRepository
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
// Sync request authentication providers with inline API keys for backwards compatibility.
|
| 378 |
syncInlineAccessProvider(&cfg)
|
| 379 |
|
internal/managementasset/updater.go
CHANGED
|
@@ -9,6 +9,7 @@ import (
|
|
| 9 |
"fmt"
|
| 10 |
"io"
|
| 11 |
"net/http"
|
|
|
|
| 12 |
"os"
|
| 13 |
"path/filepath"
|
| 14 |
"strings"
|
|
@@ -23,10 +24,10 @@ import (
|
|
| 23 |
)
|
| 24 |
|
| 25 |
const (
|
| 26 |
-
|
| 27 |
-
managementAssetName
|
| 28 |
-
httpUserAgent
|
| 29 |
-
updateCheckInterval
|
| 30 |
)
|
| 31 |
|
| 32 |
// ManagementFileName exposes the control panel asset filename.
|
|
@@ -97,7 +98,7 @@ func runAutoUpdater(ctx context.Context) {
|
|
| 97 |
|
| 98 |
configPath, _ := schedulerConfigPath.Load().(string)
|
| 99 |
staticDir := StaticDir(configPath)
|
| 100 |
-
EnsureLatestManagementHTML(ctx, staticDir, cfg.ProxyURL)
|
| 101 |
}
|
| 102 |
|
| 103 |
runOnce()
|
|
@@ -181,7 +182,7 @@ func FilePath(configFilePath string) string {
|
|
| 181 |
// EnsureLatestManagementHTML checks the latest management.html asset and updates the local copy when needed.
|
| 182 |
// The function is designed to run in a background goroutine and will never panic.
|
| 183 |
// It enforces a 3-hour rate limit to avoid frequent checks on config/auth file changes.
|
| 184 |
-
func EnsureLatestManagementHTML(ctx context.Context, staticDir string, proxyURL string) {
|
| 185 |
if ctx == nil {
|
| 186 |
ctx = context.Background()
|
| 187 |
}
|
|
@@ -214,6 +215,7 @@ func EnsureLatestManagementHTML(ctx context.Context, staticDir string, proxyURL
|
|
| 214 |
return
|
| 215 |
}
|
| 216 |
|
|
|
|
| 217 |
client := newHTTPClient(proxyURL)
|
| 218 |
|
| 219 |
localPath := filepath.Join(staticDir, managementAssetName)
|
|
@@ -225,7 +227,7 @@ func EnsureLatestManagementHTML(ctx context.Context, staticDir string, proxyURL
|
|
| 225 |
localHash = ""
|
| 226 |
}
|
| 227 |
|
| 228 |
-
asset, remoteHash, err := fetchLatestAsset(ctx, client)
|
| 229 |
if err != nil {
|
| 230 |
log.WithError(err).Warn("failed to fetch latest management release information")
|
| 231 |
return
|
|
@@ -254,8 +256,44 @@ func EnsureLatestManagementHTML(ctx context.Context, staticDir string, proxyURL
|
|
| 254 |
log.Infof("management asset updated successfully (hash=%s)", downloadedHash)
|
| 255 |
}
|
| 256 |
|
| 257 |
-
func
|
| 258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
if err != nil {
|
| 260 |
return nil, "", fmt.Errorf("create release request: %w", err)
|
| 261 |
}
|
|
|
|
| 9 |
"fmt"
|
| 10 |
"io"
|
| 11 |
"net/http"
|
| 12 |
+
"net/url"
|
| 13 |
"os"
|
| 14 |
"path/filepath"
|
| 15 |
"strings"
|
|
|
|
| 24 |
)
|
| 25 |
|
| 26 |
const (
|
| 27 |
+
defaultManagementReleaseURL = "https://api.github.com/repos/router-for-me/Cli-Proxy-API-Management-Center/releases/latest"
|
| 28 |
+
managementAssetName = "management.html"
|
| 29 |
+
httpUserAgent = "CLIProxyAPI-management-updater"
|
| 30 |
+
updateCheckInterval = 3 * time.Hour
|
| 31 |
)
|
| 32 |
|
| 33 |
// ManagementFileName exposes the control panel asset filename.
|
|
|
|
| 98 |
|
| 99 |
configPath, _ := schedulerConfigPath.Load().(string)
|
| 100 |
staticDir := StaticDir(configPath)
|
| 101 |
+
EnsureLatestManagementHTML(ctx, staticDir, cfg.ProxyURL, cfg.RemoteManagement.PanelGitHubRepository)
|
| 102 |
}
|
| 103 |
|
| 104 |
runOnce()
|
|
|
|
| 182 |
// EnsureLatestManagementHTML checks the latest management.html asset and updates the local copy when needed.
|
| 183 |
// The function is designed to run in a background goroutine and will never panic.
|
| 184 |
// It enforces a 3-hour rate limit to avoid frequent checks on config/auth file changes.
|
| 185 |
+
func EnsureLatestManagementHTML(ctx context.Context, staticDir string, proxyURL string, panelRepository string) {
|
| 186 |
if ctx == nil {
|
| 187 |
ctx = context.Background()
|
| 188 |
}
|
|
|
|
| 215 |
return
|
| 216 |
}
|
| 217 |
|
| 218 |
+
releaseURL := resolveReleaseURL(panelRepository)
|
| 219 |
client := newHTTPClient(proxyURL)
|
| 220 |
|
| 221 |
localPath := filepath.Join(staticDir, managementAssetName)
|
|
|
|
| 227 |
localHash = ""
|
| 228 |
}
|
| 229 |
|
| 230 |
+
asset, remoteHash, err := fetchLatestAsset(ctx, client, releaseURL)
|
| 231 |
if err != nil {
|
| 232 |
log.WithError(err).Warn("failed to fetch latest management release information")
|
| 233 |
return
|
|
|
|
| 256 |
log.Infof("management asset updated successfully (hash=%s)", downloadedHash)
|
| 257 |
}
|
| 258 |
|
| 259 |
+
func resolveReleaseURL(repo string) string {
|
| 260 |
+
repo = strings.TrimSpace(repo)
|
| 261 |
+
if repo == "" {
|
| 262 |
+
return defaultManagementReleaseURL
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
parsed, err := url.Parse(repo)
|
| 266 |
+
if err != nil || parsed.Host == "" {
|
| 267 |
+
return defaultManagementReleaseURL
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
host := strings.ToLower(parsed.Host)
|
| 271 |
+
parsed.Path = strings.TrimSuffix(parsed.Path, "/")
|
| 272 |
+
|
| 273 |
+
if host == "api.github.com" {
|
| 274 |
+
if !strings.HasSuffix(strings.ToLower(parsed.Path), "/releases/latest") {
|
| 275 |
+
parsed.Path = parsed.Path + "/releases/latest"
|
| 276 |
+
}
|
| 277 |
+
return parsed.String()
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
if host == "github.com" {
|
| 281 |
+
parts := strings.Split(strings.Trim(parsed.Path, "/"), "/")
|
| 282 |
+
if len(parts) >= 2 && parts[0] != "" && parts[1] != "" {
|
| 283 |
+
repoName := strings.TrimSuffix(parts[1], ".git")
|
| 284 |
+
return fmt.Sprintf("https://api.github.com/repos/%s/%s/releases/latest", parts[0], repoName)
|
| 285 |
+
}
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
return defaultManagementReleaseURL
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
func fetchLatestAsset(ctx context.Context, client *http.Client, releaseURL string) (*releaseAsset, string, error) {
|
| 292 |
+
if strings.TrimSpace(releaseURL) == "" {
|
| 293 |
+
releaseURL = defaultManagementReleaseURL
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, releaseURL, nil)
|
| 297 |
if err != nil {
|
| 298 |
return nil, "", fmt.Errorf("create release request: %w", err)
|
| 299 |
}
|
internal/watcher/watcher.go
CHANGED
|
@@ -1882,6 +1882,11 @@ func buildConfigChangeDetails(oldCfg, newCfg *config.Config) []string {
|
|
| 1882 |
if oldCfg.RemoteManagement.DisableControlPanel != newCfg.RemoteManagement.DisableControlPanel {
|
| 1883 |
changes = append(changes, fmt.Sprintf("remote-management.disable-control-panel: %t -> %t", oldCfg.RemoteManagement.DisableControlPanel, newCfg.RemoteManagement.DisableControlPanel))
|
| 1884 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1885 |
if oldCfg.RemoteManagement.SecretKey != newCfg.RemoteManagement.SecretKey {
|
| 1886 |
switch {
|
| 1887 |
case oldCfg.RemoteManagement.SecretKey == "" && newCfg.RemoteManagement.SecretKey != "":
|
|
|
|
| 1882 |
if oldCfg.RemoteManagement.DisableControlPanel != newCfg.RemoteManagement.DisableControlPanel {
|
| 1883 |
changes = append(changes, fmt.Sprintf("remote-management.disable-control-panel: %t -> %t", oldCfg.RemoteManagement.DisableControlPanel, newCfg.RemoteManagement.DisableControlPanel))
|
| 1884 |
}
|
| 1885 |
+
oldPanelRepo := strings.TrimSpace(oldCfg.RemoteManagement.PanelGitHubRepository)
|
| 1886 |
+
newPanelRepo := strings.TrimSpace(newCfg.RemoteManagement.PanelGitHubRepository)
|
| 1887 |
+
if oldPanelRepo != newPanelRepo {
|
| 1888 |
+
changes = append(changes, fmt.Sprintf("remote-management.panel-github-repository: %s -> %s", oldPanelRepo, newPanelRepo))
|
| 1889 |
+
}
|
| 1890 |
if oldCfg.RemoteManagement.SecretKey != newCfg.RemoteManagement.SecretKey {
|
| 1891 |
switch {
|
| 1892 |
case oldCfg.RemoteManagement.SecretKey == "" && newCfg.RemoteManagement.SecretKey != "":
|