From bbd3988f3d39a35750c8d1973f48c543d36e8d4c Mon Sep 17 00:00:00 2001 From: Agioi Theodoroi Date: Tue, 14 Apr 2020 21:19:52 -0400 Subject: [PATCH 1/3] clean up code --- app/dns/dnscommon_test.go | 4 ---- app/dns/server.go | 2 +- app/router/condition.go | 5 +---- infra/conf/vmess.go | 2 -- proxy/shadowsocks/protocol.go | 1 - proxy/vmess/validator.go | 3 +-- testing/servers/http/http.go | 1 - 7 files changed, 3 insertions(+), 15 deletions(-) diff --git a/app/dns/dnscommon_test.go b/app/dns/dnscommon_test.go index 62a35012..d6f43c65 100644 --- a/app/dns/dnscommon_test.go +++ b/app/dns/dnscommon_test.go @@ -16,10 +16,6 @@ import ( ) func Test_parseResponse(t *testing.T) { - type args struct { - payload []byte - } - var p [][]byte ans := new(dns.Msg) diff --git a/app/dns/server.go b/app/dns/server.go index 2d89f3aa..6598008f 100644 --- a/app/dns/server.go +++ b/app/dns/server.go @@ -308,7 +308,7 @@ func (s *Server) lookupIPInternal(domain string, option IPOption) ([]net.IP, err } // skip domain without any dot - if strings.Index(domain, ".") == -1 { + if !strings.Contains(domain, ".") { return nil, newError("invalid domain name").AtWarning() } diff --git a/app/router/condition.go b/app/router/condition.go index 4a80471f..209a60a3 100644 --- a/app/router/condition.go +++ b/app/router/condition.go @@ -294,10 +294,7 @@ func NewAttributeMatcher(code string) (*AttributeMatcher, error) { return nil, newError("attr rule").Base(err) } p, err := starlark.FileProgram(starFile, func(name string) bool { - if name == "attrs" { - return true - } - return false + return name == "attrs" }) if err != nil { return nil, err diff --git a/infra/conf/vmess.go b/infra/conf/vmess.go index b9531fde..838fa263 100644 --- a/infra/conf/vmess.go +++ b/infra/conf/vmess.go @@ -126,8 +126,6 @@ type VMessOutboundConfig struct { Receivers []*VMessOutboundTarget `json:"vnext"` } -var bUser = "a06fe789-5ab1-480b-8124-ae4599801ff3" - // Build implements Buildable func (c *VMessOutboundConfig) Build() (proto.Message, error) { config := new(outbound.Config) diff --git a/proxy/shadowsocks/protocol.go b/proxy/shadowsocks/protocol.go index 8c9d6935..7dd432bc 100644 --- a/proxy/shadowsocks/protocol.go +++ b/proxy/shadowsocks/protocol.go @@ -50,7 +50,6 @@ func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.Requ return nil, nil, newError("failed to initialize decoding stream").Base(err).AtError() } br := &buf.BufferedReader{Reader: r} - reader = nil authenticator := NewAuthenticator(HeaderKeyGenerator(account.Key, iv)) request := &protocol.RequestHeader{ diff --git a/proxy/vmess/validator.go b/proxy/vmess/validator.go index bf64d98a..a7664db4 100644 --- a/proxy/vmess/validator.go +++ b/proxy/vmess/validator.go @@ -159,8 +159,7 @@ func (v *TimedUserValidator) Get(userHash []byte) (*protocol.MemoryUser, protoco copy(fixedSizeHash[:], userHash) pair, found := v.userHash[fixedSizeHash] if found { - var user protocol.MemoryUser - user = pair.user.user + user := pair.user.user if atomic.LoadUint32(pair.taintedFuse) == 0 { return &user, protocol.Timestamp(pair.timeInc) + v.baseTime, true, nil } diff --git a/testing/servers/http/http.go b/testing/servers/http/http.go index 6bada232..379da590 100644 --- a/testing/servers/http/http.go +++ b/testing/servers/http/http.go @@ -9,7 +9,6 @@ import ( type Server struct { Port net.Port PathHandler map[string]http.HandlerFunc - accepting bool server *http.Server } From 97074c5bf475dc52095c205bfde3c0f3373e9fef Mon Sep 17 00:00:00 2001 From: Agioi Theodoroi Date: Tue, 14 Apr 2020 21:51:38 -0400 Subject: [PATCH 2/3] gofmt --- main/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/main.go b/main/main.go index fe13c3d1..d8c9c2fd 100644 --- a/main/main.go +++ b/main/main.go @@ -28,9 +28,9 @@ var ( test = flag.Bool("test", false, "Test config file only, without launching V2Ray server.") format = flag.String("format", "json", "Format of input file.") - /* We have to do this here because Golang's Test will also need to parse flag, before - main func in this file is run. - */ + /* We have to do this here because Golang's Test will also need to parse flag, before + * main func in this file is run. + */ _ = func() error { flag.Var(&configFiles, "config", "Config file for V2Ray. Multiple assign is accepted (only json). Latter ones overrides the former ones.") From 37a55653e9e972f43854612cc980a6e1ea812544 Mon Sep 17 00:00:00 2001 From: Agioi Theodoroi Date: Fri, 17 Apr 2020 20:00:40 -0400 Subject: [PATCH 3/3] remove unused parameter --- main/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/main.go b/main/main.go index d8c9c2fd..4fe18844 100644 --- a/main/main.go +++ b/main/main.go @@ -166,7 +166,7 @@ func main() { { osSignals := make(chan os.Signal, 1) - signal.Notify(osSignals, os.Interrupt, os.Kill, syscall.SIGTERM) + signal.Notify(osSignals, os.Interrupt, syscall.SIGTERM) <-osSignals } }