Compare commits

..

238 Commits

Author SHA1 Message Date
Nicholas Wang
6b5d2fed91 Merge github.com:/v2fly/v2ray-core tag v4.23.4 2020-06-03 05:03:50 -05:00
Shelikhoo
b610fc0a70 make error less sensitive 2020-06-03 16:32:58 +08:00
Shelikhoo
d31a067fc3 Release Version 2020-06-03 16:09:16 +08:00
Shelikhoo
b760ac149d Merge branch 'master' of github.com:v2fly/v2ray-core 2020-06-03 16:06:23 +08:00
Shelikhoo
221a13e658 Early detection of non http traffic to match web server behavior 2020-06-03 15:44:25 +08:00
Shelikhoo
087a62ef3d Fixed HTTP response not adjusted based on request 2020-06-03 15:16:03 +08:00
Shelikhoo
38e89bd2c7 VMess will Drain Connection On Auth failure 2020-06-03 11:25:47 +08:00
Kslr
5d616dcc75 Merge pull request #9 from v2fly/revert-8-kslr-patch-1
Revert "fix bazel not set home"
2020-06-03 09:58:32 +08:00
Kslr
b55fceba68 Revert "fix bazel not set home" 2020-06-03 09:58:15 +08:00
Shelikhoo
220b783caa Align Timeout Value 2020-06-03 09:12:45 +08:00
Shelikhoo
8f45736dd3 drain replayed connection 2020-06-02 20:02:08 +08:00
Shelikhoo
34c13f3b27 Detailed code and output 2020-06-02 18:18:31 +08:00
Shelikhoo
944c45a776 Fix not update behavior seed 2020-06-02 18:01:43 +08:00
Shelikhoo
5e59534333 Fix when rolled number is zero 2020-06-02 17:30:48 +08:00
Shelikhoo
13cef19430 Increase Drain Pool 2020-06-02 17:11:51 +08:00
Shelikhoo
ca032dd00f Drain Connection Based on uuid based behavior seed(skip auth info drain for now) 2020-06-02 15:16:17 +08:00
Shelikhoo
d671780804 Drain Connection Based on Uuid based Behavior seed 2020-06-02 14:47:54 +08:00
Nicholas Wang
85633ec25e Update SECURITY.md 2020-06-02 01:19:49 -05:00
Nicholas Wang
71aca12ab3 Create SECURITY.md 2020-06-02 01:06:34 -05:00
Kslr
46aa2c9e5e Merge pull request #8 from v2fly/kslr-patch-1
fix bazel not set home
2020-06-02 05:45:12 +08:00
Kslr
09295f7ef6 fix bazel not set home
https://github.com/v2ray/discussion/issues/714#issuecomment-637034754
2020-06-02 04:19:08 +08:00
Nicholas Wang
1eb00981de Merge branch 'master' of github.com:/v2ray/v2ray-core 2020-06-01 10:14:49 -05:00
Nicholas Wang
c84e795518 Merge branch 'master' of github.com:/v2fly/v2ray-core 2020-06-01 10:14:30 -05:00
Nicholas Wang
669b8893d7 Merge branch 'master' of github.com:/v2fly/v2ray-core 2020-06-01 09:36:02 -05:00
Shelikhoo
82ae56e710 Release 4.23.3 (Bug fix) 2020-06-01 07:29:08 -05:00
Shelikhoo
166826c478 Drain Connection with invalid checksum before closing. Emergency fix for weakness described in https://github.com/v2ray/v2ray-core/issues/2523 2020-06-01 07:29:08 -05:00
zzc10086
af9999f861 golang version number 1.14.1 2020-06-01 07:29:07 -05:00
Kslr
f48cc6df3d fix azure-pipelines bad merge 2020-06-01 07:29:06 -05:00
Kslr
43fb76ac62 Update azure-pipelines.yml 2020-06-01 07:29:05 -05:00
Dct Mei
75183b8961 Fix missing permissions 2020-06-01 07:29:04 -05:00
kslr
dc745d1e7a release 4.22.0 2020-06-01 07:29:03 -05:00
vcptr
26fd271f66 docker file compatible with ray version 2020-06-01 07:29:02 -05:00
vcptr
4684e07b14 docker pkg with name docker-fly 2020-06-01 07:29:01 -05:00
vcptr
e3aa2bdf48 adjust args 2020-06-01 07:29:00 -05:00
vcptr
89637f68e7 add abpath to user-package 2020-06-01 07:29:00 -05:00
Shelikhoo
1486ac6aa5 Fix build error, blaim golang.org/x/crypto@v0.0.0-20190308221718-c2843e01d9a2 2020-06-01 07:28:59 -05:00
Shelikhoo
7db6bd4b78 Fix merge error 2020-06-01 07:28:58 -05:00
Shelikhoo
be76b37554 Fix merge error 2020-06-01 07:28:57 -05:00
Shelikhoo
70e70d314e Set core version 2020-06-01 07:28:56 -05:00
Shelikhoo
7d1cb8aa44 Output Release ID 2020-06-01 07:28:55 -05:00
Shelikhoo
551c747013 Fix X file mode 2020-06-01 07:28:54 -05:00
Shelikhoo
7d9b9cfca7 Auto Release for Tag build 2020-06-01 07:28:53 -05:00
Shelikhoo
feb5e08c0e Added Tag into build trigger 2020-06-01 07:28:52 -05:00
fcying
9682a3df55 access log add detour tag 2020-06-01 07:28:52 -05:00
hanazaki05
534bb31ef1 Update to 4.20.0 2020-06-01 07:28:51 -05:00
Shelikhoo
289105fa8c Delay Closing Connection so that test have chance to complete(Additional) 2020-06-01 07:28:50 -05:00
Shelikhoo
6f541f60bf Delay Closing Connection so that test have chance to complete 2020-06-01 07:28:49 -05:00
Shelikhoo
82075d1868 Fix test break for windows: better error handling 2020-06-01 07:28:48 -05:00
Shelikhoo
dd617da67a Output Build Diagnose Information for common/buf(Fix) 2020-06-01 07:28:47 -05:00
Shelikhoo
8b197a042d Output Build Diagnose Information for common/buf 2020-06-01 07:28:46 -05:00
Kslr
dbc2929cfd version 4.19.1 2020-06-01 07:28:45 -05:00
Kslr
4032e20b03 Update install-release.sh
46ba7cde53
2020-06-01 07:28:44 -05:00
Kslr
423b2a815e adjust internal version 4.19 2020-06-01 07:28:44 -05:00
Shelikhoo
3700d65d8f Fix codestyle 2020-06-01 07:28:43 -05:00
boypt
f426c5cce5 fix stdin type mismatch in windows 2020-06-01 07:28:42 -05:00
Shelikhoo
774bdf202b fixed ReadV issue for windows 2020-06-01 07:28:41 -05:00
Kslr
aa4dc77978 add tls1.3 ciphers 2020-06-01 07:28:40 -05:00
Shelikhoo
8366627f5f update dat files before build 2020-06-01 07:28:39 -05:00
Shelikhoo
765d66296b Enable tls1.3 if not explicitly disabled 2020-06-01 07:28:38 -05:00
liberal-boy
dc8af28d56 enable TLS 1.3 by default 2020-06-01 07:28:37 -05:00
Shelikhoo
9f8a865772 name-prefix 2020-06-01 07:28:36 -05:00
Shelikhoo
a641f8274e parse release 2020-06-01 07:28:35 -05:00
Shelikhoo
3aab7d1dea fix var location 2020-06-01 07:28:35 -05:00
Shelikhoo
cd7c08b05e Replace Token 2020-06-01 07:28:34 -05:00
Shelikhoo
cd31b76e73 cd to code dir 2020-06-01 07:28:33 -05:00
Shelikhoo
f89bfe50cb Disable coverage upload 2020-06-01 07:28:32 -05:00
Shelikhoo
25de855502 Fix token 2020-06-01 07:28:31 -05:00
Shelikhoo
54a300af56 fix var group 2020-06-01 07:28:30 -05:00
Shelikhoo
76a8ac8434 Redo Bleeding Edge Release 2020-06-01 07:28:29 -05:00
Shelikhoo
64fd7c8ce8 fallback to release to core 2020-06-01 07:28:28 -05:00
Shelikhoo
1bcdb10811 fix 2020-06-01 07:28:27 -05:00
Shelikhoo
ae7553d117 Define target 2020-06-01 07:28:27 -05:00
Shelikhoo
6c745ac290 fix service connection 2020-06-01 07:28:26 -05:00
Shelikhoo
ba237b0361 Bleeding Edge release 2020-06-01 07:28:25 -05:00
Shelikhoo
70ae685106 unable to get sandboxing work, maybe later 2020-06-01 07:28:24 -05:00
Shelikhoo
b5433d2980 set cache to tmp dir 2020-06-01 07:28:23 -05:00
Shelikhoo
4de72b4225 set cache dir 2020-06-01 07:28:22 -05:00
Shelikhoo
a6b3281421 Fix build break 2020-06-01 07:28:21 -05:00
Shelikhoo
c3dae6305e fix rel dir 2020-06-01 07:28:20 -05:00
Shelikhoo
b6c21b1646 add debug file list 2020-06-01 07:28:19 -05:00
Shelikhoo
73f83d09ab fix dep download path 2020-06-01 07:28:19 -05:00
Shelikhoo
35809561f5 fix source download 2020-06-01 07:28:18 -05:00
Shelikhoo
9f9f0a2a96 go get trigger 2020-06-01 07:28:17 -05:00
Shelikhoo
b23e6fb1ba ln new source with old one 2020-06-01 07:28:16 -05:00
Shelikhoo
d123109fcd unset GOPATH to use go mod 2020-06-01 07:28:15 -05:00
Shelikhoo
7962aba52e Copy trigger source to seperate folder 2020-06-01 07:28:14 -05:00
Shelikhoo
1fe1b5c89a move primary dir 2020-06-01 07:28:13 -05:00
Shelikhoo
a1e4c9bc70 Release 4.23.3 (Bug fix) 2020-06-01 17:49:50 +08:00
Shelikhoo
e0aa18b6f3 Drain Connection with invalid checksum before closing. Emergency fix for weakness described in https://github.com/v2ray/v2ray-core/issues/2523 2020-06-01 16:40:54 +08:00
Kslr
4b81ba947f Merge pull request #2515 from rprx/patch-1
Update Golang version
2020-05-31 14:42:41 +08:00
rprx
371e176535 Update azure-pipelines.template.yml 2020-05-31 06:10:23 +00:00
rprx
05493cc096 Update azure-pipelines.yml 2020-05-31 06:08:36 +00:00
Kslr
9dc12961fa 4.23.2 2020-05-31 12:38:19 +08:00
Kslr
9f4fb3065d update geoip,geosite 2020-05-31 12:37:55 +08:00
Araragi Hokuto
2a96605138 Fix build failure on illumos
Previously v2ray can not be built on illumos due to following reasons:
1. missing build tags in transport/internet/sockopt_other.go
2. many definitions in syscall does not exist on illumos
This commit addresses these problems by adding missing build tags, and
updates those missing syscall deps on illumos to use x/sys/unix.
2020-05-31 12:37:24 +08:00
zzc10086
206008081d golang version number 1.14.1 2020-05-31 12:29:33 +08:00
Kslr
2d934d1027 fix azure-pipelines bad merge 2020-05-31 12:28:34 +08:00
Kslr
200e6ea3dc Update azure-pipelines.yml 2020-05-31 12:23:20 +08:00
Kslr
bab1c33de3 fix get the latest release tag error
https://github.com/v2ray/v2ray-core/issues/2373
2020-05-31 12:17:11 +08:00
vcptr
524b2aca56 let crypto/tls choose the proper ciphers 2020-05-31 11:25:56 +08:00
vcptr
e62e6608e1 tls use crypto std cipher suites 2020-05-31 11:25:50 +08:00
Dct Mei
c5842b91e6 Fix missing permissions 2020-04-03 01:42:04 +08:00
Kslr
ea62c9314d release 4.23.1 2020-03-24 22:26:03 +08:00
mzz
49b63cbd79 code quality review 2020-03-24 22:26:03 +08:00
mzz2017
9e84ce38dd feat: support more types of certificates 2020-03-24 22:26:03 +08:00
unknowndev233
b472e3e617 add v2ray@.service 2020-03-24 21:52:03 +08:00
unknowndev233
882320e45a add NoNewPrivileges=yes & CAP_NET_RAW 2020-03-24 21:52:03 +08:00
zouquan741
808ca5d473 installInitScript optimize
Should not install systemV init script when we have systemd
2020-03-24 21:52:03 +08:00
vcptr
0fd0c374c1 fix config compatibility with old inbound/inboundDetors/out 2020-03-24 21:52:03 +08:00
lucifer9
2bd5f2fe96 add SO_REUSEPORT for freebsd 11 2020-03-24 21:52:03 +08:00
vcptr
94ea326d89 fix confdir env startup priority 2020-03-24 21:52:03 +08:00
Shelikhoo
3f6ef26a00 Merge branch 'master' of github.com:v2fly/v2ray-core 2020-03-23 12:37:13 +08:00
Shelikhoo
c7d9abfb48 Update MacOS Version 2020-03-23 11:46:13 +08:00
Shelikhoo
e61b44ff78 Fix Test Parse flag before flag defined by V2 in main 2020-03-23 11:34:53 +08:00
Kslr
13b309f1b3 release 4.23.0 2020-03-19 19:11:17 +08:00
Kslr
cfbb875546 Revert "Reduce http proxy client overhead by 1RTT" 2020-03-19 19:11:17 +08:00
loyalsoldier
d555508cfe Update geoip.dat & geosite.dat on 2020.03.17 2020-03-19 19:11:17 +08:00
IceCodeNew
c7b5d178b7 Bug fix
修正当 releases 页存在多个 release 文件时(现在统统都是这样了),脚本错误将多个文件下载并合并为一个 dat 文件的问题。
该问题会导致 dat 文件无法被 v2ctl 程序解析。

简化 geoip.dat 及 geosite.dat 文件的下载代码。
2020-03-19 19:11:16 +08:00
IceCodeNew
f45baff01d SC2086
shellcheck: Double quote to prevent globbing and word splitting.
2020-03-19 19:11:16 +08:00
Loyalsoldier
c93003eab6 Update dat files download links
due to https://github.com/v2ray/geoip/issues/18
2020-03-19 19:11:16 +08:00
vcptr
0d71d3dcf8 revert back to multiconfig 2020-03-19 19:11:16 +08:00
vcptr
5d13ec9196 code style optmize in dispatch func 2020-03-12 00:42:29 +08:00
vcptr
04a0c04934 doh route strategy optimized 2020-03-12 00:42:29 +08:00
unknowndev233
19061275ca Fixed minor bugs & add Documentation 2020-03-12 00:42:29 +08:00
lucifer9
9608f77ba8 fix udp not work in ipv4 using common config 2020-03-12 00:42:29 +08:00
lucifer9
d055c0497d fix tproxy udp "unable to get destination" in IPv6 environment 2020-03-12 00:42:29 +08:00
ToutyRater
30b5f521c4 typo 2020-03-12 00:42:29 +08:00
nullptr
450bc5b3f0 Add SO_REUSEPORT to inbound 2020-03-12 00:42:29 +08:00
xymopen
0314d05792 refactor: Remove extract() 2020-03-12 00:42:29 +08:00
xymopen
01e940fd8e refactor: Install directly from zip file 2020-03-12 00:42:29 +08:00
xymopen
f9dc0a7fb6 feat: Add zipRoot()
Get root directory path inside ZIP file
2020-03-12 00:42:29 +08:00
xymopen
debbdc7276 refactor: Remove makeExecutable(), copyFile() 2020-03-12 00:42:29 +08:00
Anonymous-Someneese
99cf401867 http: send HTTP Connect if no content is written after 5ms. 2020-03-12 00:42:29 +08:00
Anonymous-Someneese
82dee01833 Fix reverse proxy with the HTTP optimization
And any other protocol that require the connection initializer to send first, E.g. freedom with TFO.
2020-03-12 00:42:29 +08:00
Anonymous-Someneese
a5caa01cb6 Optimize HTTP tunnel setup in TFO environment 2020-03-12 00:42:29 +08:00
Anonymous-Someneese
197fe15d5a Fix code quality 2020-03-12 00:42:29 +08:00
Anonymous-Someneese
f0e63c6e3c Reduce http proxy client overhead by 1RTT 2020-03-12 00:42:29 +08:00
unknowndev233
e19749180e minor changes
Weaken dependence on nss-lookup.target
Modify comments about https://github.com/v2ray/v2ray-core/issues/1011
2020-03-12 00:42:29 +08:00
unknowndev233
7cfd630a03 Update v2ray.service
default Type=exec -> Type=simple
2020-03-12 00:42:29 +08:00
unknowndev233
2614c37d50 v2ray.service upgrade
做了一点微小的工作,例如:
去掉了在非 `forking` 类型中几乎无意义的 `PIDFile` ([因为 systemd 不会写入](https://www.freedesktop.org/software/systemd/man/systemd.service.html#PIDFile=))
把[不推荐使用](https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/)的 `Wants=network.target` 换成 `Wants=network-online.target nss-lookup.target`
2020-03-12 00:42:29 +08:00
lucifer9
e176746d03 make Codacy/PR Quality Review happy 2020-03-12 00:42:29 +08:00
lucifer9
8c6dac924c code cleanup to make Codacy/PR Quality Review happy 2020-03-12 00:42:29 +08:00
lucifer
2ad7060375 add freebsd/pf support:
- transparent proxy (pf rdr) in IPv4 environment
- support both tcp and udp
- enable TCP_FASTOPEN, SO_REUSEPORT_LB, SO_REUSEADDR
- sockopt:mark is mapped to SO_USER_COOKIE
2020-03-12 00:42:29 +08:00
tnextday
ad3bcd2c07 pass username to inbound.User.Email in http/socks server 2020-03-12 00:42:29 +08:00
mzz2017
7f4f8091f9 feat/fix: dns query subscriptions group by A and AAAA. fix problem that empty result would poll dns server in DoH mode 2020-03-12 00:42:29 +08:00
mzz2017
4a663f2b25 fix(#2211): problem that AAAA query returns A result 2020-03-12 00:42:29 +08:00
xymopen
fa657b8681 refactor: Remove side effect from sysArch() 2020-03-12 00:42:29 +08:00
xymopen
4ae653e884 refactor: Extract normalizeVersion() 2020-03-12 00:42:29 +08:00
xymopen
52917c3243 refactor: Minor changes to install-release.sh
* Add missing CLI argument variables
* Remove key, COLOR variables
* Standardize EXTRACT_ONLY, ERROR_IF_UPTODATE variables
* Print output to stdout
* Print help using redirection
* Combine configuration conditions
2020-03-12 00:42:29 +08:00
xymopen
8f60e8275b style: Remove tailing space 2020-03-12 00:42:29 +08:00
Loyalsoldier
4a6ae20474 Update rules dat file URL
Update rules dat file URL to GitHub default latest downloadable assets URL
2020-03-12 00:42:29 +08:00
vcptr
556f4bf743 Merge branch 'raymaster' into flymaster 2020-01-03 08:52:41 +08:00
vcptr
3ca28ce2d8 Merge branch 'raymaster' into flymaster 2019-12-31 16:13:31 +08:00
vcptr
1aefd6ce40 Merge branch 'raymaster' into flymaster 2019-12-31 09:06:49 +08:00
Shelikhoo
30116d6433 Merge branch 'master' of github.com:v2fly/v2ray-core 2019-12-29 16:57:09 +08:00
Shelikhoo
6f22e67df4 Remove legacy release script 2019-12-29 16:55:28 +08:00
kslr
a03c4fcfb4 release 4.22.0 2019-12-29 16:55:01 +08:00
Shelikhoo
78e4d60a91 Added Armv6 file into release zip 2019-12-26 20:14:21 +08:00
Shelikhoo
4448d37c2b Merge branch 'master' of github.com:v2ray/v2ray-core 2019-12-26 19:34:48 +08:00
vcptr
622591bf03 Merge branch 'raymaster' into flymaster 2019-11-27 00:16:37 +08:00
vcptr
ca0ca362d3 Merge branch 'raymaster' into flymaster 2019-11-25 15:29:35 +08:00
vcptr
621cb8fc80 Merge branch 'raymaster' into flymaster 2019-11-21 14:37:20 +08:00
vcptr
699e73c760 Merge branch 'raymaster' into flymaster 2019-11-20 11:24:43 +08:00
vcptr
3c3a828e3b Merge branch 'raymaster' into flymaster 2019-11-19 14:00:46 +08:00
vcptr
8854c7872f early inited log 2019-11-19 09:49:33 +08:00
vcptr
8cfb682f9c Merge branch 'raymaster' into flymaster 2019-11-06 12:47:44 +08:00
vcptr
63b7eeacd1 docker file compatible with ray version 2019-11-02 13:38:29 +08:00
vcptr
b9480cb4b4 arm release include GOARM=6 2019-10-31 19:24:37 +08:00
vcptr
0d60a9e719 logger module start firstly 2019-10-31 19:13:19 +08:00
vcptr
0eb590ce7a docker pkg with name docker-fly 2019-10-31 17:30:10 +08:00
vcptr
3c8c9adcf7 Merge branch 'dockerdev' into flymaster 2019-10-31 12:38:01 +08:00
vcptr
bec564b455 adjust args 2019-10-31 11:44:57 +08:00
vcptr
4da588d406 add abpath to user-package 2019-10-31 11:29:18 +08:00
Shelikhoo
275e2d5af7 Fix build error, blaim golang.org/x/crypto@v0.0.0-20190308221718-c2843e01d9a2 2019-10-30 21:36:12 +08:00
Shelikhoo
95f808ccd8 Fix merge error 2019-10-30 20:24:38 +08:00
Shelikhoo
aecf18af0c Fix merge error 2019-10-30 20:15:31 +08:00
Shelikhoo
35e9da8ca6 Merge branch 'master' of github.com:v2ray/v2ray-core
This are significant amount of change introduced in this merge, needs 
additional testing.
2019-10-30 20:03:11 +08:00
Shelikhoo
b258ca7290 Set core version 2019-10-30 18:46:33 +08:00
Shelikhoo
d1881e2bc6 Output Release ID 2019-10-30 17:04:17 +08:00
Shelikhoo
0e39a08e10 Fix X file mode 2019-10-30 15:53:04 +08:00
Shelikhoo
a43cd8acf5 Auto Release for Tag build 2019-10-30 15:03:29 +08:00
Shelikhoo
7a9f446272 Added Tag into build trigger 2019-10-30 12:32:35 +08:00
Nicholas Wang
37d051f5e5 Merge pull request #6 from nicholascw/master
new group link in release/doc/readme.md
2019-10-16 16:18:52 -05:00
Nicholas Wang
1e49ba3b0f new group link 2019-10-16 16:18:09 -05:00
Kslr
087415850b Merge pull request #5 from fcying/access_detour_log
access log add detour tag
2019-07-24 22:08:57 +08:00
hanazaki05
8abff5a3cf Update to 4.20.0 2019-07-12 16:15:59 +08:00
Kslr
2c4c5c50c2 Sync from ray 2019-07-12 15:41:43 +08:00
Kslr
0a7d99803d fix incompatible errors when building with bazel 0.26+
a0aa7b7374
2019-07-12 14:38:48 +08:00
Kslr
e43acf6e2a add: mute access/error logger seperately
4c93d36d49
2019-07-12 14:34:38 +08:00
fcying
23e5d3cd12 access log add detour tag 2019-06-14 14:43:42 +08:00
Shelikhoo
8cf38342e9 Delay Closing Connection so that test have chance to complete(Additional) 2019-06-07 12:05:06 +08:00
Shelikhoo
dd8e957f59 Delay Closing Connection so that test have chance to complete 2019-06-07 10:01:23 +08:00
Shelikhoo
a32d6416e5 Fix test break for windows: better error handling 2019-06-06 22:14:50 +08:00
Shelikhoo
7718b9629c Output Build Diagnose Information for common/buf(Fix) 2019-06-06 20:52:26 +08:00
Shelikhoo
2a27093144 Output Build Diagnose Information for common/buf 2019-06-06 20:08:32 +08:00
Kslr
ab734056da version 4.19.1 2019-06-03 15:13:04 +08:00
Kslr
09075e62fd Fix IP rule with custom GeoIP file
b0edbec53e
2019-06-03 15:09:04 +08:00
Kslr
94ac104ffd Update install-release.sh
46ba7cde53
2019-06-03 15:04:58 +08:00
Kslr
48f5e7e76b Merge pull request #4 from boypt/fixvet
fix: json field tag syntax
2019-05-31 21:27:06 +08:00
boypt
ad4f41e1c0 fix: json field tag syntax 2019-05-30 16:48:34 +08:00
Kslr
1a294298e8 adjust internal version 4.19 2019-05-19 15:06:41 +08:00
Shelikhoo
60f3746c27 Fix codestyle 2019-05-17 22:17:57 +08:00
Shelikhoo
3446d63a1e Merge @boypt's PR #3 (Honor Merge) 2019-05-17 22:16:02 +08:00
Shelikhoo
ef6bd5e192 Merge branch 'fixwin' of git://github.com/boypt/v2ray-core into boypt-fixwin 2019-05-17 22:07:03 +08:00
Shelikhoo
847b289798 fixed ReadV issue for windows 2019-05-17 19:57:54 +08:00
boypt
388af4d1e3 fix stdin type mismatch in windows 2019-05-17 19:14:42 +08:00
Kslr
1a7b2337f8 add tls1.3 ciphers 2019-04-26 22:42:51 +08:00
Shelikhoo
f44ea4fbec update dat files before build 2019-04-16 20:24:15 +08:00
Shelikhoo
fa976b8a1b Enable tls1.3 if not explicitly disabled 2019-04-16 19:31:41 +08:00
Xiaokang Wang
20f05b5373 Merge pull request #1 from liberal-boy/master
enable TLS 1.3 by default(WIP)
2019-04-16 19:21:41 +08:00
Shelikhoo
894b6939cd name-prefix 2019-04-16 18:45:36 +08:00
Shelikhoo
7113c7e6ef parse release 2019-04-16 18:02:54 +08:00
Shelikhoo
ebb2d66a50 fix var location 2019-04-16 16:46:37 +08:00
Shelikhoo
40277a1460 Replace Token 2019-04-16 16:09:08 +08:00
Shelikhoo
8b47480f01 cd to code dir 2019-04-16 15:30:14 +08:00
Shelikhoo
73182c5952 Disable coverage upload 2019-04-16 15:02:37 +08:00
Shelikhoo
f9e3183356 Fix token 2019-04-16 15:00:26 +08:00
Shelikhoo
a9f3116fc3 fix var group 2019-04-16 14:50:20 +08:00
Shelikhoo
1f8cb7f86c Redo Bleeding Edge Release 2019-04-16 12:26:36 +08:00
Shelikhoo
81cf3059cd fallback to release to core 2019-04-16 11:58:22 +08:00
Shelikhoo
77ffbf00ce fix 2019-04-16 11:23:47 +08:00
Shelikhoo
0e7286917e Define target 2019-04-16 10:54:23 +08:00
Shelikhoo
db22d17f09 fix service connection 2019-04-16 10:24:26 +08:00
Shelikhoo
74b0181133 Bleeding Edge release 2019-04-16 10:21:35 +08:00
Shelikhoo
c8f43e9629 unable to get sandboxing work, maybe later 2019-04-16 09:36:36 +08:00
Shelikhoo
969d134681 set cache to tmp dir 2019-04-16 09:15:37 +08:00
Shelikhoo
e043c4d12e set cache dir 2019-04-16 08:53:39 +08:00
Shelikhoo
c096ee0a81 Fix build break 2019-04-16 08:36:12 +08:00
liberal-boy
15c0e975ca enable TLS 1.3 by default 2019-04-15 23:21:47 +08:00
Shelikhoo
7460f61f39 fix rel dir 2019-04-15 20:48:52 +08:00
Shelikhoo
4fef267c10 add debug file list 2019-04-15 20:33:30 +08:00
Shelikhoo
4cffa37b27 fix dep download path 2019-04-15 19:51:47 +08:00
Shelikhoo
a46459fd11 fix source download 2019-04-15 19:49:49 +08:00
Shelikhoo
d01c687f27 go get trigger 2019-04-15 19:30:40 +08:00
Shelikhoo
3c4e0d6712 ln new source with old one 2019-04-15 19:23:28 +08:00
Shelikhoo
f4f2a98e6e unset GOPATH to use go mod 2019-04-15 19:12:43 +08:00
Shelikhoo
3593db2d73 Copy trigger source to seperate folder 2019-04-15 19:00:53 +08:00
Shelikhoo
a59b3510ff move primary dir 2019-04-15 18:39:47 +08:00
25 changed files with 769 additions and 102 deletions

23
Dockerfile Normal file
View File

@@ -0,0 +1,23 @@
############################
# STEP 1 build executable binary
############################
FROM golang:alpine AS builder
RUN apk update && apk add --no-cache git bash wget
WORKDIR /go/src/v2ray.com/core
RUN git clone --progress https://github.com/v2fly/v2ray-core.git . && \
bash ./release/user-package.sh nosource noconf codename=$(git describe --tags) buildname=docker-fly abpathtgz=/tmp/v2ray.tgz
############################
# STEP 2 build a small image
############################
FROM alpine
LABEL maintainer "V2Fly Community <admin@v2fly.org>"
COPY --from=builder /tmp/v2ray.tgz /tmp
RUN apk update && apk add ca-certificates && \
mkdir -p /usr/bin/v2ray && \
tar xvfz /tmp/v2ray.tgz -C /usr/bin/v2ray
#ENTRYPOINT ["/usr/bin/v2ray/v2ray"]
ENV PATH /usr/bin/v2ray:$PATH
CMD ["v2ray", "-config=/etc/v2ray/config.json"]

79
SECURITY.md Normal file
View File

@@ -0,0 +1,79 @@
# 安全策略 Security Policy
## 受支持的版本 Supported Versions
目前 v2ray-core 项目由 [V2Fly 社区](https://github.com/v2fly) 继续提供代码维护,由于精力有限且项目复杂度较高,只维护主线代码的功能和安全性完整。原则上主页的兼容性保证继续遵循,
如有例外另行说明。
Currently v2ray-core project is maintained by [V2Fly community](https://github.com/v2fly). Feature and security guarantee may only be limited to the
master branch, though we would still try our best to follow the compatiblity claims listed on the official website.
## 汇报安全风险 Reporting a Vulnerability
可以使用邮箱 dev |at| v2fly.org或下方列出的 gpg 公钥在 GitHub 提交 issue 并注明安全风险。
You can either use email dev |at| v2fly.org, or directly open an GitHub issue with the gpg key listed below.
```
pub rsa4096 2020-06-02 [SC] [有效至2020-12-29]
E2E35E27914FB007C0D4B6DDB117BA3BE8B494A7
uid V2Fly Developers <dev |at| v2fly.org>
sub rsa4096 2020-06-02 [E] [有效至2020-12-29]
-----BEGIN PGP PUBLIC KEY BLOCK-----
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
F1cKt4RANJY=
=qRzt
-----END PGP PUBLIC KEY BLOCK-----
```

View File

@@ -14,3 +14,9 @@ jobs:
go test -p 1 -v -timeout 30m ./...
workingDirectory: '$(Build.SourcesDirectory)'
displayName: 'Test'
- script: |
go build ./common/buf
condition: always()
workingDirectory: '$(Build.SourcesDirectory)'
displayName: 'Test Buf error'

View File

@@ -3,8 +3,12 @@ trigger:
branches:
include:
- master
- dev*
- refs/tags/*
pr: none
pr:
- master
- dev*
jobs:
- template: azure-pipelines.template.yml
@@ -30,8 +34,9 @@ jobs:
pool:
vmImage: 'ubuntu-latest'
variables:
CODECOV_TOKEN: '$(coverage.token)'
#variables:
# CODECOV_TOKEN: '$(coverage.token)'
steps:
- checkout: self
@@ -50,43 +55,78 @@ jobs:
pool:
vmImage: 'ubuntu-latest'
variables:
GOPATH: '$(system.defaultWorkingDirectory)'
BAZEL_VER: '0.23.0'
- group: GithubToken
- name: GOPATH
value: '$(system.defaultWorkingDirectory)/gopath'
- name: BAZEL_VER
value: '0.23.0'
steps:
- checkout: none
- checkout: self
- task: GoTool@0
inputs:
version: '1.14.1'
- script: |
mkdir triggersrc
ls -I "triggersrc" | xargs cp -rf -t triggersrc
mkdir gopath
displayName: Prepare Environment
workingDirectory: '$(system.defaultWorkingDirectory)'
- script: |
sudo apt-get -y update
sudo apt-get -y install jq git file pkg-config zip g++ zlib1g-dev unzip python openssl
sudo apt-get -y install jq git file pkg-config zip g++ zlib1g-dev unzip python openssl tree
displayName: Apt Install
- script: |
go version
go get -insecure -v -t -d v2ray.com/core/...
workingDirectory: '$(system.defaultWorkingDirectory)'
unset GOPATH
mkdir ./src
mkdir ./src/v2ray.com
ln -s $(pwd)/../triggersrc ./src/v2ray.com/core
go get -v -t -d ./src/v2ray.com/core/...
tree
workingDirectory: '$(GOPATH)'
displayName: 'Fetch sources'
- script: |
mkdir release
cd src
zip -9 -r ../release/src_all.zip * -x '*.git*'
workingDirectory: '$(system.defaultWorkingDirectory)'
workingDirectory: '$(GOPATH)'
displayName: 'Dump sources'
- script: |
curl -L -o bazel-installer.sh https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/bazel-${BAZEL_VER}-installer-linux-x86_64.sh
chmod +x bazel-installer.sh
./bazel-installer.sh --user
workingDirectory: '$(system.defaultWorkingDirectory)'
workingDirectory: '$(GOPATH)'
displayName: 'Install Bazel'
- script: |
cd ./src/v2ray.com/core
$HOME/bin/bazel build --action_env=GOPATH=$GOPATH --action_env=PATH=$PATH --action_env=GPG_PASS=${SIGN_KEY_PASS} //release:all
workingDirectory: '$(system.defaultWorkingDirectory)'
./release/updatedat.sh
$HOME/bin/bazel build --action_env=GOPATH=$GOPATH --action_env=PATH=$PATH --action_env=GPG_PASS=${SIGN_KEY_PASS} --action_env=SPWD=$PWD --action_env=GOCACHE=$(go env GOCACHE) --spawn_strategy local //release:all
workingDirectory: '$(GOPATH)'
displayName: 'Build Binaries'
- script: |
cp ./src/v2ray.com/core/bazel-bin/release/*.zip ./release/
workingDirectory: '$(system.defaultWorkingDirectory)'
workingDirectory: '$(GOPATH)'
displayName: 'Dump Binaries'
- script: |
cd ./src/v2ray.com/core
echo $RELEASE_TAG
./release/bleedingrelease.sh
workingDirectory: '$(GOPATH)'
displayName: 'Generate Bleeding Edge Release'
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
PRERELEASE: true
RELEASE_TAG: unstable-$(Build.SourceVersion)
- script: |
cd ./src/v2ray.com/core
echo $RELEASE_TAG
./release/tagrelease.sh
workingDirectory: '$(GOPATH)'
displayName: 'Generate Tag Release'
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
PRERELEASE: true
RELEASE_TAG: unstable-$(Build.SourceVersion)
TRIGGER_REASON: $(Build.SourceBranch)

View File

@@ -15,11 +15,38 @@ func Roll(n int) int {
return rand.Intn(n)
}
// Roll returns a non-negative number between 0 (inclusive) and n (exclusive).
func RollDeterministic(n int, seed int64) int {
if n == 1 {
return 0
}
return rand.New(rand.NewSource(seed)).Intn(n)
}
// RollUint16 returns a random uint16 value.
func RollUint16() uint16 {
return uint16(rand.Intn(65536))
}
func RollUint64() uint64 {
return rand.Uint64()
}
func NewDeterministicDice(seed int64) *deterministicDice {
return &deterministicDice{rand.New(rand.NewSource(seed))}
}
type deterministicDice struct {
*rand.Rand
}
func (dd *deterministicDice) Roll(n int) int {
if n == 1 {
return 0
}
return dd.Intn(n)
}
func init() {
rand.Seed(time.Now().Unix())
}

View File

@@ -38,6 +38,8 @@ const (
RequestOptionChunkMasking bitmask.Byte = 0x04
RequestOptionGlobalPadding bitmask.Byte = 0x08
RequestOptionEarlyChecksum bitmask.Byte = 0x16
)
type RequestHeader struct {

View File

@@ -19,7 +19,7 @@ import (
)
var (
version = "4.23.2"
version = "4.23.4"
build = "Custom"
codename = "V2Fly, a community-driven edition of V2Ray."
intro = "A unified platform for anti-censorship."

View File

@@ -113,7 +113,9 @@ func defaultBufferPolicy() Buffer {
func SessionDefault() Session {
return Session{
Timeouts: Timeout{
Handshake: time.Second * 4,
//Align Handshake timeout with nginx client_header_timeout
//So that this value will not indicate server identity
Handshake: time.Second * 60,
ConnectionIdle: time.Second * 300,
UplinkOnly: time.Second * 1,
DownlinkOnly: time.Second * 1,

6
go.mod
View File

@@ -8,10 +8,10 @@ require (
github.com/miekg/dns v1.1.4
github.com/refraction-networking/utls v0.0.0-20190909200633-43c36d3c1f57
go.starlark.net v0.0.0-20190919145610-979af19b165c
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
golang.org/x/net v0.0.0-20190311183353-d8887717615a
golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
golang.org/x/sys v0.0.0-20190412213103-97732733099d
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b // indirect
google.golang.org/grpc v1.24.0
h12.io/socks v1.0.0

6
go.sum
View File

@@ -20,14 +20,20 @@ go.starlark.net v0.0.0-20190919145610-979af19b165c h1:WR7X1xgXJlXhQBdorVc9Db3Rhw
go.starlark.net v0.0.0-20190919145610-979af19b165c/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf h1:fnPsqIDRbCSgumaMCRpoIoF2s4qxv0xSSS0BVZUE/ss=
golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=

View File

@@ -28,10 +28,11 @@ def _go_command(ctx):
"CGO_ENABLED=0",
"GOOS="+ctx.attr.os,
"GOARCH="+ctx.attr.arch,
"GOROOT_FINAL=/go",
#"GOROOT_FINAL=/go",
"GO111MODULE=on",
"GOCACHE=${TMPDIR}/gocache"
]
if ctx.attr.mips: # https://github.com/golang/go/issues/27260
envs+=["GOMIPS="+ctx.attr.mips]
envs+=["GOMIPS64="+ctx.attr.mips]
@@ -40,7 +41,9 @@ def _go_command(ctx):
if ctx.attr.arm:
envs+=["GOARM="+ctx.attr.arm]
command = " ".join(envs) + " " + command
switchToPwd="cd ${SPWD} && "
command = switchToPwd + " ".join(envs) + " " + command
ctx.actions.run_shell(
outputs = [output_file],

View File

@@ -5,8 +5,10 @@ import (
"encoding/binary"
"hash/fnv"
"io"
"io/ioutil"
"sync"
"time"
"v2ray.com/core/common/dice"
"golang.org/x/crypto/chacha20poly1305"
@@ -123,7 +125,29 @@ func parseSecurityType(b byte) protocol.SecurityType {
// DecodeRequestHeader decodes and returns (if successful) a RequestHeader from an input stream.
func (s *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.RequestHeader, error) {
buffer := buf.New()
defer buffer.Release()
behaviorRand := dice.NewDeterministicDice(int64(s.userValidator.GetBehaviorSeed()))
BaseDrainSize := behaviorRand.Roll(3266)
RandDrainMax := behaviorRand.Roll(64) + 1
RandDrainRolled := dice.Roll(RandDrainMax)
DrainSize := BaseDrainSize + 16 + 38 + RandDrainRolled
readSizeRemain := DrainSize
drainConnection := func(e error) error {
//We read a deterministic generated length of data before closing the connection to offset padding read pattern
readSizeRemain -= int(buffer.Len())
if readSizeRemain > 0 {
err := s.DrainConnN(reader, readSizeRemain)
if err != nil {
return newError("failed to drain connection DrainSize = ", BaseDrainSize, " ", RandDrainMax, " ", RandDrainRolled).Base(err).Base(e)
}
return newError("connection drained DrainSize = ", BaseDrainSize, " ", RandDrainMax, " ", RandDrainRolled).Base(e)
}
return e
}
defer func() {
buffer.Release()
}()
if _, err := buffer.ReadFullFrom(reader, protocol.IDBytesLen); err != nil {
return nil, newError("failed to read request header").Base(err)
@@ -131,7 +155,7 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
user, timestamp, valid := s.userValidator.Get(buffer.Bytes())
if !valid {
return nil, newError("invalid user")
return nil, drainConnection(newError("invalid user"))
}
iv := hashTimestamp(md5.New(), timestamp)
@@ -140,6 +164,7 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
aesStream := crypto.NewAesDecryptionStream(vmessAccount.ID.CmdKey(), iv[:])
decryptor := crypto.NewCryptionReader(aesStream, reader)
readSizeRemain -= int(buffer.Len())
buffer.Clear()
if _, err := buffer.ReadFullFrom(decryptor, 38); err != nil {
return nil, newError("failed to read request header").Base(err)
@@ -157,7 +182,7 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
sid.key = s.requestBodyKey
sid.nonce = s.requestBodyIV
if !s.sessionHistory.addIfNotExits(sid) {
return nil, newError("duplicated session id, possibly under replay attack")
return nil, drainConnection(newError("duplicated session id, possibly under replay attack"))
}
s.responseHeader = buffer.Byte(33) // 1 byte
@@ -194,7 +219,8 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
expectedHash := binary.BigEndian.Uint32(buffer.BytesFrom(-4))
if actualHash != expectedHash {
return nil, newError("invalid auth")
//It is possible that we are under attack described in https://github.com/v2ray/v2ray-core/issues/2523
return nil, drainConnection(newError("invalid auth"))
}
if request.Address == nil {
@@ -347,3 +373,8 @@ func (s *ServerSession) EncodeResponseBody(request *protocol.RequestHeader, writ
panic("Unknown security type.")
}
}
func (s *ServerSession) DrainConnN(reader io.Reader, n int) error {
_, err := io.CopyN(ioutil.Discard, reader, int64(n))
return err
}

View File

@@ -3,9 +3,11 @@
package vmess
import (
"hash/crc64"
"strings"
"sync"
"time"
"v2ray.com/core/common/dice"
"v2ray.com/core/common"
"v2ray.com/core/common/protocol"
@@ -26,11 +28,13 @@ type user struct {
// TimedUserValidator is a user Validator based on time.
type TimedUserValidator struct {
sync.RWMutex
users []*user
userHash map[[16]byte]indexTimePair
hasher protocol.IDHash
baseTime protocol.Timestamp
task *task.Periodic
users []*user
userHash map[[16]byte]indexTimePair
hasher protocol.IDHash
baseTime protocol.Timestamp
task *task.Periodic
behaviorSeed uint64
behaviorFused bool
}
type indexTimePair struct {
@@ -124,6 +128,11 @@ func (v *TimedUserValidator) Add(u *protocol.MemoryUser) error {
v.users = append(v.users, uu)
v.generateNewHashes(protocol.Timestamp(nowSec), uu)
if v.behaviorFused == false {
account := uu.user.Account.(*MemoryAccount)
v.behaviorSeed = crc64.Update(v.behaviorSeed, crc64.MakeTable(crc64.ECMA), account.ID.Bytes())
}
return nil
}
@@ -131,6 +140,8 @@ func (v *TimedUserValidator) Get(userHash []byte) (*protocol.MemoryUser, protoco
defer v.RUnlock()
v.RLock()
v.behaviorFused = true
var fixedSizeHash [16]byte
copy(fixedSizeHash[:], userHash)
pair, found := v.userHash[fixedSizeHash]
@@ -170,3 +181,13 @@ func (v *TimedUserValidator) Remove(email string) bool {
func (v *TimedUserValidator) Close() error {
return v.task.Close()
}
func (v *TimedUserValidator) GetBehaviorSeed() uint64 {
v.Lock()
defer v.Unlock()
v.behaviorFused = true
if v.behaviorSeed == 0 {
v.behaviorSeed = dice.RollUint64()
}
return v.behaviorSeed
}

52
release/bleedingrelease.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/bin/bash
RELBODY="https://www.v2ray.com/chapter_00/01_versions.html"
JSON_DATA=$(echo "{}" | jq -c ".tag_name=\"${RELEASE_TAG}\"")
JSON_DATA=$(echo ${JSON_DATA} | jq -c ".prerelease=${PRERELEASE}")
JSON_DATA=$(echo ${JSON_DATA} | jq -c ".body=\"${RELBODY}\"")
RELEASE_DATA=$(curl --data "${JSON_DATA}" -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/v2fly/V2FlyBleedingEdgeBinary/releases)
echo $RELEASE_DATA
RELEASE_ID=$(echo $RELEASE_DATA| jq ".id")
function uploadfile() {
FILE=$1
CTYPE=$(file -b --mime-type $FILE)
sleep 1
curl -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: ${CTYPE}" --data-binary @$FILE "https://uploads.github.com/repos/v2fly/V2FlyBleedingEdgeBinary/releases/${RELEASE_ID}/assets?name=$(basename $FILE)"
sleep 1
}
function upload() {
FILE=$1
DGST=$1.dgst
openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >> $DGST
openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >> $DGST
openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >> $DGST
openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >> $DGST
uploadfile $FILE
uploadfile $DGST
}
ART_ROOT=$GOPATH/src/v2ray.com/core/bazel-bin/release
upload ${ART_ROOT}/v2ray-macos.zip
upload ${ART_ROOT}/v2ray-windows-64.zip
upload ${ART_ROOT}/v2ray-windows-32.zip
upload ${ART_ROOT}/v2ray-linux-64.zip
upload ${ART_ROOT}/v2ray-linux-32.zip
upload ${ART_ROOT}/v2ray-linux-arm.zip
upload ${ART_ROOT}/v2ray-linux-arm64.zip
upload ${ART_ROOT}/v2ray-linux-mips64.zip
upload ${ART_ROOT}/v2ray-linux-mips64le.zip
upload ${ART_ROOT}/v2ray-linux-mips.zip
upload ${ART_ROOT}/v2ray-linux-mipsle.zip
upload ${ART_ROOT}/v2ray-linux-ppc64.zip
upload ${ART_ROOT}/v2ray-linux-ppc64le.zip
upload ${ART_ROOT}/v2ray-linux-s390x.zip
upload ${ART_ROOT}/v2ray-freebsd-64.zip
upload ${ART_ROOT}/v2ray-freebsd-32.zip
upload ${ART_ROOT}/v2ray-openbsd-64.zip
upload ${ART_ROOT}/v2ray-openbsd-32.zip
upload ${ART_ROOT}/v2ray-dragonfly-64.zip

View File

@@ -1,25 +1,22 @@
[Unit]
Description=V2Ray - A unified platform for anti-censorship
Documentation=https://v2ray.com https://guide.v2fly.org
Description=V2Ray Service
Documentation=https://www.v2ray.com/ https://www.v2fly.org/
After=network.target nss-lookup.target
Wants=network-online.target
[Service]
# If the version of systemd is 240 or above, then uncommenting Type=exec and commenting out Type=simple
#Type=exec
Type=simple
# Runs as root or add CAP_NET_BIND_SERVICE ability can bind 1 to 1024 port.
# This service runs as root. You may consider to run it as another user for security concerns.
# By uncommenting User=v2ray and commenting out User=root, the service will run as user v2ray.
# By uncommenting User=nobody and commenting out User=root, the service will run as user nobody.
# More discussion at https://github.com/v2ray/v2ray-core/issues/1011
User=root
#User=v2ray
CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW
NoNewPrivileges=yes
#User=nobody
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/usr/bin/v2ray/v2ray -config /etc/v2ray/config.json
Restart=on-failure
# Don't restart in the case of configuration error
RestartPreventExitStatus=23
[Install]
WantedBy=multi-user.target

View File

@@ -1,26 +1,22 @@
[Unit]
Description=V2Ray - A unified platform for anti-censorship - Profile -> %i
Documentation=https://v2ray.com https://guide.v2fly.org
Description=V2Ray Service
Documentation=https://www.v2ray.com/ https://www.v2fly.org/
After=network.target nss-lookup.target
Wants=network-online.target
[Service]
# If the version of systemd is 240 or above, then uncommenting Type=exec and commenting out Type=simple
#Type=exec
Type=simple
# Runs as root or add CAP_NET_BIND_SERVICE ability can bind 1 to 1024 port.
# This service runs as root. You may consider to run it as another user for security concerns.
# By uncommenting User=v2ray and commenting out User=root, the service will run as user v2ray.
# By uncommenting User=nobody and commenting out User=root, the service will run as user nobody.
# More discussion at https://github.com/v2ray/v2ray-core/issues/1011
User=root
#User=v2ray
CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW
NoNewPrivileges=yes
#User=nobody
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/usr/bin/v2ray/v2ray -config /etc/v2ray/%i.json
Restart=on-failure
# Don't restart in the case of configuration error
RestartPreventExitStatus=23
[Install]
DefaultInstance=default
WantedBy=multi-user.target

75
release/tagrelease.sh Executable file
View File

@@ -0,0 +1,75 @@
#!/bin/bash
CONST_refs="refs"
TRIGGER_REASON_A=${TRIGGER_REASON:0:${#CONST_refs}}
if [ $TRIGGER_REASON_A != $CONST_refs ]
then
echo "not a tag: $TRIGGER_REASON_A"
exit
fi
CONST_refsB="refs/tags/"
TRIGGER_REASON_B=${TRIGGER_REASON:0:${#CONST_refsB}}
if [ $TRIGGER_REASON_B != $CONST_refsB ]
then
echo "not a tag (B)"
exit
fi
GITHUB_RELEASE_TAG=${TRIGGER_REASON:${#CONST_refsB}:10}
echo ${GITHUB_RELEASE_TAG}
RELEASE_DATA=$(curl -H "Authorization: token ${GITHUB_TOKEN}" -X GET https://api.github.com/repos/v2fly/v2ray-core/releases/tags/${GITHUB_RELEASE_TAG})
echo $RELEASE_DATA
RELEASE_ID=$(echo $RELEASE_DATA| jq ".id")
echo $RELEASE_ID
function uploadfile() {
FILE=$1
CTYPE=$(file -b --mime-type $FILE)
sleep 1
curl -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: ${CTYPE}" --data-binary @$FILE "https://uploads.github.com/repos/v2fly/v2ray-core/releases/${RELEASE_ID}/assets?name=$(basename $FILE)"
sleep 1
}
function upload() {
FILE=$1
DGST=$1.dgst
openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >> $DGST
openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >> $DGST
openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >> $DGST
openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >> $DGST
uploadfile $FILE
uploadfile $DGST
}
ART_ROOT=$GOPATH/src/v2ray.com/core/bazel-bin/release
upload ${ART_ROOT}/v2ray-macos.zip
upload ${ART_ROOT}/v2ray-windows-64.zip
upload ${ART_ROOT}/v2ray-windows-32.zip
upload ${ART_ROOT}/v2ray-linux-64.zip
upload ${ART_ROOT}/v2ray-linux-32.zip
upload ${ART_ROOT}/v2ray-linux-arm.zip
upload ${ART_ROOT}/v2ray-linux-arm64.zip
upload ${ART_ROOT}/v2ray-linux-mips64.zip
upload ${ART_ROOT}/v2ray-linux-mips64le.zip
upload ${ART_ROOT}/v2ray-linux-mips.zip
upload ${ART_ROOT}/v2ray-linux-mipsle.zip
upload ${ART_ROOT}/v2ray-linux-ppc64.zip
upload ${ART_ROOT}/v2ray-linux-ppc64le.zip
upload ${ART_ROOT}/v2ray-linux-s390x.zip
upload ${ART_ROOT}/v2ray-freebsd-64.zip
upload ${ART_ROOT}/v2ray-freebsd-32.zip
upload ${ART_ROOT}/v2ray-openbsd-64.zip
upload ${ART_ROOT}/v2ray-openbsd-32.zip
upload ${ART_ROOT}/v2ray-dragonfly-64.zip

14
release/updatedat.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
pushd $GOPATH/src/v2ray.com/core/
# Update geoip.dat
GEOIP_TAG=$(curl --silent "https://api.github.com/repos/v2ray/geoip/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
curl -L -o release/config/geoip.dat "https://github.com/v2ray/geoip/releases/download/${GEOIP_TAG}/geoip.dat"
sleep 1
# Update geosite.dat
GEOSITE_TAG=$(curl --silent "https://api.github.com/repos/v2ray/domain-list-community/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
curl -L -o release/config/geosite.dat "https://github.com/v2ray/domain-list-community/releases/download/${GEOSITE_TAG}/dlc.dat"
sleep 1
popd

View File

@@ -42,7 +42,7 @@ echo "mode: set" | cat - ${COV_SORTED} > ${COVERAGE_FILE}
if [ "$FAIL" -eq 0 ]; then
echo "Uploading coverage datea to codecov."
bash <(curl -s https://codecov.io/bash) -f ${COVERAGE_FILE} -v || echo "Codecov did not collect coverage reports."
#bash <(curl -s https://codecov.io/bash) -f ${COVERAGE_FILE} -v || echo "Codecov did not collect coverage reports."
fi
exit $FAIL

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"strings"
"testing"
"time"
@@ -265,7 +266,9 @@ func TestCommanderAddRemoveUser(t *testing.T) {
common.Must(err)
defer CloseAllServers(servers)
if err := testTCPConn(clientPort, 1024, time.Second*5)(); err != io.EOF {
if err := testTCPConn(clientPort, 1024, time.Second*5)(); err != io.EOF &&
/*We might wish to drain the connection*/
(err != nil && !strings.HasSuffix(err.Error(), "i/o timeout")) {
t.Fatal("expected error: ", err)
}

View File

@@ -919,7 +919,6 @@ func TestVMessKCPLarge(t *testing.T) {
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
common.Must(err)
defer CloseAllServers(servers)
var errg errgroup.Group
for i := 0; i < 2; i++ {
@@ -928,6 +927,11 @@ func TestVMessKCPLarge(t *testing.T) {
if err := errg.Wait(); err != nil {
t.Error(err)
}
defer func(){
<-time.After(5*time.Second)
CloseAllServers(servers)
}()
}
func TestVMessGCMMux(t *testing.T) {
@@ -1161,7 +1165,6 @@ func TestVMessGCMMuxUDP(t *testing.T) {
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
common.Must(err)
defer CloseAllServers(servers)
for range "abcd" {
var errg errgroup.Group
@@ -1174,4 +1177,9 @@ func TestVMessGCMMuxUDP(t *testing.T) {
}
time.Sleep(time.Second)
}
defer func(){
<-time.After(5*time.Second)
CloseAllServers(servers)
}()
}

View File

@@ -3,6 +3,7 @@ package http
//go:generate errorgen
import (
"bufio"
"bytes"
"context"
"io"
@@ -28,6 +29,8 @@ const (
var (
ErrHeaderToLong = newError("Header too long.")
ErrHeaderMisMatch = newError("Header Mismatch.")
)
type Reader interface {
@@ -51,12 +54,22 @@ func (NoOpWriter) Write(io.Writer) error {
}
type HeaderReader struct {
req *http.Request
expectedHeader *RequestConfig
}
func (*HeaderReader) Read(reader io.Reader) (*buf.Buffer, error) {
func (h *HeaderReader) ExpectThisRequest(expectedHeader *RequestConfig) *HeaderReader {
h.expectedHeader = expectedHeader
return h
}
func (h *HeaderReader) Read(reader io.Reader) (*buf.Buffer, error) {
buffer := buf.New()
totalBytes := int32(0)
endingDetected := false
var headerBuf bytes.Buffer
for totalBytes < maxHeaderLength {
_, err := buffer.ReadFrom(reader)
if err != nil {
@@ -64,6 +77,7 @@ func (*HeaderReader) Read(reader io.Reader) (*buf.Buffer, error) {
return nil, err
}
if n := bytes.Index(buffer.Bytes(), []byte(ENDING)); n != -1 {
headerBuf.Write(buffer.BytesRange(0, int32(n+len(ENDING))))
buffer.Advance(int32(n + len(ENDING)))
endingDetected = true
break
@@ -71,19 +85,56 @@ func (*HeaderReader) Read(reader io.Reader) (*buf.Buffer, error) {
lenEnding := int32(len(ENDING))
if buffer.Len() >= lenEnding {
totalBytes += buffer.Len() - lenEnding
headerBuf.Write(buffer.BytesRange(0, buffer.Len()-lenEnding))
leftover := buffer.BytesFrom(-lenEnding)
buffer.Clear()
copy(buffer.Extend(lenEnding), leftover)
if _, err := readRequest(bufio.NewReader(bytes.NewReader(headerBuf.Bytes())), false); err != io.ErrUnexpectedEOF {
return nil, err
}
}
}
if buffer.IsEmpty() {
buffer.Release()
return nil, nil
}
if !endingDetected {
buffer.Release()
return nil, ErrHeaderToLong
}
if h.expectedHeader == nil {
if buffer.IsEmpty() {
buffer.Release()
return nil, nil
}
return buffer, nil
}
//Parse the request
if req, err := readRequest(bufio.NewReader(bytes.NewReader(headerBuf.Bytes())), false); err != nil {
return nil, err
} else {
h.req = req
}
//Check req
path := h.req.URL.Path
hasThisUri := false
for _, u := range h.expectedHeader.Uri {
if u == path {
hasThisUri = true
}
}
if hasThisUri == false {
return nil, ErrHeaderMisMatch
}
if buffer.IsEmpty() {
buffer.Release()
return nil, nil
}
return buffer, nil
}
@@ -110,18 +161,24 @@ func (w *HeaderWriter) Write(writer io.Writer) error {
type HttpConn struct {
net.Conn
readBuffer *buf.Buffer
oneTimeReader Reader
oneTimeWriter Writer
errorWriter Writer
readBuffer *buf.Buffer
oneTimeReader Reader
oneTimeWriter Writer
errorWriter Writer
errorMismatchWriter Writer
errorTooLongWriter Writer
errReason error
}
func NewHttpConn(conn net.Conn, reader Reader, writer Writer, errorWriter Writer) *HttpConn {
func NewHttpConn(conn net.Conn, reader Reader, writer Writer, errorWriter Writer, errorMismatchWriter Writer, errorTooLongWriter Writer) *HttpConn {
return &HttpConn{
Conn: conn,
oneTimeReader: reader,
oneTimeWriter: writer,
errorWriter: errorWriter,
Conn: conn,
oneTimeReader: reader,
oneTimeWriter: writer,
errorWriter: errorWriter,
errorMismatchWriter: errorMismatchWriter,
errorTooLongWriter: errorTooLongWriter,
}
}
@@ -129,6 +186,7 @@ func (c *HttpConn) Read(b []byte) (int, error) {
if c.oneTimeReader != nil {
buffer, err := c.oneTimeReader.Read(c.Conn)
if err != nil {
c.errReason = err
return 0, err
}
c.readBuffer = buffer
@@ -165,7 +223,16 @@ func (c *HttpConn) Close() error {
if c.oneTimeWriter != nil && c.errorWriter != nil {
// Connection is being closed but header wasn't sent. This means the client request
// is probably not valid. Sending back a server error header in this case.
c.errorWriter.Write(c.Conn)
//Write response based on error reason
if c.errReason == ErrHeaderMisMatch {
c.errorMismatchWriter.Write(c.Conn)
} else if c.errReason == ErrHeaderToLong {
c.errorTooLongWriter.Write(c.Conn)
} else {
c.errorWriter.Write(c.Conn)
}
}
return c.Conn.Close()
@@ -230,36 +297,17 @@ func (a HttpAuthenticator) Client(conn net.Conn) net.Conn {
if a.config.Response != nil {
writer = a.GetClientWriter()
}
return NewHttpConn(conn, reader, writer, NoOpWriter{})
return NewHttpConn(conn, reader, writer, NoOpWriter{}, NoOpWriter{}, NoOpWriter{})
}
func (a HttpAuthenticator) Server(conn net.Conn) net.Conn {
if a.config.Request == nil && a.config.Response == nil {
return conn
}
return NewHttpConn(conn, new(HeaderReader), a.GetServerWriter(), formResponseHeader(&ResponseConfig{
Version: &Version{
Value: "1.1",
},
Status: &Status{
Code: "500",
Reason: "Internal Server Error",
},
Header: []*Header{
{
Name: "Connection",
Value: []string{"close"},
},
{
Name: "Cache-Control",
Value: []string{"private"},
},
{
Name: "Content-Length",
Value: []string{"0"},
},
},
}))
return NewHttpConn(conn, new(HeaderReader).ExpectThisRequest(a.config.Request), a.GetServerWriter(),
formResponseHeader(resp400),
formResponseHeader(resp404),
formResponseHeader(resp400))
}
func NewHttpAuthenticator(ctx context.Context, config *Config) (HttpAuthenticator, error) {

View File

@@ -1,9 +1,11 @@
package http_test
import (
"bufio"
"bytes"
"context"
"crypto/rand"
"strings"
"testing"
"time"
@@ -28,10 +30,15 @@ func TestReaderWriter(t *testing.T) {
reader := &HeaderReader{}
buffer, err := reader.Read(cache)
common.Must(err)
if buffer.String() != "efg" {
t.Error("buffer: ", buffer.String())
if err != nil && !strings.HasPrefix(err.Error(), "malformed HTTP request") {
t.Error("unknown error ", err)
}
_ = buffer
return
/*
if buffer.String() != "efg" {
t.Error("buffer: ", buffer.String())
}*/
}
func TestRequestHeader(t *testing.T) {
@@ -65,10 +72,16 @@ func TestLongRequestHeader(t *testing.T) {
reader := HeaderReader{}
b, err := reader.Read(bytes.NewReader(payload))
common.Must(err)
if b.String() != "abcd" {
t.Error("expect content abcd, but actually ", b.String())
if err != nil && !(strings.HasPrefix(err.Error(), "invalid") || strings.HasPrefix(err.Error(), "malformed")) {
t.Error("unknown error ", err)
}
_ = b
/*
common.Must(err)
if b.String() != "abcd" {
t.Error("expect content abcd, but actually ", b.String())
}*/
}
func TestConnection(t *testing.T) {
@@ -143,3 +156,164 @@ func TestConnection(t *testing.T) {
t.Error("response: ", string(actualResponse[:totalBytes]))
}
}
func TestConnectionInvPath(t *testing.T) {
auth, err := NewHttpAuthenticator(context.Background(), &Config{
Request: &RequestConfig{
Method: &Method{Value: "Post"},
Uri: []string{"/testpath"},
Header: []*Header{
{
Name: "Host",
Value: []string{"www.v2ray.com", "www.google.com"},
},
{
Name: "User-Agent",
Value: []string{"Test-Agent"},
},
},
},
Response: &ResponseConfig{
Version: &Version{
Value: "1.1",
},
Status: &Status{
Code: "404",
Reason: "Not Found",
},
},
})
common.Must(err)
authR, err := NewHttpAuthenticator(context.Background(), &Config{
Request: &RequestConfig{
Method: &Method{Value: "Post"},
Uri: []string{"/testpathErr"},
Header: []*Header{
{
Name: "Host",
Value: []string{"www.v2ray.com", "www.google.com"},
},
{
Name: "User-Agent",
Value: []string{"Test-Agent"},
},
},
},
Response: &ResponseConfig{
Version: &Version{
Value: "1.1",
},
Status: &Status{
Code: "404",
Reason: "Not Found",
},
},
})
common.Must(err)
listener, err := net.Listen("tcp", "127.0.0.1:0")
common.Must(err)
go func() {
conn, err := listener.Accept()
common.Must(err)
authConn := auth.Server(conn)
b := make([]byte, 256)
for {
n, err := authConn.Read(b)
if err != nil {
authConn.Close()
break
}
_, err = authConn.Write(b[:n])
common.Must(err)
}
}()
conn, err := net.DialTCP("tcp", nil, listener.Addr().(*net.TCPAddr))
common.Must(err)
authConn := authR.Client(conn)
defer authConn.Close()
authConn.Write([]byte("Test payload"))
authConn.Write([]byte("Test payload 2"))
expectedResponse := "Test payloadTest payload 2"
actualResponse := make([]byte, 256)
deadline := time.Now().Add(time.Second * 5)
totalBytes := 0
for {
n, err := authConn.Read(actualResponse[totalBytes:])
if err == nil {
t.Error("Error Expected", err)
} else {
return
}
totalBytes += n
if totalBytes >= len(expectedResponse) || time.Now().After(deadline) {
break
}
}
return
}
func TestConnectionInvReq(t *testing.T) {
auth, err := NewHttpAuthenticator(context.Background(), &Config{
Request: &RequestConfig{
Method: &Method{Value: "Post"},
Uri: []string{"/testpath"},
Header: []*Header{
{
Name: "Host",
Value: []string{"www.v2ray.com", "www.google.com"},
},
{
Name: "User-Agent",
Value: []string{"Test-Agent"},
},
},
},
Response: &ResponseConfig{
Version: &Version{
Value: "1.1",
},
Status: &Status{
Code: "404",
Reason: "Not Found",
},
},
})
common.Must(err)
listener, err := net.Listen("tcp", "127.0.0.1:0")
common.Must(err)
go func() {
conn, err := listener.Accept()
common.Must(err)
authConn := auth.Server(conn)
b := make([]byte, 256)
for {
n, err := authConn.Read(b)
if err != nil {
authConn.Close()
break
}
_, err = authConn.Write(b[:n])
common.Must(err)
}
}()
conn, err := net.DialTCP("tcp", nil, listener.Addr().(*net.TCPAddr))
common.Must(err)
conn.Write([]byte("ABCDEFGHIJKMLN\r\n\r\n"))
l, _, err := bufio.NewReader(conn).ReadLine()
common.Must(err)
if !strings.HasPrefix(string(l), "HTTP/1.1 400 Bad Request") {
t.Error("Resp to non http conn", string(l))
}
return
}

View File

@@ -0,0 +1,11 @@
package http
import (
"bufio"
"net/http"
_ "unsafe" // required to use //go:linkname
)
//go:linkname readRequest net/http.readRequest
func readRequest(b *bufio.Reader, deleteHostHeader bool) (req *http.Request, err error)

View File

@@ -0,0 +1,49 @@
package http
var resp400 = &ResponseConfig{
Version: &Version{
Value: "1.1",
},
Status: &Status{
Code: "400",
Reason: "Bad Request",
},
Header: []*Header{
{
Name: "Connection",
Value: []string{"close"},
},
{
Name: "Cache-Control",
Value: []string{"private"},
},
{
Name: "Content-Length",
Value: []string{"0"},
},
},
}
var resp404 = &ResponseConfig{
Version: &Version{
Value: "1.1",
},
Status: &Status{
Code: "404",
Reason: "Not Found",
},
Header: []*Header{
{
Name: "Connection",
Value: []string{"close"},
},
{
Name: "Cache-Control",
Value: []string{"private"},
},
{
Name: "Content-Length",
Value: []string{"0"},
},
},
}