1
0
mirror of https://github.com/bestnite/sub2sing-box.git synced 2026-06-08 16:04:43 +00:00

feat: add custom User-Agent support for subscription and template requests

Add --user-agent / -u CLI flag and user-agent config field to allow
customizing the User-Agent header when fetching subscriptions and
remote templates. This is useful for providers that require a specific
UA to access their subscription links.

Closes #23
This commit is contained in:
2026-05-23 18:41:55 +10:00
parent b63662347a
commit 2a98e7c1f0
6 changed files with 28 additions and 10 deletions
+6
View File
@@ -25,6 +25,7 @@ var (
sortType string
config string
groupRules string
userAgent string
)
func init() {
@@ -40,6 +41,7 @@ func init() {
convertCmd.Flags().StringVarP(&sortType, "sort-type", "T", "", "sort type, asc or desc")
convertCmd.Flags().StringVarP(&config, "config", "c", "", "configuration file path")
convertCmd.Flags().StringVarP(&groupRules, "group-rules", "R", "", "group rules")
convertCmd.Flags().StringVarP(&userAgent, "user-agent", "u", "", "custom User-Agent for fetching subscriptions and remote templates")
RootCmd.AddCommand(convertCmd)
}
@@ -71,6 +73,7 @@ func convertRun(cmd *cobra.Command, args []string) {
sortKey,
sortType,
groupRulesMap,
userAgent,
)
if err != nil {
fmt.Println("Conversion error:", err)
@@ -152,4 +155,7 @@ func mergeConfig(cfg model.ConvertRequest) {
if output == "" {
output = cfg.Output
}
if userAgent == "" {
userAgent = cfg.UserAgent
}
}