Skip to content

Commit

Permalink
fix: bug when fakePackets is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Jan 25, 2024
1 parent df63187 commit 9dfc3ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion option/fragment.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ type TLSFragmentOptions struct {

func ParseIntRange(str string) ([]int, error) {
var err error

if str == "" {
return nil, E.Cause(err, "Empty input")
}
splitString := strings.Split(str, "-")
s, err := strconv.ParseInt(splitString[0], 10, 32)
if err != nil {
Expand Down
9 changes: 6 additions & 3 deletions outbound/wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ func NewWireGuard(ctx context.Context, router adapter.Router, logger log.Context
pauseManager: service.FromContext[pause.Manager](ctx),
hforwarder: hforwarder, //hiddify
}
fakePackets, err := option.ParseIntRange(options.FakePackets)
if err != nil {
return nil, err
fakePackets = []int{0, 0}

Check failure on line 72 in outbound/wireguard.go

View workflow job for this annotation

GitHub Actions / Debug build (Go 1.20)

undefined: fakePackets
if options.FakePackets != "" {
fakePackets, err := option.ParseIntRange(options.FakePackets)

Check failure on line 74 in outbound/wireguard.go

View workflow job for this annotation

GitHub Actions / Debug build (Go 1.20)

fakePackets declared and not used
if err != nil {
return nil, err
}
}
outbound.fakePackets = fakePackets

Check failure on line 79 in outbound/wireguard.go

View workflow job for this annotation

GitHub Actions / Debug build (Go 1.20)

undefined: fakePackets
peers, err := wireguard.ParsePeers(options)
Expand Down

0 comments on commit 9dfc3ef

Please sign in to comment.