Skip to content

Commit

Permalink
ignore ps field unmarshal error in vmess
Browse files Browse the repository at this point in the history
  • Loading branch information
Sansui233 committed Oct 23, 2020
1 parent f067131 commit 71ceaf0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ bin/*

# Test binary, build with `go test -c`
*.test
# Manually add it if neccessary
*_test.go

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
Expand Down
6 changes: 5 additions & 1 deletion README_NEW.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Clash客户端支持:
- Clash for Windows(需要Clash Core1.3以上)
- ClashX(需要Clash Core1.3以上)
- 不支持ClashXR与ClashR等非原生Clash Core客户端。
- 不支持ClashXR与ClashR等非原生Clash Core客户端。

TODO
- [ ] Database报错逻辑修正
- [ ] set http context time(dev)

## New

Expand Down
12 changes: 11 additions & 1 deletion pkg/proxy/vmess.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math/rand"
"net"
"net/url"
"reflect"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -215,7 +216,16 @@ func ParseVmessLink(link string) (*Vmess, error) {
vmessJson := vmessLinkJson{}
err = json.Unmarshal([]byte(payload), &vmessJson)
if err != nil {
return nil, err
typ := reflect.TypeOf(err)
// Trying handling UnmarshalTypeError. This only fills one non-string field. More fields can't be detected by json.Unmarshal
if typ.String() == "*json.UnmarshalTypeError" {
e := err.(*json.UnmarshalTypeError)
if e.Field != "ps" { // ignore err if it's PS type error
return nil, err
}
} else {
return nil, err // Other json type error
}
}
port := 443
portInterface := vmessJson.Port
Expand Down

0 comments on commit 71ceaf0

Please sign in to comment.