mirror of
https://github.com/daeuniverse/dae.git
synced 2024-12-23 01:04:40 +07:00
optimize: pull subscription using custom UA (#233)
This commit is contained in:
parent
a2f7c37f4d
commit
9124c5d9f5
@ -1,6 +1,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/daeuniverse/dae/config"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -17,6 +18,10 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
config.Version = Version
|
||||
}
|
||||
|
||||
// Execute executes the root command.
|
||||
func Execute() error {
|
||||
return rootCmd.Execute()
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/daeuniverse/dae/common"
|
||||
"github.com/daeuniverse/dae/config"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -149,6 +150,7 @@ func ResolveSubscription(log *logrus.Logger, client *http.Client, configDir stri
|
||||
log.Debugf("ResolveSubscription: %v", subscription)
|
||||
var (
|
||||
b []byte
|
||||
req *http.Request
|
||||
resp *http.Response
|
||||
)
|
||||
switch u.Scheme {
|
||||
@ -160,7 +162,11 @@ func ResolveSubscription(log *logrus.Logger, client *http.Client, configDir stri
|
||||
goto resolve
|
||||
default:
|
||||
}
|
||||
resp, err = client.Get(subscription)
|
||||
req, err = http.NewRequest("GET", subscription, nil)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
req.Header.Set("User-Agent", fmt.Sprintf("dae/%v (like v2rayA/1.0 WebRequestHelper) (like v2rayN/1.0 WebRequestHelper)", config.Version))
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
|
@ -13,6 +13,10 @@ import (
|
||||
"github.com/daeuniverse/dae/pkg/config_parser"
|
||||
)
|
||||
|
||||
var (
|
||||
Version string
|
||||
)
|
||||
|
||||
type Global struct {
|
||||
TproxyPort uint16 `mapstructure:"tproxy_port" default:"12345"`
|
||||
TproxyPortProtect bool `mapstructure:"tproxy_port_protect" default:"true"`
|
||||
|
Loading…
Reference in New Issue
Block a user