diff --git a/cmd/sing-box/cmd_run.go b/cmd/sing-box/cmd_run.go index f31db9dc..7f46da00 100644 --- a/cmd/sing-box/cmd_run.go +++ b/cmd/sing-box/cmd_run.go @@ -3,6 +3,7 @@ package main import ( "context" "io" + "net/http" "os" "os/signal" "path/filepath" @@ -49,8 +50,16 @@ func readConfigAt(path string) (*OptionsEntry, error) { configContent []byte err error ) + subscriptionLink := os.Getenv("SING_SUBSCRIPTION_LINK") if path == "stdin" { configContent, err = io.ReadAll(os.Stdin) + } else if path == "env" && subscriptionLink != "" { + configContentResponse, err := http.Get(subscriptionLink) + if err != nil { + return nil, E.Cause(err, "failed to GET subscription link") + } + defer configContentResponse.Body.Close() + configContent, err = io.ReadAll(configContentResponse.Body) } else { configContent, err = os.ReadFile(path) }