From e8cdaeb516100bf1be586155cfe6a6bc521038e1 Mon Sep 17 00:00:00 2001 From: mzz2017 Date: Wed, 14 Jul 2021 13:12:41 +0800 Subject: [PATCH] fix(vless): a problem that cannot save node of obfuscated as http --- gui/.gitignore | 1 + gui/src/assets/js/utils.js | 17 ++++++++++------- service/core/v2ray/asset/gfwlist/gfwlist.go | 5 ++--- service/core/vmessInfo/vmessInfo.go | 4 ++++ service/db/configure/const.go | 3 ++- service/go.mod | 5 +++++ service/go.sum | 10 ++++++++++ service/server/service/resolve.go | 1 + 8 files changed, 35 insertions(+), 11 deletions(-) diff --git a/gui/.gitignore b/gui/.gitignore index a0dddc6f..4fa04ae7 100644 --- a/gui/.gitignore +++ b/gui/.gitignore @@ -19,3 +19,4 @@ yarn-error.log* *.njsproj *.sln *.sw? +.nuxt \ No newline at end of file diff --git a/gui/src/assets/js/utils.js b/gui/src/assets/js/utils.js index 6d13e22c..f5ce80ad 100644 --- a/gui/src/assets/js/utils.js +++ b/gui/src/assets/js/utils.js @@ -128,6 +128,7 @@ function generateURL({ } let user = ""; if (username || password) { + console.log(username, password, protocol ? protocol : "http://"); if (username && password) { user = `${username}:${password}@`; } else { @@ -135,6 +136,7 @@ function generateURL({ } } let query = ""; + console.log(params); if (params) { let first = true; for (const k in params) { @@ -149,19 +151,20 @@ function generateURL({ query += `${k}=${encodeURIComponent(params[k])}`; } } + console.log(query); path = path || ""; if (path && path.length > 0 && path[0] !== "/") { path = "/" + path; } - a.href = `${protocol ? protocol : "http://"}${user}${host}${ - port ? `:${port}` : "" - }${path ? path : ""}`; - a.username = username; - a.password = password; - a.search = query; + a.href = `http://${user}${host}${port ? `:${port}` : ""}${path ? path : ""}`; + console.log( + `http://${user}${host}${port ? `:${port}` : ""}${path ? path : ""}` + ); + a.search = query.length ? `?${query}` : ""; a.hash = hash; - const r = a.href; + const r = (protocol ? protocol : "http://") + a.href.substr(7); a.remove(); + console.log(r, a.href); return r; } diff --git a/service/core/v2ray/asset/gfwlist/gfwlist.go b/service/core/v2ray/asset/gfwlist/gfwlist.go index be4ca960..0a638b0a 100644 --- a/service/core/v2ray/asset/gfwlist/gfwlist.go +++ b/service/core/v2ray/asset/gfwlist/gfwlist.go @@ -11,7 +11,6 @@ import ( "github.com/v2rayA/v2rayA/core/v2ray" "github.com/v2rayA/v2rayA/core/v2ray/asset" "github.com/v2rayA/v2rayA/db/configure" - "github.com/v2rayA/v2rayA/extra/copyfile" "github.com/v2rayA/v2rayA/extra/gopeed" "io" "log" @@ -121,7 +120,7 @@ func UpdateLocalGFWList() (localGFWListVersionAfterUpdate string, err error) { var sucBackup bool if _, err = os.Stat(pathSiteDat); err == nil { //backup - err = copyfile.CopyFile(pathSiteDat, backup) + err = os.Rename(pathSiteDat, backup) if err != nil { err = newError("fail to backup gfwlist file").Base(err) return @@ -149,7 +148,7 @@ func UpdateLocalGFWList() (localGFWListVersionAfterUpdate string, err error) { defer func() { if err != nil { if sucBackup { - _ = copyfile.CopyFile(backup, pathSiteDat) + _ = os.Rename(backup, pathSiteDat) } else { _ = os.Remove(pathSiteDat) } diff --git a/service/core/vmessInfo/vmessInfo.go b/service/core/vmessInfo/vmessInfo.go index 4cf40ab6..c952cb1e 100644 --- a/service/core/vmessInfo/vmessInfo.go +++ b/service/core/vmessInfo/vmessInfo.go @@ -47,6 +47,10 @@ func (v *VmessInfo) ExportToURL() string { case "mkcp", "kcp": setValue(&query, "headerType", v.Type) setValue(&query, "seed", v.Path) + case "tcp": + setValue(&query, "headerType", v.Type) + setValue(&query, "host", v.Host) + setValue(&query, "path", v.Path) } //TODO: QUIC, gRPC if v.TLS != "none" { diff --git a/service/db/configure/const.go b/service/db/configure/const.go index d3927628..3c47d4cf 100644 --- a/service/db/configure/const.go +++ b/service/db/configure/const.go @@ -62,7 +62,8 @@ const ( RoutingATemplate = `default: proxy # write your own rules below -domain(domain:webofscience.com,domain:webofknowledge.com,domain:clarivate.com,domain:ieee.org,domain:mdpi.com,domain:qq.com)->direct +domain(geosite:google-scholar)->proxy +domain(geosite:category-scholar-!cn,geosite:category-scholar-cn,domain:qq.com)->direct ip(geoip:private, geoip:cn)->direct domain(geosite:cn)->direct` diff --git a/service/go.mod b/service/go.mod index 2c6649d0..37abb296 100644 --- a/service/go.mod +++ b/service/go.mod @@ -3,7 +3,10 @@ module github.com/v2rayA/v2rayA go 1.16 require ( + github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1 // indirect github.com/beevik/ntp v0.3.0 + github.com/codegangsta/envy v0.0.0-20141216192214-4b78388c8ce4 // indirect + github.com/codegangsta/gin v0.0.0-20171026143024-cafe2ce98974 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/gin-contrib/cors v1.3.1 github.com/gin-gonic/gin v1.7.1 @@ -20,6 +23,7 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/leodido/go-urn v1.2.1 // indirect github.com/matoous/go-nanoid v1.5.0 + github.com/mattn/go-shellwords v1.0.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.1 // indirect github.com/muhammadmuzzammil1998/jsonc v0.0.0-20201229145248-615b0916ca38 @@ -43,6 +47,7 @@ require ( google.golang.org/genproto v0.0.0-20210429181445-86c259c2b4ab // indirect google.golang.org/grpc v1.37.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + gopkg.in/urfave/cli.v1 v1.20.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect v2ray.com/core v4.19.1+incompatible diff --git a/service/go.sum b/service/go.sum index dbb9daee..c2325643 100644 --- a/service/go.sum +++ b/service/go.sum @@ -1,4 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1 h1:j9HaafapDbPbGRDku6e/HRs6KBMcKHiWcm1/9Sbxnl4= +github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1/go.mod h1:NtXa9WwQsukMHZpjNakTTz0LArxvGYdPA9CjIcUSZ6s= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= @@ -14,6 +16,10 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/codegangsta/envy v0.0.0-20141216192214-4b78388c8ce4 h1:ihrIKrLQzm6Q6NJHBMemvaIGTFxgxQUEkn2AjN0Aulw= +github.com/codegangsta/envy v0.0.0-20141216192214-4b78388c8ce4/go.mod h1:X7wHz0C25Lga6CnJ4WAQNbUQ9P/8eWSNv8qIO71YkSM= +github.com/codegangsta/gin v0.0.0-20171026143024-cafe2ce98974 h1:ysuVNDVE4LIky6I+6JlgAKG+wBNKMpVv3m3neVpvFVw= +github.com/codegangsta/gin v0.0.0-20171026143024-cafe2ce98974/go.mod h1:UBYuwaH3dMw91EZ7tGVaFF6GDj5j46S7zqB9lZPIe58= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -126,6 +132,8 @@ github.com/matoous/go-nanoid v1.5.0/go.mod h1:zyD2a71IubI24efhpvkJz+ZwfwagzgSO6U github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk= +github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y= github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mdlayher/ethernet v0.0.0-20190606142754-0394541c37b7/go.mod h1:U6ZQobyTjI/tJyq2HG+i/dfSoFUt8/aZCM+GKtmFk/Y= github.com/mdlayher/netlink v0.0.0-20190409211403-11939a169225/go.mod h1:eQB3mZE4aiYnlUsyGGCOpPETfdQq4Jhsgf1fk3cwQaA= @@ -371,6 +379,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= +gopkg.in/urfave/cli.v1 v1.20.0 h1:NdAVW6RYxDif9DhDHaAortIu956m2c0v+09AZBPTbE0= +gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/service/server/service/resolve.go b/service/server/service/resolve.go index 2e5c4665..7f1f5b47 100644 --- a/service/server/service/resolve.go +++ b/service/server/service/resolve.go @@ -123,6 +123,7 @@ func ResolveVlessURL(vless string) (data *nodeData.NodeData, err error) { Flow: u.Query().Get("flow"), Protocol: "vless", } + log.Println(data.VmessInfo) if data.VmessInfo.Net == "" { data.VmessInfo.Net = "tcp" }