Chore: add some linters and clean up the code
This commit is contained in:
parent
a7252a1576
commit
5045ca4574
@ -1,10 +1,16 @@
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- gofumpt
|
||||
- staticcheck
|
||||
- govet
|
||||
- gci
|
||||
- gofumpt
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- misspell
|
||||
- staticcheck
|
||||
- unconvert
|
||||
- unused
|
||||
- usestdlibvars
|
||||
|
||||
linters-settings:
|
||||
gci:
|
||||
|
@ -340,15 +340,15 @@ func parseVmessAddr(metadata *C.Metadata) *vmess.DstAddr {
|
||||
var addr []byte
|
||||
switch metadata.AddrType() {
|
||||
case socks5.AtypIPv4:
|
||||
addrType = byte(vmess.AtypIPv4)
|
||||
addrType = vmess.AtypIPv4
|
||||
addr = make([]byte, net.IPv4len)
|
||||
copy(addr[:], metadata.DstIP.To4())
|
||||
case socks5.AtypIPv6:
|
||||
addrType = byte(vmess.AtypIPv6)
|
||||
addrType = vmess.AtypIPv6
|
||||
addr = make([]byte, net.IPv6len)
|
||||
copy(addr[:], metadata.DstIP.To16())
|
||||
case socks5.AtypDomainName:
|
||||
addrType = byte(vmess.AtypDomainName)
|
||||
addrType = vmess.AtypDomainName
|
||||
addr = make([]byte, len(metadata.Host)+1)
|
||||
addr[0] = byte(len(metadata.Host))
|
||||
copy(addr[1:], []byte(metadata.Host))
|
||||
|
@ -62,7 +62,7 @@ func findProcessName(network string, ip net.IP, srcPort int) (string, error) {
|
||||
err := initWin32API()
|
||||
if err != nil {
|
||||
log.Errorln("Initialize PROCESS-NAME failed: %s", err.Error())
|
||||
log.Warnln("All PROCESS-NAMES rules will be skiped")
|
||||
log.Warnln("All PROCESS-NAMES rules will be skipped")
|
||||
return
|
||||
}
|
||||
})
|
||||
|
@ -65,7 +65,7 @@ func (ho *HTTPObfs) Write(b []byte) (int, error) {
|
||||
if ho.firstRequest {
|
||||
randBytes := make([]byte, 16)
|
||||
rand.Read(randBytes)
|
||||
req, _ := http.NewRequest("GET", fmt.Sprintf("http://%s/", ho.host), bytes.NewBuffer(b[:]))
|
||||
req, _ := http.NewRequest(http.MethodGet, fmt.Sprintf("http://%s/", ho.host), bytes.NewBuffer(b[:]))
|
||||
req.Header.Set("User-Agent", fmt.Sprintf("curl/7.%d.%d", mathRand.Int()%54, mathRand.Int()%2))
|
||||
req.Header.Set("Upgrade", "websocket")
|
||||
req.Header.Set("Connection", "Upgrade")
|
||||
|
@ -159,7 +159,7 @@ func ServerHandshake(rw net.Conn, authenticator auth.Authenticator) (addr Addr,
|
||||
pass := string(authBuf[:passLen])
|
||||
|
||||
// Verify
|
||||
if ok := authenticator.Verify(string(user), string(pass)); !ok {
|
||||
if ok := authenticator.Verify(user, pass); !ok {
|
||||
rw.Write([]byte{1, 1})
|
||||
err = ErrAuth
|
||||
return
|
||||
|
@ -76,7 +76,7 @@ func (vc *Conn) sendRequest() error {
|
||||
|
||||
p := mathRand.Intn(16)
|
||||
// P Sec Reserve Cmd
|
||||
buf.WriteByte(byte(p<<4) | byte(vc.security))
|
||||
buf.WriteByte(byte(p<<4) | vc.security)
|
||||
buf.WriteByte(0)
|
||||
if vc.dst.UDP {
|
||||
buf.WriteByte(CommandUDP)
|
||||
|
@ -30,7 +30,7 @@ func (hc *h2Conn) establishConn() error {
|
||||
path := hc.cfg.Path
|
||||
// TODO: connect use VMess Host instead of H2 Host
|
||||
req := http.Request{
|
||||
Method: "PUT",
|
||||
Method: http.MethodPut,
|
||||
Host: host,
|
||||
URL: &url.URL{
|
||||
Scheme: "https",
|
||||
|
@ -58,7 +58,7 @@ func (hc *httpConn) Write(b []byte) (int, error) {
|
||||
}
|
||||
|
||||
u := fmt.Sprintf("http://%s%s", host, path)
|
||||
req, _ := http.NewRequest("GET", u, bytes.NewBuffer(b))
|
||||
req, _ := http.NewRequest(http.MethodGet, u, bytes.NewBuffer(b))
|
||||
for key, list := range hc.cfg.Headers {
|
||||
req.Header.Set(key, list[rand.Intn(len(list))])
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user