Skip to content

Commit

Permalink
tmp.
Browse files Browse the repository at this point in the history
* check ctx to fix. (v2fly#841)

* remove package path from logs (v2fly#840)

* Chore: format code (v2fly#842)

* Update bundled browserforwarder firmware

* Chore: update protobuf & dependencies (v2fly#844)

* refine package prefix cleanup

* move non-VMessAEAD warning to startup

* fix logs prefix matching order

* Chore: remove deprecated scopelint (v2fly#847)

* Update Version

* rework the file name checking logic

Co-authored-by: Kslr <kslrwang@gmail.com>
Co-authored-by: Loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
Co-authored-by: Shelikhoo <xiaokangwang@outlook.com>
  • Loading branch information
4 people authored Apr 3, 2021
1 parent e20973f commit f425dca
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 85 deletions.
5 changes: 0 additions & 5 deletions .github/linters/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ run:

issues:
new: true
exclude-rules:
- path: _test\.go
linters:
- scopelint

linters:
enable:
Expand All @@ -25,7 +21,6 @@ linters:
- misspell
- nakedret
- rowserrcheck
- scopelint
- staticcheck
- structcheck
- stylecheck
Expand Down
3 changes: 2 additions & 1 deletion common/antireplay/bloomring.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package antireplay

import (
ss_bloomring "github.com/v2fly/ss-bloomring"
"sync"

ss_bloomring "github.com/v2fly/ss-bloomring"
)

type BloomRing struct {
Expand Down
33 changes: 0 additions & 33 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,36 +123,3 @@ func GetGOPATH() string {
}
return GOPATH
}

// GetModuleName returns the value of module in `go.mod` file.
func GetModuleName(pathToProjectRoot string) (string, error) {
var moduleName string
loopPath := pathToProjectRoot
for {
if idx := strings.LastIndex(loopPath, string(filepath.Separator)); idx >= 0 {
gomodPath := filepath.Join(loopPath, "go.mod")
gomodBytes, err := ioutil.ReadFile(gomodPath)
if err != nil {
loopPath = loopPath[:idx]
continue
}

gomodContent := string(gomodBytes)
moduleIdx := strings.Index(gomodContent, "module ")
newLineIdx := strings.Index(gomodContent, "\n")

if moduleIdx >= 0 {
if newLineIdx >= 0 {
moduleName = strings.TrimSpace(gomodContent[moduleIdx+6 : newLineIdx])
moduleName = strings.TrimSuffix(moduleName, "\r")
} else {
moduleName = strings.TrimSpace(gomodContent[moduleIdx+6:])
}
return moduleName, nil
}
return "", fmt.Errorf("can not get module path in `%s`", gomodPath)
}
break
}
return moduleName, fmt.Errorf("no `go.mod` file in every parent directory of `%s`", pathToProjectRoot)
}
5 changes: 4 additions & 1 deletion common/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ func (err *Error) pkgPath() string {
if err.pathObj == nil {
return ""
}
return reflect.TypeOf(err.pathObj).PkgPath()
path := reflect.TypeOf(err.pathObj).PkgPath()
path = strings.TrimPrefix(path, "github.com/v2fly/v2ray-core/v4/")
path = strings.TrimPrefix(path, "github.com/v2fly/v2ray-core/v4")
return path
}

// Error implements error.Error().
Expand Down
15 changes: 2 additions & 13 deletions common/errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package errors_test

import (
"io"
"os"
"strings"
"testing"

"github.com/google/go-cmp/cmp"

"github.com/v2fly/v2ray-core/v4/common"
. "github.com/v2fly/v2ray-core/v4/common/errors"
"github.com/v2fly/v2ray-core/v4/common/log"
)
Expand Down Expand Up @@ -42,26 +40,17 @@ func TestError(t *testing.T) {
type e struct{}

func TestErrorMessage(t *testing.T) {
pwd, err := os.Getwd()
if err != nil {
t.Error(err)
}
moduleName, gmnErr := common.GetModuleName(pwd)
if gmnErr != nil {
t.Error(gmnErr)
}

data := []struct {
err error
msg string
}{
{
err: New("a").Base(New("b")).WithPathObj(e{}),
msg: moduleName + "/common/errors_test: a > b",
msg: "common/errors_test: a > b",
},
{
err: New("a").Base(New("b").WithPathObj(e{})),
msg: "a > " + moduleName + "/common/errors_test: b",
msg: "a > common/errors_test: b",
},
}

Expand Down
2 changes: 1 addition & 1 deletion common/platform/securedload/embedded.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ const allowedHashes = `SHA256 (!#project==v2fly) = fffffffffffffffffffffffffffff
SHA256 (!#version==embedded) = ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
SHA256 (subscriptions/subscriptionsDefinition.v2flyTemplate) = 3f165dba7de0d7c506fbdff3275ea64b76f307df435316a3ea0914ee957793ab
SHA256 (browserforwarder/index.html) = 34f2c573724256421ade769bda18eeac85172bf0aaed00d7b90e41e843a2caef
SHA256 (browserforwarder/index.js) = fbc533343c9ea292b7e7a1b6ecc56c8b54a81bc48e4b939dba76e355b5a5eb15
SHA256 (browserforwarder/index.js) = cf502dfb70fc81429d3848d21dae4ac9f04d7da1386849392ebd0c5b73cccdcc
`
4 changes: 3 additions & 1 deletion common/platform/securedload/embeddedhash.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"crypto/sha256"
"encoding/hex"
"path/filepath"
"strings"

"github.com/v2fly/VSign/insmgr"
Expand All @@ -18,7 +19,8 @@ type EmbeddedHashProtectedLoader struct {
}

func (e EmbeddedHashProtectedLoader) VerifyAndLoad(filename string) ([]byte, error) {
filecontent, err := filesystem.ReadFile(platform.GetAssetLocation(filename))
platformFileName := filepath.FromSlash(filename)
filecontent, err := filesystem.ReadFile(platform.GetAssetLocation(platformFileName))
if err != nil {
return nil, newError("Cannot find file", filename).Base(err)
}
Expand Down
3 changes: 0 additions & 3 deletions common/platform/securedload/file.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package securedload

import "path/filepath"

func GetAssetSecured(name string) ([]byte, error) {
name = filepath.FromSlash(name)

var err error
for k, v := range knownProtectedLoader {
Expand Down
2 changes: 1 addition & 1 deletion core.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

var (
version = "4.36.2"
version = "4.37.0"
build = "Custom"
codename = "V2Fly, a community-driven edition of V2Ray."
intro = "A unified platform for anti-censorship."
Expand Down
12 changes: 8 additions & 4 deletions functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ func StartInstance(configFormat string, configBytes []byte) (*Instance, error) {
//
// v2ray:api:stable
func Dial(ctx context.Context, v *Instance, dest net.Destination) (net.Conn, error) {
if FromContext(ctx) == nil {
ctx = context.WithValue(ctx, v2rayKey, v)
}

dispatcher := v.GetFeature(routing.DispatcherType())
if dispatcher == nil {
return nil, newError("routing.Dispatcher is not registered in V2Ray core")
}

if ctx.Value(v2rayKey) == nil {
ctx = context.WithValue(ctx, v2rayKey, v)
}

r, err := dispatcher.(routing.Dispatcher).Dispatch(ctx, dest)
if err != nil {
return nil, err
Expand All @@ -76,6 +76,10 @@ func Dial(ctx context.Context, v *Instance, dest net.Destination) (net.Conn, err
//
// v2ray:api:beta
func DialUDP(ctx context.Context, v *Instance) (net.PacketConn, error) {
if FromContext(ctx) == nil {
ctx = context.WithValue(ctx, v2rayKey, v)
}

dispatcher := v.GetFeature(routing.DispatcherType())
if dispatcher == nil {
return nil, newError("routing.Dispatcher is not registered in V2Ray core")
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ require (
github.com/pires/go-proxyproto v0.5.0
github.com/seiflotfy/cuckoofilter v0.0.0-20201222105146-bc6005554a0c
github.com/stretchr/testify v1.7.0
github.com/v2fly/BrowserBridge v0.0.0-20210327130545-c01e4317fadd
github.com/v2fly/BrowserBridge v0.0.0-20210402111049-048ea079a400
github.com/v2fly/VSign v0.0.0-20201108000810-e2adc24bf848
github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e
go.starlark.net v0.0.0-20210312235212-74c10e2c17dc
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/net v0.0.0-20210326220855-61e056675ecf
golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210326220804-49726bf1d181
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54
google.golang.org/grpc v1.36.1
google.golang.org/protobuf v1.26.0
h12.io/socks v1.0.2
Expand Down
14 changes: 7 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/v2fly/BrowserBridge v0.0.0-20210327130545-c01e4317fadd h1:fQ4O/lTTwSPHbIDhnT/npwHTgJ/5RQWQaQG01VbIYcc=
github.com/v2fly/BrowserBridge v0.0.0-20210327130545-c01e4317fadd/go.mod h1:skmBSeT/GvVqal/eylE9E16x9RC29xFXCbxDLVmatOk=
github.com/v2fly/BrowserBridge v0.0.0-20210402111049-048ea079a400 h1:aEW75Hq5bqMEEEMGxlR9LBfPyTjskthn1BQeigjxN9c=
github.com/v2fly/BrowserBridge v0.0.0-20210402111049-048ea079a400/go.mod h1:skmBSeT/GvVqal/eylE9E16x9RC29xFXCbxDLVmatOk=
github.com/v2fly/VSign v0.0.0-20201108000810-e2adc24bf848 h1:p1UzXK6VAutXFFQMnre66h7g1BjRKUnLv0HfmmRoz7w=
github.com/v2fly/VSign v0.0.0-20201108000810-e2adc24bf848/go.mod h1:p80Bv154ZtrGpXMN15slDCqc9UGmfBuUzheDFBYaW/M=
github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF8gHIiADmOVOV5LS43gt3ONnlEl3xkwI=
Expand Down Expand Up @@ -219,8 +219,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210326220855-61e056675ecf h1:WUcCxqQqDT0aXO4VnQbfMvp4zh7m1Gb2clVuHUAGGRE=
golang.org/x/net v0.0.0-20210326220855-61e056675ecf/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c h1:KHUzaHIpjWVlVVNh65G3hhuj3KB1HnjY6Cq5cTvRQT8=
golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -250,9 +250,9 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201231184435-2d18734c6014/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210326220804-49726bf1d181 h1:64ChN/hjER/taL4YJuA+gpLfIMT+/NFherRZixbxOhg=
golang.org/x/sys v0.0.0-20210326220804-49726bf1d181/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54 h1:rF3Ohx8DRyl8h2zw9qojyLHLhrJpEMgyPOImREEryf0=
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
2 changes: 1 addition & 1 deletion proxy/shadowsocks/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"crypto/cipher"
"crypto/md5"
"crypto/sha1"
"github.com/v2fly/v2ray-core/v4/common/antireplay"
"io"

"golang.org/x/crypto/chacha20poly1305"
"golang.org/x/crypto/hkdf"

"github.com/v2fly/v2ray-core/v4/common"
"github.com/v2fly/v2ray-core/v4/common/antireplay"
"github.com/v2fly/v2ray-core/v4/common/buf"
"github.com/v2fly/v2ray-core/v4/common/crypto"
"github.com/v2fly/v2ray-core/v4/common/protocol"
Expand Down
9 changes: 2 additions & 7 deletions proxy/shadowsocks/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion proxy/vmess/encoding/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
if s.isAEADForced {
return nil, drainConnection(newError("invalid user: VMessAEAD is enforced and a non VMessAEAD connection is received. You can still disable this security feature with environment variable v2ray.vmess.aead.forced = false . You will not be able to enable legacy header workaround in the future."))
}
newError("Critical Warning: potentially invalid user: a non VMessAEAD connection is received. From 2022 Jan 1st, this kind of connection will be rejected by default. You should update or replace your client software now. ").AtWarning().WriteToLog()
user = userLegacy
iv := hashTimestamp(md5.New(), timestamp)
vmessAccount = userLegacy.Account.(*vmess.MemoryAccount)
Expand Down
Loading

0 comments on commit f425dca

Please sign in to comment.