mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-04 07:17:55 +07:00
optimize: pull subscription using custom UA (#233)
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/daeuniverse/dae/config"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,6 +18,10 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
config.Version = Version
|
||||||
|
}
|
||||||
|
|
||||||
// Execute executes the root command.
|
// Execute executes the root command.
|
||||||
func Execute() error {
|
func Execute() error {
|
||||||
return rootCmd.Execute()
|
return rootCmd.Execute()
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/daeuniverse/dae/common"
|
"github.com/daeuniverse/dae/common"
|
||||||
|
"github.com/daeuniverse/dae/config"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -149,6 +150,7 @@ func ResolveSubscription(log *logrus.Logger, client *http.Client, configDir stri
|
|||||||
log.Debugf("ResolveSubscription: %v", subscription)
|
log.Debugf("ResolveSubscription: %v", subscription)
|
||||||
var (
|
var (
|
||||||
b []byte
|
b []byte
|
||||||
|
req *http.Request
|
||||||
resp *http.Response
|
resp *http.Response
|
||||||
)
|
)
|
||||||
switch u.Scheme {
|
switch u.Scheme {
|
||||||
@ -160,7 +162,11 @@ func ResolveSubscription(log *logrus.Logger, client *http.Client, configDir stri
|
|||||||
goto resolve
|
goto resolve
|
||||||
default:
|
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 {
|
if err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,10 @@ import (
|
|||||||
"github.com/daeuniverse/dae/pkg/config_parser"
|
"github.com/daeuniverse/dae/pkg/config_parser"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
Version string
|
||||||
|
)
|
||||||
|
|
||||||
type Global struct {
|
type Global struct {
|
||||||
TproxyPort uint16 `mapstructure:"tproxy_port" default:"12345"`
|
TproxyPort uint16 `mapstructure:"tproxy_port" default:"12345"`
|
||||||
TproxyPortProtect bool `mapstructure:"tproxy_port_protect" default:"true"`
|
TproxyPortProtect bool `mapstructure:"tproxy_port_protect" default:"true"`
|
||||||
|
Reference in New Issue
Block a user