Skip to content

Commit

Permalink
fix: parse config issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Aug 7, 2024
1 parent b389963 commit f31899c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,6 @@ func DefaultConfigOptions() *ConfigOptions {
EnablePadding: false,
PaddingSize: "1200-1500",
},
UseXrayCoreWhenPossible: false,
}
}
2 changes: 1 addition & 1 deletion config/warp.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func patchWarp(base *option.Outbound, configOpt *ConfigOptions, final bool, stat
var warpConfig *T.Outbound
var err error

if configOpt == nil && (key == "p1" || key == "p2") {
if (configOpt == nil || !final) && (key == "p1" || key == "p2") {
warpConfig = base
return nil
} else if key == "p1" {
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ require (
gopkg.in/yaml.v3 v3.0.1
)

require github.com/akavel/rsrc v0.10.2 // indirect

require (
berty.tech/go-libtor v1.0.385 // indirect
github.com/ajg/form v1.5.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 h1:Wo41lDOevRJS
github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0/go.mod h1:FVGavL/QEBQDcBpr3fAojoK17xX5k9bicBphrOpP7uM=
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw=
github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
Expand Down
4 changes: 2 additions & 2 deletions v2/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func StartService(in *pb.StartRequest) (*pb.CoreInfoResponse, error) {
}
Log(pb.LogLevel_DEBUG, pb.LogType_CORE, "Parsing Config")

parsedContent, err := parseConfig(content)
parsedContent, err := readOptions(content)
Log(pb.LogLevel_DEBUG, pb.LogType_CORE, "Parsed")

if err != nil {
Expand Down Expand Up @@ -247,7 +247,7 @@ func generateConfigFromFile(path string, configOpt config.ConfigOptions) (string
if err != nil {
return "", err
}
options, err := parseConfig(string(content))
options, err := readOptions(string(content))
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion v2/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func NewService(options option.Options) (*libbox.BoxService, error) {
return &service, nil
}

func parseConfig(configContent string) (option.Options, error) {
func readOptions(configContent string) (option.Options, error) {
var options option.Options
err := options.UnmarshalJSON([]byte(configContent))
if err != nil {
Expand Down

0 comments on commit f31899c

Please sign in to comment.