Compare commits

..

725 Commits

Author SHA1 Message Date
Kslr d80440f3d5
Merge pull request #3085 from v2ray/dependabot/go_modules/github.com/stretchr/testify-1.8.1
Bump github.com/stretchr/testify from 1.6.1 to 1.8.1
2023-02-24 22:31:26 +08:00
dependabot[bot] 6a747255bc
Bump github.com/stretchr/testify from 1.6.1 to 1.8.1
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.6.1 to 1.8.1.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.6.1...v1.8.1)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-24 03:01:53 +00:00
Kslr 5dffca8423
Merge pull request #2795 from v2ray/dependabot/go_modules/github.com/google/go-cmp-0.5.3
Bump github.com/google/go-cmp from 0.5.2 to 0.5.3
2020-11-14 03:10:52 +08:00
dependabot[bot] c22fdf63e5
Bump github.com/google/go-cmp from 0.5.2 to 0.5.3
Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.5.2 to 0.5.3.
- [Release notes](https://github.com/google/go-cmp/releases)
- [Commits](https://github.com/google/go-cmp/compare/v0.5.2...v0.5.3)

Signed-off-by: dependabot[bot] <support@github.com>
2020-11-13 05:41:19 +00:00
Nicholas Wang 5fa62c393b
update security policy with renewed GPG pubkey 2020-11-08 03:55:17 -06:00
Kslr b0a9256b9d
Merge pull request #2787 from v2ray/dependabot/github_actions/actions/stale-v3.0.13
Bump actions/stale from v3.0.11 to v3.0.13
2020-11-03 14:25:37 +08:00
dependabot[bot] 418ff076c4
Bump actions/stale from v3.0.11 to v3.0.13
Bumps [actions/stale](https://github.com/actions/stale) from v3.0.11 to v3.0.13.
- [Release notes](https://github.com/actions/stale/releases)
- [Commits](https://github.com/actions/stale/compare/v3.0.11...af4072615903a8b031f986d25b1ae3bf45ec44d4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-11-03 06:20:33 +00:00
Kslr ff02f2ac16
Merge branch 'v2fly-master' into master 2020-10-11 00:46:14 +08:00
Kslr 98911dc9f3
Merge branch 'master' of https://github.com/v2fly/v2ray-core into v2fly-master 2020-10-11 00:45:44 +08:00
Loyalsoldier c50fef48a7
Refine golangci-lint settings (#294) 2020-10-10 00:19:09 +08:00
Loyalsoldier ed97a250e4
Refine golangci-lint settings (#293) 2020-10-09 22:06:40 +08:00
Loyalsoldier 807922f883
Reduce timeout & fix ineffassign (#290) 2020-10-09 16:32:12 +08:00
Vento Valery 1f70185b85
bump version 2020-10-09 12:27:55 +08:00
Loyalsoldier 811981b6f0
Geofile workflow: only run on v2fly/v2ray-core (#288) 2020-10-09 10:47:22 +08:00
Kslr a44e1ede5b
update to IETF QUIC draft-29 (#287)
* update to IETF QUIC draft-29
2020-10-09 10:04:35 +08:00
GitHub Action 9997567bd4 update geoip, geosite 2020-10-09 00:16:59 +00:00
GitHub Action 8e8127b2be update geoip, geosite 2020-10-09 00:11:37 +00:00
Loyalsoldier 97dac8cd2f
Build: comply with upstream (#283) 2020-10-08 09:53:25 +08:00
Loyalsoldier 454528353d
Fix misspelling according to goreportcard result (#282) 2020-10-08 08:53:15 +08:00
lucifer 425b4b497d
Add padding to abstract unix domain socket in fallbacks (#277)
* fix fall back to abstract unix domain socket in vless and trojan

* Update trojan.go

* Update vless.go

* Update trojan.go

* Update vless.go

Co-authored-by: RPRX <63339210+rprx@users.noreply.github.com>
2020-10-08 00:35:21 +00:00
Loyalsoldier f0403a67a1
Refine scripts (#279) 2020-10-07 20:04:09 +08:00
Loyalsoldier ba99e32b2d
Bazel: discard GOPATH (#278) 2020-10-07 18:35:21 +08:00
Loyalsoldier 93a91ea4de
Refine README (#275) 2020-10-07 16:58:19 +08:00
Loyalsoldier 26aecf095f
Refine Dockerfile (#274) 2020-10-07 16:28:51 +08:00
Loyalsoldier 6769e653ff
Run go mod tidy (#273) 2020-10-07 15:23:27 +08:00
Loyalsoldier 7ef520baa8
Refine user-package (#272) 2020-10-07 15:02:29 +08:00
Kslr 8071aa9c18
Update rights owner 2020-10-07 14:34:00 +08:00
Loyalsoldier 6e4701b700
Build: do NOT rely on GOPATH & refine user-package.sh (#270)
* Build: do NOT rely on GOPATH

* Format pipelines
2020-10-07 14:29:07 +08:00
RPRX 884feea680
Merge pull request #271 from rprx/master
VLESS PREVIEW 2.4
2020-10-07 04:26:55 +00:00
RPRX 4bf1b4ebcc
VLESS PREVIEW 2.4 2020-10-07 03:35:04 +00:00
Kslr 359f84407a
compiler use gogcc, remove gcflags and asmflags (#269) 2020-10-07 10:02:40 +08:00
RPRX bcc7b78ff7
Add XTLS support to mKCP (#267) 2020-10-06 16:25:02 +00:00
Kslr 03fb762169
removes all file system paths from the compiled executable, to improve build reproducibility 2020-10-06 13:17:30 +08:00
Kslr 48fde93020
remove unused doc in release 2020-10-06 13:05:46 +08:00
RPRX c344edd2e1
Up 2020-10-05 17:21:05 +00:00
dependabot[bot] 8599697f5a
Bump github.com/pires/go-proxyproto from 0.1.3 to 0.2.0 (#265)
Bumps [github.com/pires/go-proxyproto](https://github.com/pires/go-proxyproto) from 0.1.3 to 0.2.0.
- [Release notes](https://github.com/pires/go-proxyproto/releases)
- [Commits](https://github.com/pires/go-proxyproto/compare/v0.1.3...v0.2.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-05 16:08:44 +08:00
Loyalsoldier bb44d01096
Format proto files using clang-format according to google style (#264)
* Format proto files using clang-format according to google style
* Regenerate pb.go files
2020-10-05 08:36:40 +08:00
RPRX a308620073
Fix 2020-10-05 00:52:03 +08:00
RPRX ef872ffe01
Merge pull request #262 from rprx/master
VLESS PREVIEW 2.3
2020-10-04 12:45:46 +00:00
RPRX b8a78038a2
VLESS PREVIEW 2.3 2020-10-04 10:51:29 +00:00
Loyalsoldier 9a452bc1a1
Merge pull request #260 from Loyalsoldier/refine-errorgen
Errorgen: support to run outside of GOPATH
2020-10-04 13:15:05 +08:00
loyalsoldier b181045b0c
Errorgen: support to run outside of GOPATH 2020-10-04 13:06:12 +08:00
loyalsoldier 0650af46f4
Refine errorgen 2020-10-04 13:06:11 +08:00
loyalsoldier 4130b54579
Support to read go.mod recursively to get module path 2020-10-04 12:47:22 +08:00
Loyalsoldier d30b5fb501
Merge pull request #259 from Loyalsoldier/refine-code
Refine code
2020-10-04 10:27:28 +08:00
loyalsoldier 9b249f912b
Make variables of vprotogen easier to find 2020-10-04 10:05:00 +08:00
loyalsoldier edefca7932
Refine & make proto.go work outside GOPATH 2020-10-04 09:56:45 +08:00
loyalsoldier 4ba4cad7ae
Refine func GetModuleName 2020-10-04 09:55:21 +08:00
Loyalsoldier 68dd2a0d85
Merge pull request #258 from Loyalsoldier/refine-codes
Refine codes
2020-10-04 06:31:42 +08:00
loyalsoldier f184d16918
Fix golangci nolint 2020-10-04 06:29:35 +08:00
loyalsoldier 7a789fed37
Run go fmt 2020-10-04 06:29:21 +08:00
Loyalsoldier 088ce4ed95
Refine proto.go due to protoc-gen-go-grpc update (#257)
* Refine: remove protoc-gen-go-grpc specific version
* pb.go: regenerate due to proto.go refresh
2020-10-04 05:43:26 +08:00
RPRX 36f0b7d6e4
Fix Trojan inbound access log (#255) 2020-10-03 15:24:04 +00:00
RPRX 271532fc84
Add full VLESS fallbacks support to Trojan (#254)
* Add full VLESS fallbacks support to Trojan

* Adjustments according to linter

* Use common.Must2() for pro.Write()
2020-10-03 13:12:35 +00:00
RPRX 2e4042ebd7
Merge pull request #253 from rprx/master
VLESS PREVIEW 2.2
2020-10-03 05:31:28 +00:00
RPRX 60909dad31
VLESS PREVIEW 2.2 2020-10-03 03:23:24 +00:00
Ye Zhihao 67f409de04
Stats: Implements blocking/non-blocking messaging of Channel (#250) 2020-10-03 03:06:32 +08:00
Kslr 9f344fa1c9
remove shadowsosks ota (#238)
* remove shadowsosks ota

* remove unused buf.Reader
2020-10-02 16:13:31 +08:00
Loyalsoldier dcf368bd93
Refine Azure Pipelines & Bazel: remove unnecessary steps (#246)
* Bazel: remove GPG sign
* Azure Pipelines: remove unnecessary steps
2020-10-02 16:09:33 +08:00
Loyalsoldier 2fc5f96a1d
Refine codes (#245)
* Run go mod tidy
* Add new line
* Run gofmt
2020-10-02 09:32:39 +08:00
Loyalsoldier 353df856b3
Actions: do NOT run on repo "v2ray/v2ray-core" (#244) 2020-10-02 09:16:25 +08:00
GitHub Action 992e80baaf update geoip, geosite 2020-10-02 00:15:41 +00:00
GitHub Action 4f6e028e8b update geoip, geosite 2020-10-02 00:10:38 +00:00
Kslr 37138e044d
Merge pull request #2750 from v2fly/2750-conflicts
merge fly
2020-10-02 08:07:50 +08:00
Kslr 58694e75d9
Merge branch 'master' into 2750-conflicts 2020-10-02 06:52:29 +08:00
Kslr 6376b80f6b
bump version 2020-10-02 06:43:30 +08:00
RPRX cde63bfac1
Add XTLS support to DomainSocket (#241) 2020-09-30 08:40:08 +00:00
RPRX 65565572d3
VLESS UDP over TCP struct breaking change (#239)
具体改变:每个 UDP 载荷前加两字节长度的 length,最大值为 2048-2=2046。若不使用 Mux,服务端与客户端均需升级至 v4.30.0+。这是 VLESS 公测版(0)协议结构本身唯一一次 breaking change,正式版(1)的服务端预计会长期同时支持该版本,第三方客户端的实现应当尽快跟进。
2020-09-30 01:39:03 +00:00
Loyalsoldier dfed0dc03a
Refine: geofile reading errors (#236) 2020-09-29 14:01:12 +08:00
maskedeken e445d21f4b
Add trojan protocol support (#181)
* Add trojan protocol support

Co-authored-by: Eken Chan <ekenchan@msn.com>
Co-authored-by: Loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
Co-authored-by: GitHub Action <action@github.com>
2020-09-26 23:31:24 +08:00
Kslr 211cc67426
Merge pull request #208 from Vigilans/vigilans/stats-routing
API: Implements RoutingService
2020-09-26 23:23:38 +08:00
Kslr dea8b1e0c4
Merge pull request #228 from Loyalsoldier/refine-dns-local-tlds
DNS: refine local TLDs for localhost DNS
2020-09-26 23:22:18 +08:00
loyalsoldier ec0c3f181d
DNS: refine local TLDs for localhost DNS 2020-09-26 22:30:44 +08:00
Kslr 155c0e070b
update link 2020-09-26 02:39:08 +08:00
Kslr ad4924ac4e
bump version 2020-09-25 17:38:14 +08:00
GitHub Action d1704e1e11 update geoip, geosite 2020-09-25 00:16:03 +00:00
GitHub Action 73311d1056 update geoip, geosite 2020-09-25 00:10:56 +00:00
RPRX f55e05c166
int -> int32 2020-09-24 12:18:11 +00:00
RPRX 4b0aea1dca
Fix bug 2020-09-24 11:22:12 +00:00
RPRX d77b88c7c2
Merge pull request #224 from rprx/master
VLESS PREVIEW 2
2020-09-24 11:11:22 +00:00
RPRX 0e8e23897c
Tiny adjustment 2020-09-24 11:09:14 +00:00
RPRX 3072cdccf4
Add return 2020-09-24 11:02:27 +00:00
Vigilans cd9ac1bac7 API: Implements RoutingService 2020-09-24 10:24:26 +08:00
RPRX 648d4180aa
VLESS PREVIEW 2 2020-09-24 01:59:14 +00:00
Loyalsoldier 788dd1ebc7
Merge pull request #219 from Vigilans/vigilans/stats-channel-config
Stats: Add ChannelConfig & Return error on subscription
2020-09-24 02:21:45 +08:00
Vigilans fa37f82b89 Stats: Add ChannelConfig & Return error on subscription 2020-09-23 22:35:13 +08:00
Loyalsoldier 2cc8c1aa01
Golangci-lint: increase timeout to 5 minutes (#215) 2020-09-22 07:33:43 +08:00
RPRX 0b7d7d6898
Merge pull request #213 from XTLS/master
Add XTLS support
2020-09-21 14:58:31 +00:00
RPRX 97eddc2374
Add XTLS support 2020-09-21 14:56:43 +00:00
Kslr 7d40abaf95
Merge pull request #210 from Loyalsoldier/disable-golangci-lint-plugins
Golangci-lint: disable some plugins
2020-09-21 13:56:11 +08:00
RPRX 010fbf4d8b
Make isAEAD more efficient 2020-09-21 03:20:04 +00:00
RPRX 470dc8523b
Make isAEAD more efficient 2020-09-21 01:10:56 +00:00
loyalsoldier f9a9746fcd
Golangci-lint: disable some plugins 2020-09-21 06:39:38 +08:00
Loyalsoldier 5f620256b2
CodeQL: do NOT run on ready for review status (#209) 2020-09-21 06:26:41 +08:00
Kslr 525d4e13a9
Merge pull request #197 from Vigilans/vigilans/stats-channel-runnable
Stats: Implement common.Runnable for Channel feature
2020-09-20 22:39:46 +08:00
Kslr 64493e3811
Merge pull request #200 from Vigilans/vigilans/routing-route
Routing: Implement Route interface as Router's result
2020-09-20 18:49:15 +08:00
Kslr 14c80ec2e1
Merge pull request #207 from DuckSoft/master
kcp: removing annoying NewAEADAESGCMBasedOnSeed hint
2020-09-20 18:29:11 +08:00
DuckSoft 9def692b21
kcp: removing annoying NewAEADAESGCMBasedOnSeed hint 2020-09-20 17:47:15 +08:00
Vigilans 4d5a4f4cb6 Routing: Implement Route interface as the routing result of Router 2020-09-18 17:30:59 +08:00
Loyalsoldier df2d296ffc
Refine linter (#203)
* Linter: remove gochecknoinits plugin
* Linter: do NOT run some plugins on test files
2020-09-18 17:24:01 +08:00
Loyalsoldier 782909b9f3
Linter: only show new issues (#202)
Add option `only-new-issues` to avoid showing old issues.
2020-09-18 16:48:45 +08:00
Kslr 20926be898
Merge pull request #2740 from v2fly/master
merge v2fly
2020-09-18 15:42:31 +08:00
Kslr e5d6603454
bump version 2020-09-18 15:39:20 +08:00
GitHub Action 9cb633a5bc update geoip, geosite 2020-09-18 00:15:33 +00:00
GitHub Action 528b56474f update geoip, geosite 2020-09-18 00:10:49 +00:00
Kslr 4b7d729221
Update linter.yml 2020-09-16 23:30:01 +08:00
Kslr 0995d961c9
Update linter.yml 2020-09-16 22:00:52 +08:00
Kslr a9e932ffd4
Update linter.yml 2020-09-16 21:56:47 +08:00
Kslr 0c7dfd590b
Update linter.yml 2020-09-16 21:39:35 +08:00
Loyalsoldier e32c651573
Fix and refine workflows (#199)
* Fix linter: ansible not found error
* Refine codeql: only run on *.go files
2020-09-16 15:18:25 +08:00
dependabot[bot] b744a63990
Bump github/super-linter from v3.10.0 to v3.10.1 (#198) 2020-09-16 14:20:26 +08:00
Vigilans 4fca2fe940 Implement common.Runnable for stats.Channel feature 2020-09-15 23:04:26 +08:00
Kslr c530e36e67
Create codeql-analysis.yml 2020-09-15 16:02:46 +08:00
Kslr 0cbed7e265
Merge pull request #187 from wwqgtxx/master
support disable vmess aead by os environ
2020-09-14 18:04:12 +08:00
wwqgtxx 43174d6951 support disable vmess aead by os environ 2020-09-14 17:49:59 +08:00
Kslr f76611caa0
Merge pull request #194 from v2fly/dependabot/github_actions/actions/stale-v3.0.11
Bump actions/stale from v3.0.10 to v3.0.11
2020-09-14 14:34:51 +08:00
dependabot[bot] 554c919367
Bump actions/stale from v3.0.10 to v3.0.11
Bumps [actions/stale](https://github.com/actions/stale) from v3.0.10 to v3.0.11.
- [Release notes](https://github.com/actions/stale/releases)
- [Commits](https://github.com/actions/stale/compare/v3.0.10...1849651e2aa1b1d6d2cba4c90c719f4b6c929a28)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-14 06:12:31 +00:00
Kslr a8972cdf06
Merge pull request #188 from Vigilans/vigilans/routing-context-fix
Routing Context: Fix GetUser() & Use string for Attributes Value
2020-09-13 14:31:16 +08:00
Kslr 3d855206c2
Merge pull request #189 from darhwa/http-outbound
Fix the coarse-grained mutex in http outbound
2020-09-13 14:28:26 +08:00
Darhwa d2d4f48815 Fix the coarse-grained mutex in http outbound
fix v2ray#2731
2020-09-13 02:07:22 +08:00
Vigilans 5a497890e6 Routing Context: Fix GetUser() & Use string for Attributes Value 2020-09-13 00:34:35 +08:00
Kslr e8a27648a1
bump version 2020-09-12 17:52:13 +08:00
Shelikhoo e2e266114a
Fix incorrect IV usage which slightly reduced security 2020-09-12 16:27:40 +08:00
Kslr 7a50794964
Merge pull request #2730 from v2fly/master
merge fly
2020-09-11 15:59:46 +08:00
Kslr 86614773d9
bump version 2020-09-11 15:18:07 +08:00
RPRX ee1e18df24
Schedulers -> Flow 2020-09-11 03:37:23 +00:00
GitHub Action 1d759b4a1b update geoip, geosite 2020-09-11 00:15:06 +00:00
GitHub Action 72d8d2abdf update geoip, geosite 2020-09-11 00:10:26 +00:00
RPRX 2237528d1e
fix 2020-09-10 16:05:02 +00:00
RPRX 8c2e8e9db9
Add defer 2020-09-10 15:58:38 +00:00
RPRX 46d739d848
1.15.1 -> 1.15.2 2020-09-10 15:35:07 +00:00
Kslr d2b9dbe7cf
Update README.md 2020-09-10 16:06:27 +08:00
Kslr f9dbf2ea5a
Merge pull request #178 from v2fly/dependabot/github_actions/github/super-linter-v3.10.0
Bump github/super-linter from v3.9.4 to v3.10.0
2020-09-10 15:08:40 +08:00
dependabot[bot] 6db130ff89
Bump github/super-linter from v3.9.4 to v3.10.0
Bumps [github/super-linter](https://github.com/github/super-linter) from v3.9.4 to v3.10.0.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v3.9.4...9f3eb7d4545d595f24bb68b916b0184ae2ef9871)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-10 05:40:16 +00:00
Kslr c2d3a7339d
Merge pull request #170 from v2fly/dev-enable-vmessaead-alter-0
VMess AEAD will be used when alterId is 0
2020-09-09 21:42:31 +08:00
Kslr 26848ae959
Update README.md 2020-09-09 18:36:40 +08:00
Kslr 395174d453
update bazel 3.5.0 2020-09-09 18:31:57 +08:00
Kslr a8ce582285
update go 1.15.* 2020-09-09 18:19:49 +08:00
Kslr d3e3f787d4
golangci only show new issues 2020-09-09 18:01:33 +08:00
Kslr f624dd3249
add golangci to lint 2020-09-09 17:50:36 +08:00
Kslr c7c80ff890
Merge pull request #2728 from Loyalsoldier/merge-v2fly
Merge v2fly
2020-09-09 16:41:30 +08:00
loyalsoldier 811f0dd647
Merge branch 'v2fly-master' into v2ray-master 2020-09-09 16:33:42 +08:00
Kslr 4970af7e00
Merge pull request #173 from v2fly/dependabot/go_modules/google.golang.org/grpc-1.32.0
Bump google.golang.org/grpc from 1.31.1 to 1.32.0
2020-09-09 14:46:26 +08:00
dependabot[bot] cc25eb12f4
Bump google.golang.org/grpc from 1.31.1 to 1.32.0
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.31.1 to 1.32.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.31.1...v1.32.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-09 05:59:40 +00:00
Loyalsoldier c4d46e776f
Test: run on changes to go.mod & go.sum (#174) 2020-09-09 13:56:17 +08:00
Loyalsoldier 0a793e28fb
Merge pull request #172 from Vigilans/vigilans/stats-unregister
Add UnregisterChannel & Modify unregistering logic
2020-09-09 13:09:20 +08:00
Vigilans 0406cd896b Add UnregisterChannel & Modify unregistering logic 2020-09-09 11:33:29 +08:00
Loyalsoldier d7c99c901a
Fix: app/stats.Manager does not implement features/stats.Manager (#171) 2020-09-09 11:26:23 +08:00
Kslr 2a3fe11952
VMess AEAD will be used when alterId is 0 2020-09-09 00:02:53 +08:00
Kslr b613a9bcb6
Merge pull request #2725 from v2fly/2725
merge fly
2020-09-08 21:34:39 +08:00
Kslr d7a5f01520
Merge branch 'master' into 2725 2020-09-08 21:34:14 +08:00
RPRX 16fe0b03f6
Do not convert @ to \x00 2020-09-07 16:39:53 +08:00
RPRX f10f5b4a47
Merge pull request #164 from lucifer9/ds-enhance
fix abstract UDS & add PROXY protocol support to DS inbound
2020-09-07 16:22:40 +08:00
Kslr aecf59a6df
Merge pull request #166 from DuckSoft/master
systemd: prevent restart on corrupt config
2020-09-06 16:05:57 +08:00
DuckSoft 5751de2af5
systemd: prevent restart on corrupt config 2020-09-06 16:03:26 +08:00
RPRX e6233c9879
Merge pull request #162 from v2fly/dependabot/github_actions/github/super-linter-v3.9.4
Bump github/super-linter from v3.9.3 to v3.9.4
2020-09-05 11:03:12 +08:00
lucifer9 801b9490b8
fix abstract UDS & add PROXY protocol support to DS inbound 2020-09-04 15:35:54 +08:00
Kslr ddd091a0c2
Merge pull request #163 from Vigilans/vigilans/stats-channel
Support Subscribing Channel in Statistics Manager
2020-09-04 15:20:02 +08:00
Vigilans bff96a7a52 Support Channel (Observer Pattern) in Stats Manager 2020-09-04 15:07:42 +08:00
dependabot[bot] ce3834161d
Bump github/super-linter from v3.9.3 to v3.9.4
Bumps [github/super-linter](https://github.com/github/super-linter) from v3.9.3 to v3.9.4.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v3.9.3...e89faa7920c8993f4f9c19b5b8c6946b032c8d73)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-04 06:09:47 +00:00
Kslr b083aa2376
Merge pull request #108 from Vigilans/vigilans/routing-context
Extract session information during routing as routing context
2020-09-04 13:39:12 +08:00
Kslr 93afbc5f33
add golangci config 2020-09-04 13:38:15 +08:00
Vigilans f9d37b724c Extract session information during routing as routing context 2020-09-04 11:32:19 +08:00
Kslr 6981711fe5
Merge pull request #158 from Loyalsoldier/fix-lint
Fix lint
2020-09-04 10:56:27 +08:00
GitHub Action 8c8761e2cc update geoip, geosite 2020-09-04 00:15:00 +00:00
GitHub Action 5309338606 update geoip, geosite 2020-09-04 00:10:30 +00:00
V2Fly Team d2226cb0c8
Merge pull request #161 from felixonmars/fix-test
Fix dns tests by setting v2ray.location.asset
2020-09-03 16:51:57 +08:00
Felix Yan 11bf22b234
Fix dns tests by setting v2ray.location.asset 2020-09-03 16:47:40 +08:00
V2Fly Team 39e9916cb5
Merge pull request #160 from felixonmars/fix-test
Don't copy assets if they are already present
2020-09-03 16:33:20 +08:00
Felix Yan 7001483b62
Don't copy assets if they are already present
They can now reside in system path (like /usr/share/v2ray), so it's not
possible to copy into there.
2020-09-03 16:17:44 +08:00
Kslr 68c1e3e609
Merge pull request #159 from v2fly/dependabot/github_actions/github/super-linter-v3.9.3
Bump github/super-linter from v3.9.2 to v3.9.3
2020-09-03 14:10:50 +08:00
dependabot[bot] a1c96a18c1
Bump github/super-linter from v3.9.2 to v3.9.3
Bumps [github/super-linter](https://github.com/github/super-linter) from v3.9.2 to v3.9.3.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v3.9.2...eb0d0ed02e120ab529e69d594da9993358b070ee)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-03 06:02:59 +00:00
loyalsoldier 7fe8dd2e3d
Run go mod tidy 2020-09-03 11:34:05 +08:00
loyalsoldier 44d58295bf
Fix: change lint order to avoid file changes notice 2020-09-03 11:33:23 +08:00
RPRX d9f50f8433
Cleanup go.sum 2020-09-02 13:23:51 +00:00
RPRX af9dbbc7d9
Upgrade all dependencies 2020-09-02 13:08:50 +00:00
RPRX 7ffac22cd4
1.14.7 -> 1.15.1 2020-09-02 12:58:17 +00:00
Kslr 829a28bd0e
remove docker action 2020-09-02 17:01:38 +08:00
Kslr b6d78428f3
Merge branch 'v2fly-master' into master 2020-09-02 16:55:46 +08:00
Kslr 7e38c78ddf
Merge branch 'master' of https://github.com/v2fly/v2ray-core into v2fly-master 2020-09-02 16:55:32 +08:00
Kslr f5838d0f66
Update core.go 2020-09-02 16:43:00 +08:00
Kslr 971c5f2ee8
Merge pull request #153 from Loyalsoldier/minor-fixes
Minor fixes
2020-09-02 16:29:26 +08:00
Kslr 4da3304401
Merge pull request #155 from v2fly/dependabot/github_actions/github/super-linter-v3.9.2
Bump github/super-linter from v3.8.3 to v3.9.2
2020-09-02 16:25:40 +08:00
dependabot[bot] 2f3790928e
Bump github/super-linter from v3.8.3 to v3.9.2
Bumps [github/super-linter](https://github.com/github/super-linter) from v3.8.3 to v3.9.2.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v3.8.3...7d53a77c1150779566e918c919f5fc08b1f43ae9)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-02 06:16:55 +00:00
loyalsoldier 323ef03f02
Minor fixes 2020-09-01 08:46:55 +08:00
Kslr 8323564e9a
Merge pull request #145 from Loyalsoldier/refine-workflow
Refine workflow
2020-09-01 05:28:46 +08:00
loyalsoldier 8b377a08cd
Update: refine 2020-08-31 23:11:13 +08:00
loyalsoldier c974908e19
Test: refine & cache Go modules 2020-08-31 23:11:13 +08:00
loyalsoldier 42e33ddde6
Lint: include format 2020-08-31 23:11:13 +08:00
loyalsoldier 69da2f8526
Coverage: cache Go modules 2020-08-31 17:54:49 +08:00
Kslr f6340dd6b5
Merge pull request #149 from Vigilans/vigilans/dns-fix-localhost-ipIndexMap
Fix: Append nil to ipIndexMap when appending default local name server
2020-08-31 13:06:21 +08:00
Vigilans c973b5a484 Fix github.com/v2fly/v2ray-core/issues/146 2020-08-31 12:40:27 +08:00
Kslr e55fdda5b1
Merge pull request #148 from Vigilans/vigilans/dns-fix-array-panic
Fix: Bound check when accessing DNS server's ipIndexMap
2020-08-31 12:32:55 +08:00
Vigilans 47c997d75e Fix github.com/v2fly/v2ray-core/issues/146 2020-08-31 12:21:56 +08:00
RPRX 9e0859ee49
Merge pull request #144 from Loyalsoldier/refine-code
Refine code
2020-08-30 15:59:23 +00:00
loyalsoldier f12f76582f
Fix according to staticcheck result
staticcheck repo: https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck
2020-08-30 23:41:15 +08:00
loyalsoldier 1fa89b32d4
Format: run go fmt ./... 2020-08-30 21:17:22 +08:00
lucifer 4c9210cf11
Parse X-Forwarded-For in http transport (#142)
* Parse X-Forwarded-For

* Update hub.go

Co-authored-by: RPRX <63339210+rprx@users.noreply.github.com>
2020-08-30 04:30:05 +00:00
Shelikhoo 8c82fd3e6d
update version 2020-08-29 10:31:15 +08:00
Shelikhoo 0fdc818231
Update VSign Version 2020-08-29 10:27:23 +08:00
Kslr 2699732994
release 4.27.3 2020-08-29 10:23:53 +08:00
Kslr 1cfb044d7d
Update README.md 2020-08-28 22:27:45 +08:00
Kslr c05992b841
release 4.27.2 2020-08-28 22:14:31 +08:00
Kslr 396253308e
Update README.md 2020-08-28 22:13:28 +08:00
RPRX feea69c4c9
Merge pull request #140 from rprx/master
VLESS PREVIEW 1.5
2020-08-28 08:15:51 +00:00
RPRX 84aaf3a1e3
VLESS PREVIEW 1.5 2020-08-28 07:51:09 +00:00
Kslr 3ad73fde20
release 4.27.1 2020-08-28 10:47:14 +08:00
GitHub Action adb3fd326b update geoip, geosite 2020-08-28 00:50:23 +00:00
RPRX c4d57c6405
Merge pull request #138 from Loyalsoldier/fix-path
Fix: module path
2020-08-28 00:22:03 +00:00
GitHub Action 2898064cd9 update geoip, geosite 2020-08-28 00:12:01 +00:00
loyalsoldier 6f52a79e2e
Fix: module path 2020-08-28 03:55:07 +08:00
RPRX d3ebba6901
Merge pull request #137 from Loyalsoldier/protoc-dont-rely-on-GOBIN-GOPATH
Protoc & vprotogen: do NOT rely on GOBIN & GOPATH
2020-08-27 15:37:32 +00:00
Kslr ef99033d05
stale include pr 2020-08-27 23:26:51 +08:00
loyalsoldier cafc80d23a
vprotogen: do NOT rely on GOBIN & GOPATH 2020-08-27 23:18:06 +08:00
loyalsoldier a2a064a54d
protoc: do NOT rely on GOBIN & GOPATH
Add public functions
2020-08-27 23:18:05 +08:00
RPRX 9466e5d09b
Merge pull request #134 from Loyalsoldier/fix-go-vet
Fix according to go vet results
2020-08-26 11:55:30 +00:00
loyalsoldier f9175e3bc8
Fix according to go vet results 2020-08-26 19:35:33 +08:00
RPRX 30edcef67a
Merge pull request #133 from Loyalsoldier/mockgen-dont-rely-on-GOBIN-GOPATH
Mockgen: do NOT rely on GOBIN & GOPATH
2020-08-26 10:55:57 +00:00
loyalsoldier 1b27ec5e7c
Mockgen: do NOT rely on GOBIN & GOPATH 2020-08-26 18:54:58 +08:00
RPRX 5774addc14
Merge pull request #131 from Loyalsoldier/protoc-dont-relay-on-GOPATH
Protoc: do NOT rely on GOPATH
2020-08-26 09:41:33 +00:00
loyalsoldier 4fbefc18f4
Protoc: do NOT rely on GOPATH 2020-08-26 17:37:51 +08:00
Shelikhoo e97b9b5f3c
Merge branch 'master' of github.com:v2fly/v2ray-core 2020-08-26 17:10:03 +08:00
Shelikhoo a40727a3dc
added drain for ss and improved vmess drain 2020-08-26 13:51:23 +08:00
RPRX 38f7de5393
Merge pull request #130 from v2fly/dependabot/go_modules/google.golang.org/grpc-1.31.1
Bump google.golang.org/grpc from 1.31.0 to 1.31.1
2020-08-26 05:35:48 +00:00
RPRX 25aaf824b4
Merge pull request #129 from v2fly/dependabot/go_modules/github.com/google/go-cmp-0.5.2
Bump github.com/google/go-cmp from 0.5.1 to 0.5.2
2020-08-26 05:35:32 +00:00
dependabot[bot] 690c7fc8a8
Bump google.golang.org/grpc from 1.31.0 to 1.31.1
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.31.0 to 1.31.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.31.0...v1.31.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-08-26 05:31:54 +00:00
dependabot[bot] d9ac3f8a5d
Bump github.com/google/go-cmp from 0.5.1 to 0.5.2
Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.5.1 to 0.5.2.
- [Release notes](https://github.com/google/go-cmp/releases)
- [Commits](https://github.com/google/go-cmp/compare/v0.5.1...v0.5.2)

Signed-off-by: dependabot[bot] <support@github.com>
2020-08-26 05:31:26 +00:00
RPRX f5642b4075
L -> l, A -> a 2020-08-26 05:01:35 +00:00
RPRX 9046bea466
Adjust TCP inbound logs 2020-08-26 04:50:00 +00:00
RPRX 2bfc6c8e9b
Merge pull request #128 from rprx/master
Add PROXY protocol support to WS inbound
2020-08-26 04:42:08 +00:00
RPRX a3bc930075
Add PROXY protocol support to WS inbound
https://github.com/v2fly/v2ray-core/pull/103
2020-08-26 04:29:12 +00:00
Kslr fd9128fbf5
Merge pull request #125 from dikaixu1999/patch-2
Fix a typo
2020-08-25 18:42:24 +08:00
Isaac 588b40ffad
Fix a typo
Fix a typo in bytes.go
2020-08-25 17:55:53 +08:00
Kslr 243a8262fc
Merge pull request #123 from Loyalsoldier/refine-go-generate
Proto & Mock: refine go generate command
2020-08-25 17:51:14 +08:00
loyalsoldier f3368b1d79
Mock: refine go generate command 2020-08-25 16:23:33 +08:00
loyalsoldier e036db835e
Proto: refine go generate command 2020-08-25 16:18:23 +08:00
RPRX ca5f2532e8
Merge pull request #121 from Loyalsoldier/test-running-exception
Test: only triggered by *.go file on push event
2020-08-25 07:21:48 +00:00
loyalsoldier 71191aa407
Test: only triggered by *.go file on push event 2020-08-25 14:46:04 +08:00
RPRX 1eb5836e3c
Merge pull request #120 from v2fly/dependabot/github_actions/github/super-linter-v3.8.3
Bump github/super-linter from V3.8.0 to v3.8.3
2020-08-25 06:25:35 +00:00
dependabot[bot] 190b1cb044
Bump github/super-linter from V3.8.0 to v3.8.3
Bumps [github/super-linter](https://github.com/github/super-linter) from V3.8.0 to v3.8.3.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/V3.8.0...9f2c65685b15fc1f26feeca84d889bf27f1c31d2)

Signed-off-by: dependabot[bot] <support@github.com>
2020-08-25 06:18:53 +00:00
Kslr b94e4eb835
Merge pull request #119 from Loyalsoldier/refine-workflow
Refine workflow
2020-08-25 03:15:00 +08:00
loyalsoldier 2f1f0470a2
Test: only be triggered by *.go files 2020-08-25 00:04:55 +08:00
loyalsoldier efb53bd59e
Lint: refine 2020-08-25 00:04:31 +08:00
loyalsoldier bd533a506a
Coverage: only be triggered by *.go files 2020-08-24 21:30:40 +08:00
Loyalsoldier ef460f68f8
Adjust Protocol Buffers (#109)
* Update protoc binary executable files to v3.13.0

* Write proto files in more standard way

* Make go generate & vprotogen compatible with protoc-gen-gofast

* Regenerate pb.go files according to new proto files

* Clean go.sum by running go mod tidy

* Implement mustEmbedUnimplementedServiceServer for gPRC services
2020-08-24 12:10:26 +00:00
RPRX 969f68ba24
Merge pull request #117 from Loyalsoldier/fix-lint
Fix: lint lack of GitHub Token
2020-08-24 12:09:19 +00:00
loyalsoldier 6f04c36d33
Fix: lint lack of GitHub Token 2020-08-24 19:57:46 +08:00
Kslr edb9bc45ac
Merge pull request #113 from Loyalsoldier/refine-format-rename-workflow
Refine & format & rename workflow files
2020-08-24 17:52:41 +08:00
Kslr 288e40abd4
Merge branch 'master' into refine-format-rename-workflow 2020-08-24 17:51:13 +08:00
RPRX 42b21f651c
Merge pull request #116 from v2fly/dependabot/github_actions/actions/stale-v3.0.10
Bump actions/stale from v1 to v3.0.10
2020-08-24 08:45:51 +00:00
RPRX 298f2b67a1
Merge pull request #115 from v2fly/dependabot/github_actions/github/super-linter-V3.8.0
Bump github/super-linter from v2.2.0 to V3.8.0
2020-08-24 08:45:32 +00:00
dependabot[bot] 41b9784e7c
Bump actions/stale from v1 to v3.0.10
Bumps [actions/stale](https://github.com/actions/stale) from v1 to v3.0.10.
- [Release notes](https://github.com/actions/stale/releases)
- [Commits](https://github.com/actions/stale/compare/v1...e976731ae824d9e0165ade8f9e2e8f1743b2fc09)

Signed-off-by: dependabot[bot] <support@github.com>
2020-08-24 08:34:15 +00:00
dependabot[bot] 20471caf14
Bump github/super-linter from v2.2.0 to V3.8.0
Bumps [github/super-linter](https://github.com/github/super-linter) from v2.2.0 to V3.8.0.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v2.2.0...ef99a48ce63440e6eff58d67bb87e97d9fda48f1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-08-24 08:34:15 +00:00
RPRX 6cab7d958d
Merge pull request #114 from Loyalsoldier/autoupdate-github-actions
Auto update GitHub Actions workflow version
2020-08-24 08:33:45 +00:00
loyalsoldier 3954a4859f
Auto update GitHub Actions workflow version 2020-08-24 16:23:24 +08:00
loyalsoldier cd47623dc1
Rename dlc.yml to updateGeofile.yml 2020-08-24 16:11:14 +08:00
loyalsoldier d8fe670b53
Refine & format 2020-08-24 16:09:51 +08:00
Kslr 8cd710ddc4
Merge pull request #110 from Loyalsoldier/update-gomod
Clean go.sum by running go mod tidy
2020-08-24 01:57:03 +08:00
loyalsoldier b54fe33e07
Clean go.sum by running go mod tidy 2020-08-24 01:37:47 +08:00
RPRX 1ff89cda11
Merge pull request #107 from Loyalsoldier/fix-empty-rules-and-dns
Fix: loging empty rules & DNS
2020-08-22 16:46:50 +00:00
loyalsoldier 00b4217aab
Fix: loging empty rules & DNS 2020-08-22 19:07:14 +08:00
lucifer 5df17338a1
Add PROXY protocol support to tcp inbound (#103)
* Add  PROXY protocol support to tcp inbound

* add settings for PROXY protocol

* Adjust hub.go

Co-authored-by: RPRX <63339210+rprx@users.noreply.github.com>
2020-08-21 13:31:44 +00:00
GitHub Action fa11d15456 update geoip, geosite 2020-08-21 00:44:36 +00:00
GitHub Action 9362e2b5dd update geoip, geosite 2020-08-21 00:26:13 +00:00
Kslr 32580c3823
use fly file 2020-08-19 23:06:16 +08:00
Kslr c162fa86e9
default single config and remove V2RAY_LOCATION_ASSET 2020-08-18 20:44:00 +08:00
Kslr ea5d1ee664
Merge pull request #99 from darhwa/http-outbound
Reduce extra RTT when setting up CONNECT tunnel in http outbound (not vmess through http)
2020-08-18 01:02:31 +08:00
Kslr dabefc6338
Merge pull request #98 from Vigilans/vigilans/dns-server-matcher-info
Refactor & Log rules matching of built-in DNS's domain matcher
2020-08-18 01:01:06 +08:00
Kslr f5de4fce92
Merge pull request #101 from vcptr/assetpath
add asset location search
2020-08-17 19:15:45 +08:00
vcptr bc008113b6 add asset location search 2020-08-17 18:56:01 +08:00
RPRX 0c72d72f46
Merge pull request #100 from dctxmei/master
feat: New systemd unit file
2020-08-17 10:25:40 +00:00
Dct Mei 3e612d899c
feat: New systemd unit file
1. Add systemd/system/v2ray.service .
2. Add systemd/system/v2ray@.service .
3. Modify the installation path in the BUILD file.

issue v2fly/fhs-install-v2ray#53
2020-08-17 10:23:39 +08:00
Kslr a150775352
remove systemdv 2020-08-17 05:34:36 +08:00
Kslr 886cef691d
clean release 2020-08-17 05:29:06 +08:00
Kslr 0dc68ee9b9
clean release 2020-08-17 05:24:35 +08:00
Vigilans 22b4e68a2d Log matched rules and DNS to use during priority matching
2. Dotless domain support in static host & modify first letter's captial in log
2020-08-16 22:18:28 +08:00
Vigilans dfeaef75e7 Refactor DNS Server to record original rule of domain matchers 2020-08-16 22:18:12 +08:00
Darhwa d05ddc8f78 Make http outbound 0-rtt 2020-08-15 23:58:58 +08:00
Kslr e1b349bf74
Merge pull request #2682 from v2fly/master
merge
2020-08-15 22:08:26 +08:00
RPRX e0bbf474ae
Add more guide 2020-08-15 13:55:07 +00:00
Kslr b9dd0efb21
Merge pull request #97 from Vigilans/vigilans/matcher-group-test
Supply test for domain matcher group
2020-08-15 21:30:57 +08:00
Vigilans 1ab9e58dce Supply test for domain matcher group 2020-08-15 21:28:34 +08:00
Kslr 66eedfb832
Merge pull request #96 from DuckSoft/patch-3
goodbye go.sh
2020-08-15 18:31:26 +08:00
DuckSoft 353f927ddf
goodbye go.sh 2020-08-15 16:04:57 +08:00
RPRX 9e99343b43
ERROR: This script has been deprecated 2020-08-15 02:40:30 +00:00
Kslr 720c0d0c4b
Merge pull request #2679 from v2fly/master
merge
2020-08-14 18:35:28 +08:00
kslr ac8bc4e731 Deprecated https://install.direct/go.sh 2020-08-14 17:44:08 +08:00
GitHub Action 50b9b95762 update geoip, geosite 2020-08-14 00:42:38 +00:00
GitHub Action 7d49371f07 update geoip, geosite 2020-08-14 00:24:25 +00:00
Kslr aa800355c3
Merge pull request #95 from Vigilans/vigilans/dns-subdomain-multimatch
Amend domain matcher with returning values of all matched subdomains
2020-08-13 18:36:01 +08:00
Vigilans 1e222425b6 Amend domain matcher with returning values of all matched subdomains 2020-08-13 15:26:30 +08:00
Kslr 8b4ba03e6f
Merge pull request #94 from Vigilans/vigilans/dns-domain-matcher
Amend domain matcher with returning array of all matches
2020-08-12 19:43:06 +08:00
RPRX e0472f1e69
1.14.6 -> 1.14.7 2020-08-11 18:35:58 +00:00
Kslr 488e39948e
Create pull_request_template.md 2020-08-11 15:36:45 +08:00
Vigilans c74a33f827 Amending domain matcher with returning array of all matches 2020-08-11 13:31:04 +08:00
RPRX 65c16cd44c
2019 -> 2020 2020-08-09 16:25:29 +00:00
Kslr 111d48130d
Merge pull request #89 from Vigilans/vigilans/dns-dotless-domain
Dotless and local domain support in built-in DNS
2020-08-09 19:27:53 +08:00
Kslr 2dfd9844e7
Merge pull request #87 from Vigilans/vigilans/routing-source-port
Support source port matching in routing config
2020-08-09 19:18:42 +08:00
Vigilans 40c0bcc3ab Support source port matching in routing config 2020-08-09 16:53:45 +08:00
Vigilans 17f51f412c Dotless domain support in built-in DNS 2020-08-09 16:51:06 +08:00
Kslr 1664b4ec9c
Merge pull request #85 from dctxmei/master
feat: Add obsolete warning for old script
2020-08-09 06:51:30 +08:00
Dct Mei e65c393017
feat: Add obsolete warning for old script
issue #83
2020-08-09 06:43:24 +08:00
Kslr 2f6c3b4f59
update issue template 2020-08-08 22:32:25 +08:00
GitHub Action 7ca6f073d5 update geoip, geosite 2020-08-07 00:41:56 +00:00
GitHub Action 91b4bf8154 update geoip, geosite 2020-08-07 00:24:09 +00:00
Kslr 90a61a5b04
Merge pull request #2667 from v2fly/master
merge fly
2020-08-06 19:51:58 +08:00
kslr 75363deb84 release 4.27.0 2020-08-06 19:09:23 +08:00
RPRX a4d411b085
Merge pull request #80 from rprx/master
VLESS PREVIEW 1.3
2020-08-04 13:30:23 +00:00
RPRX 5708edd117
VLESS PREVIEW 1.3 2020-08-04 13:08:35 +00:00
RPRX e425876afe
Fix totalSize 2020-08-04 03:50:22 +00:00
RPRX 070e72f581
unexpected -> invalid 2020-08-03 19:16:14 +00:00
RPRX 5e753007ad
Fix test 2020-08-03 15:17:06 +00:00
RPRX 9b36ce95d9
Merge pull request #78 from rprx/master
VLESS PREVIEW 1.2
2020-08-03 13:52:52 +00:00
Kslr f04821905d
Merge pull request #77 from v2fly/dependabot/go_modules/github.com/miekg/dns-1.1.31
Bump github.com/miekg/dns from 1.1.30 to 1.1.31
2020-08-03 15:45:31 +08:00
RPRX 1cfc02e720
VLESS PREVIEW 1.2 2020-08-03 06:13:26 +00:00
dependabot[bot] 81a7fedc95
Bump github.com/miekg/dns from 1.1.30 to 1.1.31
Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.30 to 1.1.31.
- [Release notes](https://github.com/miekg/dns/releases)
- [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release)
- [Commits](https://github.com/miekg/dns/compare/v1.1.30...v1.1.31)

Signed-off-by: dependabot[bot] <support@github.com>
2020-08-03 05:54:55 +00:00
RPRX 2c49559c61
Merge pull request #76 from Vigilans/vigilans/tproxy-sockopt
Apply sockopt from inbound config to dokodemo tproxy's response connection
2020-08-02 03:02:36 +00:00
RPRX 7ec05363f3
Merge pull request #74 from darhwa/http-outbound
Fix http outbound to get correct TLS negotiated protocol when "stats" setting exists
2020-08-01 09:40:42 +00:00
Nicholas Wang 62db92f632 initial security policy 2020-08-01 01:10:32 -05:00
Nicholas Wang 59cd686bb0
dev at v2fly.org >> security at v2fly.org 2020-08-01 01:09:03 -05:00
Vigilans 30e312f72b Apply sockopt from inbound config to dokodemo tproxy's response connection 2020-08-01 02:04:06 +08:00
Darhwa cae278dd00 Fix http outbound
Get correct TLS negotiated protocol when stats setting exists
2020-07-31 23:51:08 +08:00
Darhwa 1acb2fd854 Some cleaning and linting 2020-07-31 23:49:54 +08:00
Kslr 45bf57826d
Merge pull request #72 from darhwa/doh-h2
Enable ForceAttemptHTTP2 on DoH client
2020-07-31 22:54:51 +08:00
Darhwa e9c891d5b5 Enable ForceAttemptHTTP2 on DoH client 2020-07-31 17:07:56 +08:00
Kslr d84507ae15
Merge pull request #71 from v2fly/dependabot/go_modules/google.golang.org/grpc-1.31.0
Bump google.golang.org/grpc from 1.30.0 to 1.31.0
2020-07-31 14:35:08 +08:00
dependabot[bot] dfdb930109
Bump google.golang.org/grpc from 1.30.0 to 1.31.0
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.30.0 to 1.31.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.30.0...v1.31.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-31 05:11:40 +00:00
Kslr 746ec61fb6
Merge pull request #70 from Vigilans/vigilans/inbound-sockopt
Move setting of SO_REUSEPORT out of applyInboundSocketOptions
2020-07-31 10:10:33 +08:00
GitHub Action 0ce8b1945c update geoip, geosite 2020-07-31 00:39:38 +00:00
GitHub Action 89a2ac81c6 update geoip, geosite 2020-07-31 00:22:55 +00:00
Vigilans 39cbe4ab13 Implement `setReuseAddr` and `setReusePort` in sockopt_{os}.go 2020-07-31 01:20:12 +08:00
Vigilans bb932d8a1e Move setting of SO_REUSEPORT out of applyInboundSocketOptions 2020-07-31 00:01:36 +08:00
RPRX 541fb5c5b1
Merge pull request #66 from rprx/master
VLESS PROTOCOL
2020-07-29 14:30:23 +00:00
Kslr 1fdd9f85c0
Merge pull request #67 from v2fly/dependabot/go_modules/github.com/golang/mock-1.4.4
Bump github.com/golang/mock from 1.4.3 to 1.4.4
2020-07-29 14:33:26 +08:00
dependabot[bot] 5ee8f7aa5c
Bump github.com/golang/mock from 1.4.3 to 1.4.4
Bumps [github.com/golang/mock](https://github.com/golang/mock) from 1.4.3 to 1.4.4.
- [Release notes](https://github.com/golang/mock/releases)
- [Changelog](https://github.com/golang/mock/blob/master/.goreleaser.yml)
- [Commits](https://github.com/golang/mock/compare/v1.4.3...v1.4.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-29 05:47:02 +00:00
RPRX bad7e2cfd8
VLESS PREVIEW 1.1 2020-07-28 15:00:23 +00:00
Kslr 0a19fb5a3a
Merge pull request #64 from kallydev/docker
Add docker.yaml to actions
2020-07-25 15:58:06 +08:00
kallydev 964d0fbbbe
Refactor docker.yaml 2020-07-24 13:32:10 +08:00
kallydev 168675a61b
Update docker.yaml 2020-07-24 12:37:33 +08:00
GitHub Action c3b747f660 update geoip, geosite 2020-07-24 00:38:03 +00:00
GitHub Action f64d4bb8f8 update geoip, geosite 2020-07-24 00:22:53 +00:00
kallydev 1f29446c5f
Add docker.yaml to actions 2020-07-23 21:31:47 +08:00
Kslr f95cb41f63
fix ci dependencies 2020-07-23 12:54:26 +08:00
Kslr 6f1ac51e08
only keep release 2020-07-23 12:20:19 +08:00
Kslr 108b9b3c7a
Merge pull request #61 from v2fly/dependabot/go_modules/github.com/google/go-cmp-0.5.1
Bump github.com/google/go-cmp from 0.5.0 to 0.5.1
2020-07-23 04:34:33 +08:00
Kslr a44a8245d3
Merge pull request #62 from kallydev/master
Fix the error of missing curl in Dockerfile
2020-07-23 04:32:33 +08:00
kallydev 9b09c83b08
Fix the error of missing curl in Dockerfile 2020-07-22 19:25:22 +08:00
dependabot[bot] 19d04e583a
Bump github.com/google/go-cmp from 0.5.0 to 0.5.1
Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/google/go-cmp/releases)
- [Commits](https://github.com/google/go-cmp/compare/v0.5.0...v0.5.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-22 05:46:28 +00:00
Kslr 34d6818a85
Merge pull request #60 from rprx/patch-1
Remove unused utls
2020-07-20 22:16:23 +08:00
RPRX 9311cb18e4
Remove unused utls 2020-07-20 05:59:46 +00:00
Kslr 34cdd884f3
Merge pull request #59 from rprx/patch-1
Add linux riscv64 build
2020-07-20 04:59:05 +08:00
RPRX e46531261b
Add linux riscv64 build 2020-07-19 20:51:39 +00:00
RPRX 38b5cd4728
Update WORKSPACE 2020-07-19 20:50:37 +00:00
Kslr b08d71f56d
Merge pull request #48 from v2fly/dependabot/go_modules/github.com/miekg/dns-1.1.30
Bump github.com/miekg/dns from 1.1.29 to 1.1.30
2020-07-20 03:58:38 +08:00
Kslr b3bfded682
Merge pull request #58 from rprx/patch-1
Adjust Bazel
2020-07-20 03:57:43 +08:00
RPRX c8f266c740
Adjust Bazel 2020-07-19 02:40:33 +00:00
RPRX 3da772249b
Update WORKSPACE 2020-07-19 02:39:34 +00:00
Kslr fc2ff502b1
Merge pull request #55 from rprx/patch-1
Update Golang version to 1.14.6
2020-07-17 18:29:54 +08:00
Kslr 520500e0f3
Merge pull request #56 from DuckSoft/master
some typo fixes
2020-07-17 18:29:10 +08:00
DuckSoft 1525712214
some typo fixes
note: there are other typos in external/ folder.
considering the fact that the folder "will be removed in future", I skipped those typos.
2020-07-17 18:09:24 +08:00
RPRX 6653b8ac81
Update azure-pipelines.yml 2020-07-17 03:22:23 +00:00
GitHub Action 9fa3c10f8d update geoip, geosite 2020-07-17 00:36:30 +00:00
GitHub Action 81985d918f update geoip, geosite 2020-07-17 00:20:55 +00:00
Kslr 3a7784b3e2
Merge pull request #50 from yuhan6665/master
Fix parser for shadowsocks cipher "none"
2020-07-15 04:14:57 +08:00
Kslr 5d31c54bdf
Merge pull request #51 from lucifer9/dokodemo-log
Add access log for dokodemo inbound
2020-07-15 04:14:26 +08:00
lucifer9 9da4339d8a Add access log for dokodemo inbound 2020-07-13 21:02:19 +08:00
yuhan6665 2e20d34f84 Fix parser for shadowsocks cipher none 2020-07-11 15:27:15 -04:00
Shelikhoo d2266bb52c
Alias for ext: to reduce ambiguous ext: used without context 2020-07-11 09:24:03 +08:00
GitHub Action 89260eaafb update geoip, geosite 2020-07-10 00:35:18 +00:00
GitHub Action ff42cc8c86 update geoip, geosite 2020-07-10 00:20:35 +00:00
Kslr 4bb3e4eb30
Merge pull request #2625 from v2fly/master
marge fly
2020-07-07 21:16:29 +08:00
dependabot[bot] 04addcb767
Bump github.com/miekg/dns from 1.1.29 to 1.1.30
Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.29 to 1.1.30.
- [Release notes](https://github.com/miekg/dns/releases)
- [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release)
- [Commits](https://github.com/miekg/dns/compare/v1.1.29...v1.1.30)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-07 05:21:00 +00:00
Shelikhoo b02a781ab9
Update Version 2020-07-05 16:40:59 +08:00
Shelikhoo 1be3d52787
Allow VSign function to be disabled if V2Ray is included in a package and should be verified by the package manager. 2020-07-05 08:55:10 +08:00
Shelikhoo 3952f81b49
Update Signing key 2020-07-05 08:52:29 +08:00
Shelikhoo b23c4fce05
Adopt to new signature key and format (Fix) 2020-07-04 21:04:38 +08:00
Shelikhoo 432bc627bb
Adopt to new signature key and format 2020-07-04 20:28:15 +08:00
Shelikhoo 8c415a791b
Merge branch 'master' of github.com:v2fly/v2ray-core 2020-07-04 13:53:17 +08:00
Shelikhoo 437a66b7de
Added Unit Test for VMessAEAD 2020-07-04 13:48:47 +08:00
Kslr 39d12c8946
Merge pull request #46 from rprx/patch-1
Fix
2020-07-03 20:39:46 +08:00
rprx 11efebfd31
Update tagrelease.sh 2020-07-03 12:31:17 +00:00
rprx e0a5285658
Update bleedingrelease.sh 2020-07-03 12:29:10 +00:00
Shelikhoo ad1927e6f9
Actually Request the SIGN 2020-07-03 16:07:15 +08:00
Shelikhoo 9928eca26f
Fix bug with tag name extract 2020-07-03 14:55:31 +08:00
Xiaokang Wang a5fa0f5afd
Merge pull request #43 from v2fly/dev-cimanifest
Generate and Sign Manifest
2020-07-03 13:14:20 +08:00
GitHub Action 22ae1d6041 update geoip, geosite 2020-07-03 00:19:55 +00:00
Shelikhoo 40e21fde1d
Added Signing Request 2020-07-03 00:34:15 +08:00
Shelikhoo 9142c0d9a8
Generate manifest on tag release 2020-07-02 20:27:34 +08:00
Shelikhoo d2064b0021
Bug fix 2020-07-02 19:40:44 +08:00
Shelikhoo dadcda034d
Generate Manifest for bleeding edge release 2020-07-02 19:10:38 +08:00
Kslr 9ae36dae05
Merge pull request #41 from rprx/patch-1
Adjust arm build
2020-06-28 19:52:29 +08:00
Kslr 2008310a0a
Merge pull request #32 from v2fly/dependabot/go_modules/google.golang.org/grpc-1.30.0
Bump google.golang.org/grpc from 1.27.0 to 1.30.0
2020-06-28 18:46:18 +08:00
rprx a2c86aaaeb
Adjust arm build 2020-06-28 10:11:50 +00:00
rprx 4947537eee
Adjust arm build 2020-06-28 08:56:55 +00:00
rprx 19c5014ed1
Adjust arm build 2020-06-28 08:55:08 +00:00
Kslr a8f3450b89
Merge pull request #38 from yuhan6665/master
Add stats counter for outbounds
2020-06-28 16:29:29 +08:00
Kslr 4f7384c020
Merge pull request #2208 from remote-v2ray/feature/UnregisterCounter
add UnregisterCounter method to stats manager
2020-06-28 16:11:55 +08:00
dependabot[bot] c564aa6cef
Bump google.golang.org/grpc from 1.27.0 to 1.30.0
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.27.0 to 1.30.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.27.0...v1.30.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-06-28 07:59:24 +00:00
dependabot[bot] 2af1a8fc3d
Bump google.golang.org/protobuf from 1.24.0 to 1.25.0 (#34)
Bumps [google.golang.org/protobuf](https://github.com/protocolbuffers/protobuf-go) from 1.24.0 to 1.25.0.
- [Release notes](https://github.com/protocolbuffers/protobuf-go/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf-go/blob/master/release.bash)
- [Commits](https://github.com/protocolbuffers/protobuf-go/compare/v1.24.0...v1.25.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-06-28 15:57:59 +08:00
Shelikhoo e4acbcee8f
Allow the use of Browser Bridge 2020-06-28 15:54:53 +08:00
Shelikhoo 218d6204b8
Fix test break on socks TestSocksConformance, use ip instead of hostname 2020-06-28 13:59:26 +08:00
yuhan6665 cef1836f5a Add unit test for outbound handler 2020-06-27 20:50:39 -04:00
Kslr 62813a9ede
ci add windows arm 2020-06-28 01:29:33 +08:00
rprx 694180fc9a
Add windows arm build (#39)
* Add windows arm build

* Add windows arm build

* Add windows arm build
2020-06-28 00:46:43 +08:00
Kslr 0392312b74
fix undefined: u 2020-06-27 21:33:45 +08:00
Kslr d017ceda7d
Create dlc.yml 2020-06-27 21:15:13 +08:00
Kslr 221aaad315
Create stale.yml 2020-06-27 20:59:30 +08:00
Kslr 00908a12fe
Update linter.yml 2020-06-27 20:50:41 +08:00
Kslr 475676eb87
update h12.io/socks 2020-06-27 20:36:10 +08:00
yuhan6665 886598542c Add stats counter for outbounds 2020-06-27 00:31:46 -04:00
yuhan6665 f34c092a06 Rename fields in StatCouterConnection
The fields will be used by Outbounds as well in the next commit
2020-06-27 00:31:46 -04:00
Kslr 1fb57ebab0
Merge pull request #2606 from v2fly/master
merge fly
2020-06-27 08:09:27 +08:00
Kslr 2f12e0caf3
Merge branch 'agioi-master' 2020-06-27 07:59:36 +08:00
Agioi Theodoroi 744fca3845
gofmt 2020-06-27 07:58:21 +08:00
Agioi Theodoroi 7bd324dcec
clean up code 2020-06-27 07:57:16 +08:00
Kslr 2b25988129
Merge branch 'agioi-master' 2020-06-27 07:52:02 +08:00
Agioi Theodoroi 37a55653e9
remove unused parameter 2020-06-27 07:51:44 +08:00
Agioi Theodoroi 97074c5bf4
gofmt 2020-06-27 07:51:43 +08:00
Agioi Theodoroi bbd3988f3d
clean up code 2020-06-27 07:51:42 +08:00
Kslr 50b0fa6ebb
Merge pull request #2416 from sosiska/patch-1
Some code optimization
2020-06-27 07:31:07 +08:00
Kslr 665e9b042c
Merge pull request #2437 from jejayhe/master
Some code optimization
2020-06-27 07:27:27 +08:00
Kslr 634201f29a
Merge pull request #2543 from Mygod/patch-1
Discourage reporting security vulnerabilities publicly
2020-06-27 07:17:12 +08:00
Kslr 48cc4f545f
Merge pull request #2577 from fzhyzamt/master
支持非抢先验证的客户端
2020-06-27 07:14:58 +08:00
rprx 1432278c2c
Fix typo (#36) 2020-06-26 21:27:23 +08:00
Shelikhoo f19f95af35
Update AEAD design to rely more on AEAD 2020-06-26 20:15:37 +08:00
Xiaokang Wang 327a6ee1f7
Merge pull request #18 from darhwa/enhance_http_outbound
使http outbound支持连接https与http/2代理服务器
2020-06-25 16:25:44 +08:00
DuckSoft 780318c5c8
handle dns.PackMessage error
this will fix #2599
2020-06-25 16:22:56 +08:00
Xiaokang Wang dd106b7cda
Merge pull request #35 from DuckSoft/patch-2
dohdns.go: multiple typo fixes
2020-06-25 16:10:46 +08:00
DuckSoft bde766770d
dohdns.go: multiple typo fixes 2020-06-25 14:10:24 +08:00
Roger Shimizu 90af5f19ba
Apply Debian's patch to upstream 2020-06-24 12:57:03 +08:00
Kslr c5a33062b8
Merge pull request #2590 from v2fly/master
merge fly
2020-06-23 22:23:22 +08:00
Kslr bf80143789
v4.25.1 2020-06-23 18:57:57 +08:00
Kslr 477daeb1d3
clean go.sum 2020-06-23 18:55:37 +08:00
JH2628 98a5d3fc7b
Update install-release.sh (#16)
更改安装路径到 v2fly/v2ray-core
2020-06-23 06:11:05 +08:00
dependabot[bot] b4a071a3bb
Bump github.com/miekg/dns from 1.1.4 to 1.1.29 (#28)
Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.4 to 1.1.29.
- [Release notes](https://github.com/miekg/dns/releases)
- [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release)
- [Commits](https://github.com/miekg/dns/compare/v1.1.4...v1.1.29)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-06-23 06:09:12 +08:00
Kslr 4a37179aef
update net,sync,sys package 2020-06-23 06:02:40 +08:00
Kslr 6b256238dc
update crypto package 2020-06-23 05:58:11 +08:00
Darhwa d29370a654 Enhance http outbound
1. Enables http outbound to set up a HTTP tunnel above HTTP/1.1,
  HTTP/1.1 over TLS, or HTTP/2 over TLS. Previously it only works for
  plain HTTP/1.1
2. In setting up CONNECT tunnel, replaces handcrafted request with
  standard http.Request
2020-06-20 23:03:44 +08:00
dependabot[bot] 36ff6bb903
Bump github.com/google/go-cmp from 0.4.0 to 0.5.0 (#29)
Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/google/go-cmp/releases)
- [Commits](https://github.com/google/go-cmp/compare/v0.4.0...v0.5.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-06-20 20:32:29 +08:00
dependabot[bot] e0f38a1d23
Bump github.com/gorilla/websocket from 1.4.1 to 1.4.2 (#27)
Bumps [github.com/gorilla/websocket](https://github.com/gorilla/websocket) from 1.4.1 to 1.4.2.
- [Release notes](https://github.com/gorilla/websocket/releases)
- [Commits](https://github.com/gorilla/websocket/compare/v1.4.1...v1.4.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-06-20 20:01:06 +08:00
Kslr 48c489aff0
only handle push 2020-06-20 19:56:52 +08:00
dependabot-preview[bot] 825e5b8c8f
Bump github.com/golang/mock from 1.2.0 to 1.4.3 (#26)
Bumps [github.com/golang/mock](https://github.com/golang/mock) from 1.2.0 to 1.4.3.
- [Release notes](https://github.com/golang/mock/releases)
- [Changelog](https://github.com/golang/mock/blob/master/.goreleaser.yml)
- [Commits](https://github.com/golang/mock/compare/v1.2.0...v1.4.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-06-20 19:53:20 +08:00
dependabot-preview[bot] e5f028b3f6
Create Dependabot config file (#25)
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-06-20 19:30:46 +08:00
kslr 3c5476a7cb update codecov badge 2020-06-20 16:15:12 +08:00
kslr 78729fc698 improve test coverage 2020-06-20 16:10:07 +08:00
Kslr 8dc133c4c6
update test badge 2020-06-20 03:39:50 +08:00
Kslr 0b612c43ec
Merge branch 'master' of github.com:v2fly/v2ray-core 2020-06-20 03:10:37 +08:00
Kslr 51be32fa12
actions add coverage 2020-06-20 03:07:58 +08:00
Loyalsoldier 70283d705c
Refine updatedat script (#24) 2020-06-20 02:01:45 +08:00
Kslr 3628ca4713
Merge pull request #2582 from v2fly/master
merge fly
2020-06-19 23:10:25 +08:00
Shelikhoo d6cad0b426
Update Version 2020-06-19 22:24:58 +08:00
Kslr 2c8f06e121
clean code (#22) 2020-06-19 21:57:03 +08:00
Kslr 0dfeba6a2f
在 actions 添加 lint 和 test (#21)
* actions add lint and test

* Only check new code
2020-06-19 21:19:37 +08:00
Kslr 6880b5a6d8
Merge pull request #20 from kslr/master
add armv5
2020-06-19 20:38:51 +08:00
kslr bc96f75bcb add armv5 2020-06-19 20:20:14 +08:00
Shelikhoo 38868e0469
Fix context layering in Shadowsocks UDP 2020-06-19 17:52:39 +08:00
Shelikhoo 3e13d79af7
Fix TProxy Process Logic 2020-06-18 13:40:48 +08:00
Shelikhoo 85bd352bc1
propagate context 2020-06-18 12:37:10 +08:00
Shelikhoo 73616ab9e2
branch context instead of layer it 2020-06-18 12:01:37 +08:00
Darhwa 8e791e92bc
Further strip unique signatures of tls handshake
1. allow users to disable session ticket
2. set default alpn to ["h2", "http/1.1"]
2020-06-18 11:32:37 +08:00
Shelikhoo 9e62f4a934
Merge branch 'master' of github.com:v2fly/v2ray-core
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2020-06-18 11:20:18 +08:00
Shelikhoo a26534c79c
Allow client to submit a context in v2ray.New 2020-06-18 11:19:05 +08:00
fzhyzamt afe313890e
支持非抢先验证的客户端 2020-06-15 17:08:21 +08:00
Xiaokang Wang f9935d0e93
Merge pull request #2561 from v2fly/master
Merge fly/master
2020-06-10 22:12:38 +08:00
Xiaokang Wang 4eeb913c9a
Update core.go 2020-06-10 18:17:18 +08:00
Xiaokang Wang 448d24496c
Merge pull request #10 from rprx/patch-1
Update Golang version to 1.14.4
2020-06-10 18:15:46 +08:00
Xiaokang Wang e920d39b11
Update core.go
Update Version
2020-06-10 18:13:43 +08:00
Xiaokang Wang e4ec9807a2
Merge pull request #12 from zhuobixin/master
LocalAddr() should return local address
2020-06-10 17:45:08 +08:00
Shelikhoo 8988dc32b9
Update Version 2020-06-10 11:15:28 +08:00
Shelikhoo aece8a6a86
Added Seed to mKCP, encrypts the packets 2020-06-09 08:36:40 +08:00
Shelikhoo d06a4d1f50
Added TestsEnabled Settings to enable VMessAEAD test 2020-06-08 16:50:50 +08:00
Shelikhoo 00103d1f73
Fix tests 2020-06-08 16:16:50 +08:00
Shelikhoo 09b81b78c3
regenerate pb data 2020-06-08 16:16:32 +08:00
Shelikhoo da0b63bc12
allow user to define tests enable for this server 2020-06-08 14:20:31 +08:00
Shelikhoo 870ff52775
Apply Coding Style 2020-06-08 13:25:33 +08:00
Shelikhoo 8c886b4b46
Apply Coding Style 2020-06-08 13:21:59 +08:00
Shelikhoo a58b20b5b8
Reserve sign bit 2020-06-08 10:23:59 +08:00
Shelikhoo 78d7b4f183
Check replay only for AEAD connection, and later 2020-06-06 20:54:29 +08:00
Shelikhoo 9fc37646b6
Check replay only for AEAD connection 2020-06-06 20:51:01 +08:00
Shelikhoo 6a29fa5fe2
Enable AEAD by Default 2020-06-06 20:37:30 +08:00
Shelikhoo 8d489f6c7c
Make taint acquire lesser lock 2020-06-06 19:22:27 +08:00
Shelikhoo 6007e4cc6f
Detailed AEAD Auth Error 2020-06-06 18:57:49 +08:00
Shelikhoo 9bf07b1f26
VMess AEAD Experiment 2020-06-06 17:11:30 +08:00
zhuobixin dc906cf68a
LocalAddr() should return local address 2020-06-05 11:17:02 +08:00
Mygod 32495de775
Fix https://github.com/v2ray/discussion/issues/726 2020-06-03 21:39:42 -04:00
rprx 2ef709997b
Update azure-pipelines.template.yml 2020-06-03 14:52:30 +00:00
rprx 3507f39677
Update azure-pipelines.yml 2020-06-03 14:51:09 +00:00
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 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
jejayhe c6694e0f1a Some code optimization
os.Kill is non-catchable, non-ignorable
2020-04-16 10:24:11 +08:00
Kirill Motkov 0fdad6f0fd Some code optimization
* Removed unnecessary `strings.ToLower()`.
* Removed redundant `u` variable.
2020-04-06 11:57:21 +03: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
remote-v2ray 86d5bd866b add UnregisterCounter method to stats manager 2020-02-03 13:53:14 +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
582 changed files with 38596 additions and 51366 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,7 @@
如果你遇到的问题不是 V2Ray 的 bug比如你不清楚要如何配置请使用[Discussion](https://github.com/v2ray/discussion/issues)进行讨论。
如果你遇到的问题不是 V2Ray 的 bug比如你不清楚要如何配置请使用[Discussion](https://github.com/v2fly/discussion/issues)进行讨论。
此 Issue 会被立即关闭。
If you are not sure if your question is truely a bug in V2Ray, please discuss it [here](https://github.com/v2ray/discussion/issues) first.
If you are not sure if your question is truely a bug in V2Ray, please discuss it [here](https://github.com/v2fly/discussion/issues) first.
This issue will be closed immediately.

View File

@ -1,11 +1,10 @@
---
name: V2Ray程序问题
name: V2Ray 程序问题
about: "提交一个 V2Ray 的程序问题报告。"
---
提交 Issue 之前请先阅读 [Issue 指引](https://github.com/v2ray/v2ray-core/blob/master/.github/SUPPORT.md),然后回答下面的问题,谢谢。
除非特殊情况,请完整填写所有问题。不按模板发的 issue 将直接被关闭。
如果你遇到的问题不是 V2Ray 的 bug比如你不清楚要如何配置请使用[Discussion](https://github.com/v2ray/discussion/issues)进行讨论。
如果你遇到的问题不是 V2Ray 的 bug比如你不清楚要如何配置请使用[Discussion](https://github.com/v2fly/discussion/issues)进行讨论。
1) 你正在使用哪个版本的 V2Ray如果服务器和客户端使用了不同版本请注明

View File

@ -3,9 +3,8 @@ name: Bug report
about: "Create a bug report to help us improve"
---
Please read the [instruction](https://github.com/v2ray/v2ray-core/blob/master/.github/SUPPORT.md) and answer the following questions before submitting your issue. Thank you.
Please answer all the questions with enough information. All issues not following this template will be closed immediately.
If you are not sure if your question is truely a bug in V2Ray, please discuss it [here](https://github.com/v2ray/discussion/issues) first.
If you are not sure if your question is truely a bug in V2Ray, please discuss it [here](https://github.com/v2fly/discussion/issues) first.
1) What version of V2Ray are you using (If you deploy different version on server and client, please explicitly point out)?

View File

@ -1,23 +0,0 @@
---
name: Crash report
about: "Create a report for panics"
---
Please answer all the questions with enough information. All issues not following this template will be closed immediately.
If you are not sure if your question is truely a bug in V2Ray, please discuss it [here](https://github.com/v2ray/discussion/issues) first.
1) What version of V2Ray are you using (If you deploy different version on server and client, please explicitly point out)?
2) What's your scenario of using V2Ray? E.g., Watching YouTube videos in Chrome via Socks/VMess proxy.
3) Please attach full panic log.
You may get panic log using command `journalctl -u v2ray` if your system is Linux (systemd).
4) Please attach your configuration file (**Mask IP addresses before submit this issue**).
```javascript
// Please attach your configuration here.
```
Please review your issue before submitting.

View File

@ -1,6 +0,0 @@
---
name: Feature Request
about: "Open a feature request to V2Ray"
---
Please describe the new feature you want in detail.

View File

@ -1,12 +1,12 @@
---
name: Other
about: "其它问题请使用 https://github.com/v2ray/discussion/issues 进行讨论 / Please discuss other issues at https://github.com/v2ray/discussion/issues"
about: "其它问题请使用 https://github.com/v2fly/discussion/issues 进行讨论 / Please discuss other issues at https://github.com/v2fly/discussion/issues"
---
如果你遇到的问题不是 V2Ray 的 bug比如你不清楚要如何配置请使用[Discussion](https://github.com/v2ray/discussion/issues)进行讨论。
如果你遇到的问题不是 V2Ray 的 bug比如你不清楚要如何配置请使用[Discussion](https://github.com/v2fly/discussion/issues)进行讨论。
此 Issue 会被立即关闭。
If you are not sure if your question is truely a bug in V2Ray, please discuss it [here](https://github.com/v2ray/discussion/issues) first.
If you are not sure if your question is truely a bug in V2Ray, please discuss it [here](https://github.com/v2fly/discussion/issues) first.
This issue will be closed immediately.

63
.github/SUPPORT.md vendored
View File

@ -1,63 +0,0 @@
# V2Ray 用户支持 (User Support)
**English reader please skip to the [English section](#way-to-get-support) below**
## 获得帮助信息的途径
您可以从以下渠道获取帮助:
1. 官方网站:[v2ray.com](https://www.v2ray.com)
1. Github[Issues](https://github.com/v2ray/v2ray-core/issues)
1. Telegram[主群](https://t.me/projectv2ray)
## Github Issue 规则
1. 请按模板填写 issue
1. 配置文件内容使用格式化代码段进行修饰(见下面的解释);
1. 在提交 issue 前尝试减化配置文件,比如删除不必要 inbound / outbound 模块;
1. 在提交 issue 前尝试确定问题所在,比如将 socks 代理换成 http 再次观察问题是否能重现;
1. 配置文件必须结构完整,即除了必要的隐私信息之外,配置文件可以直接拿来运行。
**不按模板填写的 issue 将直接被关闭**
## 格式化代码段
在配置文件上下加入 Markdown 特定的修饰符,如下:
\`\`\`javascript
{
// 配置文件内容
}
\`\`\`
## Way to Get Support
You may get help in the following ways:
1. Office Site: [v2ray.com](https://www.v2ray.com)
1. Github: [Issues](https://github.com/v2ray/v2ray-core/issues)
1. Telegram: [Main Group](https://t.me/projectv2ray)
## Github Issue Rules
1. Please fill in the issue template.
1. Decorate config file with Markdown formatter (See below).
1. Try to simplify config file before submitting the issue, such as removing unnecessary inbound / outbound blocks.
1. Try to determine the cause of the issue, for example, replacing socks inbound with http inbound to see if the issue still exists.
1. Config file must be structurally complete.
**Any issue not following the issue template will be closed immediately.**
## Code formatter
Add the following Markdown decorator to config file content:
\`\`\`javascript
{
// config file
}
\`\`\`

17
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,17 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

38
.github/linters/.golangci.yml vendored Normal file
View File

@ -0,0 +1,38 @@
run:
timeout: 5m
skip-files:
- generated.*
issues:
new: true
linters:
enable:
- bodyclose
- depguard
- gocritic
- gofmt
- goimports
- golint
- goprintffuncname
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- noctx
- nolintlint
- rowserrcheck
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- varcheck
- whitespace
disable:
- deadcode
- errcheck
- unused

1
.github/pull_request_template.md vendored Normal file
View File

@ -0,0 +1 @@
Please Move to https://github.com/v2fly/v2ray-core/pulls

69
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@ -0,0 +1,69 @@
name: CodeQL
on:
push:
branches: [master]
paths:
- "**/*.go"
pull_request:
branches: [master]
types: [opened, synchronize, reopened]
paths:
- "**/*.go"
schedule:
- cron: '0 0 * * 1'
jobs:
analyze:
if: github.repository != 'v2ray/v2ray-core'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['go']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

43
.github/workflows/coverage.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: Coverage
on:
push:
branches: [master]
paths:
- "**/*.go"
jobs:
coverage:
if: github.repository != 'v2ray/v2ray-core'
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
- name: Checkout codebase
uses: actions/checkout@v2
- name: Cache go module
uses: actions/cache@v2
id: cache-gomodules
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get dependencies
if: steps.cache-gomodules.outputs.cache-hit != 'true'
run: |
go get -v -t -d ./...
- name: Run coverage
run: ./testing/coverage/coverall2
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.txt
fail_ci_if_error: true

32
.github/workflows/linter.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: Linter
on:
push:
branches: [master]
paths:
- "**/*.go"
pull_request:
branches: [master]
types: [opened, synchronize, reopened]
paths:
- "**/*.go"
jobs:
lint:
if: github.repository != 'v2ray/v2ray-core'
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
- name: Checkout codebase
uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.31
args: --config=.github/linters/.golangci.yml
only-new-issues: true

25
.github/workflows/sign.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: Sign
on:
release:
types: [released]
jobs:
sign:
if: github.repository != 'v2ray/v2ray-core'
runs-on: ubuntu-latest
steps:
- name: Checkout default branch
uses: actions/checkout@v2
- name: Grant it execution permission
run: |
chmod +x $GITHUB_WORKSPACE/release/requestsign_github.sh
chmod +x $GITHUB_WORKSPACE/release/requestsign.sh
- name: Invoke release signing
env:
SIGN_SERVICE_PASSWORD: ${{ secrets.SIGN_SERVICE_PASSWORD }}
SIGN_SERIVCE_URL: ${{ secrets.SIGN_SERIVCE_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: $GITHUB_WORKSPACE/release/requestsign_github.sh

17
.github/workflows/stale.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: Mark stale issues and pull requests
on:
schedule:
- cron: "30 1 * * *"
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3.0.13
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: "This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days"
stale-pr-message: 'It has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days'
days-before-stale: 120
days-before-close: 5

42
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,42 @@
name: Test
on:
push:
branches: [master]
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
pull_request:
branches: [master]
types: [opened, synchronize, reopened]
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
jobs:
test:
if: github.repository != 'v2ray/v2ray-core'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
- name: Checkout codebase
uses: actions/checkout@v2
- name: Cache go module
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Test
run: go test -timeout 1h -v ./...

25
.github/workflows/updateGeofile.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: Update Geofiles
on:
schedule:
- cron: "0 0 * * FRI"
jobs:
update:
if: github.repository == 'v2fly/v2ray-core'
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v2
- name: Download
run: |
curl -L -o release/config/geoip.dat "https://github.com/v2fly/geoip/raw/release/geoip.dat"
curl -L -o release/config/geosite.dat "https://github.com/v2fly/domain-list-community/raw/release/dlc.dat"
- name: push
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "update geoip, geosite"
git push -v --progress

10
.vscode/settings.json vendored
View File

@ -1,10 +0,0 @@
// Place your settings in this file to overwrite default and user settings.
{
"editor.tabSize": 2,
"protoc": {
"options": [
"--proto_path=${env.GOPATH}/src/",
"--proto_path=${env.GOPATH}/src/github.com/google/protobuf/src"
]
}
}

51
.vscode/tasks.json vendored
View File

@ -1,51 +0,0 @@
{
"version": "2.0.0",
"command": "go",
"type": "shell",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"tasks": [
{
"label": "build",
"args": ["v2ray.com/core/..."],
"group": "build",
"problemMatcher": {
"owner": "go",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^([^:]+\\.go):(\\d+):(.*)",
"file": 1,
"line": 2,
"message": 3
}
}
},
{
"label": "test",
"args": ["-p", "1", "v2ray.com/core/..."],
"group": "test"
},
{
"label": "Escape Analysis",
"type": "shell",
"command": "go build -gcflags -m .",
"problemMatcher": {
"pattern": {
"regexp": "^(.*):(.*):(.*): (.*)$",
"file": 1,
"line": 2,
"column": 3,
"message": 4
},
"fileLocation": ["relative", "${fileDirname}"]
},
"options": {
"cwd": "${fileDirname}"
}
}
]
}

24
Dockerfile Normal file
View File

@ -0,0 +1,24 @@
############################
# STEP 1 build executable binary
############################
FROM golang:alpine AS builder
RUN apk update && apk add --no-cache git bash wget curl
WORKDIR /build
RUN git clone --progress https://github.com/v2fly/v2ray-core.git . && \
bash ./release/user-package.sh nosource noconf codename=$(git describe --abbrev=0 --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"]

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2015-2019 V2Ray
Copyright (c) 2015-2020 V2Fly Community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,31 +1,37 @@
# Move To https://github.com/v2fly/v2ray-core
***
# Project V
[![Build Status][1]][2] [![codecov.io][3]][4] [![GoDoc][5]][6] [![codebeat][7]][8] [![Downloads][9]][10]
[![GitHub Test Badge][1]][2] [![codecov.io][3]][4] [![GoDoc][5]][6] [![codebeat][7]][8] [![Downloads][9]][10] [![Downloads][11]][12]
[1]: https://dev.azure.com/v2ray/core/_apis/build/status/v2ray.core "Build Status badge"
[2]: https://dev.azure.com/v2ray/core/_build/latest?definitionId=1 "Azure Build Status"
[3]: https://codecov.io/github/v2ray/v2ray-core/coverage.svg?branch=master "Coverage badge"
[4]: https://codecov.io/github/v2ray/v2ray-core?branch=master "Codecov Status"
[5]: https://godoc.org/v2ray.com/core?status.svg "GoDoc badge"
[1]: https://github.com/v2fly/v2ray-core/workflows/Test/badge.svg "GitHub Test Badge"
[2]: https://github.com/v2fly/v2ray-core/actions "GitHub Actions Page"
[3]: https://codecov.io/gh/v2fly/v2ray-core/branch/master/graph/badge.svg?branch=master "Coverage Badge"
[4]: https://codecov.io/gh/v2fly/v2ray-core?branch=master "Codecov Status"
[5]: https://godoc.org/v2ray.com/core?status.svg "GoDoc Badge"
[6]: https://godoc.org/v2ray.com/core "GoDoc"
[7]: https://codebeat.co/badges/f2354ca8-3e24-463d-a2e3-159af73b2477 "Codebeat badge"
[8]: https://codebeat.co/projects/github-com-v2ray-v2ray-core-master "Codebeat"
[9]: https://img.shields.io/github/downloads/v2ray/v2ray-core/total.svg "All releases badge"
[10]: https://github.com/v2ray/v2ray-core/releases/ "All releases number"
[7]: https://goreportcard.com/badge/github.com/v2fly/v2ray-core "Goreportcard Badge"
[8]: https://goreportcard.com/report/github.com/v2fly/v2ray-core "Goreportcard Result"
[9]: https://img.shields.io/github/downloads/v2ray/v2ray-core/total.svg "v2ray/v2ray-core downloads count"
[10]: https://github.com/v2ray/v2ray-core/releases "v2ray/v2ray-core release page"
[11]: https://img.shields.io/github/downloads/v2fly/v2ray-core/total.svg "v2fly/v2ray-core downloads count"
[12]: https://github.com/v2fly/v2ray-core/releases "v2fly/v2ray-core release page"
Project V is a set of network tools that help you to build your own computer network. It secures your network connections and thus protects your privacy. See [our website](https://www.v2ray.com/) for more information.
Project V is a set of network tools that help you to build your own computer network. It secures your network connections and thus protects your privacy. See [our website](https://www.v2fly.org/) for more information.
## License
[The MIT License (MIT)](https://raw.githubusercontent.com/v2ray/v2ray-core/master/LICENSE)
[The MIT License (MIT)](https://raw.githubusercontent.com/v2fly/v2ray-core/master/LICENSE)
## Credits
This repo relies on the following third-party projects:
* In production:
* [gorilla/websocket](https://github.com/gorilla/websocket)
* [gRPC](https://google.golang.org/grpc)
* For testing only:
* [miekg/dns](https://github.com/miekg/dns)
* [h12w/socks](https://github.com/h12w/socks)
- In production:
- [gorilla/websocket](https://github.com/gorilla/websocket)
- [gRPC](https://google.golang.org/grpc)
- For testing only:
- [miekg/dns](https://github.com/miekg/dns)
- [h12w/socks](https://github.com/h12w/socks)

115
SECURITY.md Normal file
View File

@ -0,0 +1,115 @@
# 安全策略 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
使用邮箱: security |at| v2fly.org。
Report to email: security |at| v2fly.org.
GPG public key:
```
pub rsa4096 2020-06-02 [SC] [有效至2022-01-02]
E2E35E27914FB007C0D4B6DDB117BA3BE8B494A7
uid [ 绝对 ] V2Fly Developers <dev@v2fly.org>
sub rsa4096 2020-06-02 [E] [有效至2022-01-02]
sub rsa4096 2020-11-08 [S] [有效至2022-01-02] // 用于 Debian / Ubuntu 签名
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBF7V7pQBEACozcw4/BlPgFWaz4AdN8HKSrCDLlN+/g7m4AKZIo13fAnDh+sJ
2H4NrWNr0xxgovbco5Xw4OSSwY1BuUhnb4AmIyxbwqUQD2UADe5xD6gMBwNiJTP4
02VCHhh7DnWTeLbAsUgRotxUCxsWVvd2F08SYGfJggOVftOnG+VNnwzTOvHWFVEw
1Pv1DaY7bKSA0voACerRbAPCYqhmElAGJHYNjBMaxqCaWFJWpAFfBxkvS1FDVyZk
BsABhn6sOcGJn8EYSHUIXhWwqtkQCjBB4OOik+Jn+S2DFGyk5l1NrGRQtX8C0BYn
nc7VaxtFOp5fnJ4y0GNd4AM9KO0/Ojosi6b64l407Fj9i9OXznmZUACQw2u+VcL3
qNy768hsTmka3pXzpRHZwYcOLOEr3jGHmLOtXgQ656OjF8Xd9DJ4cB42X8iBeqTp
iQchHIdBpnu27ZbBFy09OMak+STB5zA0JmxDaC8b48mVkc0BMRXdYl7wWXJsEJf1
roAOr3RCBKiE840w0PLOTnUljfqazPYTwzs91oP+SeZjBmGOpaAh7bh5BVOpzPSE
bdA61/n01GEb5bpOKpaTi9GviF3RCbfFnLKJnBq0vHvW9BqKTVFRPAKkBGuOPBdy
8MBNY+VY/2aP3ukZUoYe8Ypl9Q7dVPRjnoWaH0sEMzftoh+3s7GSSgAylQARAQAB
tCBWMkZseSBEZXZlbG9wZXJzIDxkZXZAdjJmbHkub3JnPokCVAQTAQgAPgIbAwUL
CQgHAgYVCgkICwIEFgIDAQIeAQIXgBYhBOLjXieRT7AHwNS23bEXujvotJSnBQJf
p4leBQkC+1DKAAoJELEXujvotJSn124P/0swu9POvEQtxVlRzNh2VjAGHZ5NEDnl
pMrhfC5ryCYtlVS/kc2WwRhIRHKzr9nbamgSxUCiyLagfnIjhIvAohun49grYNzG
MZWRURiuFrCnYbD7juJTvfbzZCzJk7LPsdnqHWr8fYcOZMTOZVzQiQB2jUx2KeRm
yV8aV21Z8gMLqSGjs06a0UaRbKB0FSysTURm91/jFmiH43aG1s/LcB9/lKf5HpNl
9or6LrEOrokAwtkMSBYTqm7Dp1j+cK0iOMw2CmMqmQZkV+i6msYrQRiX/X6YufiM
wfMMSdOZOz9KG+k+C6N1swSbGeDMrJfnDUDbvrAXKhDjNgY7UBwbk69Abd7Y9aQz
/jVmrFEWt4lisBxglBot60CRUTM2boK/uQS5zBCJhemeg14F9Q/FRiUTlS8jQoeK
PWeK2lagYJS8lpJZLXkqe4xSpjCgoT0Z+lYSfTjx+T0AFF+xz5E243Lb5kDxwnR9
Y5CZt3vV6GWBYOt9MEL3pk7AnYyNT1y1KIiMyONh/Z1koUdHr4J9exllnsmAJQUa
W/j0UtVsLsvUjFv9RTr9w5p/U0J0VLIN0YOpx4wYaBEwFIa8lsL+Ey1Vphkvvjfz
uMRAHe4v+axWb1f1hVCBjtyCVyvzf+i9RTAYsBJ3MJ0C8cvvrm10N9B7MHh0JZA5
PcJSilailp1TuQINBF7V7pQBEADkQdO75smeKnmPt0/aNNlb7JDOSWW5VY0kYgx3
6Toh139JstIQ2xz0CLSGReizUFB6eR3DXmezLrmhkgN2Aq5A+hCtFAJwWKuKr1HS
usvJ1el9h0oh7IO+tF8E/gNYwWfabjPX27FGVCHR1qG7ffN51Bghrnwi1T4YC98E
R9EGU6N0Xs9DeIJL9WQPH/DF22251i/OAXkqKVGn3PNe2cBsp0yKxr9mlSyzjrha
KXokPiPcvNqlnkiDCgfiRj7c2C2Lyl9PoEiGpsNZaCZYkMPgjM0xiLenQddwRyOU
z2cLG3d8WdCTRyHSZd/YQtSi5R6AnkJEsVtUiDN5zwNFVpQlTq3jNHsVUpjFU2nK
ourTZVCCLbAC60VTdxLN6eFO0f+lS2WjyJ7uZ9SGbS6uP0jMNphH/QjVF848bWXs
1CuZty5QQY7+MTNUAhSWWntrpTkdXYqT0zUqiOc1YNnkfg3hvC4d0dbnFTfcyZnB
Sg8e7/9n6+ms75/deYgnLuA6h7pkIcflm7pUMfVKXKz5Vlc8FC9ia0UtobeKBKqi
jObfiO/zmNL0HQBeX0e8GkJrCyv6ikD8cUqsmVtgw7jdxGsV0SL5CddDnGKsc68O
pGDmkAuRqR3QtXju/4r7a8IEVveGWc3rUvddYrtqbbCNWCN0JKX13PEvbNAm+2eD
MGQtcQARAQABiQI8BBgBCAAmAhsMFiEE4uNeJ5FPsAfA1LbdsRe6O+i0lKcFAl+n
dwcFCQL7PnMACgkQsRe6O+i0lKeWfxAApopL5I9p4btmkcLIg2lkA1n+czFekbdr
2tjFKrBER4QWkyDCUE8QaVo/ECveTHmnxrTB/djW6xqPVS77PL8xOATIYTo6qU38
oTCB1T7/P2L9qI72BzcRY5f9ZPyJhCtrkvjCPzjUjw+ZIPIOgQcWgKHWnE+OyUKD
0GkVEUME3QP5S4Nr3XGrgS7oxDAmD52u7pn0mSk5WmEcLW0oGwsVdc4aDXxpX+u/
gkBZysmAuomPov7iXVosMakl+4rz30yPcrL9A81m1WAeB3PGkpaO3B++8Ql+FBCQ
OrLtPn/nnIzEuAXB1Hd8vYzxtRM2CZvhRExM7xofnhkBJOtR/ddfbJa7H5+Aruc0
4S0JIaqMCrC6tZezjTACAzrWULmZZGmrHbLrmXBuLk0huRkeIRnDzHP+DoE2UciL
3hR9EGOHX9O/dGb3bb3y11LAf7GI28ZG7So1GeoFkEOga1IJnsBnXCqwM8vbDDWq
/7aLb3/m0gT7DUfjeXKfWPJXcnaq8r4llHzDn2i6ax4Uq/brCOLj9ovVGIctZTbt
yvsFOc1bVkSuUM+pMkCtBx80/sJSB2Nu94S6osdaUlRE+jaCcqEbPd+G68Yd0Khi
CL8zF1a3dX1dpuVFTLNpXOgrviGBzXQmzFeil7mWFs0l+1XZOPz9nhmRrMn6wV3n
i4KItRSJAXy5Ag0EX6d5hQEQAMsVyLTXdybeei2nWDb5jtzzC3AtSnPWtKG4B86C
BXncaZpU43hKI3oduW2+42eM8n8KTvO11r9xv4zKATfaHBZq2hkKZdDQjuSstovr
a3hapHHknHeNVTg3yuiakKzpr6FK23W/GE1lJfhz254v9+dRV0KazWksXvpGEdgI
+6sC4Nr5bKgJVEQibyrrL0gmzlVB/oQU/W4eGvk21zmgMlHri+edBLpVtlCmn7k/
0t+2X9D1Pq2nkjMUurB9EJ1z24LMldmPOl6P7iJCx9kSUjcHrEg56q5VSZq50FAj
DeSjAqsdussI8cdstCMktE9nhizxVKFXpbXifqoYfJwCo23wFqQJpyPgQqHIT12s
GWRUa/MF6hRYg/5CyeadDmkmnKPTPjmQ2S2SFNXX7xs+dZKvIvXP30z4cpuVY8i8
chZSRNb8K0L9T0Jme7CPm28F6lvDUkNDQ1WErXZruHbOKwQOfQBdXK3nedOiUpBt
401HVlGUJSInfEb3JXU01tRqnnzI/y5z7cWCGEMEa6TeaCrMbVvl8xeAA1w/nw0y
zHz6/Pnf4TITuCH22aa7+xfgpq8gRLhUUws89mbQT+9fd8tT65+Q8xcaLCyzrLAq
zND5sVZ4/PwaYc8UNZcHjeQR7aYWI1xgr/IwY1wyDWZLbWgkk0HVxpvYdMEpJryD
AyMdABEBAAGJBHIEGAEIACYWIQTi414nkU+wB8DUtt2xF7o76LSUpwUCX6d5hQIb
AgUJAim2AAJACRCxF7o76LSUp8F0IAQZAQgAHRYhBK8FZLGpNMztuW02YbJOz+X/
ddOBBQJfp3mFAAoJELJOz+X/ddOBNKQP/0nwIC4R9gQhY53vME7VA7elIrBiSM6d
Va26a7J1nrCcpDAE7Lp0TqzrDMqyen+IL4X5QK5sKTgenYTgjppEJIQn+Wup54ix
I+YOQ8MVLfN6/3QPACWMngSPRF+UKDg4hyTCEL+/GCgTp58oXrl/YIO6Oqt5drog
w4+4ufU1/eKTb2ruGULGl9jZvFSZpLdsvJ19xJB2kC1k8GVNu7MnUL+S2pU/9kO4
5EZ/jEa1wT45zev+HdmzX5TYW6SLaI9HKHMqbQz2EHc3tRYIDaz3FE3s4VdMjqpp
e42SvkOYaguc6cXToDbzBmU+iWGlXCTHfNhxwxoUYcKZlDEkEtvSYHJOb0k9eqbT
gvMb5GjbAgqqwOBwtN3v790j8jEG+cdXR3qHcEx0bw3F2Bd18U7j946OxHLKE5Xk
2sWEG422maVrE9o1DdeTV5oDFNNPBzqfjgGBZCCKrjkpldhDOHeoDU2aFMJ7yVqw
ZwKwJ5f8fdNS13UnQVwGsZ2BsW1cox5ZGZ/C5A7mfSF1WAgJcYIw4M2JQbDn4Yuw
yqjyg53lT3OurBONbEZ7unnsLqpT9qKwZ1qCemqGRJieXXxJwl7G4gBgZbH0rBJR
6dhbyt4c2JE8MMdC65mDWneltNM6pttC/j5jCuvIlZGACZ91UuLLediJJWAlOJ+1
fBQ0m8TD6d8ZrakP/RFMLZrxh9WPaFB43sW/b1Fq2h933HQ29oSQFuXhsHsx1Vaq
HTRTcBB7kywAr9+zMYsOsk0/WnoZNGoMkUWu/gFkb6CdUcsdEumgyZ8S24VoBCHB
T1fD/8eOA5K82hwAFcKbPwuuTLtf9b9HB4/xsObfcczTeqIknzIPsGlgVz4w1c9a
StSo4iI4bCSLL+/mqiXZ+ArXJ/z4Vejl92fNLWVOlOrjkBV+AY6iAFCCsxJ1O5ud
5a5r1bUeBXd0BcQ1m/hpjawMC1y0SkIBTQCgxIQoPoxJ27hHNIN1R2nkqfY9vboQ
7O0uIHF8fmuz93xg68ZTW0JHwOw4Mz88lGibE2laHApjKWZAtF/i+LlhbnewtESL
EuGTT7gt7cSHgnBiDEIm5UJVEGeM0sMReztxy9V7glohH5DV8GpVK/GncKlsrh1K
BuEuz7IrqKlBzhsDy0SrNZpX7EzsiU1uvoA6teT4EPey8qXH+7WR9B2ad1Zc5yE3
zv4BpnWkkJp8qdYu4fdCs/mrmnBR5G1YdOAIlNWhU74Wdyq+W4HfTWMgvJHmElnZ
UvQ9RDTWnw2+3n2ATeLf9ZwW1g4/Dqh55OaLtJZo5me8vU9W+vkm34xzfVfD/mus
ljogw5eiGyj8j3lUVjYWu28l/bz0zDUueWmHhV8E8z0Cn7OhrHPpUCHx2Aep
=quYd
-----END PGP PUBLIC KEY BLOCK-----
```

View File

@ -2,7 +2,7 @@
package commander
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen
import (
"context"

View File

@ -1,95 +1,174 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.13.0
// source: app/commander/config.proto
package commander
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
serial "v2ray.com/core/common/serial"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
// Config is the settings for Commander.
type Config struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Tag of the outbound handler that handles grpc connections.
Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
// Services that supported by this server. All services must implement Service interface.
Service []*serial.TypedMessage `protobuf:"bytes,2,rep,name=service,proto3" json:"service,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
// Services that supported by this server. All services must implement Service
// interface.
Service []*serial.TypedMessage `protobuf:"bytes,2,rep,name=service,proto3" json:"service,omitempty"`
}
func (m *Config) Reset() { *m = Config{} }
func (m *Config) String() string { return proto.CompactTextString(m) }
func (*Config) ProtoMessage() {}
func (x *Config) Reset() {
*x = Config{}
if protoimpl.UnsafeEnabled {
mi := &file_app_commander_config_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Config) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Config) ProtoMessage() {}
func (x *Config) ProtoReflect() protoreflect.Message {
mi := &file_app_commander_config_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
func (*Config) Descriptor() ([]byte, []int) {
return fileDescriptor_4af9cfd3f0e2019e, []int{0}
return file_app_commander_config_proto_rawDescGZIP(), []int{0}
}
func (m *Config) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Config.Unmarshal(m, b)
}
func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Config.Marshal(b, m, deterministic)
}
func (m *Config) XXX_Merge(src proto.Message) {
xxx_messageInfo_Config.Merge(m, src)
}
func (m *Config) XXX_Size() int {
return xxx_messageInfo_Config.Size(m)
}
func (m *Config) XXX_DiscardUnknown() {
xxx_messageInfo_Config.DiscardUnknown(m)
}
var xxx_messageInfo_Config proto.InternalMessageInfo
func (m *Config) GetTag() string {
if m != nil {
return m.Tag
func (x *Config) GetTag() string {
if x != nil {
return x.Tag
}
return ""
}
func (m *Config) GetService() []*serial.TypedMessage {
if m != nil {
return m.Service
func (x *Config) GetService() []*serial.TypedMessage {
if x != nil {
return x.Service
}
return nil
}
func init() {
proto.RegisterType((*Config)(nil), "v2ray.core.app.commander.Config")
var File_app_commander_config_proto protoreflect.FileDescriptor
var file_app_commander_config_proto_rawDesc = []byte{
0x0a, 0x1a, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x65, 0x72, 0x2f,
0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x76, 0x32,
0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x63, 0x6f, 0x6d,
0x6d, 0x61, 0x6e, 0x64, 0x65, 0x72, 0x1a, 0x21, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x73,
0x65, 0x72, 0x69, 0x61, 0x6c, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x64, 0x5f, 0x6d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5c, 0x0a, 0x06, 0x43, 0x6f, 0x6e,
0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x40, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63,
0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61,
0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x07,
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x59, 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 0x2e, 0x76,
0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x63, 0x6f,
0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x65, 0x72, 0x50, 0x01, 0x5a, 0x1c, 0x76, 0x32, 0x72, 0x61, 0x79,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f,
0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x65, 0x72, 0xaa, 0x02, 0x18, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e,
0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64,
0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
func init() {
proto.RegisterFile("v2ray.com/core/app/commander/config.proto", fileDescriptor_4af9cfd3f0e2019e)
var (
file_app_commander_config_proto_rawDescOnce sync.Once
file_app_commander_config_proto_rawDescData = file_app_commander_config_proto_rawDesc
)
func file_app_commander_config_proto_rawDescGZIP() []byte {
file_app_commander_config_proto_rawDescOnce.Do(func() {
file_app_commander_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_commander_config_proto_rawDescData)
})
return file_app_commander_config_proto_rawDescData
}
var fileDescriptor_4af9cfd3f0e2019e = []byte{
// 212 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2c, 0x33, 0x2a, 0x4a,
0xac, 0xd4, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x2c, 0x28, 0xd0, 0x4f,
0xce, 0xcf, 0xcd, 0x4d, 0xcc, 0x4b, 0x49, 0x2d, 0xd2, 0x4f, 0xce, 0xcf, 0x4b, 0xcb, 0x4c, 0xd7,
0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x80, 0x29, 0x2d, 0x4a, 0xd5, 0x4b, 0x2c, 0x28, 0xd0,
0x83, 0x2b, 0x93, 0x32, 0x40, 0x33, 0x04, 0x24, 0x93, 0x9f, 0xa7, 0x5f, 0x9c, 0x5a, 0x94, 0x99,
0x98, 0xa3, 0x5f, 0x52, 0x59, 0x90, 0x9a, 0x12, 0x9f, 0x9b, 0x5a, 0x5c, 0x9c, 0x98, 0x9e, 0x0a,
0x31, 0x4b, 0x29, 0x86, 0x8b, 0xcd, 0x19, 0x6c, 0xb6, 0x90, 0x00, 0x17, 0x73, 0x49, 0x62, 0xba,
0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x88, 0x29, 0xe4, 0xc0, 0xc5, 0x5e, 0x9c, 0x5a, 0x54,
0x96, 0x99, 0x9c, 0x2a, 0xc1, 0xa4, 0xc0, 0xac, 0xc1, 0x6d, 0xa4, 0xa6, 0x87, 0x64, 0x33, 0xc4,
0x6c, 0x3d, 0x88, 0xd9, 0x7a, 0x21, 0x20, 0xb3, 0x7d, 0x21, 0x46, 0x07, 0xc1, 0xb4, 0x39, 0xb9,
0x71, 0xc9, 0x24, 0xe7, 0xe7, 0xea, 0xe1, 0x72, 0x6f, 0x00, 0x63, 0x14, 0x27, 0x9c, 0xb3, 0x8a,
0x49, 0x22, 0xcc, 0x28, 0x28, 0xb1, 0x52, 0xcf, 0x19, 0xa4, 0xce, 0xb1, 0xa0, 0x40, 0xcf, 0x19,
0x26, 0x95, 0xc4, 0x06, 0x76, 0xac, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x29, 0x02, 0xa6, 0x19,
0x25, 0x01, 0x00, 0x00,
var file_app_commander_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_app_commander_config_proto_goTypes = []interface{}{
(*Config)(nil), // 0: v2ray.core.app.commander.Config
(*serial.TypedMessage)(nil), // 1: v2ray.core.common.serial.TypedMessage
}
var file_app_commander_config_proto_depIdxs = []int32{
1, // 0: v2ray.core.app.commander.Config.service:type_name -> v2ray.core.common.serial.TypedMessage
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_app_commander_config_proto_init() }
func file_app_commander_config_proto_init() {
if File_app_commander_config_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_app_commander_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Config); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_app_commander_config_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_app_commander_config_proto_goTypes,
DependencyIndexes: file_app_commander_config_proto_depIdxs,
MessageInfos: file_app_commander_config_proto_msgTypes,
}.Build()
File_app_commander_config_proto = out.File
file_app_commander_config_proto_rawDesc = nil
file_app_commander_config_proto_goTypes = nil
file_app_commander_config_proto_depIdxs = nil
}

View File

@ -2,16 +2,17 @@ syntax = "proto3";
package v2ray.core.app.commander;
option csharp_namespace = "V2Ray.Core.App.Commander";
option go_package = "commander";
option go_package = "v2ray.com/core/app/commander";
option java_package = "com.v2ray.core.app.commander";
option java_multiple_files = true;
import "v2ray.com/core/common/serial/typed_message.proto";
import "common/serial/typed_message.proto";
// Config is the settings for Commander.
message Config {
// Tag of the outbound handler that handles grpc connections.
string tag = 1;
// Services that supported by this server. All services must implement Service interface.
// Services that supported by this server. All services must implement Service
// interface.
repeated v2ray.core.common.serial.TypedMessage service = 2;
}

View File

@ -1,112 +1,210 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.13.0
// source: app/dispatcher/config.proto
package dispatcher
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type SessionConfig struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (m *SessionConfig) Reset() { *m = SessionConfig{} }
func (m *SessionConfig) String() string { return proto.CompactTextString(m) }
func (*SessionConfig) ProtoMessage() {}
func (x *SessionConfig) Reset() {
*x = SessionConfig{}
if protoimpl.UnsafeEnabled {
mi := &file_app_dispatcher_config_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SessionConfig) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SessionConfig) ProtoMessage() {}
func (x *SessionConfig) ProtoReflect() protoreflect.Message {
mi := &file_app_dispatcher_config_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SessionConfig.ProtoReflect.Descriptor instead.
func (*SessionConfig) Descriptor() ([]byte, []int) {
return fileDescriptor_90b7c41cce355532, []int{0}
return file_app_dispatcher_config_proto_rawDescGZIP(), []int{0}
}
func (m *SessionConfig) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SessionConfig.Unmarshal(m, b)
}
func (m *SessionConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SessionConfig.Marshal(b, m, deterministic)
}
func (m *SessionConfig) XXX_Merge(src proto.Message) {
xxx_messageInfo_SessionConfig.Merge(m, src)
}
func (m *SessionConfig) XXX_Size() int {
return xxx_messageInfo_SessionConfig.Size(m)
}
func (m *SessionConfig) XXX_DiscardUnknown() {
xxx_messageInfo_SessionConfig.DiscardUnknown(m)
}
var xxx_messageInfo_SessionConfig proto.InternalMessageInfo
type Config struct {
Settings *SessionConfig `protobuf:"bytes,1,opt,name=settings,proto3" json:"settings,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Settings *SessionConfig `protobuf:"bytes,1,opt,name=settings,proto3" json:"settings,omitempty"`
}
func (m *Config) Reset() { *m = Config{} }
func (m *Config) String() string { return proto.CompactTextString(m) }
func (*Config) ProtoMessage() {}
func (x *Config) Reset() {
*x = Config{}
if protoimpl.UnsafeEnabled {
mi := &file_app_dispatcher_config_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Config) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Config) ProtoMessage() {}
func (x *Config) ProtoReflect() protoreflect.Message {
mi := &file_app_dispatcher_config_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
func (*Config) Descriptor() ([]byte, []int) {
return fileDescriptor_90b7c41cce355532, []int{1}
return file_app_dispatcher_config_proto_rawDescGZIP(), []int{1}
}
func (m *Config) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Config.Unmarshal(m, b)
}
func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Config.Marshal(b, m, deterministic)
}
func (m *Config) XXX_Merge(src proto.Message) {
xxx_messageInfo_Config.Merge(m, src)
}
func (m *Config) XXX_Size() int {
return xxx_messageInfo_Config.Size(m)
}
func (m *Config) XXX_DiscardUnknown() {
xxx_messageInfo_Config.DiscardUnknown(m)
}
var xxx_messageInfo_Config proto.InternalMessageInfo
func (m *Config) GetSettings() *SessionConfig {
if m != nil {
return m.Settings
func (x *Config) GetSettings() *SessionConfig {
if x != nil {
return x.Settings
}
return nil
}
func init() {
proto.RegisterType((*SessionConfig)(nil), "v2ray.core.app.dispatcher.SessionConfig")
proto.RegisterType((*Config)(nil), "v2ray.core.app.dispatcher.Config")
var File_app_dispatcher_config_proto protoreflect.FileDescriptor
var file_app_dispatcher_config_proto_rawDesc = []byte{
0x0a, 0x1b, 0x61, 0x70, 0x70, 0x2f, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72,
0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x19, 0x76,
0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x69,
0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x22, 0x15, 0x0a, 0x0d, 0x53, 0x65, 0x73, 0x73,
0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22,
0x4e, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x44, 0x0a, 0x08, 0x73, 0x65, 0x74,
0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x76, 0x32,
0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x69, 0x73,
0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x43,
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x42,
0x5c, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72,
0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72,
0x50, 0x01, 0x5a, 0x1d, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f,
0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65,
0x72, 0xaa, 0x02, 0x19, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41,
0x70, 0x70, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
func init() {
proto.RegisterFile("v2ray.com/core/app/dispatcher/config.proto", fileDescriptor_90b7c41cce355532)
var (
file_app_dispatcher_config_proto_rawDescOnce sync.Once
file_app_dispatcher_config_proto_rawDescData = file_app_dispatcher_config_proto_rawDesc
)
func file_app_dispatcher_config_proto_rawDescGZIP() []byte {
file_app_dispatcher_config_proto_rawDescOnce.Do(func() {
file_app_dispatcher_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_dispatcher_config_proto_rawDescData)
})
return file_app_dispatcher_config_proto_rawDescData
}
var fileDescriptor_90b7c41cce355532 = []byte{
// 176 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2a, 0x33, 0x2a, 0x4a,
0xac, 0xd4, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x2c, 0x28, 0xd0, 0x4f,
0xc9, 0x2c, 0x2e, 0x48, 0x2c, 0x49, 0xce, 0x48, 0x2d, 0xd2, 0x4f, 0xce, 0xcf, 0x4b, 0xcb, 0x4c,
0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x84, 0xa9, 0x2d, 0x4a, 0xd5, 0x4b, 0x2c, 0x28,
0xd0, 0x43, 0xa8, 0x53, 0x12, 0xe5, 0xe2, 0x0d, 0x4e, 0x2d, 0x2e, 0xce, 0xcc, 0xcf, 0x73, 0x06,
0xeb, 0xf0, 0x62, 0xe1, 0x60, 0x14, 0x60, 0x52, 0xf2, 0xe3, 0x62, 0x83, 0xf0, 0x85, 0x5c, 0xb8,
0x38, 0x8a, 0x53, 0x4b, 0x4a, 0x32, 0xf3, 0xd2, 0x8b, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d,
0x34, 0xf4, 0x70, 0x1a, 0xa7, 0x87, 0x62, 0x56, 0x10, 0x5c, 0xa7, 0x93, 0x27, 0x97, 0x6c, 0x72,
0x7e, 0x2e, 0x6e, 0x8d, 0x01, 0x8c, 0x51, 0x5c, 0x08, 0xde, 0x2a, 0x26, 0xc9, 0x30, 0xa3, 0xa0,
0xc4, 0x4a, 0x3d, 0x67, 0x90, 0x4a, 0xc7, 0x82, 0x02, 0x3d, 0x17, 0xb8, 0x5c, 0x12, 0x1b, 0xd8,
0x4f, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x47, 0xc5, 0xd6, 0x01, 0x01, 0x00, 0x00,
var file_app_dispatcher_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_app_dispatcher_config_proto_goTypes = []interface{}{
(*SessionConfig)(nil), // 0: v2ray.core.app.dispatcher.SessionConfig
(*Config)(nil), // 1: v2ray.core.app.dispatcher.Config
}
var file_app_dispatcher_config_proto_depIdxs = []int32{
0, // 0: v2ray.core.app.dispatcher.Config.settings:type_name -> v2ray.core.app.dispatcher.SessionConfig
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_app_dispatcher_config_proto_init() }
func file_app_dispatcher_config_proto_init() {
if File_app_dispatcher_config_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_app_dispatcher_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SessionConfig); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_dispatcher_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Config); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_app_dispatcher_config_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_app_dispatcher_config_proto_goTypes,
DependencyIndexes: file_app_dispatcher_config_proto_depIdxs,
MessageInfos: file_app_dispatcher_config_proto_msgTypes,
}.Build()
File_app_dispatcher_config_proto = out.File
file_app_dispatcher_config_proto_rawDesc = nil
file_app_dispatcher_config_proto_goTypes = nil
file_app_dispatcher_config_proto_depIdxs = nil
}

View File

@ -2,13 +2,12 @@ syntax = "proto3";
package v2ray.core.app.dispatcher;
option csharp_namespace = "V2Ray.Core.App.Dispatcher";
option go_package = "dispatcher";
option go_package = "v2ray.com/core/app/dispatcher";
option java_package = "com.v2ray.core.app.dispatcher";
option java_multiple_files = true;
message SessionConfig {
reserved 1;
}
message Config {

View File

@ -2,7 +2,7 @@
package dispatcher
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen
import (
"context"
@ -20,6 +20,7 @@ import (
"v2ray.com/core/features/outbound"
"v2ray.com/core/features/policy"
"v2ray.com/core/features/routing"
routing_session "v2ray.com/core/features/routing/session"
"v2ray.com/core/features/stats"
"v2ray.com/core/transport"
"v2ray.com/core/transport/pipe"
@ -265,7 +266,8 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
}
if d.router != nil && !skipRoutePick {
if tag, err := d.router.PickRoute(ctx); err == nil {
if route, err := d.router.PickRoute(routing_session.AsRoutingContext(ctx)); err == nil {
tag := route.GetOutboundTag()
if h := d.ohm.GetHandler(tag); h != nil {
newError("taking detour [", tag, "] for [", destination, "]").WriteToLog(session.ExportIDToError(ctx))
handler = h

View File

@ -2,4 +2,4 @@
package dispatcher
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen

View File

@ -1,23 +1,31 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.13.0
// source: app/dns/config.proto
package dns
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
router "v2ray.com/core/app/router"
net "v2ray.com/core/common/net"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type DomainMatchingType int32
@ -28,333 +36,623 @@ const (
DomainMatchingType_Regex DomainMatchingType = 3
)
var DomainMatchingType_name = map[int32]string{
0: "Full",
1: "Subdomain",
2: "Keyword",
3: "Regex",
}
// Enum value maps for DomainMatchingType.
var (
DomainMatchingType_name = map[int32]string{
0: "Full",
1: "Subdomain",
2: "Keyword",
3: "Regex",
}
DomainMatchingType_value = map[string]int32{
"Full": 0,
"Subdomain": 1,
"Keyword": 2,
"Regex": 3,
}
)
var DomainMatchingType_value = map[string]int32{
"Full": 0,
"Subdomain": 1,
"Keyword": 2,
"Regex": 3,
func (x DomainMatchingType) Enum() *DomainMatchingType {
p := new(DomainMatchingType)
*p = x
return p
}
func (x DomainMatchingType) String() string {
return proto.EnumName(DomainMatchingType_name, int32(x))
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (DomainMatchingType) Descriptor() protoreflect.EnumDescriptor {
return file_app_dns_config_proto_enumTypes[0].Descriptor()
}
func (DomainMatchingType) Type() protoreflect.EnumType {
return &file_app_dns_config_proto_enumTypes[0]
}
func (x DomainMatchingType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use DomainMatchingType.Descriptor instead.
func (DomainMatchingType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_ed5695198e3def8f, []int{0}
return file_app_dns_config_proto_rawDescGZIP(), []int{0}
}
type NameServer struct {
Address *net.Endpoint `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
PrioritizedDomain []*NameServer_PriorityDomain `protobuf:"bytes,2,rep,name=prioritized_domain,json=prioritizedDomain,proto3" json:"prioritized_domain,omitempty"`
Geoip []*router.GeoIP `protobuf:"bytes,3,rep,name=geoip,proto3" json:"geoip,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Address *net.Endpoint `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
PrioritizedDomain []*NameServer_PriorityDomain `protobuf:"bytes,2,rep,name=prioritized_domain,json=prioritizedDomain,proto3" json:"prioritized_domain,omitempty"`
Geoip []*router.GeoIP `protobuf:"bytes,3,rep,name=geoip,proto3" json:"geoip,omitempty"`
OriginalRules []*NameServer_OriginalRule `protobuf:"bytes,4,rep,name=original_rules,json=originalRules,proto3" json:"original_rules,omitempty"`
}
func (m *NameServer) Reset() { *m = NameServer{} }
func (m *NameServer) String() string { return proto.CompactTextString(m) }
func (*NameServer) ProtoMessage() {}
func (x *NameServer) Reset() {
*x = NameServer{}
if protoimpl.UnsafeEnabled {
mi := &file_app_dns_config_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *NameServer) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NameServer) ProtoMessage() {}
func (x *NameServer) ProtoReflect() protoreflect.Message {
mi := &file_app_dns_config_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NameServer.ProtoReflect.Descriptor instead.
func (*NameServer) Descriptor() ([]byte, []int) {
return fileDescriptor_ed5695198e3def8f, []int{0}
return file_app_dns_config_proto_rawDescGZIP(), []int{0}
}
func (m *NameServer) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NameServer.Unmarshal(m, b)
}
func (m *NameServer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_NameServer.Marshal(b, m, deterministic)
}
func (m *NameServer) XXX_Merge(src proto.Message) {
xxx_messageInfo_NameServer.Merge(m, src)
}
func (m *NameServer) XXX_Size() int {
return xxx_messageInfo_NameServer.Size(m)
}
func (m *NameServer) XXX_DiscardUnknown() {
xxx_messageInfo_NameServer.DiscardUnknown(m)
}
var xxx_messageInfo_NameServer proto.InternalMessageInfo
func (m *NameServer) GetAddress() *net.Endpoint {
if m != nil {
return m.Address
func (x *NameServer) GetAddress() *net.Endpoint {
if x != nil {
return x.Address
}
return nil
}
func (m *NameServer) GetPrioritizedDomain() []*NameServer_PriorityDomain {
if m != nil {
return m.PrioritizedDomain
func (x *NameServer) GetPrioritizedDomain() []*NameServer_PriorityDomain {
if x != nil {
return x.PrioritizedDomain
}
return nil
}
func (m *NameServer) GetGeoip() []*router.GeoIP {
if m != nil {
return m.Geoip
func (x *NameServer) GetGeoip() []*router.GeoIP {
if x != nil {
return x.Geoip
}
return nil
}
type NameServer_PriorityDomain struct {
Type DomainMatchingType `protobuf:"varint,1,opt,name=type,proto3,enum=v2ray.core.app.dns.DomainMatchingType" json:"type,omitempty"`
Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *NameServer_PriorityDomain) Reset() { *m = NameServer_PriorityDomain{} }
func (m *NameServer_PriorityDomain) String() string { return proto.CompactTextString(m) }
func (*NameServer_PriorityDomain) ProtoMessage() {}
func (*NameServer_PriorityDomain) Descriptor() ([]byte, []int) {
return fileDescriptor_ed5695198e3def8f, []int{0, 0}
}
func (m *NameServer_PriorityDomain) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NameServer_PriorityDomain.Unmarshal(m, b)
}
func (m *NameServer_PriorityDomain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_NameServer_PriorityDomain.Marshal(b, m, deterministic)
}
func (m *NameServer_PriorityDomain) XXX_Merge(src proto.Message) {
xxx_messageInfo_NameServer_PriorityDomain.Merge(m, src)
}
func (m *NameServer_PriorityDomain) XXX_Size() int {
return xxx_messageInfo_NameServer_PriorityDomain.Size(m)
}
func (m *NameServer_PriorityDomain) XXX_DiscardUnknown() {
xxx_messageInfo_NameServer_PriorityDomain.DiscardUnknown(m)
}
var xxx_messageInfo_NameServer_PriorityDomain proto.InternalMessageInfo
func (m *NameServer_PriorityDomain) GetType() DomainMatchingType {
if m != nil {
return m.Type
func (x *NameServer) GetOriginalRules() []*NameServer_OriginalRule {
if x != nil {
return x.OriginalRules
}
return DomainMatchingType_Full
}
func (m *NameServer_PriorityDomain) GetDomain() string {
if m != nil {
return m.Domain
}
return ""
return nil
}
type Config struct {
// Nameservers used by this DNS. Only traditional UDP servers are support at the moment.
// A special value 'localhost' as a domain address can be set to use DNS on local system.
NameServers []*net.Endpoint `protobuf:"bytes,1,rep,name=NameServers,proto3" json:"NameServers,omitempty"` // Deprecated: Do not use.
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Nameservers used by this DNS. Only traditional UDP servers are support at
// the moment. A special value 'localhost' as a domain address can be set to
// use DNS on local system.
//
// Deprecated: Do not use.
NameServers []*net.Endpoint `protobuf:"bytes,1,rep,name=NameServers,proto3" json:"NameServers,omitempty"`
// NameServer list used by this DNS client.
NameServer []*NameServer `protobuf:"bytes,5,rep,name=name_server,json=nameServer,proto3" json:"name_server,omitempty"`
// Static hosts. Domain to IP.
// Deprecated. Use static_hosts.
Hosts map[string]*net.IPOrDomain `protobuf:"bytes,2,rep,name=Hosts,proto3" json:"Hosts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // Deprecated: Do not use.
// Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes (IPv6).
//
// Deprecated: Do not use.
Hosts map[string]*net.IPOrDomain `protobuf:"bytes,2,rep,name=Hosts,proto3" json:"Hosts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
// Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes
// (IPv6).
ClientIp []byte `protobuf:"bytes,3,opt,name=client_ip,json=clientIp,proto3" json:"client_ip,omitempty"`
StaticHosts []*Config_HostMapping `protobuf:"bytes,4,rep,name=static_hosts,json=staticHosts,proto3" json:"static_hosts,omitempty"`
// Tag is the inbound tag of DNS client.
Tag string `protobuf:"bytes,6,opt,name=tag,proto3" json:"tag,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Tag string `protobuf:"bytes,6,opt,name=tag,proto3" json:"tag,omitempty"`
}
func (m *Config) Reset() { *m = Config{} }
func (m *Config) String() string { return proto.CompactTextString(m) }
func (*Config) ProtoMessage() {}
func (x *Config) Reset() {
*x = Config{}
if protoimpl.UnsafeEnabled {
mi := &file_app_dns_config_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Config) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Config) ProtoMessage() {}
func (x *Config) ProtoReflect() protoreflect.Message {
mi := &file_app_dns_config_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
func (*Config) Descriptor() ([]byte, []int) {
return fileDescriptor_ed5695198e3def8f, []int{1}
return file_app_dns_config_proto_rawDescGZIP(), []int{1}
}
func (m *Config) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Config.Unmarshal(m, b)
}
func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Config.Marshal(b, m, deterministic)
}
func (m *Config) XXX_Merge(src proto.Message) {
xxx_messageInfo_Config.Merge(m, src)
}
func (m *Config) XXX_Size() int {
return xxx_messageInfo_Config.Size(m)
}
func (m *Config) XXX_DiscardUnknown() {
xxx_messageInfo_Config.DiscardUnknown(m)
}
var xxx_messageInfo_Config proto.InternalMessageInfo
// Deprecated: Do not use.
func (m *Config) GetNameServers() []*net.Endpoint {
if m != nil {
return m.NameServers
func (x *Config) GetNameServers() []*net.Endpoint {
if x != nil {
return x.NameServers
}
return nil
}
func (m *Config) GetNameServer() []*NameServer {
if m != nil {
return m.NameServer
func (x *Config) GetNameServer() []*NameServer {
if x != nil {
return x.NameServer
}
return nil
}
// Deprecated: Do not use.
func (m *Config) GetHosts() map[string]*net.IPOrDomain {
if m != nil {
return m.Hosts
func (x *Config) GetHosts() map[string]*net.IPOrDomain {
if x != nil {
return x.Hosts
}
return nil
}
func (m *Config) GetClientIp() []byte {
if m != nil {
return m.ClientIp
func (x *Config) GetClientIp() []byte {
if x != nil {
return x.ClientIp
}
return nil
}
func (m *Config) GetStaticHosts() []*Config_HostMapping {
if m != nil {
return m.StaticHosts
func (x *Config) GetStaticHosts() []*Config_HostMapping {
if x != nil {
return x.StaticHosts
}
return nil
}
func (m *Config) GetTag() string {
if m != nil {
return m.Tag
func (x *Config) GetTag() string {
if x != nil {
return x.Tag
}
return ""
}
type Config_HostMapping struct {
type NameServer_PriorityDomain struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Type DomainMatchingType `protobuf:"varint,1,opt,name=type,proto3,enum=v2ray.core.app.dns.DomainMatchingType" json:"type,omitempty"`
Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"`
Ip [][]byte `protobuf:"bytes,3,rep,name=ip,proto3" json:"ip,omitempty"`
// ProxiedDomain indicates the mapped domain has the same IP address on this domain. V2Ray will use this domain for IP queries.
// This field is only effective if ip is empty.
ProxiedDomain string `protobuf:"bytes,4,opt,name=proxied_domain,json=proxiedDomain,proto3" json:"proxied_domain,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Config_HostMapping) Reset() { *m = Config_HostMapping{} }
func (m *Config_HostMapping) String() string { return proto.CompactTextString(m) }
func (*Config_HostMapping) ProtoMessage() {}
func (*Config_HostMapping) Descriptor() ([]byte, []int) {
return fileDescriptor_ed5695198e3def8f, []int{1, 1}
func (x *NameServer_PriorityDomain) Reset() {
*x = NameServer_PriorityDomain{}
if protoimpl.UnsafeEnabled {
mi := &file_app_dns_config_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (m *Config_HostMapping) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Config_HostMapping.Unmarshal(m, b)
}
func (m *Config_HostMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Config_HostMapping.Marshal(b, m, deterministic)
}
func (m *Config_HostMapping) XXX_Merge(src proto.Message) {
xxx_messageInfo_Config_HostMapping.Merge(m, src)
}
func (m *Config_HostMapping) XXX_Size() int {
return xxx_messageInfo_Config_HostMapping.Size(m)
}
func (m *Config_HostMapping) XXX_DiscardUnknown() {
xxx_messageInfo_Config_HostMapping.DiscardUnknown(m)
func (x *NameServer_PriorityDomain) String() string {
return protoimpl.X.MessageStringOf(x)
}
var xxx_messageInfo_Config_HostMapping proto.InternalMessageInfo
func (*NameServer_PriorityDomain) ProtoMessage() {}
func (m *Config_HostMapping) GetType() DomainMatchingType {
if m != nil {
return m.Type
func (x *NameServer_PriorityDomain) ProtoReflect() protoreflect.Message {
mi := &file_app_dns_config_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NameServer_PriorityDomain.ProtoReflect.Descriptor instead.
func (*NameServer_PriorityDomain) Descriptor() ([]byte, []int) {
return file_app_dns_config_proto_rawDescGZIP(), []int{0, 0}
}
func (x *NameServer_PriorityDomain) GetType() DomainMatchingType {
if x != nil {
return x.Type
}
return DomainMatchingType_Full
}
func (m *Config_HostMapping) GetDomain() string {
if m != nil {
return m.Domain
func (x *NameServer_PriorityDomain) GetDomain() string {
if x != nil {
return x.Domain
}
return ""
}
func (m *Config_HostMapping) GetIp() [][]byte {
if m != nil {
return m.Ip
type NameServer_OriginalRule struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Rule string `protobuf:"bytes,1,opt,name=rule,proto3" json:"rule,omitempty"`
Size uint32 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"`
}
func (x *NameServer_OriginalRule) Reset() {
*x = NameServer_OriginalRule{}
if protoimpl.UnsafeEnabled {
mi := &file_app_dns_config_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *NameServer_OriginalRule) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NameServer_OriginalRule) ProtoMessage() {}
func (x *NameServer_OriginalRule) ProtoReflect() protoreflect.Message {
mi := &file_app_dns_config_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NameServer_OriginalRule.ProtoReflect.Descriptor instead.
func (*NameServer_OriginalRule) Descriptor() ([]byte, []int) {
return file_app_dns_config_proto_rawDescGZIP(), []int{0, 1}
}
func (x *NameServer_OriginalRule) GetRule() string {
if x != nil {
return x.Rule
}
return ""
}
func (x *NameServer_OriginalRule) GetSize() uint32 {
if x != nil {
return x.Size
}
return 0
}
type Config_HostMapping struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Type DomainMatchingType `protobuf:"varint,1,opt,name=type,proto3,enum=v2ray.core.app.dns.DomainMatchingType" json:"type,omitempty"`
Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"`
Ip [][]byte `protobuf:"bytes,3,rep,name=ip,proto3" json:"ip,omitempty"`
// ProxiedDomain indicates the mapped domain has the same IP address on this
// domain. V2Ray will use this domain for IP queries. This field is only
// effective if ip is empty.
ProxiedDomain string `protobuf:"bytes,4,opt,name=proxied_domain,json=proxiedDomain,proto3" json:"proxied_domain,omitempty"`
}
func (x *Config_HostMapping) Reset() {
*x = Config_HostMapping{}
if protoimpl.UnsafeEnabled {
mi := &file_app_dns_config_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Config_HostMapping) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Config_HostMapping) ProtoMessage() {}
func (x *Config_HostMapping) ProtoReflect() protoreflect.Message {
mi := &file_app_dns_config_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Config_HostMapping.ProtoReflect.Descriptor instead.
func (*Config_HostMapping) Descriptor() ([]byte, []int) {
return file_app_dns_config_proto_rawDescGZIP(), []int{1, 1}
}
func (x *Config_HostMapping) GetType() DomainMatchingType {
if x != nil {
return x.Type
}
return DomainMatchingType_Full
}
func (x *Config_HostMapping) GetDomain() string {
if x != nil {
return x.Domain
}
return ""
}
func (x *Config_HostMapping) GetIp() [][]byte {
if x != nil {
return x.Ip
}
return nil
}
func (m *Config_HostMapping) GetProxiedDomain() string {
if m != nil {
return m.ProxiedDomain
func (x *Config_HostMapping) GetProxiedDomain() string {
if x != nil {
return x.ProxiedDomain
}
return ""
}
func init() {
proto.RegisterEnum("v2ray.core.app.dns.DomainMatchingType", DomainMatchingType_name, DomainMatchingType_value)
proto.RegisterType((*NameServer)(nil), "v2ray.core.app.dns.NameServer")
proto.RegisterType((*NameServer_PriorityDomain)(nil), "v2ray.core.app.dns.NameServer.PriorityDomain")
proto.RegisterType((*Config)(nil), "v2ray.core.app.dns.Config")
proto.RegisterMapType((map[string]*net.IPOrDomain)(nil), "v2ray.core.app.dns.Config.HostsEntry")
proto.RegisterType((*Config_HostMapping)(nil), "v2ray.core.app.dns.Config.HostMapping")
var File_app_dns_config_proto protoreflect.FileDescriptor
var file_app_dns_config_proto_rawDesc = []byte{
0x0a, 0x14, 0x61, 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f,
0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x1a, 0x18, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74,
0x2f, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x1a, 0x17, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63,
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcb, 0x03, 0x0a, 0x0a,
0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x39, 0x0a, 0x07, 0x61, 0x64,
0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x76, 0x32,
0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e,
0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x64,
0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x5c, 0x0a, 0x12, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74,
0x69, 0x7a, 0x65, 0x64, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x2d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61,
0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65,
0x72, 0x2e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e,
0x52, 0x11, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x69, 0x7a, 0x65, 0x64, 0x44, 0x6f, 0x6d,
0x61, 0x69, 0x6e, 0x12, 0x32, 0x0a, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e,
0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50,
0x52, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x52, 0x0a, 0x0e, 0x6f, 0x72, 0x69, 0x67, 0x69,
0x6e, 0x61, 0x6c, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x2b, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70,
0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e,
0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x0d, 0x6f, 0x72,
0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x1a, 0x64, 0x0a, 0x0e, 0x50,
0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x3a, 0x0a,
0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x76, 0x32,
0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73,
0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54,
0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d,
0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69,
0x6e, 0x1a, 0x36, 0x0a, 0x0c, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c,
0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0xc3, 0x04, 0x0a, 0x06, 0x43, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x12, 0x45, 0x0a, 0x0b, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76,
0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x76, 0x32, 0x72, 0x61,
0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65,
0x74, 0x2e, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0b,
0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x12, 0x3f, 0x0a, 0x0b, 0x6e,
0x61, 0x6d, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x1e, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70,
0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72,
0x52, 0x0a, 0x6e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x3f, 0x0a, 0x05,
0x48, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x76, 0x32,
0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73,
0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x45, 0x6e, 0x74,
0x72, 0x79, 0x42, 0x02, 0x18, 0x01, 0x52, 0x05, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x1b, 0x0a,
0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c,
0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x70, 0x12, 0x49, 0x0a, 0x0c, 0x73, 0x74,
0x61, 0x74, 0x69, 0x63, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x26, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70,
0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x6f, 0x73,
0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63,
0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x06, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x1a, 0x5b, 0x0a, 0x0a, 0x48, 0x6f, 0x73, 0x74, 0x73,
0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x37, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63,
0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49,
0x50, 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
0x3a, 0x02, 0x38, 0x01, 0x1a, 0x98, 0x01, 0x0a, 0x0b, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70,
0x70, 0x69, 0x6e, 0x67, 0x12, 0x3a, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0e, 0x32, 0x26, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e,
0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61,
0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65,
0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03,
0x20, 0x03, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x70, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78,
0x69, 0x65, 0x64, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2a,
0x45, 0x0a, 0x12, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e,
0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x75, 0x6c, 0x6c, 0x10, 0x00, 0x12,
0x0d, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x10, 0x01, 0x12, 0x0b,
0x0a, 0x07, 0x4b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x52,
0x65, 0x67, 0x65, 0x78, 0x10, 0x03, 0x42, 0x47, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32,
0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73,
0x50, 0x01, 0x5a, 0x16, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f,
0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0xaa, 0x02, 0x12, 0x56, 0x32, 0x52,
0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x44, 0x6e, 0x73, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
func init() {
proto.RegisterFile("v2ray.com/core/app/dns/config.proto", fileDescriptor_ed5695198e3def8f)
var (
file_app_dns_config_proto_rawDescOnce sync.Once
file_app_dns_config_proto_rawDescData = file_app_dns_config_proto_rawDesc
)
func file_app_dns_config_proto_rawDescGZIP() []byte {
file_app_dns_config_proto_rawDescOnce.Do(func() {
file_app_dns_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_dns_config_proto_rawDescData)
})
return file_app_dns_config_proto_rawDescData
}
var fileDescriptor_ed5695198e3def8f = []byte{
// 583 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xdf, 0x6e, 0xd3, 0x3e,
0x18, 0xfd, 0x25, 0xfd, 0xb3, 0xf5, 0xcb, 0x56, 0xf5, 0xe7, 0x8b, 0x29, 0x2a, 0x08, 0xc6, 0xd0,
0x46, 0x05, 0xc2, 0x91, 0x02, 0x12, 0xb0, 0x9b, 0x89, 0x6d, 0x05, 0x2a, 0x34, 0xa8, 0x3c, 0xc4,
0x05, 0x20, 0x55, 0x5e, 0x62, 0x32, 0x8b, 0xc6, 0xb6, 0x1c, 0x77, 0x2c, 0x3c, 0x09, 0xcf, 0xc0,
0x4b, 0x70, 0xc1, 0x8b, 0xa1, 0xda, 0x19, 0xed, 0xb6, 0x0e, 0xb8, 0xe1, 0xce, 0x7f, 0xce, 0xf9,
0xce, 0xf9, 0x8e, 0xbf, 0x04, 0x6e, 0x9f, 0xc4, 0x9a, 0x96, 0x38, 0x91, 0x79, 0x94, 0x48, 0xcd,
0x22, 0xaa, 0x54, 0x94, 0x8a, 0x22, 0x4a, 0xa4, 0xf8, 0xc8, 0x33, 0xac, 0xb4, 0x34, 0x12, 0xa1,
0x33, 0x90, 0x66, 0x98, 0x2a, 0x85, 0x53, 0x51, 0x74, 0xef, 0x5c, 0x20, 0x26, 0x32, 0xcf, 0xa5,
0x88, 0x04, 0x33, 0x11, 0x4d, 0x53, 0xcd, 0x8a, 0xc2, 0x91, 0xbb, 0xf7, 0xae, 0x06, 0xa6, 0xac,
0x30, 0x5c, 0x50, 0xc3, 0xa5, 0xa8, 0xc0, 0x5b, 0x0b, 0xec, 0x68, 0x39, 0x31, 0x4c, 0x9f, 0x73,
0xb4, 0xf1, 0xdd, 0x07, 0x78, 0x45, 0x73, 0x76, 0xc8, 0xf4, 0x09, 0xd3, 0xe8, 0x09, 0x2c, 0x55,
0xa2, 0xa1, 0xb7, 0xee, 0xf5, 0x82, 0xf8, 0x26, 0x9e, 0xb3, 0xec, 0x14, 0xb1, 0x60, 0x06, 0xf7,
0x45, 0xaa, 0x24, 0x17, 0x86, 0x9c, 0xe1, 0xd1, 0x07, 0x40, 0x4a, 0x73, 0xa9, 0xb9, 0xe1, 0x5f,
0x58, 0x3a, 0x4a, 0x65, 0x4e, 0xb9, 0x08, 0xfd, 0xf5, 0x5a, 0x2f, 0x88, 0xef, 0xe3, 0xcb, 0x8d,
0xe3, 0x99, 0x2c, 0x1e, 0x3a, 0x62, 0xb9, 0x6f, 0x49, 0xe4, 0xff, 0xb9, 0x42, 0xee, 0x08, 0xc5,
0xd0, 0xc8, 0x98, 0xe4, 0x2a, 0xac, 0xd9, 0x82, 0xd7, 0x2f, 0x16, 0x74, 0xbd, 0xe1, 0xe7, 0x4c,
0x0e, 0x86, 0xc4, 0x41, 0xbb, 0x29, 0xb4, 0xcf, 0x17, 0x46, 0xdb, 0x50, 0x37, 0xa5, 0x62, 0xb6,
0xb7, 0x76, 0xbc, 0xb5, 0xc8, 0x95, 0x43, 0x1e, 0x50, 0x93, 0x1c, 0x73, 0x91, 0xbd, 0x29, 0x15,
0x23, 0x96, 0x83, 0xd6, 0xa0, 0xf9, 0xab, 0x27, 0xaf, 0xd7, 0x22, 0xd5, 0x6e, 0xe3, 0x47, 0x1d,
0x9a, 0x7b, 0x36, 0x52, 0xd4, 0x87, 0x60, 0xd6, 0xd4, 0x34, 0xc1, 0xda, 0x5f, 0x24, 0xb8, 0xeb,
0x87, 0x1e, 0x99, 0xe7, 0xa1, 0x1d, 0x08, 0x04, 0xcd, 0xd9, 0xa8, 0xb0, 0xfb, 0xb0, 0x61, 0xcb,
0xdc, 0xf8, 0x7d, 0x84, 0x04, 0xc4, 0xec, 0x15, 0x77, 0xa0, 0xf1, 0x42, 0x16, 0xa6, 0xa8, 0xd2,
0xdf, 0x5c, 0x44, 0x75, 0x96, 0xb1, 0xc5, 0xf5, 0x85, 0xd1, 0xa5, 0xf5, 0xe1, 0x78, 0xe8, 0x1a,
0xb4, 0x92, 0x31, 0x67, 0xc2, 0x8c, 0x6c, 0xe2, 0x5e, 0x6f, 0x85, 0x2c, 0xbb, 0x83, 0x81, 0x42,
0x03, 0x58, 0x29, 0x0c, 0x35, 0x3c, 0x19, 0x1d, 0x5b, 0x91, 0xba, 0x15, 0xd9, 0xfa, 0x83, 0xc8,
0x01, 0x55, 0x8a, 0x8b, 0x8c, 0x04, 0x8e, 0xeb, 0x74, 0x3a, 0x50, 0x33, 0x34, 0x0b, 0x9b, 0x36,
0xd0, 0xe9, 0xb2, 0xfb, 0x1e, 0x60, 0x66, 0x69, 0x7a, 0xff, 0x89, 0x95, 0xf6, 0xb9, 0x5a, 0x64,
0xba, 0x44, 0x8f, 0xa0, 0x71, 0x42, 0xc7, 0x13, 0x66, 0x1f, 0x21, 0x88, 0x6f, 0x5d, 0x11, 0xee,
0x60, 0xf8, 0x5a, 0x57, 0xc3, 0xe4, 0xf0, 0xdb, 0xfe, 0x63, 0xaf, 0xfb, 0xd5, 0x83, 0x60, 0xce,
0xcb, 0xbf, 0x18, 0x07, 0xd4, 0x06, 0xbf, 0x9a, 0xd2, 0x15, 0xe2, 0x73, 0x85, 0x36, 0xa1, 0xad,
0xb4, 0x3c, 0xe5, 0xb3, 0x4f, 0xa2, 0x6e, 0xf1, 0xab, 0xd5, 0xa9, 0x13, 0xb8, 0xdb, 0x07, 0x74,
0x59, 0x0a, 0x2d, 0x43, 0xfd, 0xd9, 0x64, 0x3c, 0xee, 0xfc, 0x87, 0x56, 0xa1, 0x75, 0x38, 0x39,
0x72, 0x15, 0x3a, 0x1e, 0x0a, 0x60, 0xe9, 0x25, 0x2b, 0x3f, 0x4b, 0x9d, 0x76, 0x7c, 0xd4, 0x82,
0x06, 0x61, 0x19, 0x3b, 0xed, 0xd4, 0x76, 0x1f, 0xc2, 0x5a, 0x22, 0xf3, 0x05, 0x8d, 0x0c, 0xbd,
0x77, 0xb5, 0x54, 0x14, 0xdf, 0x7c, 0xf4, 0x36, 0x26, 0xb4, 0xc4, 0x7b, 0xd3, 0xbb, 0xa7, 0x4a,
0xe1, 0x7d, 0x51, 0x1c, 0x35, 0xed, 0xbf, 0xe0, 0xc1, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4c,
0x2a, 0x66, 0x8a, 0xc4, 0x04, 0x00, 0x00,
var file_app_dns_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_app_dns_config_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_app_dns_config_proto_goTypes = []interface{}{
(DomainMatchingType)(0), // 0: v2ray.core.app.dns.DomainMatchingType
(*NameServer)(nil), // 1: v2ray.core.app.dns.NameServer
(*Config)(nil), // 2: v2ray.core.app.dns.Config
(*NameServer_PriorityDomain)(nil), // 3: v2ray.core.app.dns.NameServer.PriorityDomain
(*NameServer_OriginalRule)(nil), // 4: v2ray.core.app.dns.NameServer.OriginalRule
nil, // 5: v2ray.core.app.dns.Config.HostsEntry
(*Config_HostMapping)(nil), // 6: v2ray.core.app.dns.Config.HostMapping
(*net.Endpoint)(nil), // 7: v2ray.core.common.net.Endpoint
(*router.GeoIP)(nil), // 8: v2ray.core.app.router.GeoIP
(*net.IPOrDomain)(nil), // 9: v2ray.core.common.net.IPOrDomain
}
var file_app_dns_config_proto_depIdxs = []int32{
7, // 0: v2ray.core.app.dns.NameServer.address:type_name -> v2ray.core.common.net.Endpoint
3, // 1: v2ray.core.app.dns.NameServer.prioritized_domain:type_name -> v2ray.core.app.dns.NameServer.PriorityDomain
8, // 2: v2ray.core.app.dns.NameServer.geoip:type_name -> v2ray.core.app.router.GeoIP
4, // 3: v2ray.core.app.dns.NameServer.original_rules:type_name -> v2ray.core.app.dns.NameServer.OriginalRule
7, // 4: v2ray.core.app.dns.Config.NameServers:type_name -> v2ray.core.common.net.Endpoint
1, // 5: v2ray.core.app.dns.Config.name_server:type_name -> v2ray.core.app.dns.NameServer
5, // 6: v2ray.core.app.dns.Config.Hosts:type_name -> v2ray.core.app.dns.Config.HostsEntry
6, // 7: v2ray.core.app.dns.Config.static_hosts:type_name -> v2ray.core.app.dns.Config.HostMapping
0, // 8: v2ray.core.app.dns.NameServer.PriorityDomain.type:type_name -> v2ray.core.app.dns.DomainMatchingType
9, // 9: v2ray.core.app.dns.Config.HostsEntry.value:type_name -> v2ray.core.common.net.IPOrDomain
0, // 10: v2ray.core.app.dns.Config.HostMapping.type:type_name -> v2ray.core.app.dns.DomainMatchingType
11, // [11:11] is the sub-list for method output_type
11, // [11:11] is the sub-list for method input_type
11, // [11:11] is the sub-list for extension type_name
11, // [11:11] is the sub-list for extension extendee
0, // [0:11] is the sub-list for field type_name
}
func init() { file_app_dns_config_proto_init() }
func file_app_dns_config_proto_init() {
if File_app_dns_config_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_app_dns_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NameServer); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_dns_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Config); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_dns_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NameServer_PriorityDomain); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_dns_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NameServer_OriginalRule); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_dns_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Config_HostMapping); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_app_dns_config_proto_rawDesc,
NumEnums: 1,
NumMessages: 6,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_app_dns_config_proto_goTypes,
DependencyIndexes: file_app_dns_config_proto_depIdxs,
EnumInfos: file_app_dns_config_proto_enumTypes,
MessageInfos: file_app_dns_config_proto_msgTypes,
}.Build()
File_app_dns_config_proto = out.File
file_app_dns_config_proto_rawDesc = nil
file_app_dns_config_proto_goTypes = nil
file_app_dns_config_proto_depIdxs = nil
}

View File

@ -2,13 +2,13 @@ syntax = "proto3";
package v2ray.core.app.dns;
option csharp_namespace = "V2Ray.Core.App.Dns";
option go_package = "dns";
option go_package = "v2ray.com/core/app/dns";
option java_package = "com.v2ray.core.app.dns";
option java_multiple_files = true;
import "v2ray.com/core/common/net/address.proto";
import "v2ray.com/core/common/net/destination.proto";
import "v2ray.com/core/app/router/config.proto";
import "common/net/address.proto";
import "common/net/destination.proto";
import "app/router/config.proto";
message NameServer {
v2ray.core.common.net.Endpoint address = 1;
@ -18,8 +18,14 @@ message NameServer {
string domain = 2;
}
message OriginalRule {
string rule = 1;
uint32 size = 2;
}
repeated PriorityDomain prioritized_domain = 2;
repeated v2ray.core.app.router.GeoIP geoip = 3;
repeated OriginalRule original_rules = 4;
}
enum DomainMatchingType {
@ -30,8 +36,9 @@ enum DomainMatchingType {
}
message Config {
// Nameservers used by this DNS. Only traditional UDP servers are support at the moment.
// A special value 'localhost' as a domain address can be set to use DNS on local system.
// Nameservers used by this DNS. Only traditional UDP servers are support at
// the moment. A special value 'localhost' as a domain address can be set to
// use DNS on local system.
repeated v2ray.core.common.net.Endpoint NameServers = 1 [deprecated = true];
// NameServer list used by this DNS client.
@ -41,7 +48,8 @@ message Config {
// Deprecated. Use static_hosts.
map<string, v2ray.core.common.net.IPOrDomain> Hosts = 2 [deprecated = true];
// Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes (IPv6).
// Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes
// (IPv6).
bytes client_ip = 3;
message HostMapping {
@ -50,8 +58,9 @@ message Config {
repeated bytes ip = 3;
// ProxiedDomain indicates the mapped domain has the same IP address on this domain. V2Ray will use this domain for IP queries.
// This field is only effective if ip is empty.
// ProxiedDomain indicates the mapped domain has the same IP address on this
// domain. V2Ray will use this domain for IP queries. This field is only
// effective if ip is empty.
string proxied_domain = 4;
}

View File

@ -1,4 +1,4 @@
// Package dns is an implementation of core.DNS feature.
package dns
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen

View File

@ -12,14 +12,9 @@ import (
"golang.org/x/net/dns/dnsmessage"
"v2ray.com/core/common"
"v2ray.com/core/common/net"
v2net "v2ray.com/core/common/net"
)
func Test_parseResponse(t *testing.T) {
type args struct {
payload []byte
}
var p [][]byte
ans := new(dns.Msg)
@ -56,7 +51,7 @@ func Test_parseResponse(t *testing.T) {
wantErr bool
}{
{"empty",
&IPRecord{0, []v2net.Address(nil), time.Time{}, dnsmessage.RCodeSuccess},
&IPRecord{0, []net.Address(nil), time.Time{}, dnsmessage.RCodeSuccess},
false,
},
{"error",
@ -64,12 +59,12 @@ func Test_parseResponse(t *testing.T) {
true,
},
{"a record",
&IPRecord{1, []v2net.Address{v2net.ParseAddress("8.8.8.8"), v2net.ParseAddress("8.8.4.4")},
&IPRecord{1, []net.Address{net.ParseAddress("8.8.8.8"), net.ParseAddress("8.8.4.4")},
time.Time{}, dnsmessage.RCodeSuccess},
false,
},
{"aaaa record",
&IPRecord{2, []v2net.Address{v2net.ParseAddress("2001::123:8888"), v2net.ParseAddress("2001::123:8844")}, time.Time{}, dnsmessage.RCodeSuccess},
&IPRecord{2, []net.Address{net.ParseAddress("2001::123:8888"), net.ParseAddress("2001::123:8844")}, time.Time{}, dnsmessage.RCodeSuccess},
false,
},
}

View File

@ -14,8 +14,6 @@ import (
"sync/atomic"
"time"
dns_feature "v2ray.com/core/features/dns"
"golang.org/x/net/dns/dnsmessage"
"v2ray.com/core/common"
"v2ray.com/core/common/net"
@ -23,13 +21,14 @@ import (
"v2ray.com/core/common/session"
"v2ray.com/core/common/signal/pubsub"
"v2ray.com/core/common/task"
dns_feature "v2ray.com/core/features/dns"
"v2ray.com/core/features/routing"
"v2ray.com/core/transport/internet"
)
// DoHNameServer implimented DNS over HTTPS (RFC8484) Wire Format,
// which is compatiable with traditional dns over udp(RFC1035),
// thus most of the DOH implimentation is copied from udpns.go
// DoHNameServer implemented DNS over HTTPS (RFC8484) Wire Format,
// which is compatible with traditional dns over udp(RFC1035),
// thus most of the DOH implementation is copied from udpns.go
type DoHNameServer struct {
sync.RWMutex
ips map[string]record
@ -48,16 +47,17 @@ func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher, clientIP net.
newError("DNS: created Remote DOH client for ", url.String()).AtInfo().WriteToLog()
s := baseDOHNameServer(url, "DOH", clientIP)
// Dispatched connection will be closed (interupted) after each request
// This makes DOH inefficient without a keeped-alive connection
// Dispatched connection will be closed (interrupted) after each request
// This makes DOH inefficient without a keep-alived connection
// See: core/app/proxyman/outbound/handler.go:113
// Using mux (https request wrapped in a stream layer) improves the situation.
// Recommand to use NewDoHLocalNameServer (DOHL:) if v2ray instance is running on
// Recommend to use NewDoHLocalNameServer (DOHL:) if v2ray instance is running on
// a normal network eg. the server side of v2ray
tr := &http.Transport{
MaxIdleConns: 30,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 30 * time.Second,
ForceAttemptHTTP2: true,
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
dest, err := net.ParseDestination(network + ":" + addr)
if err != nil {
@ -89,7 +89,8 @@ func NewDoHLocalNameServer(url *url.URL, clientIP net.IP) *DoHNameServer {
url.Scheme = "https"
s := baseDOHNameServer(url, "DOHL", clientIP)
tr := &http.Transport{
IdleConnTimeout: 90 * time.Second,
IdleConnTimeout: 90 * time.Second,
ForceAttemptHTTP2: true,
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
dest, err := net.ParseDestination(network + ":" + addr)
if err != nil {
@ -191,7 +192,7 @@ func (s *DoHNameServer) updateIP(req *dnsRequest, ipRec *IPRecord) {
updated = true
}
}
newError(s.name, " got answere: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed).AtInfo().WriteToLog()
newError(s.name, " got answer: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed).AtInfo().WriteToLog()
if updated {
s.ips[req.domain] = rec
@ -219,13 +220,11 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPO
if d, ok := ctx.Deadline(); ok {
deadline = d
} else {
deadline = time.Now().Add(time.Second * 8)
deadline = time.Now().Add(time.Second * 5)
}
for _, req := range reqs {
go func(r *dnsRequest) {
// generate new context for each req, using same context
// may cause reqs all aborted if any one encounter an error
dnsCtx := context.Background()
@ -243,13 +242,18 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPO
// forced to use mux for DOH
dnsCtx = session.ContextWithMuxPrefered(dnsCtx, true)
dnsCtx, cancel := context.WithDeadline(dnsCtx, deadline)
var cancel context.CancelFunc
dnsCtx, cancel = context.WithDeadline(dnsCtx, deadline)
defer cancel()
b, _ := dns.PackMessage(r.msg)
b, err := dns.PackMessage(r.msg)
if err != nil {
newError("failed to pack dns query").Base(err).AtError().WriteToLog()
return
}
resp, err := s.dohHTTPSContext(dnsCtx, b.Bytes())
if err != nil {
newError("failed to retrive response").Base(err).AtError().WriteToLog()
newError("failed to retrieve response").Base(err).AtError().WriteToLog()
return
}
rec, err := parseResponse(resp)
@ -263,7 +267,6 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPO
}
func (s *DoHNameServer) dohHTTPSContext(ctx context.Context, b []byte) ([]byte, error) {
body := bytes.NewBuffer(b)
req, err := http.NewRequest("POST", s.dohURL, body)
if err != nil {

View File

@ -106,11 +106,14 @@ func filterIP(ips []net.Address, option IPOption) []net.Address {
// LookupIP returns IP address for the given domain, if exists in this StaticHosts.
func (h *StaticHosts) LookupIP(domain string, option IPOption) []net.Address {
id := h.matchers.Match(domain)
if id == 0 {
indices := h.matchers.Match(domain)
if len(indices) == 0 {
return nil
}
ips := h.ips[id]
ips := []net.Address{}
for _, id := range indices {
ips = append(ips, h.ips[id]...)
}
if len(ips) == 1 && ips[0].Family().IsDomain() {
return ips
}

View File

@ -2,10 +2,11 @@
package dns
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen
import (
"context"
"fmt"
"log"
"net/url"
"strings"
@ -28,13 +29,20 @@ import (
// Server is a DNS rely server.
type Server struct {
sync.Mutex
hosts *StaticHosts
clients []Client
clientIP net.IP
domainMatcher strmatcher.IndexMatcher
domainIndexMap map[uint32]uint32
ipIndexMap map[uint32]*MultiGeoIPMatcher
tag string
hosts *StaticHosts
clientIP net.IP
clients []Client // clientIdx -> Client
ipIndexMap []*MultiGeoIPMatcher // clientIdx -> *MultiGeoIPMatcher
domainRules [][]string // clientIdx -> domainRuleIdx -> DomainRule
domainMatcher strmatcher.IndexMatcher
matcherInfos []DomainMatcherInfo // matcherIdx -> DomainMatcherInfo
tag string
}
// DomainMatcherInfo contains information attached to index returned by Server.domainMatcher
type DomainMatcherInfo struct {
clientIdx uint16
domainRuleIdx uint16
}
// MultiGeoIPMatcher for match
@ -86,10 +94,27 @@ func New(ctx context.Context, config *Config) (*Server, error) {
}
server.hosts = hosts
addNameServer := func(endpoint *net.Endpoint) int {
addNameServer := func(ns *NameServer) int {
endpoint := ns.Address
address := endpoint.Address.AsAddress()
if address.Family().IsDomain() && address.Domain() == "localhost" {
server.clients = append(server.clients, NewLocalNameServer())
// Priotize local domains with specific TLDs or without any dot to local DNS
// References:
// https://www.iana.org/assignments/special-use-domain-names/special-use-domain-names.xhtml
// https://unix.stackexchange.com/questions/92441/whats-the-difference-between-local-home-and-lan
localTLDsAndDotlessDomains := []*NameServer_PriorityDomain{
{Type: DomainMatchingType_Regex, Domain: "^[^.]+$"}, // This will only match domains without any dot
{Type: DomainMatchingType_Subdomain, Domain: "local"},
{Type: DomainMatchingType_Subdomain, Domain: "localdomain"},
{Type: DomainMatchingType_Subdomain, Domain: "localhost"},
{Type: DomainMatchingType_Subdomain, Domain: "lan"},
{Type: DomainMatchingType_Subdomain, Domain: "home.arpa"},
{Type: DomainMatchingType_Subdomain, Domain: "example"},
{Type: DomainMatchingType_Subdomain, Domain: "invalid"},
{Type: DomainMatchingType_Subdomain, Domain: "test"},
}
ns.PrioritizedDomain = append(ns.PrioritizedDomain, localTLDsAndDotlessDomains...)
} else if address.Family().IsDomain() && strings.HasPrefix(address.Domain(), "https+local://") {
// URI schemed string treated as domain
// DOH Local mode
@ -98,8 +123,7 @@ func New(ctx context.Context, config *Config) (*Server, error) {
log.Fatalln(newError("DNS config error").Base(err))
}
server.clients = append(server.clients, NewDoHLocalNameServer(u, server.clientIP))
} else if address.Family().IsDomain() &&
strings.HasPrefix(address.Domain(), "https://") {
} else if address.Family().IsDomain() && strings.HasPrefix(address.Domain(), "https://") {
// DOH Remote mode
u, err := url.Parse(address.Domain())
if err != nil {
@ -131,33 +155,66 @@ func New(ctx context.Context, config *Config) (*Server, error) {
}))
}
}
server.ipIndexMap = append(server.ipIndexMap, nil)
return len(server.clients) - 1
}
if len(config.NameServers) > 0 {
features.PrintDeprecatedFeatureWarning("simple DNS server")
for _, destPB := range config.NameServers {
addNameServer(destPB)
addNameServer(&NameServer{Address: destPB})
}
}
if len(config.NameServer) > 0 {
domainMatcher := &strmatcher.MatcherGroup{}
domainIndexMap := make(map[uint32]uint32)
ipIndexMap := make(map[uint32]*MultiGeoIPMatcher)
var geoIPMatcherContainer router.GeoIPMatcherContainer
clientIndices := []int{}
domainRuleCount := 0
for _, ns := range config.NameServer {
idx := addNameServer(ns.Address)
idx := addNameServer(ns)
clientIndices = append(clientIndices, idx)
domainRuleCount += len(ns.PrioritizedDomain)
}
domainRules := make([][]string, len(server.clients))
domainMatcher := &strmatcher.MatcherGroup{}
matcherInfos := make([]DomainMatcherInfo, domainRuleCount+1) // matcher index starts from 1
var geoIPMatcherContainer router.GeoIPMatcherContainer
for nidx, ns := range config.NameServer {
idx := clientIndices[nidx]
// Establish domain rule matcher
rules := []string{}
ruleCurr := 0
ruleIter := 0
for _, domain := range ns.PrioritizedDomain {
matcher, err := toStrMatcher(domain.Type, domain.Domain)
if err != nil {
return nil, newError("failed to create prioritized domain").Base(err).AtWarning()
}
midx := domainMatcher.Add(matcher)
domainIndexMap[midx] = uint32(idx)
if midx >= uint32(len(matcherInfos)) { // This rarely happens according to current matcher's implementation
newError("expanding domain matcher info array to size ", midx, " when adding ", matcher).AtDebug().WriteToLog()
matcherInfos = append(matcherInfos, make([]DomainMatcherInfo, midx-uint32(len(matcherInfos))+1)...)
}
info := &matcherInfos[midx]
info.clientIdx = uint16(idx)
if ruleCurr < len(ns.OriginalRules) {
info.domainRuleIdx = uint16(ruleCurr)
rule := ns.OriginalRules[ruleCurr]
if ruleCurr >= len(rules) {
rules = append(rules, rule.Rule)
}
ruleIter++
if ruleIter >= int(rule.Size) {
ruleIter = 0
ruleCurr++
}
} else { // No original rule, generate one according to current domain matcher (majorly for compatibility with tests)
info.domainRuleIdx = uint16(len(rules))
rules = append(rules, matcher.String())
}
}
domainRules[idx] = rules
// only add to ipIndexMap if GeoIP is configured
if len(ns.Geoip) > 0 {
@ -170,17 +227,17 @@ func New(ctx context.Context, config *Config) (*Server, error) {
matchers = append(matchers, matcher)
}
matcher := &MultiGeoIPMatcher{matchers: matchers}
ipIndexMap[uint32(idx)] = matcher
server.ipIndexMap[idx] = matcher
}
}
server.domainRules = domainRules
server.domainMatcher = domainMatcher
server.domainIndexMap = domainIndexMap
server.ipIndexMap = ipIndexMap
server.matcherInfos = matcherInfos
}
if len(server.clients) == 0 {
server.clients = append(server.clients, NewLocalNameServer())
server.ipIndexMap = append(server.ipIndexMap, nil)
}
return server, nil
@ -207,9 +264,12 @@ func (s *Server) IsOwnLink(ctx context.Context) bool {
}
// Match check dns ip match geoip
func (s *Server) Match(idx uint32, client Client, domain string, ips []net.IP) ([]net.IP, error) {
matcher, exist := s.ipIndexMap[idx]
if !exist {
func (s *Server) Match(idx int, client Client, domain string, ips []net.IP) ([]net.IP, error) {
var matcher *MultiGeoIPMatcher
if idx < len(s.ipIndexMap) {
matcher = s.ipIndexMap[idx]
}
if matcher == nil {
return ips, nil
}
@ -231,7 +291,7 @@ func (s *Server) Match(idx uint32, client Client, domain string, ips []net.IP) (
return newIps, nil
}
func (s *Server) queryIPTimeout(idx uint32, client Client, domain string, option IPOption) ([]net.IP, error) {
func (s *Server) queryIPTimeout(idx int, client Client, domain string, option IPOption) ([]net.IP, error) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*4)
if len(s.tag) > 0 {
ctx = session.ContextWithInbound(ctx, &session.Inbound{
@ -307,11 +367,6 @@ func (s *Server) lookupIPInternal(domain string, option IPOption) ([]net.IP, err
domain = domain[:len(domain)-1]
}
// skip domain without any dot
if strings.Index(domain, ".") == -1 {
return nil, newError("invalid domain name").AtWarning()
}
ips := s.lookupStatic(domain, option, 0)
if ips != nil && ips[0].Family().IsIP() {
newError("returning ", len(ips), " IPs for domain ", domain).WriteToLog()
@ -327,10 +382,25 @@ func (s *Server) lookupIPInternal(domain string, option IPOption) ([]net.IP, err
var lastErr error
var matchedClient Client
if s.domainMatcher != nil {
idx := s.domainMatcher.Match(domain)
if idx > 0 {
matchedClient = s.clients[s.domainIndexMap[idx]]
ips, err := s.queryIPTimeout(s.domainIndexMap[idx], matchedClient, domain, option)
indices := s.domainMatcher.Match(domain)
domainRules := []string{}
matchingDNS := []string{}
for _, idx := range indices {
info := s.matcherInfos[idx]
rule := s.domainRules[info.clientIdx][info.domainRuleIdx]
domainRules = append(domainRules, fmt.Sprintf("%s(DNS idx:%d)", rule, info.clientIdx))
matchingDNS = append(matchingDNS, s.clients[info.clientIdx].Name())
}
if len(domainRules) > 0 {
newError("domain ", domain, " matches following rules: ", domainRules).AtDebug().WriteToLog()
}
if len(matchingDNS) > 0 {
newError("domain ", domain, " uses following DNS first: ", matchingDNS).AtDebug().WriteToLog()
}
for _, idx := range indices {
clientIdx := int(s.matcherInfos[idx].clientIdx)
matchedClient = s.clients[clientIdx]
ips, err := s.queryIPTimeout(clientIdx, matchedClient, domain, option)
if len(ips) > 0 {
return ips, nil
}
@ -350,7 +420,7 @@ func (s *Server) lookupIPInternal(domain string, option IPOption) ([]net.IP, err
continue
}
ips, err := s.queryIPTimeout(uint32(idx), client, domain, option)
ips, err := s.queryIPTimeout(idx, client, domain, option)
if len(ips) > 0 {
return ips, nil
}

View File

@ -50,6 +50,12 @@ func (*staticHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
rr, _ := dns.NewRR("google.com. IN A 8.8.4.4")
ans.Answer = append(ans.Answer, rr)
}
} else if q.Name == "api.google.com." && q.Qtype == dns.TypeA {
rr, _ := dns.NewRR("api.google.com. IN A 8.8.7.7")
ans.Answer = append(ans.Answer, rr)
} else if q.Name == "v2.api.google.com." && q.Qtype == dns.TypeA {
rr, _ := dns.NewRR("v2.api.google.com. IN A 8.8.7.8")
ans.Answer = append(ans.Answer, rr)
} else if q.Name == "facebook.com." && q.Qtype == dns.TypeA {
rr, _ := dns.NewRR("facebook.com. IN A 9.9.9.9")
ans.Answer = append(ans.Answer, rr)
@ -63,6 +69,27 @@ func (*staticHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
ans.Answer = append(ans.Answer, rr)
} else if q.Name == "notexist.google.com." && q.Qtype == dns.TypeAAAA {
ans.MsgHdr.Rcode = dns.RcodeNameError
} else if q.Name == "hostname." && q.Qtype == dns.TypeA {
rr, _ := dns.NewRR("hostname. IN A 127.0.0.1")
ans.Answer = append(ans.Answer, rr)
} else if q.Name == "hostname.local." && q.Qtype == dns.TypeA {
rr, _ := dns.NewRR("hostname.local. IN A 127.0.0.1")
ans.Answer = append(ans.Answer, rr)
} else if q.Name == "hostname.localdomain." && q.Qtype == dns.TypeA {
rr, _ := dns.NewRR("hostname.localdomain. IN A 127.0.0.1")
ans.Answer = append(ans.Answer, rr)
} else if q.Name == "localhost." && q.Qtype == dns.TypeA {
rr, _ := dns.NewRR("localhost. IN A 127.0.0.2")
ans.Answer = append(ans.Answer, rr)
} else if q.Name == "localhost-a." && q.Qtype == dns.TypeA {
rr, _ := dns.NewRR("localhost-a. IN A 127.0.0.3")
ans.Answer = append(ans.Answer, rr)
} else if q.Name == "localhost-b." && q.Qtype == dns.TypeA {
rr, _ := dns.NewRR("localhost-b. IN A 127.0.0.4")
ans.Answer = append(ans.Answer, rr)
} else if q.Name == "Mijia\\ Cloud." && q.Qtype == dns.TypeA {
rr, _ := dns.NewRR("Mijia\\ Cloud. IN A 127.0.0.1")
ans.Answer = append(ans.Answer, rr)
}
}
w.WriteMsg(ans)
@ -537,3 +564,395 @@ func TestIPMatch(t *testing.T) {
t.Error("DNS query doesn't finish in 2 seconds.")
}
}
func TestLocalDomain(t *testing.T) {
port := udp.PickPort()
dnsServer := dns.Server{
Addr: "127.0.0.1:" + port.String(),
Net: "udp",
Handler: &staticHandler{},
UDPSize: 1200,
}
go dnsServer.ListenAndServe()
time.Sleep(time.Second)
config := &core.Config{
App: []*serial.TypedMessage{
serial.ToTypedMessage(&Config{
NameServers: []*net.Endpoint{
{
Network: net.Network_UDP,
Address: &net.IPOrDomain{
Address: &net.IPOrDomain_Ip{
Ip: []byte{127, 0, 0, 1},
},
},
Port: 9999, /* unreachable */
},
},
NameServer: []*NameServer{
{
Address: &net.Endpoint{
Network: net.Network_UDP,
Address: &net.IPOrDomain{
Address: &net.IPOrDomain_Ip{
Ip: []byte{127, 0, 0, 1},
},
},
Port: uint32(port),
},
PrioritizedDomain: []*NameServer_PriorityDomain{
// Equivalent of dotless:localhost
{Type: DomainMatchingType_Regex, Domain: "^[^.]*localhost[^.]*$"},
},
Geoip: []*router.GeoIP{
{ // Will match localhost, localhost-a and localhost-b,
CountryCode: "local",
Cidr: []*router.CIDR{
{Ip: []byte{127, 0, 0, 2}, Prefix: 32},
{Ip: []byte{127, 0, 0, 3}, Prefix: 32},
{Ip: []byte{127, 0, 0, 4}, Prefix: 32},
},
},
},
},
{
Address: &net.Endpoint{
Network: net.Network_UDP,
Address: &net.IPOrDomain{
Address: &net.IPOrDomain_Ip{
Ip: []byte{127, 0, 0, 1},
},
},
Port: uint32(port),
},
PrioritizedDomain: []*NameServer_PriorityDomain{
// Equivalent of dotless: and domain:local
{Type: DomainMatchingType_Regex, Domain: "^[^.]*$"},
{Type: DomainMatchingType_Subdomain, Domain: "local"},
{Type: DomainMatchingType_Subdomain, Domain: "localdomain"},
},
},
},
StaticHosts: []*Config_HostMapping{
{
Type: DomainMatchingType_Full,
Domain: "hostnamestatic",
Ip: [][]byte{{127, 0, 0, 53}},
},
{
Type: DomainMatchingType_Full,
Domain: "hostnamealias",
ProxiedDomain: "hostname.localdomain",
},
},
}),
serial.ToTypedMessage(&dispatcher.Config{}),
serial.ToTypedMessage(&proxyman.OutboundConfig{}),
serial.ToTypedMessage(&policy.Config{}),
},
Outbound: []*core.OutboundHandlerConfig{
{
ProxySettings: serial.ToTypedMessage(&freedom.Config{}),
},
},
}
v, err := core.New(config)
common.Must(err)
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
startTime := time.Now()
{ // Will match dotless:
ips, err := client.LookupIP("hostname")
if err != nil {
t.Fatal("unexpected error: ", err)
}
if r := cmp.Diff(ips, []net.IP{{127, 0, 0, 1}}); r != "" {
t.Fatal(r)
}
}
{ // Will match domain:local
ips, err := client.LookupIP("hostname.local")
if err != nil {
t.Fatal("unexpected error: ", err)
}
if r := cmp.Diff(ips, []net.IP{{127, 0, 0, 1}}); r != "" {
t.Fatal(r)
}
}
{ // Will match static ip
ips, err := client.LookupIP("hostnamestatic")
if err != nil {
t.Fatal("unexpected error: ", err)
}
if r := cmp.Diff(ips, []net.IP{{127, 0, 0, 53}}); r != "" {
t.Fatal(r)
}
}
{ // Will match domain replacing
ips, err := client.LookupIP("hostnamealias")
if err != nil {
t.Fatal("unexpected error: ", err)
}
if r := cmp.Diff(ips, []net.IP{{127, 0, 0, 1}}); r != "" {
t.Fatal(r)
}
}
{ // Will match dotless:localhost, but not expectIPs: 127.0.0.2, 127.0.0.3, then matches at dotless:
ips, err := client.LookupIP("localhost")
if err != nil {
t.Fatal("unexpected error: ", err)
}
if r := cmp.Diff(ips, []net.IP{{127, 0, 0, 2}}); r != "" {
t.Fatal(r)
}
}
{ // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3
ips, err := client.LookupIP("localhost-a")
if err != nil {
t.Fatal("unexpected error: ", err)
}
if r := cmp.Diff(ips, []net.IP{{127, 0, 0, 3}}); r != "" {
t.Fatal(r)
}
}
{ // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3
ips, err := client.LookupIP("localhost-b")
if err != nil {
t.Fatal("unexpected error: ", err)
}
if r := cmp.Diff(ips, []net.IP{{127, 0, 0, 4}}); r != "" {
t.Fatal(r)
}
}
{ // Will match dotless:
ips, err := client.LookupIP("Mijia Cloud")
if err != nil {
t.Fatal("unexpected error: ", err)
}
if r := cmp.Diff(ips, []net.IP{{127, 0, 0, 1}}); r != "" {
t.Fatal(r)
}
}
endTime := time.Now()
if startTime.After(endTime.Add(time.Second * 2)) {
t.Error("DNS query doesn't finish in 2 seconds.")
}
}
func TestMultiMatchPrioritizedDomain(t *testing.T) {
port := udp.PickPort()
dnsServer := dns.Server{
Addr: "127.0.0.1:" + port.String(),
Net: "udp",
Handler: &staticHandler{},
UDPSize: 1200,
}
go dnsServer.ListenAndServe()
time.Sleep(time.Second)
config := &core.Config{
App: []*serial.TypedMessage{
serial.ToTypedMessage(&Config{
NameServers: []*net.Endpoint{
{
Network: net.Network_UDP,
Address: &net.IPOrDomain{
Address: &net.IPOrDomain_Ip{
Ip: []byte{127, 0, 0, 1},
},
},
Port: 9999, /* unreachable */
},
},
NameServer: []*NameServer{
{
Address: &net.Endpoint{
Network: net.Network_UDP,
Address: &net.IPOrDomain{
Address: &net.IPOrDomain_Ip{
Ip: []byte{127, 0, 0, 1},
},
},
Port: uint32(port),
},
PrioritizedDomain: []*NameServer_PriorityDomain{
{
Type: DomainMatchingType_Subdomain,
Domain: "google.com",
},
},
Geoip: []*router.GeoIP{
{ // Will only match 8.8.8.8 and 8.8.4.4
Cidr: []*router.CIDR{
{Ip: []byte{8, 8, 8, 8}, Prefix: 32},
{Ip: []byte{8, 8, 4, 4}, Prefix: 32},
},
},
},
},
{
Address: &net.Endpoint{
Network: net.Network_UDP,
Address: &net.IPOrDomain{
Address: &net.IPOrDomain_Ip{
Ip: []byte{127, 0, 0, 1},
},
},
Port: uint32(port),
},
PrioritizedDomain: []*NameServer_PriorityDomain{
{
Type: DomainMatchingType_Subdomain,
Domain: "google.com",
},
},
Geoip: []*router.GeoIP{
{ // Will match 8.8.8.8 and 8.8.8.7, etc
Cidr: []*router.CIDR{
{Ip: []byte{8, 8, 8, 7}, Prefix: 24},
},
},
},
},
{
Address: &net.Endpoint{
Network: net.Network_UDP,
Address: &net.IPOrDomain{
Address: &net.IPOrDomain_Ip{
Ip: []byte{127, 0, 0, 1},
},
},
Port: uint32(port),
},
PrioritizedDomain: []*NameServer_PriorityDomain{
{
Type: DomainMatchingType_Subdomain,
Domain: "api.google.com",
},
},
Geoip: []*router.GeoIP{
{ // Will only match 8.8.7.7 (api.google.com)
Cidr: []*router.CIDR{
{Ip: []byte{8, 8, 7, 7}, Prefix: 32},
},
},
},
},
{
Address: &net.Endpoint{
Network: net.Network_UDP,
Address: &net.IPOrDomain{
Address: &net.IPOrDomain_Ip{
Ip: []byte{127, 0, 0, 1},
},
},
Port: uint32(port),
},
PrioritizedDomain: []*NameServer_PriorityDomain{
{
Type: DomainMatchingType_Full,
Domain: "v2.api.google.com",
},
},
Geoip: []*router.GeoIP{
{ // Will only match 8.8.7.8 (v2.api.google.com)
Cidr: []*router.CIDR{
{Ip: []byte{8, 8, 7, 8}, Prefix: 32},
},
},
},
},
},
}),
serial.ToTypedMessage(&dispatcher.Config{}),
serial.ToTypedMessage(&proxyman.OutboundConfig{}),
serial.ToTypedMessage(&policy.Config{}),
},
Outbound: []*core.OutboundHandlerConfig{
{
ProxySettings: serial.ToTypedMessage(&freedom.Config{}),
},
},
}
v, err := core.New(config)
common.Must(err)
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
startTime := time.Now()
{ // Will match server 1,2 and server 1 returns expected ip
ips, err := client.LookupIP("google.com")
if err != nil {
t.Fatal("unexpected error: ", err)
}
if r := cmp.Diff(ips, []net.IP{{8, 8, 8, 8}}); r != "" {
t.Fatal(r)
}
}
{ // Will match server 1,2 and server 1 returns unexpected ip, then server 2 returns expected one
clientv4 := client.(feature_dns.IPv4Lookup)
ips, err := clientv4.LookupIPv4("ipv6.google.com")
if err != nil {
t.Fatal("unexpected error: ", err)
}
if r := cmp.Diff(ips, []net.IP{{8, 8, 8, 7}}); r != "" {
t.Fatal(r)
}
}
{ // Will match server 3,1,2 and server 3 returns expected one
ips, err := client.LookupIP("api.google.com")
if err != nil {
t.Fatal("unexpected error: ", err)
}
if r := cmp.Diff(ips, []net.IP{{8, 8, 7, 7}}); r != "" {
t.Fatal(r)
}
}
{ // Will match server 4,3,1,2 and server 4 returns expected one
ips, err := client.LookupIP("v2.api.google.com")
if err != nil {
t.Fatal("unexpected error: ", err)
}
if r := cmp.Diff(ips, []net.IP{{8, 8, 7, 8}}); r != "" {
t.Fatal(r)
}
}
endTime := time.Now()
if startTime.After(endTime.Add(time.Second * 2)) {
t.Error("DNS query doesn't finish in 2 seconds.")
}
}

View File

@ -108,7 +108,7 @@ func (s *ClassicNameServer) HandleResponse(ctx context.Context, packet *udp_prot
ipRec, err := parseResponse(packet.Payload.Bytes())
if err != nil {
newError(s.name, " fail to parse responsed DNS udp").AtError().WriteToLog()
newError(s.name, " fail to parse responded DNS udp").AtError().WriteToLog()
return
}
@ -134,7 +134,7 @@ func (s *ClassicNameServer) HandleResponse(ctx context.Context, packet *udp_prot
}
elapsed := time.Since(req.start)
newError(s.name, " got answere: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed).AtInfo().WriteToLog()
newError(s.name, " got answer: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed).AtInfo().WriteToLog()
if len(req.domain) > 0 && (rec.A != nil || rec.AAAA != nil) {
s.updateIP(req.domain, rec)
}

View File

@ -2,7 +2,7 @@
package command
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen
import (
"context"
@ -33,6 +33,8 @@ func (s *LoggerServer) RestartLogger(ctx context.Context, request *RestartLogger
return &RestartLoggerResponse{}, nil
}
func (s *LoggerServer) mustEmbedUnimplementedLoggerServiceServer() {}
type service struct {
v *core.Instance
}

View File

@ -1,213 +1,259 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.13.0
// source: app/log/command/config.proto
package command
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
math "math"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type Config struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (m *Config) Reset() { *m = Config{} }
func (m *Config) String() string { return proto.CompactTextString(m) }
func (*Config) ProtoMessage() {}
func (x *Config) Reset() {
*x = Config{}
if protoimpl.UnsafeEnabled {
mi := &file_app_log_command_config_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Config) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Config) ProtoMessage() {}
func (x *Config) ProtoReflect() protoreflect.Message {
mi := &file_app_log_command_config_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
func (*Config) Descriptor() ([]byte, []int) {
return fileDescriptor_46d95b63a682e4a6, []int{0}
return file_app_log_command_config_proto_rawDescGZIP(), []int{0}
}
func (m *Config) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Config.Unmarshal(m, b)
}
func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Config.Marshal(b, m, deterministic)
}
func (m *Config) XXX_Merge(src proto.Message) {
xxx_messageInfo_Config.Merge(m, src)
}
func (m *Config) XXX_Size() int {
return xxx_messageInfo_Config.Size(m)
}
func (m *Config) XXX_DiscardUnknown() {
xxx_messageInfo_Config.DiscardUnknown(m)
}
var xxx_messageInfo_Config proto.InternalMessageInfo
type RestartLoggerRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (m *RestartLoggerRequest) Reset() { *m = RestartLoggerRequest{} }
func (m *RestartLoggerRequest) String() string { return proto.CompactTextString(m) }
func (*RestartLoggerRequest) ProtoMessage() {}
func (x *RestartLoggerRequest) Reset() {
*x = RestartLoggerRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_app_log_command_config_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RestartLoggerRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RestartLoggerRequest) ProtoMessage() {}
func (x *RestartLoggerRequest) ProtoReflect() protoreflect.Message {
mi := &file_app_log_command_config_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RestartLoggerRequest.ProtoReflect.Descriptor instead.
func (*RestartLoggerRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_46d95b63a682e4a6, []int{1}
return file_app_log_command_config_proto_rawDescGZIP(), []int{1}
}
func (m *RestartLoggerRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RestartLoggerRequest.Unmarshal(m, b)
}
func (m *RestartLoggerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_RestartLoggerRequest.Marshal(b, m, deterministic)
}
func (m *RestartLoggerRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_RestartLoggerRequest.Merge(m, src)
}
func (m *RestartLoggerRequest) XXX_Size() int {
return xxx_messageInfo_RestartLoggerRequest.Size(m)
}
func (m *RestartLoggerRequest) XXX_DiscardUnknown() {
xxx_messageInfo_RestartLoggerRequest.DiscardUnknown(m)
}
var xxx_messageInfo_RestartLoggerRequest proto.InternalMessageInfo
type RestartLoggerResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (m *RestartLoggerResponse) Reset() { *m = RestartLoggerResponse{} }
func (m *RestartLoggerResponse) String() string { return proto.CompactTextString(m) }
func (*RestartLoggerResponse) ProtoMessage() {}
func (x *RestartLoggerResponse) Reset() {
*x = RestartLoggerResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_app_log_command_config_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RestartLoggerResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RestartLoggerResponse) ProtoMessage() {}
func (x *RestartLoggerResponse) ProtoReflect() protoreflect.Message {
mi := &file_app_log_command_config_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RestartLoggerResponse.ProtoReflect.Descriptor instead.
func (*RestartLoggerResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_46d95b63a682e4a6, []int{2}
return file_app_log_command_config_proto_rawDescGZIP(), []int{2}
}
func (m *RestartLoggerResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RestartLoggerResponse.Unmarshal(m, b)
}
func (m *RestartLoggerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_RestartLoggerResponse.Marshal(b, m, deterministic)
}
func (m *RestartLoggerResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_RestartLoggerResponse.Merge(m, src)
}
func (m *RestartLoggerResponse) XXX_Size() int {
return xxx_messageInfo_RestartLoggerResponse.Size(m)
}
func (m *RestartLoggerResponse) XXX_DiscardUnknown() {
xxx_messageInfo_RestartLoggerResponse.DiscardUnknown(m)
var File_app_log_command_config_proto protoreflect.FileDescriptor
var file_app_log_command_config_proto_rawDesc = []byte{
0x0a, 0x1c, 0x61, 0x70, 0x70, 0x2f, 0x6c, 0x6f, 0x67, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
0x64, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1a,
0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c,
0x6f, 0x67, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x22, 0x16, 0x0a, 0x14, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x4c,
0x6f, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x17, 0x0a, 0x15,
0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x87, 0x01, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x76, 0x0a, 0x0d, 0x52, 0x65, 0x73, 0x74, 0x61,
0x72, 0x74, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x12, 0x30, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79,
0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x2e, 0x63, 0x6f,
0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x4c, 0x6f, 0x67,
0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x76, 0x32, 0x72,
0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x2e,
0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x4c,
0x6f, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42,
0x5f, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72,
0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
0x64, 0x50, 0x01, 0x5a, 0x1e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63,
0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x6c, 0x6f, 0x67, 0x2f, 0x63, 0x6f, 0x6d, 0x6d,
0x61, 0x6e, 0x64, 0xaa, 0x02, 0x1a, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65,
0x2e, 0x41, 0x70, 0x70, 0x2e, 0x4c, 0x6f, 0x67, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var xxx_messageInfo_RestartLoggerResponse proto.InternalMessageInfo
var (
file_app_log_command_config_proto_rawDescOnce sync.Once
file_app_log_command_config_proto_rawDescData = file_app_log_command_config_proto_rawDesc
)
func init() {
proto.RegisterType((*Config)(nil), "v2ray.core.app.log.command.Config")
proto.RegisterType((*RestartLoggerRequest)(nil), "v2ray.core.app.log.command.RestartLoggerRequest")
proto.RegisterType((*RestartLoggerResponse)(nil), "v2ray.core.app.log.command.RestartLoggerResponse")
func file_app_log_command_config_proto_rawDescGZIP() []byte {
file_app_log_command_config_proto_rawDescOnce.Do(func() {
file_app_log_command_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_log_command_config_proto_rawDescData)
})
return file_app_log_command_config_proto_rawDescData
}
func init() {
proto.RegisterFile("v2ray.com/core/app/log/command/config.proto", fileDescriptor_46d95b63a682e4a6)
var file_app_log_command_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_app_log_command_config_proto_goTypes = []interface{}{
(*Config)(nil), // 0: v2ray.core.app.log.command.Config
(*RestartLoggerRequest)(nil), // 1: v2ray.core.app.log.command.RestartLoggerRequest
(*RestartLoggerResponse)(nil), // 2: v2ray.core.app.log.command.RestartLoggerResponse
}
var file_app_log_command_config_proto_depIdxs = []int32{
1, // 0: v2ray.core.app.log.command.LoggerService.RestartLogger:input_type -> v2ray.core.app.log.command.RestartLoggerRequest
2, // 1: v2ray.core.app.log.command.LoggerService.RestartLogger:output_type -> v2ray.core.app.log.command.RestartLoggerResponse
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
var fileDescriptor_46d95b63a682e4a6 = []byte{
// 210 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2e, 0x33, 0x2a, 0x4a,
0xac, 0xd4, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x2c, 0x28, 0xd0, 0xcf,
0xc9, 0x4f, 0xd7, 0x4f, 0xce, 0xcf, 0xcd, 0x4d, 0xcc, 0x4b, 0xd1, 0x4f, 0xce, 0xcf, 0x4b, 0xcb,
0x4c, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x82, 0x29, 0x2e, 0x4a, 0xd5, 0x4b, 0x2c,
0x28, 0xd0, 0xcb, 0xc9, 0x4f, 0xd7, 0x83, 0x2a, 0x54, 0xe2, 0xe0, 0x62, 0x73, 0x06, 0xab, 0x55,
0x12, 0xe3, 0x12, 0x09, 0x4a, 0x2d, 0x2e, 0x49, 0x2c, 0x2a, 0xf1, 0xc9, 0x4f, 0x4f, 0x4f, 0x2d,
0x0a, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x51, 0x12, 0xe7, 0x12, 0x45, 0x13, 0x2f, 0x2e, 0xc8,
0xcf, 0x2b, 0x4e, 0x35, 0x6a, 0x67, 0xe4, 0xe2, 0x85, 0x08, 0x05, 0xa7, 0x16, 0x95, 0x65, 0x26,
0xa7, 0x0a, 0x95, 0x71, 0xf1, 0xa2, 0x28, 0x15, 0x32, 0xd0, 0xc3, 0x6d, 0xb5, 0x1e, 0x36, 0xdb,
0xa4, 0x0c, 0x49, 0xd0, 0x01, 0x71, 0x87, 0x12, 0x83, 0x93, 0x07, 0x97, 0x5c, 0x72, 0x7e, 0x2e,
0x1e, 0x9d, 0x01, 0x8c, 0x51, 0xec, 0x50, 0xe6, 0x2a, 0x26, 0xa9, 0x30, 0xa3, 0xa0, 0xc4, 0x4a,
0x3d, 0x67, 0x90, 0x3a, 0xc7, 0x82, 0x02, 0x3d, 0x9f, 0xfc, 0x74, 0x3d, 0x67, 0x88, 0x64, 0x12,
0x1b, 0x38, 0xc4, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x37, 0xc7, 0xfc, 0xda, 0x60, 0x01,
0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// LoggerServiceClient is the client API for LoggerService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type LoggerServiceClient interface {
RestartLogger(ctx context.Context, in *RestartLoggerRequest, opts ...grpc.CallOption) (*RestartLoggerResponse, error)
}
type loggerServiceClient struct {
cc *grpc.ClientConn
}
func NewLoggerServiceClient(cc *grpc.ClientConn) LoggerServiceClient {
return &loggerServiceClient{cc}
}
func (c *loggerServiceClient) RestartLogger(ctx context.Context, in *RestartLoggerRequest, opts ...grpc.CallOption) (*RestartLoggerResponse, error) {
out := new(RestartLoggerResponse)
err := c.cc.Invoke(ctx, "/v2ray.core.app.log.command.LoggerService/RestartLogger", in, out, opts...)
if err != nil {
return nil, err
func init() { file_app_log_command_config_proto_init() }
func file_app_log_command_config_proto_init() {
if File_app_log_command_config_proto != nil {
return
}
return out, nil
}
// LoggerServiceServer is the server API for LoggerService service.
type LoggerServiceServer interface {
RestartLogger(context.Context, *RestartLoggerRequest) (*RestartLoggerResponse, error)
}
func RegisterLoggerServiceServer(s *grpc.Server, srv LoggerServiceServer) {
s.RegisterService(&_LoggerService_serviceDesc, srv)
}
func _LoggerService_RestartLogger_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RestartLoggerRequest)
if err := dec(in); err != nil {
return nil, err
if !protoimpl.UnsafeEnabled {
file_app_log_command_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Config); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_log_command_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RestartLoggerRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_log_command_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RestartLoggerResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
if interceptor == nil {
return srv.(LoggerServiceServer).RestartLogger(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/v2ray.core.app.log.command.LoggerService/RestartLogger",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LoggerServiceServer).RestartLogger(ctx, req.(*RestartLoggerRequest))
}
return interceptor(ctx, in, info, handler)
}
var _LoggerService_serviceDesc = grpc.ServiceDesc{
ServiceName: "v2ray.core.app.log.command.LoggerService",
HandlerType: (*LoggerServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "RestartLogger",
Handler: _LoggerService_RestartLogger_Handler,
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_app_log_command_config_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 1,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "v2ray.com/core/app/log/command/config.proto",
GoTypes: file_app_log_command_config_proto_goTypes,
DependencyIndexes: file_app_log_command_config_proto_depIdxs,
MessageInfos: file_app_log_command_config_proto_msgTypes,
}.Build()
File_app_log_command_config_proto = out.File
file_app_log_command_config_proto_rawDesc = nil
file_app_log_command_config_proto_goTypes = nil
file_app_log_command_config_proto_depIdxs = nil
}

View File

@ -2,16 +2,15 @@ syntax = "proto3";
package v2ray.core.app.log.command;
option csharp_namespace = "V2Ray.Core.App.Log.Command";
option go_package = "command";
option go_package = "v2ray.com/core/app/log/command";
option java_package = "com.v2ray.core.app.log.command";
option java_multiple_files = true;
message Config {
}
message Config {}
message RestartLoggerRequest {}
message RestartLoggerResponse{}
message RestartLoggerResponse {}
service LoggerService {
rpc RestartLogger(RestartLoggerRequest) returns (RestartLoggerResponse) {}

View File

@ -0,0 +1,97 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package command
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion7
// LoggerServiceClient is the client API for LoggerService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type LoggerServiceClient interface {
RestartLogger(ctx context.Context, in *RestartLoggerRequest, opts ...grpc.CallOption) (*RestartLoggerResponse, error)
}
type loggerServiceClient struct {
cc grpc.ClientConnInterface
}
func NewLoggerServiceClient(cc grpc.ClientConnInterface) LoggerServiceClient {
return &loggerServiceClient{cc}
}
func (c *loggerServiceClient) RestartLogger(ctx context.Context, in *RestartLoggerRequest, opts ...grpc.CallOption) (*RestartLoggerResponse, error) {
out := new(RestartLoggerResponse)
err := c.cc.Invoke(ctx, "/v2ray.core.app.log.command.LoggerService/RestartLogger", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// LoggerServiceServer is the server API for LoggerService service.
// All implementations must embed UnimplementedLoggerServiceServer
// for forward compatibility
type LoggerServiceServer interface {
RestartLogger(context.Context, *RestartLoggerRequest) (*RestartLoggerResponse, error)
mustEmbedUnimplementedLoggerServiceServer()
}
// UnimplementedLoggerServiceServer must be embedded to have forward compatible implementations.
type UnimplementedLoggerServiceServer struct {
}
func (UnimplementedLoggerServiceServer) RestartLogger(context.Context, *RestartLoggerRequest) (*RestartLoggerResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RestartLogger not implemented")
}
func (UnimplementedLoggerServiceServer) mustEmbedUnimplementedLoggerServiceServer() {}
// UnsafeLoggerServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to LoggerServiceServer will
// result in compilation errors.
type UnsafeLoggerServiceServer interface {
mustEmbedUnimplementedLoggerServiceServer()
}
func RegisterLoggerServiceServer(s *grpc.Server, srv LoggerServiceServer) {
s.RegisterService(&_LoggerService_serviceDesc, srv)
}
func _LoggerService_RestartLogger_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RestartLoggerRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LoggerServiceServer).RestartLogger(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/v2ray.core.app.log.command.LoggerService/RestartLogger",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LoggerServiceServer).RestartLogger(ctx, req.(*RestartLoggerRequest))
}
return interceptor(ctx, in, info, handler)
}
var _LoggerService_serviceDesc = grpc.ServiceDesc{
ServiceName: "v2ray.core.app.log.command.LoggerService",
HandlerType: (*LoggerServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "RestartLogger",
Handler: _LoggerService_RestartLogger_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "app/log/command/config.proto",
}

View File

@ -1,22 +1,30 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.13.0
// source: app/log/config.proto
package log
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
log "v2ray.com/core/common/log"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type LogType int32
@ -27,128 +35,231 @@ const (
LogType_Event LogType = 3
)
var LogType_name = map[int32]string{
0: "None",
1: "Console",
2: "File",
3: "Event",
}
// Enum value maps for LogType.
var (
LogType_name = map[int32]string{
0: "None",
1: "Console",
2: "File",
3: "Event",
}
LogType_value = map[string]int32{
"None": 0,
"Console": 1,
"File": 2,
"Event": 3,
}
)
var LogType_value = map[string]int32{
"None": 0,
"Console": 1,
"File": 2,
"Event": 3,
func (x LogType) Enum() *LogType {
p := new(LogType)
*p = x
return p
}
func (x LogType) String() string {
return proto.EnumName(LogType_name, int32(x))
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (LogType) Descriptor() protoreflect.EnumDescriptor {
return file_app_log_config_proto_enumTypes[0].Descriptor()
}
func (LogType) Type() protoreflect.EnumType {
return &file_app_log_config_proto_enumTypes[0]
}
func (x LogType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use LogType.Descriptor instead.
func (LogType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_92dfeade43d9e989, []int{0}
return file_app_log_config_proto_rawDescGZIP(), []int{0}
}
type Config struct {
ErrorLogType LogType `protobuf:"varint,1,opt,name=error_log_type,json=errorLogType,proto3,enum=v2ray.core.app.log.LogType" json:"error_log_type,omitempty"`
ErrorLogLevel log.Severity `protobuf:"varint,2,opt,name=error_log_level,json=errorLogLevel,proto3,enum=v2ray.core.common.log.Severity" json:"error_log_level,omitempty"`
ErrorLogPath string `protobuf:"bytes,3,opt,name=error_log_path,json=errorLogPath,proto3" json:"error_log_path,omitempty"`
AccessLogType LogType `protobuf:"varint,4,opt,name=access_log_type,json=accessLogType,proto3,enum=v2ray.core.app.log.LogType" json:"access_log_type,omitempty"`
AccessLogPath string `protobuf:"bytes,5,opt,name=access_log_path,json=accessLogPath,proto3" json:"access_log_path,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ErrorLogType LogType `protobuf:"varint,1,opt,name=error_log_type,json=errorLogType,proto3,enum=v2ray.core.app.log.LogType" json:"error_log_type,omitempty"`
ErrorLogLevel log.Severity `protobuf:"varint,2,opt,name=error_log_level,json=errorLogLevel,proto3,enum=v2ray.core.common.log.Severity" json:"error_log_level,omitempty"`
ErrorLogPath string `protobuf:"bytes,3,opt,name=error_log_path,json=errorLogPath,proto3" json:"error_log_path,omitempty"`
AccessLogType LogType `protobuf:"varint,4,opt,name=access_log_type,json=accessLogType,proto3,enum=v2ray.core.app.log.LogType" json:"access_log_type,omitempty"`
AccessLogPath string `protobuf:"bytes,5,opt,name=access_log_path,json=accessLogPath,proto3" json:"access_log_path,omitempty"`
}
func (m *Config) Reset() { *m = Config{} }
func (m *Config) String() string { return proto.CompactTextString(m) }
func (*Config) ProtoMessage() {}
func (x *Config) Reset() {
*x = Config{}
if protoimpl.UnsafeEnabled {
mi := &file_app_log_config_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Config) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Config) ProtoMessage() {}
func (x *Config) ProtoReflect() protoreflect.Message {
mi := &file_app_log_config_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
func (*Config) Descriptor() ([]byte, []int) {
return fileDescriptor_92dfeade43d9e989, []int{0}
return file_app_log_config_proto_rawDescGZIP(), []int{0}
}
func (m *Config) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Config.Unmarshal(m, b)
}
func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Config.Marshal(b, m, deterministic)
}
func (m *Config) XXX_Merge(src proto.Message) {
xxx_messageInfo_Config.Merge(m, src)
}
func (m *Config) XXX_Size() int {
return xxx_messageInfo_Config.Size(m)
}
func (m *Config) XXX_DiscardUnknown() {
xxx_messageInfo_Config.DiscardUnknown(m)
}
var xxx_messageInfo_Config proto.InternalMessageInfo
func (m *Config) GetErrorLogType() LogType {
if m != nil {
return m.ErrorLogType
func (x *Config) GetErrorLogType() LogType {
if x != nil {
return x.ErrorLogType
}
return LogType_None
}
func (m *Config) GetErrorLogLevel() log.Severity {
if m != nil {
return m.ErrorLogLevel
func (x *Config) GetErrorLogLevel() log.Severity {
if x != nil {
return x.ErrorLogLevel
}
return log.Severity_Unknown
}
func (m *Config) GetErrorLogPath() string {
if m != nil {
return m.ErrorLogPath
func (x *Config) GetErrorLogPath() string {
if x != nil {
return x.ErrorLogPath
}
return ""
}
func (m *Config) GetAccessLogType() LogType {
if m != nil {
return m.AccessLogType
func (x *Config) GetAccessLogType() LogType {
if x != nil {
return x.AccessLogType
}
return LogType_None
}
func (m *Config) GetAccessLogPath() string {
if m != nil {
return m.AccessLogPath
func (x *Config) GetAccessLogPath() string {
if x != nil {
return x.AccessLogPath
}
return ""
}
func init() {
proto.RegisterEnum("v2ray.core.app.log.LogType", LogType_name, LogType_value)
proto.RegisterType((*Config)(nil), "v2ray.core.app.log.Config")
var File_app_log_config_proto protoreflect.FileDescriptor
var file_app_log_config_proto_rawDesc = []byte{
0x0a, 0x14, 0x61, 0x70, 0x70, 0x2f, 0x6c, 0x6f, 0x67, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f,
0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x1a, 0x14, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x2f, 0x6c, 0x6f, 0x67, 0x2f, 0x6c, 0x6f, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x22, 0xa7, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x41, 0x0a, 0x0e, 0x65,
0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65,
0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x2e, 0x4c, 0x6f, 0x67, 0x54, 0x79, 0x70, 0x65,
0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4c, 0x6f, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x47,
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x6c, 0x65, 0x76, 0x65,
0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1f, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e,
0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6c, 0x6f, 0x67, 0x2e,
0x53, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x52, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4c,
0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x24, 0x0a, 0x0e, 0x65, 0x72, 0x72, 0x6f, 0x72,
0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4c, 0x6f, 0x67, 0x50, 0x61, 0x74, 0x68, 0x12, 0x43, 0x0a,
0x0f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65,
0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63,
0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x2e, 0x4c, 0x6f, 0x67, 0x54,
0x79, 0x70, 0x65, 0x52, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x54, 0x79,
0x70, 0x65, 0x12, 0x26, 0x0a, 0x0f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x6c, 0x6f, 0x67,
0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x63, 0x63,
0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x50, 0x61, 0x74, 0x68, 0x2a, 0x35, 0x0a, 0x07, 0x4c, 0x6f,
0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12,
0x0b, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04,
0x46, 0x69, 0x6c, 0x65, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x10,
0x03, 0x42, 0x47, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63,
0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x50, 0x01, 0x5a, 0x16, 0x76,
0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70,
0x70, 0x2f, 0x6c, 0x6f, 0x67, 0xaa, 0x02, 0x12, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f,
0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x4c, 0x6f, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
func init() {
proto.RegisterFile("v2ray.com/core/app/log/config.proto", fileDescriptor_92dfeade43d9e989)
var (
file_app_log_config_proto_rawDescOnce sync.Once
file_app_log_config_proto_rawDescData = file_app_log_config_proto_rawDesc
)
func file_app_log_config_proto_rawDescGZIP() []byte {
file_app_log_config_proto_rawDescOnce.Do(func() {
file_app_log_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_log_config_proto_rawDescData)
})
return file_app_log_config_proto_rawDescData
}
var fileDescriptor_92dfeade43d9e989 = []byte{
// 306 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xcd, 0x4a, 0xfb, 0x40,
0x14, 0x47, 0xff, 0x49, 0xbf, 0xfe, 0x1d, 0x6d, 0x1b, 0x66, 0x21, 0x45, 0x17, 0x16, 0x15, 0x29,
0x2e, 0x26, 0x50, 0xf5, 0x01, 0x6a, 0x50, 0x37, 0x45, 0x4a, 0x14, 0x17, 0x6e, 0xca, 0x38, 0x5c,
0xa7, 0x81, 0x49, 0xee, 0x30, 0x19, 0x02, 0x79, 0x22, 0xc1, 0xa7, 0x94, 0x4c, 0x1b, 0x52, 0x3f,
0xc0, 0x65, 0x92, 0x7b, 0xce, 0xef, 0x40, 0xc8, 0x69, 0x31, 0x33, 0xbc, 0x64, 0x02, 0xd3, 0x50,
0xa0, 0x81, 0x90, 0x6b, 0x1d, 0x2a, 0x94, 0xa1, 0xc0, 0xec, 0x2d, 0x91, 0x4c, 0x1b, 0xb4, 0x48,
0x69, 0x7d, 0x64, 0x80, 0x71, 0xad, 0x99, 0x42, 0x79, 0xf8, 0x1d, 0x14, 0x98, 0xa6, 0x98, 0x39,
0x56, 0xe1, 0x16, 0x3c, 0x79, 0xf7, 0x49, 0x37, 0x72, 0x26, 0x3a, 0x27, 0x43, 0x30, 0x06, 0xcd,
0x4a, 0xa1, 0x5c, 0xd9, 0x52, 0xc3, 0xd8, 0x9b, 0x78, 0xd3, 0xe1, 0xec, 0x88, 0xfd, 0x94, 0xb3,
0x05, 0xca, 0xa7, 0x52, 0x43, 0xbc, 0xef, 0x90, 0xed, 0x13, 0xbd, 0x27, 0xa3, 0x46, 0xa1, 0xa0,
0x00, 0x35, 0xf6, 0x9d, 0xe3, 0x78, 0xd7, 0xb1, 0x09, 0x71, 0x9a, 0x47, 0x28, 0xc0, 0x24, 0xb6,
0x8c, 0x07, 0xb5, 0x67, 0x51, 0x51, 0xf4, 0x6c, 0xb7, 0x45, 0x73, 0xbb, 0x1e, 0xb7, 0x26, 0xde,
0xb4, 0xdf, 0xcc, 0x2d, 0xb9, 0x5d, 0xd3, 0x88, 0x8c, 0xb8, 0x10, 0x90, 0xe7, 0x4d, 0x72, 0xfb,
0xef, 0xe4, 0xc1, 0x86, 0xa9, 0x9b, 0xcf, 0xbf, 0x48, 0xdc, 0x56, 0xc7, 0x6d, 0x35, 0x77, 0xd5,
0xd8, 0xc5, 0x35, 0xe9, 0xd5, 0xc8, 0x7f, 0xd2, 0x7e, 0xc0, 0x0c, 0x82, 0x7f, 0x74, 0x8f, 0xf4,
0x22, 0xcc, 0x72, 0x54, 0x10, 0x78, 0xd5, 0xeb, 0xbb, 0x44, 0x41, 0xe0, 0xd3, 0x3e, 0xe9, 0xdc,
0x16, 0x90, 0xd9, 0xa0, 0x75, 0x73, 0x45, 0x0e, 0x04, 0xa6, 0xbf, 0xf4, 0x2c, 0xbd, 0x97, 0x96,
0x42, 0xf9, 0xe1, 0xd3, 0xe7, 0x59, 0xcc, 0x4b, 0x16, 0x55, 0xdf, 0xe6, 0x5a, 0x57, 0x9d, 0xaf,
0x5d, 0xf7, 0x77, 0x2e, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x33, 0xd5, 0x99, 0x3f, 0xfd, 0x01,
0x00, 0x00,
var file_app_log_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_app_log_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_app_log_config_proto_goTypes = []interface{}{
(LogType)(0), // 0: v2ray.core.app.log.LogType
(*Config)(nil), // 1: v2ray.core.app.log.Config
(log.Severity)(0), // 2: v2ray.core.common.log.Severity
}
var file_app_log_config_proto_depIdxs = []int32{
0, // 0: v2ray.core.app.log.Config.error_log_type:type_name -> v2ray.core.app.log.LogType
2, // 1: v2ray.core.app.log.Config.error_log_level:type_name -> v2ray.core.common.log.Severity
0, // 2: v2ray.core.app.log.Config.access_log_type:type_name -> v2ray.core.app.log.LogType
3, // [3:3] is the sub-list for method output_type
3, // [3:3] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_app_log_config_proto_init() }
func file_app_log_config_proto_init() {
if File_app_log_config_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_app_log_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Config); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_app_log_config_proto_rawDesc,
NumEnums: 1,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_app_log_config_proto_goTypes,
DependencyIndexes: file_app_log_config_proto_depIdxs,
EnumInfos: file_app_log_config_proto_enumTypes,
MessageInfos: file_app_log_config_proto_msgTypes,
}.Build()
File_app_log_config_proto = out.File
file_app_log_config_proto_rawDesc = nil
file_app_log_config_proto_goTypes = nil
file_app_log_config_proto_depIdxs = nil
}

View File

@ -2,11 +2,11 @@ syntax = "proto3";
package v2ray.core.app.log;
option csharp_namespace = "V2Ray.Core.App.Log";
option go_package = "log";
option go_package = "v2ray.com/core/app/log";
option java_package = "com.v2ray.core.app.log";
option java_multiple_files = true;
import "v2ray.com/core/common/log/log.proto";
import "common/log/log.proto";
enum LogType {
None = 0;

View File

@ -2,7 +2,7 @@
package log
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen
import (
"context"

View File

@ -50,8 +50,8 @@ func (p *Policy) overrideWith(another *Policy) {
p.Timeout.overrideWith(another.Timeout)
}
if another.Stats != nil && p.Stats == nil {
p.Stats = new(Policy_Stats)
*p.Stats = *another.Stats
p.Stats = &Policy_Stats{}
p.Stats = another.Stats
}
if another.Buffer != nil {
p.Buffer = &Policy_Buffer{
@ -84,8 +84,10 @@ func (p *Policy) ToCorePolicy() policy.Session {
func (p *SystemPolicy) ToCorePolicy() policy.System {
return policy.System{
Stats: policy.SystemStats{
InboundUplink: p.Stats.InboundUplink,
InboundDownlink: p.Stats.InboundDownlink,
InboundUplink: p.Stats.InboundUplink,
InboundDownlink: p.Stats.InboundDownlink,
OutboundUplink: p.Stats.OutboundUplink,
OutboundDownlink: p.Stats.OutboundDownlink,
},
}
}

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@ syntax = "proto3";
package v2ray.core.app.policy;
option csharp_namespace = "V2Ray.Core.App.Policy";
option go_package = "policy";
option go_package = "v2ray.com/core/app/policy";
option java_package = "com.v2ray.core.app.policy";
option java_multiple_files = true;
@ -38,6 +38,8 @@ message SystemPolicy {
message Stats {
bool inbound_uplink = 1;
bool inbound_downlink = 2;
bool outbound_uplink = 3;
bool outbound_downlink = 4;
}
Stats stats = 1;

View File

@ -1,4 +1,4 @@
// Package policy is an implementation of policy.Manager feature.
package policy
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen

2
app/proxyman/command/command.go Executable file → Normal file
View File

@ -125,6 +125,8 @@ func (s *handlerServer) AlterOutbound(ctx context.Context, request *AlterOutboun
return &AlterOutboundResponse{}, operation.ApplyOutbound(ctx, handler)
}
func (s *handlerServer) mustEmbedUnimplementedHandlerServiceServer() {}
type service struct {
v *core.Instance
}

File diff suppressed because it is too large Load Diff

View File

@ -2,13 +2,13 @@ syntax = "proto3";
package v2ray.core.app.proxyman.command;
option csharp_namespace = "V2Ray.Core.App.Proxyman.Command";
option go_package = "command";
option go_package = "v2ray.com/core/app/proxyman/command";
option java_package = "com.v2ray.core.app.proxyman.command";
option java_multiple_files = true;
import "v2ray.com/core/common/protocol/user.proto";
import "v2ray.com/core/common/serial/typed_message.proto";
import "v2ray.com/core/config.proto";
import "common/protocol/user.proto";
import "common/serial/typed_message.proto";
import "config.proto";
message AddUserOperation {
v2ray.core.common.protocol.User user = 1;
@ -22,9 +22,7 @@ message AddInboundRequest {
core.InboundHandlerConfig inbound = 1;
}
message AddInboundResponse{
}
message AddInboundResponse {}
message RemoveInboundRequest {
string tag = 1;
@ -37,31 +35,26 @@ message AlterInboundRequest {
v2ray.core.common.serial.TypedMessage operation = 2;
}
message AlterInboundResponse {
}
message AlterInboundResponse {}
message AddOutboundRequest {
core.OutboundHandlerConfig outbound = 1;
}
message AddOutboundResponse {
}
message AddOutboundResponse {}
message RemoveOutboundRequest {
string tag = 1;
}
message RemoveOutboundResponse {
}
message RemoveOutboundResponse {}
message AlterOutboundRequest {
string tag = 1;
v2ray.core.common.serial.TypedMessage operation = 2;
}
message AlterOutboundResponse {
}
message AlterOutboundResponse {}
service HandlerService {
rpc AddInbound(AddInboundRequest) returns (AddInboundResponse) {}

View File

@ -0,0 +1,277 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package command
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion7
// HandlerServiceClient is the client API for HandlerService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type HandlerServiceClient interface {
AddInbound(ctx context.Context, in *AddInboundRequest, opts ...grpc.CallOption) (*AddInboundResponse, error)
RemoveInbound(ctx context.Context, in *RemoveInboundRequest, opts ...grpc.CallOption) (*RemoveInboundResponse, error)
AlterInbound(ctx context.Context, in *AlterInboundRequest, opts ...grpc.CallOption) (*AlterInboundResponse, error)
AddOutbound(ctx context.Context, in *AddOutboundRequest, opts ...grpc.CallOption) (*AddOutboundResponse, error)
RemoveOutbound(ctx context.Context, in *RemoveOutboundRequest, opts ...grpc.CallOption) (*RemoveOutboundResponse, error)
AlterOutbound(ctx context.Context, in *AlterOutboundRequest, opts ...grpc.CallOption) (*AlterOutboundResponse, error)
}
type handlerServiceClient struct {
cc grpc.ClientConnInterface
}
func NewHandlerServiceClient(cc grpc.ClientConnInterface) HandlerServiceClient {
return &handlerServiceClient{cc}
}
func (c *handlerServiceClient) AddInbound(ctx context.Context, in *AddInboundRequest, opts ...grpc.CallOption) (*AddInboundResponse, error) {
out := new(AddInboundResponse)
err := c.cc.Invoke(ctx, "/v2ray.core.app.proxyman.command.HandlerService/AddInbound", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *handlerServiceClient) RemoveInbound(ctx context.Context, in *RemoveInboundRequest, opts ...grpc.CallOption) (*RemoveInboundResponse, error) {
out := new(RemoveInboundResponse)
err := c.cc.Invoke(ctx, "/v2ray.core.app.proxyman.command.HandlerService/RemoveInbound", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *handlerServiceClient) AlterInbound(ctx context.Context, in *AlterInboundRequest, opts ...grpc.CallOption) (*AlterInboundResponse, error) {
out := new(AlterInboundResponse)
err := c.cc.Invoke(ctx, "/v2ray.core.app.proxyman.command.HandlerService/AlterInbound", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *handlerServiceClient) AddOutbound(ctx context.Context, in *AddOutboundRequest, opts ...grpc.CallOption) (*AddOutboundResponse, error) {
out := new(AddOutboundResponse)
err := c.cc.Invoke(ctx, "/v2ray.core.app.proxyman.command.HandlerService/AddOutbound", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *handlerServiceClient) RemoveOutbound(ctx context.Context, in *RemoveOutboundRequest, opts ...grpc.CallOption) (*RemoveOutboundResponse, error) {
out := new(RemoveOutboundResponse)
err := c.cc.Invoke(ctx, "/v2ray.core.app.proxyman.command.HandlerService/RemoveOutbound", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *handlerServiceClient) AlterOutbound(ctx context.Context, in *AlterOutboundRequest, opts ...grpc.CallOption) (*AlterOutboundResponse, error) {
out := new(AlterOutboundResponse)
err := c.cc.Invoke(ctx, "/v2ray.core.app.proxyman.command.HandlerService/AlterOutbound", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// HandlerServiceServer is the server API for HandlerService service.
// All implementations must embed UnimplementedHandlerServiceServer
// for forward compatibility
type HandlerServiceServer interface {
AddInbound(context.Context, *AddInboundRequest) (*AddInboundResponse, error)
RemoveInbound(context.Context, *RemoveInboundRequest) (*RemoveInboundResponse, error)
AlterInbound(context.Context, *AlterInboundRequest) (*AlterInboundResponse, error)
AddOutbound(context.Context, *AddOutboundRequest) (*AddOutboundResponse, error)
RemoveOutbound(context.Context, *RemoveOutboundRequest) (*RemoveOutboundResponse, error)
AlterOutbound(context.Context, *AlterOutboundRequest) (*AlterOutboundResponse, error)
mustEmbedUnimplementedHandlerServiceServer()
}
// UnimplementedHandlerServiceServer must be embedded to have forward compatible implementations.
type UnimplementedHandlerServiceServer struct {
}
func (UnimplementedHandlerServiceServer) AddInbound(context.Context, *AddInboundRequest) (*AddInboundResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddInbound not implemented")
}
func (UnimplementedHandlerServiceServer) RemoveInbound(context.Context, *RemoveInboundRequest) (*RemoveInboundResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RemoveInbound not implemented")
}
func (UnimplementedHandlerServiceServer) AlterInbound(context.Context, *AlterInboundRequest) (*AlterInboundResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AlterInbound not implemented")
}
func (UnimplementedHandlerServiceServer) AddOutbound(context.Context, *AddOutboundRequest) (*AddOutboundResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddOutbound not implemented")
}
func (UnimplementedHandlerServiceServer) RemoveOutbound(context.Context, *RemoveOutboundRequest) (*RemoveOutboundResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RemoveOutbound not implemented")
}
func (UnimplementedHandlerServiceServer) AlterOutbound(context.Context, *AlterOutboundRequest) (*AlterOutboundResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AlterOutbound not implemented")
}
func (UnimplementedHandlerServiceServer) mustEmbedUnimplementedHandlerServiceServer() {}
// UnsafeHandlerServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to HandlerServiceServer will
// result in compilation errors.
type UnsafeHandlerServiceServer interface {
mustEmbedUnimplementedHandlerServiceServer()
}
func RegisterHandlerServiceServer(s *grpc.Server, srv HandlerServiceServer) {
s.RegisterService(&_HandlerService_serviceDesc, srv)
}
func _HandlerService_AddInbound_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AddInboundRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HandlerServiceServer).AddInbound(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/v2ray.core.app.proxyman.command.HandlerService/AddInbound",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HandlerServiceServer).AddInbound(ctx, req.(*AddInboundRequest))
}
return interceptor(ctx, in, info, handler)
}
func _HandlerService_RemoveInbound_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RemoveInboundRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HandlerServiceServer).RemoveInbound(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/v2ray.core.app.proxyman.command.HandlerService/RemoveInbound",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HandlerServiceServer).RemoveInbound(ctx, req.(*RemoveInboundRequest))
}
return interceptor(ctx, in, info, handler)
}
func _HandlerService_AlterInbound_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AlterInboundRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HandlerServiceServer).AlterInbound(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/v2ray.core.app.proxyman.command.HandlerService/AlterInbound",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HandlerServiceServer).AlterInbound(ctx, req.(*AlterInboundRequest))
}
return interceptor(ctx, in, info, handler)
}
func _HandlerService_AddOutbound_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AddOutboundRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HandlerServiceServer).AddOutbound(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/v2ray.core.app.proxyman.command.HandlerService/AddOutbound",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HandlerServiceServer).AddOutbound(ctx, req.(*AddOutboundRequest))
}
return interceptor(ctx, in, info, handler)
}
func _HandlerService_RemoveOutbound_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RemoveOutboundRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HandlerServiceServer).RemoveOutbound(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/v2ray.core.app.proxyman.command.HandlerService/RemoveOutbound",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HandlerServiceServer).RemoveOutbound(ctx, req.(*RemoveOutboundRequest))
}
return interceptor(ctx, in, info, handler)
}
func _HandlerService_AlterOutbound_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AlterOutboundRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HandlerServiceServer).AlterOutbound(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/v2ray.core.app.proxyman.command.HandlerService/AlterOutbound",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HandlerServiceServer).AlterOutbound(ctx, req.(*AlterOutboundRequest))
}
return interceptor(ctx, in, info, handler)
}
var _HandlerService_serviceDesc = grpc.ServiceDesc{
ServiceName: "v2ray.core.app.proxyman.command.HandlerService",
HandlerType: (*HandlerServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "AddInbound",
Handler: _HandlerService_AddInbound_Handler,
},
{
MethodName: "RemoveInbound",
Handler: _HandlerService_RemoveInbound_Handler,
},
{
MethodName: "AlterInbound",
Handler: _HandlerService_AlterInbound_Handler,
},
{
MethodName: "AddOutbound",
Handler: _HandlerService_AddOutbound_Handler,
},
{
MethodName: "RemoveOutbound",
Handler: _HandlerService_RemoveOutbound_Handler,
},
{
MethodName: "AlterOutbound",
Handler: _HandlerService_AlterOutbound_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "app/proxyman/command/command.proto",
}

View File

@ -1,3 +1,3 @@
package command
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen

File diff suppressed because it is too large Load Diff

View File

@ -2,17 +2,16 @@ syntax = "proto3";
package v2ray.core.app.proxyman;
option csharp_namespace = "V2Ray.Core.App.Proxyman";
option go_package = "proxyman";
option go_package = "v2ray.com/core/app/proxyman";
option java_package = "com.v2ray.core.app.proxyman";
option java_multiple_files = true;
import "v2ray.com/core/common/net/address.proto";
import "v2ray.com/core/common/net/port.proto";
import "v2ray.com/core/transport/internet/config.proto";
import "v2ray.com/core/common/serial/typed_message.proto";
import "common/net/address.proto";
import "common/net/port.proto";
import "transport/internet/config.proto";
import "common/serial/typed_message.proto";
message InboundConfig {
}
message InboundConfig {}
message AllocationStrategy {
enum Type {
@ -36,7 +35,6 @@ message AllocationStrategy {
// Default value is 3 if unset.
AllocationStrategyConcurrency concurrency = 2;
message AllocationStrategyRefresh {
uint32 value = 1;
}
@ -81,9 +79,7 @@ message InboundHandlerConfig {
v2ray.core.common.serial.TypedMessage proxy_settings = 3;
}
message OutboundConfig {
}
message OutboundConfig {}
message SenderConfig {
// Send traffic through the given IP. Only IP is allowed.

View File

@ -103,6 +103,7 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *
sniffingConfig: receiverConfig.GetEffectiveSniffingSettings(),
uplinkCounter: uplinkCounter,
downlinkCounter: downlinkCounter,
ctx: ctx,
}
h.workers = append(h.workers, worker)
}

View File

@ -28,6 +28,8 @@ type DynamicInboundHandler struct {
lastRefresh time.Time
mux *mux.Server
task *task.Periodic
ctx context.Context
}
func NewDynamicInboundHandler(ctx context.Context, tag string, receiverConfig *proxyman.ReceiverConfig, proxyConfig interface{}) (*DynamicInboundHandler, error) {
@ -39,6 +41,7 @@ func NewDynamicInboundHandler(ctx context.Context, tag string, receiverConfig *p
portsInUse: make(map[net.Port]bool),
mux: mux.NewServer(ctx),
v: v,
ctx: ctx,
}
mss, err := internet.ToMemoryStreamConfig(receiverConfig.StreamSettings)
@ -134,6 +137,7 @@ func (h *DynamicInboundHandler) refresh() error {
sniffingConfig: h.receiverConfig.GetEffectiveSniffingSettings(),
uplinkCounter: uplinkCounter,
downlinkCounter: downlinkCounter,
ctx: h.ctx,
}
if err := worker.Start(); err != nil {
newError("failed to create TCP worker").Base(err).AtWarning().WriteToLog()

View File

@ -1,6 +1,6 @@
package inbound
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen
import (
"context"
@ -150,6 +150,13 @@ func NewHandler(ctx context.Context, config *core.InboundHandlerConfig) (inbound
return nil, newError("not a ReceiverConfig").AtError()
}
streamSettings := receiverSettings.StreamSettings
if streamSettings != nil && streamSettings.SocketSettings != nil {
ctx = session.ContextWithSockopt(ctx, &session.Sockopt{
Mark: streamSettings.SocketSettings.Mark,
})
}
allocStrategy := receiverSettings.AllocationStrategy
if allocStrategy == nil || allocStrategy.Type == proxyman.AllocationStrategy_Always {
return NewAlwaysOnInboundHandler(ctx, tag, receiverSettings, proxySettings)

View File

@ -43,6 +43,8 @@ type tcpWorker struct {
downlinkCounter stats.Counter
hub internet.Listener
ctx context.Context
}
func getTProxyType(s *internet.MemoryStreamConfig) internet.SocketConfig_TProxyMode {
@ -53,7 +55,7 @@ func getTProxyType(s *internet.MemoryStreamConfig) internet.SocketConfig_TProxyM
}
func (w *tcpWorker) callback(conn internet.Connection) {
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(w.ctx)
sid := session.NewID()
ctx = session.ContextWithID(ctx, sid)
@ -89,9 +91,9 @@ func (w *tcpWorker) callback(conn internet.Connection) {
ctx = session.ContextWithContent(ctx, content)
if w.uplinkCounter != nil || w.downlinkCounter != nil {
conn = &internet.StatCouterConnection{
Connection: conn,
Uplink: w.uplinkCounter,
Downlink: w.downlinkCounter,
Connection: conn,
ReadCounter: w.uplinkCounter,
WriteCounter: w.downlinkCounter,
}
}
if err := w.proxy.Process(ctx, net.Network_TCP, conn, w.dispatcher); err != nil {
@ -198,7 +200,7 @@ func (c *udpConn) RemoteAddr() net.Addr {
}
func (c *udpConn) LocalAddr() net.Addr {
return c.remote
return c.local
}
func (*udpConn) SetDeadline(time.Time) error {
@ -330,7 +332,7 @@ func (w *udpWorker) clean() error {
}
for addr, conn := range w.activeConn {
if nowSec-atomic.LoadInt64(&conn.lastActivityTime) > 8 {
if nowSec-atomic.LoadInt64(&conn.lastActivityTime) > 8 { //TODO Timeout too small
delete(w.activeConn, addr)
conn.Close() // nolint: errcheck
}

View File

@ -10,6 +10,8 @@ import (
"v2ray.com/core/common/net"
"v2ray.com/core/common/session"
"v2ray.com/core/features/outbound"
"v2ray.com/core/features/policy"
"v2ray.com/core/features/stats"
"v2ray.com/core/proxy"
"v2ray.com/core/transport"
"v2ray.com/core/transport/internet"
@ -17,6 +19,31 @@ import (
"v2ray.com/core/transport/pipe"
)
func getStatCounter(v *core.Instance, tag string) (stats.Counter, stats.Counter) {
var uplinkCounter stats.Counter
var downlinkCounter stats.Counter
policy := v.GetFeature(policy.ManagerType()).(policy.Manager)
if len(tag) > 0 && policy.ForSystem().Stats.OutboundUplink {
statsManager := v.GetFeature(stats.ManagerType()).(stats.Manager)
name := "outbound>>>" + tag + ">>>traffic>>>uplink"
c, _ := stats.GetOrRegisterCounter(statsManager, name)
if c != nil {
uplinkCounter = c
}
}
if len(tag) > 0 && policy.ForSystem().Stats.OutboundDownlink {
statsManager := v.GetFeature(stats.ManagerType()).(stats.Manager)
name := "outbound>>>" + tag + ">>>traffic>>>downlink"
c, _ := stats.GetOrRegisterCounter(statsManager, name)
if c != nil {
downlinkCounter = c
}
}
return uplinkCounter, downlinkCounter
}
// Handler is an implements of outbound.Handler.
type Handler struct {
tag string
@ -25,14 +52,19 @@ type Handler struct {
proxy proxy.Outbound
outboundManager outbound.Manager
mux *mux.ClientManager
uplinkCounter stats.Counter
downlinkCounter stats.Counter
}
// NewHandler create a new Handler based on the given configuration.
func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbound.Handler, error) {
v := core.MustFromContext(ctx)
uplinkCounter, downlinkCounter := getStatCounter(v, config.Tag)
h := &Handler{
tag: config.Tag,
outboundManager: v.GetFeature(outbound.ManagerType()).(outbound.Manager),
uplinkCounter: uplinkCounter,
downlinkCounter: downlinkCounter,
}
if config.SenderSettings != nil {
@ -144,11 +176,11 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (internet.Conn
conn := net.NewConnection(net.ConnectionInputMulti(uplinkWriter), net.ConnectionOutputMulti(downlinkReader))
if config := tls.ConfigFromStreamSettings(h.streamSettings); config != nil {
tlsConfig := config.GetTLSConfig(tls.WithDestination(dest), tls.WithNextProto("h2"))
tlsConfig := config.GetTLSConfig(tls.WithDestination(dest))
conn = tls.Client(conn, tlsConfig)
}
return conn, nil
return h.getStatCouterConnection(conn), nil
}
newError("failed to get outbound handler with tag: ", tag).AtWarning().WriteToLog(session.ExportIDToError(ctx))
@ -164,7 +196,19 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (internet.Conn
}
}
return internet.Dial(ctx, dest, h.streamSettings)
conn, err := internet.Dial(ctx, dest, h.streamSettings)
return h.getStatCouterConnection(conn), err
}
func (h *Handler) getStatCouterConnection(conn internet.Connection) internet.Connection {
if h.uplinkCounter != nil || h.downlinkCounter != nil {
return &internet.StatCouterConnection{
Connection: conn,
ReadCounter: h.downlinkCounter,
WriteCounter: h.uplinkCounter,
}
}
return conn
}
// GetOutbound implements proxy.GetOutbound.

View File

@ -1,13 +1,80 @@
package outbound_test
import (
"context"
"testing"
"v2ray.com/core"
"v2ray.com/core/app/policy"
. "v2ray.com/core/app/proxyman/outbound"
"v2ray.com/core/app/stats"
"v2ray.com/core/common/net"
"v2ray.com/core/common/serial"
"v2ray.com/core/features/outbound"
"v2ray.com/core/proxy/freedom"
"v2ray.com/core/transport/internet"
)
func TestInterfaces(t *testing.T) {
_ = (outbound.Handler)(new(Handler))
_ = (outbound.Manager)(new(Manager))
}
const v2rayKey core.V2rayKey = 1
func TestOutboundWithoutStatCounter(t *testing.T) {
config := &core.Config{
App: []*serial.TypedMessage{
serial.ToTypedMessage(&stats.Config{}),
serial.ToTypedMessage(&policy.Config{
System: &policy.SystemPolicy{
Stats: &policy.SystemPolicy_Stats{
InboundUplink: true,
},
},
}),
},
}
v, _ := core.New(config)
v.AddFeature((outbound.Manager)(new(Manager)))
ctx := context.WithValue(context.Background(), v2rayKey, v)
h, _ := NewHandler(ctx, &core.OutboundHandlerConfig{
Tag: "tag",
ProxySettings: serial.ToTypedMessage(&freedom.Config{}),
})
conn, _ := h.(*Handler).Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), 13146))
_, ok := conn.(*internet.StatCouterConnection)
if ok {
t.Errorf("Expected conn to not be StatCouterConnection")
}
}
func TestOutboundWithStatCounter(t *testing.T) {
config := &core.Config{
App: []*serial.TypedMessage{
serial.ToTypedMessage(&stats.Config{}),
serial.ToTypedMessage(&policy.Config{
System: &policy.SystemPolicy{
Stats: &policy.SystemPolicy_Stats{
OutboundUplink: true,
OutboundDownlink: true,
},
},
}),
},
}
v, _ := core.New(config)
v.AddFeature((outbound.Manager)(new(Manager)))
ctx := context.WithValue(context.Background(), v2rayKey, v)
h, _ := NewHandler(ctx, &core.OutboundHandlerConfig{
Tag: "tag",
ProxySettings: serial.ToTypedMessage(&freedom.Config{}),
})
conn, _ := h.(*Handler).Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), 13146))
_, ok := conn.(*internet.StatCouterConnection)
if !ok {
t.Errorf("Expected conn to be StatCouterConnection")
}
}

View File

@ -1,6 +1,6 @@
package outbound
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen
import (
"context"

View File

@ -1,21 +1,29 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.13.0
// source: app/reverse/config.proto
package reverse
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type Control_State int32
@ -24,244 +32,409 @@ const (
Control_DRAIN Control_State = 1
)
var Control_State_name = map[int32]string{
0: "ACTIVE",
1: "DRAIN",
}
// Enum value maps for Control_State.
var (
Control_State_name = map[int32]string{
0: "ACTIVE",
1: "DRAIN",
}
Control_State_value = map[string]int32{
"ACTIVE": 0,
"DRAIN": 1,
}
)
var Control_State_value = map[string]int32{
"ACTIVE": 0,
"DRAIN": 1,
func (x Control_State) Enum() *Control_State {
p := new(Control_State)
*p = x
return p
}
func (x Control_State) String() string {
return proto.EnumName(Control_State_name, int32(x))
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Control_State) Descriptor() protoreflect.EnumDescriptor {
return file_app_reverse_config_proto_enumTypes[0].Descriptor()
}
func (Control_State) Type() protoreflect.EnumType {
return &file_app_reverse_config_proto_enumTypes[0]
}
func (x Control_State) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Control_State.Descriptor instead.
func (Control_State) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_829a0eeb60380cbc, []int{0, 0}
return file_app_reverse_config_proto_rawDescGZIP(), []int{0, 0}
}
type Control struct {
State Control_State `protobuf:"varint,1,opt,name=state,proto3,enum=v2ray.core.app.reverse.Control_State" json:"state,omitempty"`
Random []byte `protobuf:"bytes,99,opt,name=random,proto3" json:"random,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
State Control_State `protobuf:"varint,1,opt,name=state,proto3,enum=v2ray.core.app.reverse.Control_State" json:"state,omitempty"`
Random []byte `protobuf:"bytes,99,opt,name=random,proto3" json:"random,omitempty"`
}
func (m *Control) Reset() { *m = Control{} }
func (m *Control) String() string { return proto.CompactTextString(m) }
func (*Control) ProtoMessage() {}
func (x *Control) Reset() {
*x = Control{}
if protoimpl.UnsafeEnabled {
mi := &file_app_reverse_config_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Control) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Control) ProtoMessage() {}
func (x *Control) ProtoReflect() protoreflect.Message {
mi := &file_app_reverse_config_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Control.ProtoReflect.Descriptor instead.
func (*Control) Descriptor() ([]byte, []int) {
return fileDescriptor_829a0eeb60380cbc, []int{0}
return file_app_reverse_config_proto_rawDescGZIP(), []int{0}
}
func (m *Control) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Control.Unmarshal(m, b)
}
func (m *Control) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Control.Marshal(b, m, deterministic)
}
func (m *Control) XXX_Merge(src proto.Message) {
xxx_messageInfo_Control.Merge(m, src)
}
func (m *Control) XXX_Size() int {
return xxx_messageInfo_Control.Size(m)
}
func (m *Control) XXX_DiscardUnknown() {
xxx_messageInfo_Control.DiscardUnknown(m)
}
var xxx_messageInfo_Control proto.InternalMessageInfo
func (m *Control) GetState() Control_State {
if m != nil {
return m.State
func (x *Control) GetState() Control_State {
if x != nil {
return x.State
}
return Control_ACTIVE
}
func (m *Control) GetRandom() []byte {
if m != nil {
return m.Random
func (x *Control) GetRandom() []byte {
if x != nil {
return x.Random
}
return nil
}
type BridgeConfig struct {
Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"`
}
func (m *BridgeConfig) Reset() { *m = BridgeConfig{} }
func (m *BridgeConfig) String() string { return proto.CompactTextString(m) }
func (*BridgeConfig) ProtoMessage() {}
func (x *BridgeConfig) Reset() {
*x = BridgeConfig{}
if protoimpl.UnsafeEnabled {
mi := &file_app_reverse_config_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BridgeConfig) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BridgeConfig) ProtoMessage() {}
func (x *BridgeConfig) ProtoReflect() protoreflect.Message {
mi := &file_app_reverse_config_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BridgeConfig.ProtoReflect.Descriptor instead.
func (*BridgeConfig) Descriptor() ([]byte, []int) {
return fileDescriptor_829a0eeb60380cbc, []int{1}
return file_app_reverse_config_proto_rawDescGZIP(), []int{1}
}
func (m *BridgeConfig) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BridgeConfig.Unmarshal(m, b)
}
func (m *BridgeConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_BridgeConfig.Marshal(b, m, deterministic)
}
func (m *BridgeConfig) XXX_Merge(src proto.Message) {
xxx_messageInfo_BridgeConfig.Merge(m, src)
}
func (m *BridgeConfig) XXX_Size() int {
return xxx_messageInfo_BridgeConfig.Size(m)
}
func (m *BridgeConfig) XXX_DiscardUnknown() {
xxx_messageInfo_BridgeConfig.DiscardUnknown(m)
}
var xxx_messageInfo_BridgeConfig proto.InternalMessageInfo
func (m *BridgeConfig) GetTag() string {
if m != nil {
return m.Tag
func (x *BridgeConfig) GetTag() string {
if x != nil {
return x.Tag
}
return ""
}
func (m *BridgeConfig) GetDomain() string {
if m != nil {
return m.Domain
func (x *BridgeConfig) GetDomain() string {
if x != nil {
return x.Domain
}
return ""
}
type PortalConfig struct {
Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"`
}
func (m *PortalConfig) Reset() { *m = PortalConfig{} }
func (m *PortalConfig) String() string { return proto.CompactTextString(m) }
func (*PortalConfig) ProtoMessage() {}
func (x *PortalConfig) Reset() {
*x = PortalConfig{}
if protoimpl.UnsafeEnabled {
mi := &file_app_reverse_config_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PortalConfig) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PortalConfig) ProtoMessage() {}
func (x *PortalConfig) ProtoReflect() protoreflect.Message {
mi := &file_app_reverse_config_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PortalConfig.ProtoReflect.Descriptor instead.
func (*PortalConfig) Descriptor() ([]byte, []int) {
return fileDescriptor_829a0eeb60380cbc, []int{2}
return file_app_reverse_config_proto_rawDescGZIP(), []int{2}
}
func (m *PortalConfig) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PortalConfig.Unmarshal(m, b)
}
func (m *PortalConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PortalConfig.Marshal(b, m, deterministic)
}
func (m *PortalConfig) XXX_Merge(src proto.Message) {
xxx_messageInfo_PortalConfig.Merge(m, src)
}
func (m *PortalConfig) XXX_Size() int {
return xxx_messageInfo_PortalConfig.Size(m)
}
func (m *PortalConfig) XXX_DiscardUnknown() {
xxx_messageInfo_PortalConfig.DiscardUnknown(m)
}
var xxx_messageInfo_PortalConfig proto.InternalMessageInfo
func (m *PortalConfig) GetTag() string {
if m != nil {
return m.Tag
func (x *PortalConfig) GetTag() string {
if x != nil {
return x.Tag
}
return ""
}
func (m *PortalConfig) GetDomain() string {
if m != nil {
return m.Domain
func (x *PortalConfig) GetDomain() string {
if x != nil {
return x.Domain
}
return ""
}
type Config struct {
BridgeConfig []*BridgeConfig `protobuf:"bytes,1,rep,name=bridge_config,json=bridgeConfig,proto3" json:"bridge_config,omitempty"`
PortalConfig []*PortalConfig `protobuf:"bytes,2,rep,name=portal_config,json=portalConfig,proto3" json:"portal_config,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
BridgeConfig []*BridgeConfig `protobuf:"bytes,1,rep,name=bridge_config,json=bridgeConfig,proto3" json:"bridge_config,omitempty"`
PortalConfig []*PortalConfig `protobuf:"bytes,2,rep,name=portal_config,json=portalConfig,proto3" json:"portal_config,omitempty"`
}
func (m *Config) Reset() { *m = Config{} }
func (m *Config) String() string { return proto.CompactTextString(m) }
func (*Config) ProtoMessage() {}
func (x *Config) Reset() {
*x = Config{}
if protoimpl.UnsafeEnabled {
mi := &file_app_reverse_config_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Config) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Config) ProtoMessage() {}
func (x *Config) ProtoReflect() protoreflect.Message {
mi := &file_app_reverse_config_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
func (*Config) Descriptor() ([]byte, []int) {
return fileDescriptor_829a0eeb60380cbc, []int{3}
return file_app_reverse_config_proto_rawDescGZIP(), []int{3}
}
func (m *Config) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Config.Unmarshal(m, b)
}
func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Config.Marshal(b, m, deterministic)
}
func (m *Config) XXX_Merge(src proto.Message) {
xxx_messageInfo_Config.Merge(m, src)
}
func (m *Config) XXX_Size() int {
return xxx_messageInfo_Config.Size(m)
}
func (m *Config) XXX_DiscardUnknown() {
xxx_messageInfo_Config.DiscardUnknown(m)
}
var xxx_messageInfo_Config proto.InternalMessageInfo
func (m *Config) GetBridgeConfig() []*BridgeConfig {
if m != nil {
return m.BridgeConfig
func (x *Config) GetBridgeConfig() []*BridgeConfig {
if x != nil {
return x.BridgeConfig
}
return nil
}
func (m *Config) GetPortalConfig() []*PortalConfig {
if m != nil {
return m.PortalConfig
func (x *Config) GetPortalConfig() []*PortalConfig {
if x != nil {
return x.PortalConfig
}
return nil
}
func init() {
proto.RegisterEnum("v2ray.core.app.reverse.Control_State", Control_State_name, Control_State_value)
proto.RegisterType((*Control)(nil), "v2ray.core.app.reverse.Control")
proto.RegisterType((*BridgeConfig)(nil), "v2ray.core.app.reverse.BridgeConfig")
proto.RegisterType((*PortalConfig)(nil), "v2ray.core.app.reverse.PortalConfig")
proto.RegisterType((*Config)(nil), "v2ray.core.app.reverse.Config")
var File_app_reverse_config_proto protoreflect.FileDescriptor
var file_app_reverse_config_proto_rawDesc = []byte{
0x0a, 0x18, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x2f, 0x63, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x76, 0x32, 0x72, 0x61,
0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x65, 0x76, 0x65, 0x72,
0x73, 0x65, 0x22, 0x7e, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x12, 0x3b, 0x0a,
0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x25, 0x2e, 0x76,
0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x65,
0x76, 0x65, 0x72, 0x73, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x74,
0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x61,
0x6e, 0x64, 0x6f, 0x6d, 0x18, 0x63, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x61, 0x6e, 0x64,
0x6f, 0x6d, 0x22, 0x1e, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x41,
0x43, 0x54, 0x49, 0x56, 0x45, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x44, 0x52, 0x41, 0x49, 0x4e,
0x10, 0x01, 0x22, 0x38, 0x0a, 0x0c, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x03, 0x74, 0x61, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0x38, 0x0a, 0x0c,
0x50, 0x6f, 0x72, 0x74, 0x61, 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03,
0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x16,
0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0x9e, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x12, 0x49, 0x0a, 0x0d, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79,
0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73,
0x65, 0x2e, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0c,
0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x49, 0x0a, 0x0d,
0x70, 0x6f, 0x72, 0x74, 0x61, 0x6c, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65,
0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x2e, 0x50, 0x6f, 0x72,
0x74, 0x61, 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0c, 0x70, 0x6f, 0x72, 0x74, 0x61,
0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x42, 0x57, 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 0x2e, 0x76,
0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e,
0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x01, 0x5a, 0x1a, 0x76, 0x32, 0x72, 0x61, 0x79,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x65,
0x76, 0x65, 0x72, 0x73, 0x65, 0xaa, 0x02, 0x18, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f,
0x72, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
func init() {
proto.RegisterFile("v2ray.com/core/app/reverse/config.proto", fileDescriptor_829a0eeb60380cbc)
var (
file_app_reverse_config_proto_rawDescOnce sync.Once
file_app_reverse_config_proto_rawDescData = file_app_reverse_config_proto_rawDesc
)
func file_app_reverse_config_proto_rawDescGZIP() []byte {
file_app_reverse_config_proto_rawDescOnce.Do(func() {
file_app_reverse_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_reverse_config_proto_rawDescData)
})
return file_app_reverse_config_proto_rawDescData
}
var fileDescriptor_829a0eeb60380cbc = []byte{
// 310 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xc1, 0x4b, 0xfb, 0x30,
0x14, 0xc7, 0x7f, 0xd9, 0x58, 0xc7, 0xde, 0xaf, 0x93, 0x91, 0xc3, 0xe8, 0x41, 0x64, 0x0c, 0xc5,
0x9d, 0x52, 0xa8, 0x17, 0xc1, 0xd3, 0xd6, 0x79, 0xe8, 0x45, 0x46, 0x94, 0x1d, 0xbc, 0x48, 0xd6,
0xc5, 0x52, 0x58, 0xfb, 0x42, 0x16, 0x86, 0xbd, 0xf8, 0xa7, 0xf8, 0x07, 0xf8, 0x57, 0x4a, 0xd3,
0x14, 0x7a, 0x50, 0xc1, 0xdb, 0x7b, 0xc9, 0xe7, 0xf3, 0xf2, 0x4d, 0x02, 0xd7, 0xa7, 0x48, 0x8b,
0x8a, 0xa5, 0x58, 0x84, 0x29, 0x6a, 0x19, 0x0a, 0xa5, 0x42, 0x2d, 0x4f, 0x52, 0x1f, 0x65, 0x98,
0x62, 0xf9, 0x9a, 0x67, 0x4c, 0x69, 0x34, 0x48, 0xa7, 0x2d, 0xa8, 0x25, 0x13, 0x4a, 0x31, 0x07,
0xcd, 0xdf, 0x61, 0x18, 0x63, 0x69, 0x34, 0x1e, 0xe8, 0x1d, 0x0c, 0x8e, 0x46, 0x18, 0x19, 0x90,
0x19, 0x59, 0x9c, 0x45, 0x57, 0xec, 0x7b, 0x85, 0x39, 0x9e, 0x3d, 0xd6, 0x30, 0x6f, 0x1c, 0x3a,
0x05, 0x4f, 0x8b, 0x72, 0x8f, 0x45, 0x90, 0xce, 0xc8, 0xc2, 0xe7, 0xae, 0x9b, 0x5f, 0xc0, 0xc0,
0x72, 0x14, 0xc0, 0x5b, 0xc6, 0x4f, 0xc9, 0xf6, 0x7e, 0xf2, 0x8f, 0x8e, 0x60, 0xb0, 0xe6, 0xcb,
0xe4, 0x61, 0x42, 0xe6, 0xb7, 0xe0, 0xaf, 0x74, 0xbe, 0xcf, 0x64, 0x6c, 0xd3, 0xd2, 0x09, 0xf4,
0x8d, 0xc8, 0x6c, 0x84, 0x11, 0xaf, 0xcb, 0x7a, 0xf2, 0x1e, 0x0b, 0x91, 0x97, 0x41, 0xcf, 0x2e,
0xba, 0xae, 0x36, 0x37, 0xa8, 0x8d, 0x38, 0xfc, 0xd9, 0xfc, 0x20, 0xe0, 0x39, 0x29, 0x81, 0xf1,
0xce, 0x1e, 0xff, 0xd2, 0xbc, 0x56, 0x40, 0x66, 0xfd, 0xc5, 0xff, 0xe8, 0xf2, 0xa7, 0xbb, 0x77,
0xb3, 0x72, 0x7f, 0xd7, 0x4d, 0x9e, 0xc0, 0x58, 0xd9, 0x3c, 0xed, 0xa8, 0xde, 0xef, 0xa3, 0xba,
0xe1, 0xb9, 0xaf, 0x3a, 0xdd, 0x6a, 0x0d, 0xe7, 0x29, 0x16, 0x5d, 0x51, 0x69, 0x7c, 0xab, 0x5a,
0x75, 0x43, 0x9e, 0x87, 0xae, 0xfc, 0xec, 0x05, 0xdb, 0x88, 0x8b, 0x8a, 0xc5, 0x35, 0xb5, 0xb1,
0x14, 0x6f, 0xb6, 0x76, 0x9e, 0xfd, 0xf9, 0x9b, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x83,
0x30, 0xdb, 0x24, 0x02, 0x00, 0x00,
var file_app_reverse_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_app_reverse_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_app_reverse_config_proto_goTypes = []interface{}{
(Control_State)(0), // 0: v2ray.core.app.reverse.Control.State
(*Control)(nil), // 1: v2ray.core.app.reverse.Control
(*BridgeConfig)(nil), // 2: v2ray.core.app.reverse.BridgeConfig
(*PortalConfig)(nil), // 3: v2ray.core.app.reverse.PortalConfig
(*Config)(nil), // 4: v2ray.core.app.reverse.Config
}
var file_app_reverse_config_proto_depIdxs = []int32{
0, // 0: v2ray.core.app.reverse.Control.state:type_name -> v2ray.core.app.reverse.Control.State
2, // 1: v2ray.core.app.reverse.Config.bridge_config:type_name -> v2ray.core.app.reverse.BridgeConfig
3, // 2: v2ray.core.app.reverse.Config.portal_config:type_name -> v2ray.core.app.reverse.PortalConfig
3, // [3:3] is the sub-list for method output_type
3, // [3:3] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_app_reverse_config_proto_init() }
func file_app_reverse_config_proto_init() {
if File_app_reverse_config_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_app_reverse_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Control); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_reverse_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BridgeConfig); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_reverse_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PortalConfig); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_reverse_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Config); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_app_reverse_config_proto_rawDesc,
NumEnums: 1,
NumMessages: 4,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_app_reverse_config_proto_goTypes,
DependencyIndexes: file_app_reverse_config_proto_depIdxs,
EnumInfos: file_app_reverse_config_proto_enumTypes,
MessageInfos: file_app_reverse_config_proto_msgTypes,
}.Build()
File_app_reverse_config_proto = out.File
file_app_reverse_config_proto_rawDesc = nil
file_app_reverse_config_proto_goTypes = nil
file_app_reverse_config_proto_depIdxs = nil
}

View File

@ -2,7 +2,7 @@ syntax = "proto3";
package v2ray.core.app.reverse;
option csharp_namespace = "V2Ray.Core.Proxy.Reverse";
option go_package = "reverse";
option go_package = "v2ray.com/core/app/reverse";
option java_package = "com.v2ray.core.proxy.reverse";
option java_multiple_files = true;
@ -19,7 +19,6 @@ message Control {
message BridgeConfig {
string tag = 1;
string domain = 2;
}
message PortalConfig {

View File

@ -2,7 +2,7 @@
package reverse
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen
import (
"context"

View File

@ -0,0 +1,95 @@
// +build !confonly
package command
//go:generate go run v2ray.com/core/common/errors/errorgen
import (
"context"
"time"
"google.golang.org/grpc"
"v2ray.com/core"
"v2ray.com/core/common"
"v2ray.com/core/features/routing"
"v2ray.com/core/features/stats"
)
// routingServer is an implementation of RoutingService.
type routingServer struct {
router routing.Router
routingStats stats.Channel
}
// NewRoutingServer creates a statistics service with statistics manager.
func NewRoutingServer(router routing.Router, routingStats stats.Channel) RoutingServiceServer {
return &routingServer{
router: router,
routingStats: routingStats,
}
}
func (s *routingServer) TestRoute(ctx context.Context, request *TestRouteRequest) (*RoutingContext, error) {
if request.RoutingContext == nil {
return nil, newError("Invalid routing request.")
}
route, err := s.router.PickRoute(AsRoutingContext(request.RoutingContext))
if err != nil {
return nil, err
}
if request.PublishResult && s.routingStats != nil {
ctx, _ := context.WithTimeout(context.Background(), 4*time.Second) // nolint: govet
s.routingStats.Publish(ctx, route)
}
return AsProtobufMessage(request.FieldSelectors)(route), nil
}
func (s *routingServer) SubscribeRoutingStats(request *SubscribeRoutingStatsRequest, stream RoutingService_SubscribeRoutingStatsServer) error {
if s.routingStats == nil {
return newError("Routing statistics not enabled.")
}
genMessage := AsProtobufMessage(request.FieldSelectors)
subscriber, err := stats.SubscribeRunnableChannel(s.routingStats)
if err != nil {
return err
}
defer stats.UnsubscribeClosableChannel(s.routingStats, subscriber) // nolint: errcheck
for {
select {
case value, ok := <-subscriber:
if !ok {
return newError("Upstream closed the subscriber channel.")
}
route, ok := value.(routing.Route)
if !ok {
return newError("Upstream sent malformed statistics.")
}
err := stream.Send(genMessage(route))
if err != nil {
return err
}
case <-stream.Context().Done():
return stream.Context().Err()
}
}
}
func (s *routingServer) mustEmbedUnimplementedRoutingServiceServer() {}
type service struct {
v *core.Instance
}
func (s *service) Register(server *grpc.Server) {
common.Must(s.v.RequireFeatures(func(router routing.Router, stats stats.Manager) {
RegisterRoutingServiceServer(server, NewRoutingServer(router, nil))
}))
}
func init() {
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, cfg interface{}) (interface{}, error) {
s := core.MustFromContext(ctx)
return &service{v: s}, nil
}))
}

View File

@ -0,0 +1,534 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.13.0
// source: app/router/command/command.proto
package command
import (
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
net "v2ray.com/core/common/net"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
// RoutingContext is the context with information relative to routing process.
// It conforms to the structure of v2ray.core.features.routing.Context and
// v2ray.core.features.routing.Route.
type RoutingContext struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
InboundTag string `protobuf:"bytes,1,opt,name=InboundTag,proto3" json:"InboundTag,omitempty"`
Network net.Network `protobuf:"varint,2,opt,name=Network,proto3,enum=v2ray.core.common.net.Network" json:"Network,omitempty"`
SourceIPs [][]byte `protobuf:"bytes,3,rep,name=SourceIPs,proto3" json:"SourceIPs,omitempty"`
TargetIPs [][]byte `protobuf:"bytes,4,rep,name=TargetIPs,proto3" json:"TargetIPs,omitempty"`
SourcePort uint32 `protobuf:"varint,5,opt,name=SourcePort,proto3" json:"SourcePort,omitempty"`
TargetPort uint32 `protobuf:"varint,6,opt,name=TargetPort,proto3" json:"TargetPort,omitempty"`
TargetDomain string `protobuf:"bytes,7,opt,name=TargetDomain,proto3" json:"TargetDomain,omitempty"`
Protocol string `protobuf:"bytes,8,opt,name=Protocol,proto3" json:"Protocol,omitempty"`
User string `protobuf:"bytes,9,opt,name=User,proto3" json:"User,omitempty"`
Attributes map[string]string `protobuf:"bytes,10,rep,name=Attributes,proto3" json:"Attributes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
OutboundGroupTags []string `protobuf:"bytes,11,rep,name=OutboundGroupTags,proto3" json:"OutboundGroupTags,omitempty"`
OutboundTag string `protobuf:"bytes,12,opt,name=OutboundTag,proto3" json:"OutboundTag,omitempty"`
}
func (x *RoutingContext) Reset() {
*x = RoutingContext{}
if protoimpl.UnsafeEnabled {
mi := &file_app_router_command_command_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RoutingContext) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RoutingContext) ProtoMessage() {}
func (x *RoutingContext) ProtoReflect() protoreflect.Message {
mi := &file_app_router_command_command_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RoutingContext.ProtoReflect.Descriptor instead.
func (*RoutingContext) Descriptor() ([]byte, []int) {
return file_app_router_command_command_proto_rawDescGZIP(), []int{0}
}
func (x *RoutingContext) GetInboundTag() string {
if x != nil {
return x.InboundTag
}
return ""
}
func (x *RoutingContext) GetNetwork() net.Network {
if x != nil {
return x.Network
}
return net.Network_Unknown
}
func (x *RoutingContext) GetSourceIPs() [][]byte {
if x != nil {
return x.SourceIPs
}
return nil
}
func (x *RoutingContext) GetTargetIPs() [][]byte {
if x != nil {
return x.TargetIPs
}
return nil
}
func (x *RoutingContext) GetSourcePort() uint32 {
if x != nil {
return x.SourcePort
}
return 0
}
func (x *RoutingContext) GetTargetPort() uint32 {
if x != nil {
return x.TargetPort
}
return 0
}
func (x *RoutingContext) GetTargetDomain() string {
if x != nil {
return x.TargetDomain
}
return ""
}
func (x *RoutingContext) GetProtocol() string {
if x != nil {
return x.Protocol
}
return ""
}
func (x *RoutingContext) GetUser() string {
if x != nil {
return x.User
}
return ""
}
func (x *RoutingContext) GetAttributes() map[string]string {
if x != nil {
return x.Attributes
}
return nil
}
func (x *RoutingContext) GetOutboundGroupTags() []string {
if x != nil {
return x.OutboundGroupTags
}
return nil
}
func (x *RoutingContext) GetOutboundTag() string {
if x != nil {
return x.OutboundTag
}
return ""
}
// SubscribeRoutingStatsRequest subscribes to routing statistics channel if
// opened by v2ray-core.
// * FieldSelectors selects a subset of fields in routing statistics to return.
// Valid selectors:
// - inbound: Selects connection's inbound tag.
// - network: Selects connection's network.
// - ip: Equivalent as "ip_source" and "ip_target", selects both source and
// target IP.
// - port: Equivalent as "port_source" and "port_target", selects both source
// and target port.
// - domain: Selects target domain.
// - protocol: Select connection's protocol.
// - user: Select connection's inbound user email.
// - attributes: Select connection's additional attributes.
// - outbound: Equivalent as "outbound" and "outbound_group", select both
// outbound tag and outbound group tags.
// * If FieldSelectors is left empty, all fields will be returned.
type SubscribeRoutingStatsRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
FieldSelectors []string `protobuf:"bytes,1,rep,name=FieldSelectors,proto3" json:"FieldSelectors,omitempty"`
}
func (x *SubscribeRoutingStatsRequest) Reset() {
*x = SubscribeRoutingStatsRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_app_router_command_command_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SubscribeRoutingStatsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SubscribeRoutingStatsRequest) ProtoMessage() {}
func (x *SubscribeRoutingStatsRequest) ProtoReflect() protoreflect.Message {
mi := &file_app_router_command_command_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SubscribeRoutingStatsRequest.ProtoReflect.Descriptor instead.
func (*SubscribeRoutingStatsRequest) Descriptor() ([]byte, []int) {
return file_app_router_command_command_proto_rawDescGZIP(), []int{1}
}
func (x *SubscribeRoutingStatsRequest) GetFieldSelectors() []string {
if x != nil {
return x.FieldSelectors
}
return nil
}
// TestRouteRequest manually tests a routing result according to the routing
// context message.
// * RoutingContext is the routing message without outbound information.
// * FieldSelectors selects the fields to return in the routing result. All
// fields are returned if left empty.
// * PublishResult broadcasts the routing result to routing statistics channel
// if set true.
type TestRouteRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RoutingContext *RoutingContext `protobuf:"bytes,1,opt,name=RoutingContext,proto3" json:"RoutingContext,omitempty"`
FieldSelectors []string `protobuf:"bytes,2,rep,name=FieldSelectors,proto3" json:"FieldSelectors,omitempty"`
PublishResult bool `protobuf:"varint,3,opt,name=PublishResult,proto3" json:"PublishResult,omitempty"`
}
func (x *TestRouteRequest) Reset() {
*x = TestRouteRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_app_router_command_command_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TestRouteRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TestRouteRequest) ProtoMessage() {}
func (x *TestRouteRequest) ProtoReflect() protoreflect.Message {
mi := &file_app_router_command_command_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TestRouteRequest.ProtoReflect.Descriptor instead.
func (*TestRouteRequest) Descriptor() ([]byte, []int) {
return file_app_router_command_command_proto_rawDescGZIP(), []int{2}
}
func (x *TestRouteRequest) GetRoutingContext() *RoutingContext {
if x != nil {
return x.RoutingContext
}
return nil
}
func (x *TestRouteRequest) GetFieldSelectors() []string {
if x != nil {
return x.FieldSelectors
}
return nil
}
func (x *TestRouteRequest) GetPublishResult() bool {
if x != nil {
return x.PublishResult
}
return false
}
type Config struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *Config) Reset() {
*x = Config{}
if protoimpl.UnsafeEnabled {
mi := &file_app_router_command_command_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Config) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Config) ProtoMessage() {}
func (x *Config) ProtoReflect() protoreflect.Message {
mi := &file_app_router_command_command_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
func (*Config) Descriptor() ([]byte, []int) {
return file_app_router_command_command_proto_rawDescGZIP(), []int{3}
}
var File_app_router_command_command_proto protoreflect.FileDescriptor
var file_app_router_command_command_proto_rawDesc = []byte{
0x0a, 0x20, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d,
0x6d, 0x61, 0x6e, 0x64, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x12, 0x1d, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61,
0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
0x64, 0x1a, 0x18, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x6e, 0x65,
0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa8, 0x04, 0x0a, 0x0e,
0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x1e,
0x0a, 0x0a, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0a, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x12, 0x38,
0x0a, 0x07, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32,
0x1e, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d,
0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52,
0x07, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x72,
0x63, 0x65, 0x49, 0x50, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x53, 0x6f, 0x75,
0x72, 0x63, 0x65, 0x49, 0x50, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74,
0x49, 0x50, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x54, 0x61, 0x72, 0x67, 0x65,
0x74, 0x49, 0x50, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f,
0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65,
0x50, 0x6f, 0x72, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x50, 0x6f,
0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74,
0x50, 0x6f, 0x72, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x44, 0x6f,
0x6d, 0x61, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x54, 0x61, 0x72, 0x67,
0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x74,
0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x72, 0x6f, 0x74,
0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x18, 0x09, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x5d, 0x0a, 0x0a, 0x41, 0x74, 0x74, 0x72,
0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3d, 0x2e, 0x76,
0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f,
0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x6f, 0x75,
0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2e, 0x41, 0x74, 0x74, 0x72,
0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x41, 0x74, 0x74,
0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x2c, 0x0a, 0x11, 0x4f, 0x75, 0x74, 0x62, 0x6f,
0x75, 0x6e, 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x54, 0x61, 0x67, 0x73, 0x18, 0x0b, 0x20, 0x03,
0x28, 0x09, 0x52, 0x11, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x47, 0x72, 0x6f, 0x75,
0x70, 0x54, 0x61, 0x67, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e,
0x64, 0x54, 0x61, 0x67, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x4f, 0x75, 0x74, 0x62,
0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x1a, 0x3d, 0x0a, 0x0f, 0x41, 0x74, 0x74, 0x72, 0x69,
0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65,
0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c,
0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x46, 0x0a, 0x1c, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72,
0x69, 0x62, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x53,
0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e,
0x46, 0x69, 0x65, 0x6c, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x22, 0xb7,
0x01, 0x0a, 0x10, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x55, 0x0a, 0x0e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f,
0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x76, 0x32,
0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75,
0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x6f, 0x75, 0x74,
0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x0e, 0x52, 0x6f, 0x75, 0x74,
0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x46, 0x69,
0x65, 0x6c, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03,
0x28, 0x09, 0x52, 0x0e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f,
0x72, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73,
0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x50, 0x75, 0x62, 0x6c, 0x69,
0x73, 0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x32, 0x89, 0x02, 0x0a, 0x0e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x87, 0x01, 0x0a, 0x15, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72,
0x69, 0x62, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12,
0x3b, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70,
0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e,
0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67,
0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x76,
0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f,
0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x6f, 0x75,
0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x00, 0x30, 0x01, 0x12,
0x6d, 0x0a, 0x09, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x2f, 0x2e, 0x76,
0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f,
0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x65, 0x73,
0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e,
0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72,
0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x6f,
0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x00, 0x42, 0x68,
0x0a, 0x21, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65,
0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d,
0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x21, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72,
0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x1d, 0x56, 0x32, 0x52, 0x61, 0x79,
0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72,
0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_app_router_command_command_proto_rawDescOnce sync.Once
file_app_router_command_command_proto_rawDescData = file_app_router_command_command_proto_rawDesc
)
func file_app_router_command_command_proto_rawDescGZIP() []byte {
file_app_router_command_command_proto_rawDescOnce.Do(func() {
file_app_router_command_command_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_router_command_command_proto_rawDescData)
})
return file_app_router_command_command_proto_rawDescData
}
var file_app_router_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_app_router_command_command_proto_goTypes = []interface{}{
(*RoutingContext)(nil), // 0: v2ray.core.app.router.command.RoutingContext
(*SubscribeRoutingStatsRequest)(nil), // 1: v2ray.core.app.router.command.SubscribeRoutingStatsRequest
(*TestRouteRequest)(nil), // 2: v2ray.core.app.router.command.TestRouteRequest
(*Config)(nil), // 3: v2ray.core.app.router.command.Config
nil, // 4: v2ray.core.app.router.command.RoutingContext.AttributesEntry
(net.Network)(0), // 5: v2ray.core.common.net.Network
}
var file_app_router_command_command_proto_depIdxs = []int32{
5, // 0: v2ray.core.app.router.command.RoutingContext.Network:type_name -> v2ray.core.common.net.Network
4, // 1: v2ray.core.app.router.command.RoutingContext.Attributes:type_name -> v2ray.core.app.router.command.RoutingContext.AttributesEntry
0, // 2: v2ray.core.app.router.command.TestRouteRequest.RoutingContext:type_name -> v2ray.core.app.router.command.RoutingContext
1, // 3: v2ray.core.app.router.command.RoutingService.SubscribeRoutingStats:input_type -> v2ray.core.app.router.command.SubscribeRoutingStatsRequest
2, // 4: v2ray.core.app.router.command.RoutingService.TestRoute:input_type -> v2ray.core.app.router.command.TestRouteRequest
0, // 5: v2ray.core.app.router.command.RoutingService.SubscribeRoutingStats:output_type -> v2ray.core.app.router.command.RoutingContext
0, // 6: v2ray.core.app.router.command.RoutingService.TestRoute:output_type -> v2ray.core.app.router.command.RoutingContext
5, // [5:7] is the sub-list for method output_type
3, // [3:5] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_app_router_command_command_proto_init() }
func file_app_router_command_command_proto_init() {
if File_app_router_command_command_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_app_router_command_command_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RoutingContext); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_router_command_command_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SubscribeRoutingStatsRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_router_command_command_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TestRouteRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_router_command_command_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Config); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_app_router_command_command_proto_rawDesc,
NumEnums: 0,
NumMessages: 5,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_app_router_command_command_proto_goTypes,
DependencyIndexes: file_app_router_command_command_proto_depIdxs,
MessageInfos: file_app_router_command_command_proto_msgTypes,
}.Build()
File_app_router_command_command_proto = out.File
file_app_router_command_command_proto_rawDesc = nil
file_app_router_command_command_proto_goTypes = nil
file_app_router_command_command_proto_depIdxs = nil
}

View File

@ -0,0 +1,69 @@
syntax = "proto3";
package v2ray.core.app.router.command;
option csharp_namespace = "V2Ray.Core.App.Router.Command";
option go_package = "v2ray.com/core/app/router/command";
option java_package = "com.v2ray.core.app.router.command";
option java_multiple_files = true;
import "common/net/network.proto";
// RoutingContext is the context with information relative to routing process.
// It conforms to the structure of v2ray.core.features.routing.Context and
// v2ray.core.features.routing.Route.
message RoutingContext {
string InboundTag = 1;
v2ray.core.common.net.Network Network = 2;
repeated bytes SourceIPs = 3;
repeated bytes TargetIPs = 4;
uint32 SourcePort = 5;
uint32 TargetPort = 6;
string TargetDomain = 7;
string Protocol = 8;
string User = 9;
map<string, string> Attributes = 10;
repeated string OutboundGroupTags = 11;
string OutboundTag = 12;
}
// SubscribeRoutingStatsRequest subscribes to routing statistics channel if
// opened by v2ray-core.
// * FieldSelectors selects a subset of fields in routing statistics to return.
// Valid selectors:
// - inbound: Selects connection's inbound tag.
// - network: Selects connection's network.
// - ip: Equivalent as "ip_source" and "ip_target", selects both source and
// target IP.
// - port: Equivalent as "port_source" and "port_target", selects both source
// and target port.
// - domain: Selects target domain.
// - protocol: Select connection's protocol.
// - user: Select connection's inbound user email.
// - attributes: Select connection's additional attributes.
// - outbound: Equivalent as "outbound" and "outbound_group", select both
// outbound tag and outbound group tags.
// * If FieldSelectors is left empty, all fields will be returned.
message SubscribeRoutingStatsRequest {
repeated string FieldSelectors = 1;
}
// TestRouteRequest manually tests a routing result according to the routing
// context message.
// * RoutingContext is the routing message without outbound information.
// * FieldSelectors selects the fields to return in the routing result. All
// fields are returned if left empty.
// * PublishResult broadcasts the routing result to routing statistics channel
// if set true.
message TestRouteRequest {
RoutingContext RoutingContext = 1;
repeated string FieldSelectors = 2;
bool PublishResult = 3;
}
service RoutingService {
rpc SubscribeRoutingStats(SubscribeRoutingStatsRequest)
returns (stream RoutingContext) {}
rpc TestRoute(TestRouteRequest) returns (RoutingContext) {}
}
message Config {}

View File

@ -0,0 +1,161 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package command
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion7
// RoutingServiceClient is the client API for RoutingService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type RoutingServiceClient interface {
SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (RoutingService_SubscribeRoutingStatsClient, error)
TestRoute(ctx context.Context, in *TestRouteRequest, opts ...grpc.CallOption) (*RoutingContext, error)
}
type routingServiceClient struct {
cc grpc.ClientConnInterface
}
func NewRoutingServiceClient(cc grpc.ClientConnInterface) RoutingServiceClient {
return &routingServiceClient{cc}
}
func (c *routingServiceClient) SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (RoutingService_SubscribeRoutingStatsClient, error) {
stream, err := c.cc.NewStream(ctx, &_RoutingService_serviceDesc.Streams[0], "/v2ray.core.app.router.command.RoutingService/SubscribeRoutingStats", opts...)
if err != nil {
return nil, err
}
x := &routingServiceSubscribeRoutingStatsClient{stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
type RoutingService_SubscribeRoutingStatsClient interface {
Recv() (*RoutingContext, error)
grpc.ClientStream
}
type routingServiceSubscribeRoutingStatsClient struct {
grpc.ClientStream
}
func (x *routingServiceSubscribeRoutingStatsClient) Recv() (*RoutingContext, error) {
m := new(RoutingContext)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *routingServiceClient) TestRoute(ctx context.Context, in *TestRouteRequest, opts ...grpc.CallOption) (*RoutingContext, error) {
out := new(RoutingContext)
err := c.cc.Invoke(ctx, "/v2ray.core.app.router.command.RoutingService/TestRoute", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// RoutingServiceServer is the server API for RoutingService service.
// All implementations must embed UnimplementedRoutingServiceServer
// for forward compatibility
type RoutingServiceServer interface {
SubscribeRoutingStats(*SubscribeRoutingStatsRequest, RoutingService_SubscribeRoutingStatsServer) error
TestRoute(context.Context, *TestRouteRequest) (*RoutingContext, error)
mustEmbedUnimplementedRoutingServiceServer()
}
// UnimplementedRoutingServiceServer must be embedded to have forward compatible implementations.
type UnimplementedRoutingServiceServer struct {
}
func (UnimplementedRoutingServiceServer) SubscribeRoutingStats(*SubscribeRoutingStatsRequest, RoutingService_SubscribeRoutingStatsServer) error {
return status.Errorf(codes.Unimplemented, "method SubscribeRoutingStats not implemented")
}
func (UnimplementedRoutingServiceServer) TestRoute(context.Context, *TestRouteRequest) (*RoutingContext, error) {
return nil, status.Errorf(codes.Unimplemented, "method TestRoute not implemented")
}
func (UnimplementedRoutingServiceServer) mustEmbedUnimplementedRoutingServiceServer() {}
// UnsafeRoutingServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to RoutingServiceServer will
// result in compilation errors.
type UnsafeRoutingServiceServer interface {
mustEmbedUnimplementedRoutingServiceServer()
}
func RegisterRoutingServiceServer(s *grpc.Server, srv RoutingServiceServer) {
s.RegisterService(&_RoutingService_serviceDesc, srv)
}
func _RoutingService_SubscribeRoutingStats_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(SubscribeRoutingStatsRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(RoutingServiceServer).SubscribeRoutingStats(m, &routingServiceSubscribeRoutingStatsServer{stream})
}
type RoutingService_SubscribeRoutingStatsServer interface {
Send(*RoutingContext) error
grpc.ServerStream
}
type routingServiceSubscribeRoutingStatsServer struct {
grpc.ServerStream
}
func (x *routingServiceSubscribeRoutingStatsServer) Send(m *RoutingContext) error {
return x.ServerStream.SendMsg(m)
}
func _RoutingService_TestRoute_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TestRouteRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RoutingServiceServer).TestRoute(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/v2ray.core.app.router.command.RoutingService/TestRoute",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RoutingServiceServer).TestRoute(ctx, req.(*TestRouteRequest))
}
return interceptor(ctx, in, info, handler)
}
var _RoutingService_serviceDesc = grpc.ServiceDesc{
ServiceName: "v2ray.core.app.router.command.RoutingService",
HandlerType: (*RoutingServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "TestRoute",
Handler: _RoutingService_TestRoute_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "SubscribeRoutingStats",
Handler: _RoutingService_SubscribeRoutingStats_Handler,
ServerStreams: true,
},
},
Metadata: "app/router/command/command.proto",
}

View File

@ -0,0 +1,361 @@
package command_test
import (
"context"
"testing"
"time"
"github.com/golang/mock/gomock"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"google.golang.org/grpc"
"google.golang.org/grpc/test/bufconn"
"v2ray.com/core/app/router"
. "v2ray.com/core/app/router/command"
"v2ray.com/core/app/stats"
"v2ray.com/core/common"
"v2ray.com/core/common/net"
"v2ray.com/core/features/routing"
"v2ray.com/core/testing/mocks"
)
func TestServiceSubscribeRoutingStats(t *testing.T) {
c := stats.NewChannel(&stats.ChannelConfig{
SubscriberLimit: 1,
BufferSize: 0,
Blocking: true,
})
common.Must(c.Start())
defer c.Close()
lis := bufconn.Listen(1024 * 1024)
bufDialer := func(context.Context, string) (net.Conn, error) {
return lis.Dial()
}
testCases := []*RoutingContext{
{InboundTag: "in", OutboundTag: "out"},
{TargetIPs: [][]byte{{1, 2, 3, 4}}, TargetPort: 8080, OutboundTag: "out"},
{TargetDomain: "example.com", TargetPort: 443, OutboundTag: "out"},
{SourcePort: 9999, TargetPort: 9999, OutboundTag: "out"},
{Network: net.Network_UDP, OutboundGroupTags: []string{"outergroup", "innergroup"}, OutboundTag: "out"},
{Protocol: "bittorrent", OutboundTag: "blocked"},
{User: "example@v2fly.org", OutboundTag: "out"},
{SourceIPs: [][]byte{{127, 0, 0, 1}}, Attributes: map[string]string{"attr": "value"}, OutboundTag: "out"},
}
errCh := make(chan error)
nextPub := make(chan struct{})
// Server goroutine
go func() {
server := grpc.NewServer()
RegisterRoutingServiceServer(server, NewRoutingServer(nil, c))
errCh <- server.Serve(lis)
}()
// Publisher goroutine
go func() {
publishTestCases := func() error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
for { // Wait until there's one subscriber in routing stats channel
if len(c.Subscribers()) > 0 {
break
}
if ctx.Err() != nil {
return ctx.Err()
}
}
for _, tc := range testCases {
c.Publish(context.Background(), AsRoutingRoute(tc))
time.Sleep(time.Millisecond)
}
return nil
}
if err := publishTestCases(); err != nil {
errCh <- err
}
// Wait for next round of publishing
<-nextPub
if err := publishTestCases(); err != nil {
errCh <- err
}
}()
// Client goroutine
go func() {
defer lis.Close()
conn, err := grpc.DialContext(context.Background(), "bufnet", grpc.WithContextDialer(bufDialer), grpc.WithInsecure())
if err != nil {
errCh <- err
return
}
defer conn.Close()
client := NewRoutingServiceClient(conn)
// Test retrieving all fields
testRetrievingAllFields := func() error {
streamCtx, streamClose := context.WithCancel(context.Background())
// Test the unsubscription of stream works well
defer func() {
streamClose()
timeOutCtx, timeout := context.WithTimeout(context.Background(), time.Second)
defer timeout()
for { // Wait until there's no subscriber in routing stats channel
if len(c.Subscribers()) == 0 {
break
}
if timeOutCtx.Err() != nil {
t.Error("unexpected subscribers not decreased in channel", timeOutCtx.Err())
}
}
}()
stream, err := client.SubscribeRoutingStats(streamCtx, &SubscribeRoutingStatsRequest{})
if err != nil {
return err
}
for _, tc := range testCases {
msg, err := stream.Recv()
if err != nil {
return err
}
if r := cmp.Diff(msg, tc, cmpopts.IgnoreUnexported(RoutingContext{})); r != "" {
t.Error(r)
}
}
// Test that double subscription will fail
errStream, err := client.SubscribeRoutingStats(context.Background(), &SubscribeRoutingStatsRequest{
FieldSelectors: []string{"ip", "port", "domain", "outbound"},
})
if err != nil {
return err
}
if _, err := errStream.Recv(); err == nil {
t.Error("unexpected successful subscription")
}
return nil
}
// Test retrieving only a subset of fields
testRetrievingSubsetOfFields := func() error {
streamCtx, streamClose := context.WithCancel(context.Background())
defer streamClose()
stream, err := client.SubscribeRoutingStats(streamCtx, &SubscribeRoutingStatsRequest{
FieldSelectors: []string{"ip", "port", "domain", "outbound"},
})
if err != nil {
return err
}
// Send nextPub signal to start next round of publishing
close(nextPub)
for _, tc := range testCases {
msg, err := stream.Recv()
if err != nil {
return err
}
stat := &RoutingContext{ // Only a subset of stats is retrieved
SourceIPs: tc.SourceIPs,
TargetIPs: tc.TargetIPs,
SourcePort: tc.SourcePort,
TargetPort: tc.TargetPort,
TargetDomain: tc.TargetDomain,
OutboundGroupTags: tc.OutboundGroupTags,
OutboundTag: tc.OutboundTag,
}
if r := cmp.Diff(msg, stat, cmpopts.IgnoreUnexported(RoutingContext{})); r != "" {
t.Error(r)
}
}
return nil
}
if err := testRetrievingAllFields(); err != nil {
errCh <- err
}
if err := testRetrievingSubsetOfFields(); err != nil {
errCh <- err
}
errCh <- nil // Client passed all tests successfully
}()
// Wait for goroutines to complete
select {
case <-time.After(2 * time.Second):
t.Fatal("Test timeout after 2s")
case err := <-errCh:
if err != nil {
t.Fatal(err)
}
}
}
func TestSerivceTestRoute(t *testing.T) {
c := stats.NewChannel(&stats.ChannelConfig{
SubscriberLimit: 1,
BufferSize: 16,
Blocking: true,
})
common.Must(c.Start())
defer c.Close()
r := new(router.Router)
mockCtl := gomock.NewController(t)
defer mockCtl.Finish()
common.Must(r.Init(&router.Config{
Rule: []*router.RoutingRule{
{
InboundTag: []string{"in"},
TargetTag: &router.RoutingRule_Tag{Tag: "out"},
},
{
Protocol: []string{"bittorrent"},
TargetTag: &router.RoutingRule_Tag{Tag: "blocked"},
},
{
PortList: &net.PortList{Range: []*net.PortRange{{From: 8080, To: 8080}}},
TargetTag: &router.RoutingRule_Tag{Tag: "out"},
},
{
SourcePortList: &net.PortList{Range: []*net.PortRange{{From: 9999, To: 9999}}},
TargetTag: &router.RoutingRule_Tag{Tag: "out"},
},
{
Domain: []*router.Domain{{Type: router.Domain_Domain, Value: "com"}},
TargetTag: &router.RoutingRule_Tag{Tag: "out"},
},
{
SourceGeoip: []*router.GeoIP{{CountryCode: "private", Cidr: []*router.CIDR{{Ip: []byte{127, 0, 0, 0}, Prefix: 8}}}},
TargetTag: &router.RoutingRule_Tag{Tag: "out"},
},
{
UserEmail: []string{"example@v2fly.org"},
TargetTag: &router.RoutingRule_Tag{Tag: "out"},
},
{
Networks: []net.Network{net.Network_UDP, net.Network_TCP},
TargetTag: &router.RoutingRule_Tag{Tag: "out"},
},
},
}, mocks.NewDNSClient(mockCtl), mocks.NewOutboundManager(mockCtl)))
lis := bufconn.Listen(1024 * 1024)
bufDialer := func(context.Context, string) (net.Conn, error) {
return lis.Dial()
}
errCh := make(chan error)
// Server goroutine
go func() {
server := grpc.NewServer()
RegisterRoutingServiceServer(server, NewRoutingServer(r, c))
errCh <- server.Serve(lis)
}()
// Client goroutine
go func() {
defer lis.Close()
conn, err := grpc.DialContext(context.Background(), "bufnet", grpc.WithContextDialer(bufDialer), grpc.WithInsecure())
if err != nil {
errCh <- err
}
defer conn.Close()
client := NewRoutingServiceClient(conn)
testCases := []*RoutingContext{
{InboundTag: "in", OutboundTag: "out"},
{TargetIPs: [][]byte{{1, 2, 3, 4}}, TargetPort: 8080, OutboundTag: "out"},
{TargetDomain: "example.com", TargetPort: 443, OutboundTag: "out"},
{SourcePort: 9999, TargetPort: 9999, OutboundTag: "out"},
{Network: net.Network_UDP, Protocol: "bittorrent", OutboundTag: "blocked"},
{User: "example@v2fly.org", OutboundTag: "out"},
{SourceIPs: [][]byte{{127, 0, 0, 1}}, Attributes: map[string]string{"attr": "value"}, OutboundTag: "out"},
}
// Test simple TestRoute
testSimple := func() error {
for _, tc := range testCases {
route, err := client.TestRoute(context.Background(), &TestRouteRequest{RoutingContext: tc})
if err != nil {
return err
}
if r := cmp.Diff(route, tc, cmpopts.IgnoreUnexported(RoutingContext{})); r != "" {
t.Error(r)
}
}
return nil
}
// Test TestRoute with special options
testOptions := func() error {
sub, err := c.Subscribe()
if err != nil {
return err
}
for _, tc := range testCases {
route, err := client.TestRoute(context.Background(), &TestRouteRequest{
RoutingContext: tc,
FieldSelectors: []string{"ip", "port", "domain", "outbound"},
PublishResult: true,
})
if err != nil {
return err
}
stat := &RoutingContext{ // Only a subset of stats is retrieved
SourceIPs: tc.SourceIPs,
TargetIPs: tc.TargetIPs,
SourcePort: tc.SourcePort,
TargetPort: tc.TargetPort,
TargetDomain: tc.TargetDomain,
OutboundGroupTags: tc.OutboundGroupTags,
OutboundTag: tc.OutboundTag,
}
if r := cmp.Diff(route, stat, cmpopts.IgnoreUnexported(RoutingContext{})); r != "" {
t.Error(r)
}
select { // Check that routing result has been published to statistics channel
case msg, received := <-sub:
if route, ok := msg.(routing.Route); received && ok {
if r := cmp.Diff(AsProtobufMessage(nil)(route), tc, cmpopts.IgnoreUnexported(RoutingContext{})); r != "" {
t.Error(r)
}
} else {
t.Error("unexpected failure in receiving published routing result for testcase", tc)
}
case <-time.After(100 * time.Millisecond):
t.Error("unexpected failure in receiving published routing result", tc)
}
}
return nil
}
if err := testSimple(); err != nil {
errCh <- err
}
if err := testOptions(); err != nil {
errCh <- err
}
errCh <- nil // Client passed all tests successfully
}()
// Wait for goroutines to complete
select {
case <-time.After(2 * time.Second):
t.Fatal("Test timeout after 2s")
case err := <-errCh:
if err != nil {
t.Fatal(err)
}
}
}

View File

@ -0,0 +1,94 @@
package command
import (
"strings"
"v2ray.com/core/common/net"
"v2ray.com/core/features/routing"
)
// routingContext is an wrapper of protobuf RoutingContext as implementation of routing.Context and routing.Route.
type routingContext struct {
*RoutingContext
}
func (c routingContext) GetSourceIPs() []net.IP {
return mapBytesToIPs(c.RoutingContext.GetSourceIPs())
}
func (c routingContext) GetSourcePort() net.Port {
return net.Port(c.RoutingContext.GetSourcePort())
}
func (c routingContext) GetTargetIPs() []net.IP {
return mapBytesToIPs(c.RoutingContext.GetTargetIPs())
}
func (c routingContext) GetTargetPort() net.Port {
return net.Port(c.RoutingContext.GetTargetPort())
}
// AsRoutingContext converts a protobuf RoutingContext into an implementation of routing.Context.
func AsRoutingContext(r *RoutingContext) routing.Context {
return routingContext{r}
}
// AsRoutingRoute converts a protobuf RoutingContext into an implementation of routing.Route.
func AsRoutingRoute(r *RoutingContext) routing.Route {
return routingContext{r}
}
var fieldMap = map[string]func(*RoutingContext, routing.Route){
"inbound": func(s *RoutingContext, r routing.Route) { s.InboundTag = r.GetInboundTag() },
"network": func(s *RoutingContext, r routing.Route) { s.Network = r.GetNetwork() },
"ip_source": func(s *RoutingContext, r routing.Route) { s.SourceIPs = mapIPsToBytes(r.GetSourceIPs()) },
"ip_target": func(s *RoutingContext, r routing.Route) { s.TargetIPs = mapIPsToBytes(r.GetTargetIPs()) },
"port_source": func(s *RoutingContext, r routing.Route) { s.SourcePort = uint32(r.GetSourcePort()) },
"port_target": func(s *RoutingContext, r routing.Route) { s.TargetPort = uint32(r.GetTargetPort()) },
"domain": func(s *RoutingContext, r routing.Route) { s.TargetDomain = r.GetTargetDomain() },
"protocol": func(s *RoutingContext, r routing.Route) { s.Protocol = r.GetProtocol() },
"user": func(s *RoutingContext, r routing.Route) { s.User = r.GetUser() },
"attributes": func(s *RoutingContext, r routing.Route) { s.Attributes = r.GetAttributes() },
"outbound_group": func(s *RoutingContext, r routing.Route) { s.OutboundGroupTags = r.GetOutboundGroupTags() },
"outbound": func(s *RoutingContext, r routing.Route) { s.OutboundTag = r.GetOutboundTag() },
}
// AsProtobufMessage takes selectors of fields and returns a function to convert routing.Route to protobuf RoutingContext.
func AsProtobufMessage(fieldSelectors []string) func(routing.Route) *RoutingContext {
initializers := []func(*RoutingContext, routing.Route){}
for field, init := range fieldMap {
if len(fieldSelectors) == 0 { // If selectors not set, retrieve all fields
initializers = append(initializers, init)
continue
}
for _, selector := range fieldSelectors {
if strings.HasPrefix(field, selector) {
initializers = append(initializers, init)
break
}
}
}
return func(ctx routing.Route) *RoutingContext {
message := new(RoutingContext)
for _, init := range initializers {
init(message, ctx)
}
return message
}
}
func mapBytesToIPs(bytes [][]byte) []net.IP {
var ips []net.IP
for _, rawIP := range bytes {
ips = append(ips, net.IP(rawIP))
}
return ips
}
func mapIPsToBytes(ips []net.IP) [][]byte {
var bytes [][]byte
for _, ip := range ips {
bytes = append(bytes, []byte(ip))
}
return bytes
}

View File

@ -0,0 +1,9 @@
package command
import "v2ray.com/core/common/errors"
type errPathObjHolder struct{}
func newError(values ...interface{}) *errors.Error {
return errors.New(values...).WithPathObj(errPathObjHolder{})
}

View File

@ -10,10 +10,11 @@ import (
"v2ray.com/core/common/net"
"v2ray.com/core/common/strmatcher"
"v2ray.com/core/features/routing"
)
type Condition interface {
Apply(ctx *Context) bool
Apply(ctx routing.Context) bool
}
type ConditionChan []Condition
@ -28,7 +29,8 @@ func (v *ConditionChan) Add(cond Condition) *ConditionChan {
return v
}
func (v *ConditionChan) Apply(ctx *Context) bool {
// Apply applies all conditions registered in this chan.
func (v *ConditionChan) Apply(ctx routing.Context) bool {
for _, cond := range *v {
if !cond.Apply(ctx) {
return false
@ -82,39 +84,21 @@ func NewDomainMatcher(domains []*Domain) (*DomainMatcher, error) {
}
func (m *DomainMatcher) ApplyDomain(domain string) bool {
return m.matchers.Match(domain) > 0
return len(m.matchers.Match(domain)) > 0
}
func (m *DomainMatcher) Apply(ctx *Context) bool {
if ctx.Outbound == nil || !ctx.Outbound.Target.IsValid() {
// Apply implements Condition.
func (m *DomainMatcher) Apply(ctx routing.Context) bool {
domain := ctx.GetTargetDomain()
if len(domain) == 0 {
return false
}
dest := ctx.Outbound.Target
if !dest.Address.Family().IsDomain() {
return false
}
return m.ApplyDomain(dest.Address.Domain())
}
func getIPsFromSource(ctx *Context) []net.IP {
if ctx.Inbound == nil || !ctx.Inbound.Source.IsValid() {
return nil
}
dest := ctx.Inbound.Source
if dest.Address.Family().IsDomain() {
return nil
}
return []net.IP{dest.Address.IP()}
}
func getIPsFromTarget(ctx *Context) []net.IP {
return ctx.GetTargetIPs()
return m.ApplyDomain(domain)
}
type MultiGeoIPMatcher struct {
matchers []*GeoIPMatcher
ipFunc func(*Context) []net.IP
onSource bool
}
func NewMultiGeoIPMatcher(geoips []*GeoIP, onSource bool) (*MultiGeoIPMatcher, error) {
@ -129,20 +113,20 @@ func NewMultiGeoIPMatcher(geoips []*GeoIP, onSource bool) (*MultiGeoIPMatcher, e
matcher := &MultiGeoIPMatcher{
matchers: matchers,
}
if onSource {
matcher.ipFunc = getIPsFromSource
} else {
matcher.ipFunc = getIPsFromTarget
onSource: onSource,
}
return matcher, nil
}
func (m *MultiGeoIPMatcher) Apply(ctx *Context) bool {
ips := m.ipFunc(ctx)
// Apply implements Condition.
func (m *MultiGeoIPMatcher) Apply(ctx routing.Context) bool {
var ips []net.IP
if m.onSource {
ips = ctx.GetSourceIPs()
} else {
ips = ctx.GetTargetIPs()
}
for _, ip := range ips {
for _, matcher := range m.matchers {
if matcher.Match(ip) {
@ -154,20 +138,25 @@ func (m *MultiGeoIPMatcher) Apply(ctx *Context) bool {
}
type PortMatcher struct {
port net.MemoryPortList
port net.MemoryPortList
onSource bool
}
func NewPortMatcher(list *net.PortList) *PortMatcher {
// NewPortMatcher create a new port matcher that can match source or destination port
func NewPortMatcher(list *net.PortList, onSource bool) *PortMatcher {
return &PortMatcher{
port: net.PortListFromProto(list),
port: net.PortListFromProto(list),
onSource: onSource,
}
}
func (v *PortMatcher) Apply(ctx *Context) bool {
if ctx.Outbound == nil || !ctx.Outbound.Target.IsValid() {
return false
// Apply implements Condition.
func (v *PortMatcher) Apply(ctx routing.Context) bool {
if v.onSource {
return v.port.Contains(ctx.GetSourcePort())
} else {
return v.port.Contains(ctx.GetTargetPort())
}
return v.port.Contains(ctx.Outbound.Target.Port)
}
type NetworkMatcher struct {
@ -182,11 +171,9 @@ func NewNetworkMatcher(network []net.Network) NetworkMatcher {
return matcher
}
func (v NetworkMatcher) Apply(ctx *Context) bool {
if ctx.Outbound == nil || !ctx.Outbound.Target.IsValid() {
return false
}
return v.list[int(ctx.Outbound.Target.Network)]
// Apply implements Condition.
func (v NetworkMatcher) Apply(ctx routing.Context) bool {
return v.list[int(ctx.GetNetwork())]
}
type UserMatcher struct {
@ -205,17 +192,14 @@ func NewUserMatcher(users []string) *UserMatcher {
}
}
func (v *UserMatcher) Apply(ctx *Context) bool {
if ctx.Inbound == nil {
return false
}
user := ctx.Inbound.User
if user == nil {
// Apply implements Condition.
func (v *UserMatcher) Apply(ctx routing.Context) bool {
user := ctx.GetUser()
if len(user) == 0 {
return false
}
for _, u := range v.user {
if u == user.Email {
if u == user {
return true
}
}
@ -238,11 +222,12 @@ func NewInboundTagMatcher(tags []string) *InboundTagMatcher {
}
}
func (v *InboundTagMatcher) Apply(ctx *Context) bool {
if ctx.Inbound == nil || len(ctx.Inbound.Tag) == 0 {
// Apply implements Condition.
func (v *InboundTagMatcher) Apply(ctx routing.Context) bool {
tag := ctx.GetInboundTag()
if len(tag) == 0 {
return false
}
tag := ctx.Inbound.Tag
for _, t := range v.tags {
if t == tag {
return true
@ -269,18 +254,17 @@ func NewProtocolMatcher(protocols []string) *ProtocolMatcher {
}
}
func (m *ProtocolMatcher) Apply(ctx *Context) bool {
if ctx.Content == nil {
// Apply implements Condition.
func (m *ProtocolMatcher) Apply(ctx routing.Context) bool {
protocol := ctx.GetProtocol()
if len(protocol) == 0 {
return false
}
protocol := ctx.Content.Protocol
for _, p := range m.protocols {
if strings.HasPrefix(protocol, p) {
return true
}
}
return false
}
@ -294,10 +278,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
@ -307,17 +288,11 @@ func NewAttributeMatcher(code string) (*AttributeMatcher, error) {
}, nil
}
func (m *AttributeMatcher) Match(attrs map[string]interface{}) bool {
// Match implements attributes matching.
func (m *AttributeMatcher) Match(attrs map[string]string) bool {
attrsDict := new(starlark.Dict)
for key, value := range attrs {
var starValue starlark.Value
switch value := value.(type) {
case string:
starValue = starlark.String(value)
}
if starValue != nil {
attrsDict.SetKey(starlark.String(key), starValue)
}
attrsDict.SetKey(starlark.String(key), starlark.String(value))
}
predefined := make(starlark.StringDict)
@ -334,9 +309,11 @@ func (m *AttributeMatcher) Match(attrs map[string]interface{}) bool {
return satisfied != nil && bool(satisfied.Truth())
}
func (m *AttributeMatcher) Apply(ctx *Context) bool {
if ctx.Content == nil {
// Apply implements Condition.
func (m *AttributeMatcher) Apply(ctx routing.Context) bool {
attributes := ctx.GetAttributes()
if attributes == nil {
return false
}
return m.Match(ctx.Content.Attributes)
return m.Match(attributes)
}

View File

@ -17,8 +17,12 @@ func init() {
wd, err := os.Getwd()
common.Must(err)
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(wd, "..", "..", "release", "config", "geoip.dat")))
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geosite.dat"), filepath.Join(wd, "..", "..", "release", "config", "geosite.dat")))
if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && os.IsNotExist(err) {
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(wd, "..", "..", "release", "config", "geoip.dat")))
}
if _, err := os.Stat(platform.GetAssetLocation("geosite.dat")); err != nil && os.IsNotExist(err) {
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geosite.dat"), filepath.Join(wd, "..", "..", "release", "config", "geosite.dat")))
}
}
func TestGeoIPMatcherContainer(t *testing.T) {

View File

@ -17,27 +17,41 @@ import (
"v2ray.com/core/common/protocol"
"v2ray.com/core/common/protocol/http"
"v2ray.com/core/common/session"
"v2ray.com/core/features/routing"
routing_session "v2ray.com/core/features/routing/session"
)
func init() {
wd, err := os.Getwd()
common.Must(err)
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(wd, "..", "..", "release", "config", "geoip.dat")))
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geosite.dat"), filepath.Join(wd, "..", "..", "release", "config", "geosite.dat")))
if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && os.IsNotExist(err) {
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(wd, "..", "..", "release", "config", "geoip.dat")))
}
if _, err := os.Stat(platform.GetAssetLocation("geosite.dat")); err != nil && os.IsNotExist(err) {
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geosite.dat"), filepath.Join(wd, "..", "..", "release", "config", "geosite.dat")))
}
}
func withOutbound(outbound *session.Outbound) *Context {
return &Context{Outbound: outbound}
func withBackground() routing.Context {
return &routing_session.Context{}
}
func withInbound(inbound *session.Inbound) *Context {
return &Context{Inbound: inbound}
func withOutbound(outbound *session.Outbound) routing.Context {
return &routing_session.Context{Outbound: outbound}
}
func withInbound(inbound *session.Inbound) routing.Context {
return &routing_session.Context{Inbound: inbound}
}
func withContent(content *session.Content) routing.Context {
return &routing_session.Context{Content: content}
}
func TestRoutingRule(t *testing.T) {
type ruleTest struct {
input *Context
input routing.Context
output bool
}
@ -88,7 +102,7 @@ func TestRoutingRule(t *testing.T) {
output: false,
},
{
input: &Context{},
input: withBackground(),
output: false,
},
},
@ -124,7 +138,7 @@ func TestRoutingRule(t *testing.T) {
output: true,
},
{
input: &Context{},
input: withBackground(),
output: false,
},
},
@ -164,7 +178,7 @@ func TestRoutingRule(t *testing.T) {
output: true,
},
{
input: &Context{},
input: withBackground(),
output: false,
},
},
@ -205,7 +219,7 @@ func TestRoutingRule(t *testing.T) {
output: false,
},
{
input: &Context{},
input: withBackground(),
output: false,
},
},
@ -216,7 +230,7 @@ func TestRoutingRule(t *testing.T) {
},
test: []ruleTest{
{
input: &Context{Content: &session.Content{Protocol: (&http.SniffHeader{}).Protocol()}},
input: withContent(&session.Content{Protocol: (&http.SniffHeader{}).Protocol()}),
output: true,
},
},
@ -264,6 +278,34 @@ func TestRoutingRule(t *testing.T) {
},
},
},
{
rule: &RoutingRule{
SourcePortList: &net.PortList{
Range: []*net.PortRange{
{From: 123, To: 123},
{From: 9993, To: 9999},
},
},
},
test: []ruleTest{
{
input: withInbound(&session.Inbound{Source: net.UDPDestination(net.LocalHostIP, 123)}),
output: true,
},
{
input: withInbound(&session.Inbound{Source: net.UDPDestination(net.LocalHostIP, 9999)}),
output: true,
},
{
input: withInbound(&session.Inbound{Source: net.UDPDestination(net.LocalHostIP, 9994)}),
output: true,
},
{
input: withInbound(&session.Inbound{Source: net.UDPDestination(net.LocalHostIP, 53)}),
output: false,
},
},
},
{
rule: &RoutingRule{
Protocol: []string{"http"},
@ -271,7 +313,7 @@ func TestRoutingRule(t *testing.T) {
},
test: []ruleTest{
{
input: &Context{Content: &session.Content{Protocol: "http/1.1", Attributes: map[string]interface{}{":path": "/test/1"}}},
input: withContent(&session.Content{Protocol: "http/1.1", Attributes: map[string]string{":path": "/test/1"}}),
output: true,
},
},

View File

@ -5,6 +5,7 @@ package router
import (
"v2ray.com/core/common/net"
"v2ray.com/core/features/outbound"
"v2ray.com/core/features/routing"
)
// CIDRList is an alias of []*CIDR to provide sort.Interface.
@ -59,7 +60,8 @@ func (r *Rule) GetTag() (string, error) {
return r.Tag, nil
}
func (r *Rule) Apply(ctx *Context) bool {
// Apply checks rule matching of current routing context.
func (r *Rule) Apply(ctx routing.Context) bool {
return r.Condition.Apply(ctx)
}
@ -83,9 +85,13 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
}
if rr.PortList != nil {
conds.Add(NewPortMatcher(rr.PortList))
conds.Add(NewPortMatcher(rr.PortList, false))
} else if rr.PortRange != nil {
conds.Add(NewPortMatcher(&net.PortList{Range: []*net.PortRange{rr.PortRange}}))
conds.Add(NewPortMatcher(&net.PortList{Range: []*net.PortRange{rr.PortRange}}, false))
}
if rr.SourcePortList != nil {
conds.Add(NewPortMatcher(rr.SourcePortList, true))
}
if len(rr.Networks) > 0 {

File diff suppressed because it is too large Load Diff

View File

@ -2,12 +2,12 @@ syntax = "proto3";
package v2ray.core.app.router;
option csharp_namespace = "V2Ray.Core.App.Router";
option go_package = "router";
option go_package = "v2ray.com/core/app/router";
option java_package = "com.v2ray.core.app.router";
option java_multiple_files = true;
import "v2ray.com/core/common/net/port.proto";
import "v2ray.com/core/common/net/network.proto";
import "common/net/port.proto";
import "common/net/network.proto";
// Domain for routing decision.
message Domain {
@ -65,7 +65,7 @@ message GeoSite {
repeated Domain domain = 2;
}
message GeoSiteList{
message GeoSiteList {
repeated GeoSite entry = 1;
}
@ -78,7 +78,6 @@ message RoutingRule {
string balancing_tag = 12;
}
// List of domains for target domain matching.
repeated Domain domain = 2;
@ -86,13 +85,14 @@ message RoutingRule {
// Deprecated. Use geoip below.
repeated CIDR cidr = 3 [deprecated = true];
// List of GeoIPs for target IP address matching. If this entry exists, the cidr above will have no effect.
// GeoIP fields with the same country code are supposed to contain exactly same content. They will be merged during runtime.
// For customized GeoIPs, please leave country code empty.
// List of GeoIPs for target IP address matching. If this entry exists, the
// cidr above will have no effect. GeoIP fields with the same country code are
// supposed to contain exactly same content. They will be merged during
// runtime. For customized GeoIPs, please leave country code empty.
repeated GeoIP geoip = 10;
// A range of port [from, to]. If the destination port is in this range, this rule takes effect.
// Deprecated. Use port_list.
// A range of port [from, to]. If the destination port is in this range, this
// rule takes effect. Deprecated. Use port_list.
v2ray.core.common.net.PortRange port_range = 4 [deprecated = true];
// List of ports.
@ -107,9 +107,13 @@ message RoutingRule {
// List of CIDRs for source IP address matching.
repeated CIDR source_cidr = 6 [deprecated = true];
// List of GeoIPs for source IP address matching. If this entry exists, the source_cidr above will have no effect.
// List of GeoIPs for source IP address matching. If this entry exists, the
// source_cidr above will have no effect.
repeated GeoIP source_geoip = 11;
// List of ports for source port matching.
v2ray.core.common.net.PortList source_port_list = 16;
repeated string user_email = 7;
repeated string inbound_tag = 8;
repeated string protocol = 9;

View File

@ -2,32 +2,19 @@
package router
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen
import (
"context"
"v2ray.com/core"
"v2ray.com/core/common"
"v2ray.com/core/common/net"
"v2ray.com/core/common/session"
"v2ray.com/core/features/dns"
"v2ray.com/core/features/outbound"
"v2ray.com/core/features/routing"
routing_dns "v2ray.com/core/features/routing/dns"
)
func init() {
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
r := new(Router)
if err := core.RequireFeatures(ctx, func(d dns.Client, ohm outbound.Manager) error {
return r.Init(config.(*Config), d, ohm)
}); err != nil {
return nil, err
}
return r, nil
}))
}
// Router is an implementation of routing.Router.
type Router struct {
domainStrategy Config_DomainStrategy
@ -36,6 +23,13 @@ type Router struct {
dns dns.Client
}
// Route is an implementation of routing.Route.
type Route struct {
routing.Context
outboundGroupTags []string
outboundTag string
}
// Init initializes the Router.
func (r *Router) Init(config *Config, d dns.Client, ohm outbound.Manager) error {
r.domainStrategy = config.DomainStrategy
@ -74,50 +68,44 @@ func (r *Router) Init(config *Config, d dns.Client, ohm outbound.Manager) error
return nil
}
func (r *Router) PickRoute(ctx context.Context) (string, error) {
rule, err := r.pickRouteInternal(ctx)
if err != nil {
return "", err
}
return rule.GetTag()
}
func isDomainOutbound(outbound *session.Outbound) bool {
return outbound != nil && outbound.Target.IsValid() && outbound.Target.Address.Family().IsDomain()
}
// PickRoute implements routing.Router.
func (r *Router) pickRouteInternal(ctx context.Context) (*Rule, error) {
sessionContext := &Context{
Inbound: session.InboundFromContext(ctx),
Outbound: session.OutboundFromContext(ctx),
Content: session.ContentFromContext(ctx),
func (r *Router) PickRoute(ctx routing.Context) (routing.Route, error) {
rule, ctx, err := r.pickRouteInternal(ctx)
if err != nil {
return nil, err
}
tag, err := rule.GetTag()
if err != nil {
return nil, err
}
return &Route{Context: ctx, outboundTag: tag}, nil
}
func (r *Router) pickRouteInternal(ctx routing.Context) (*Rule, routing.Context, error) {
if r.domainStrategy == Config_IpOnDemand {
sessionContext.dnsClient = r.dns
ctx = routing_dns.ContextWithDNSClient(ctx, r.dns)
}
for _, rule := range r.rules {
if rule.Apply(sessionContext) {
return rule, nil
if rule.Apply(ctx) {
return rule, ctx, nil
}
}
if r.domainStrategy != Config_IpIfNonMatch || !isDomainOutbound(sessionContext.Outbound) {
return nil, common.ErrNoClue
if r.domainStrategy != Config_IpIfNonMatch || len(ctx.GetTargetDomain()) == 0 {
return nil, ctx, common.ErrNoClue
}
sessionContext.dnsClient = r.dns
ctx = routing_dns.ContextWithDNSClient(ctx, r.dns)
// Try applying rules again if we have IPs.
for _, rule := range r.rules {
if rule.Apply(sessionContext) {
return rule, nil
if rule.Apply(ctx) {
return rule, ctx, nil
}
}
return nil, common.ErrNoClue
return nil, ctx, common.ErrNoClue
}
// Start implements common.Runnable.
@ -135,36 +123,24 @@ func (*Router) Type() interface{} {
return routing.RouterType()
}
type Context struct {
Inbound *session.Inbound
Outbound *session.Outbound
Content *session.Content
dnsClient dns.Client
// GetOutboundGroupTags implements routing.Route.
func (r *Route) GetOutboundGroupTags() []string {
return r.outboundGroupTags
}
func (c *Context) GetTargetIPs() []net.IP {
if c.Outbound == nil || !c.Outbound.Target.IsValid() {
return nil
}
// GetOutboundTag implements routing.Route.
func (r *Route) GetOutboundTag() string {
return r.outboundTag
}
if c.Outbound.Target.Address.Family().IsIP() {
return []net.IP{c.Outbound.Target.Address.IP()}
}
if len(c.Outbound.ResolvedIPs) > 0 {
return c.Outbound.ResolvedIPs
}
if c.dnsClient != nil {
domain := c.Outbound.Target.Address.Domain()
ips, err := c.dnsClient.LookupIP(domain)
if err == nil {
c.Outbound.ResolvedIPs = ips
return ips
func init() {
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
r := new(Router)
if err := core.RequireFeatures(ctx, func(d dns.Client, ohm outbound.Manager) error {
return r.Init(config.(*Config), d, ohm)
}); err != nil {
return nil, err
}
newError("resolve ip for ", domain).Base(err).WriteToLog()
}
return nil
return r, nil
}))
}

View File

@ -10,6 +10,7 @@ import (
"v2ray.com/core/common/net"
"v2ray.com/core/common/session"
"v2ray.com/core/features/outbound"
routing_session "v2ray.com/core/features/routing/session"
"v2ray.com/core/testing/mocks"
)
@ -44,9 +45,9 @@ func TestSimpleRouter(t *testing.T) {
}))
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)})
tag, err := r.PickRoute(ctx)
route, err := r.PickRoute(routing_session.AsRoutingContext(ctx))
common.Must(err)
if tag != "test" {
if tag := route.GetOutboundTag(); tag != "test" {
t.Error("expect tag 'test', bug actually ", tag)
}
}
@ -85,9 +86,9 @@ func TestSimpleBalancer(t *testing.T) {
}))
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)})
tag, err := r.PickRoute(ctx)
route, err := r.PickRoute(routing_session.AsRoutingContext(ctx))
common.Must(err)
if tag != "test" {
if tag := route.GetOutboundTag(); tag != "test" {
t.Error("expect tag 'test', bug actually ", tag)
}
}
@ -120,9 +121,9 @@ func TestIPOnDemand(t *testing.T) {
common.Must(r.Init(config, mockDns, nil))
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)})
tag, err := r.PickRoute(ctx)
route, err := r.PickRoute(routing_session.AsRoutingContext(ctx))
common.Must(err)
if tag != "test" {
if tag := route.GetOutboundTag(); tag != "test" {
t.Error("expect tag 'test', bug actually ", tag)
}
}
@ -155,9 +156,9 @@ func TestIPIfNonMatchDomain(t *testing.T) {
common.Must(r.Init(config, mockDns, nil))
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)})
tag, err := r.PickRoute(ctx)
route, err := r.PickRoute(routing_session.AsRoutingContext(ctx))
common.Must(err)
if tag != "test" {
if tag := route.GetOutboundTag(); tag != "test" {
t.Error("expect tag 'test', bug actually ", tag)
}
}
@ -189,9 +190,9 @@ func TestIPIfNonMatchIP(t *testing.T) {
common.Must(r.Init(config, mockDns, nil))
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.LocalHostIP, 80)})
tag, err := r.PickRoute(ctx)
route, err := r.PickRoute(routing_session.AsRoutingContext(ctx))
common.Must(err)
if tag != "test" {
if tag := route.GetOutboundTag(); tag != "test" {
t.Error("expect tag 'test', bug actually ", tag)
}
}

174
app/stats/channel.go Normal file
View File

@ -0,0 +1,174 @@
// +build !confonly
package stats
import (
"context"
"sync"
"v2ray.com/core/common"
)
// Channel is an implementation of stats.Channel.
type Channel struct {
channel chan channelMessage
subscribers []chan interface{}
// Synchronization components
access sync.RWMutex
closed chan struct{}
// Channel options
blocking bool // Set blocking state if channel buffer reaches limit
bufferSize int // Set to 0 as no buffering
subsLimit int // Set to 0 as no subscriber limit
}
// NewChannel creates an instance of Statistics Channel.
func NewChannel(config *ChannelConfig) *Channel {
return &Channel{
channel: make(chan channelMessage, config.BufferSize),
subsLimit: int(config.SubscriberLimit),
bufferSize: int(config.BufferSize),
blocking: config.Blocking,
}
}
// Subscribers implements stats.Channel.
func (c *Channel) Subscribers() []chan interface{} {
c.access.RLock()
defer c.access.RUnlock()
return c.subscribers
}
// Subscribe implements stats.Channel.
func (c *Channel) Subscribe() (chan interface{}, error) {
c.access.Lock()
defer c.access.Unlock()
if c.subsLimit > 0 && len(c.subscribers) >= c.subsLimit {
return nil, newError("Number of subscribers has reached limit")
}
subscriber := make(chan interface{}, c.bufferSize)
c.subscribers = append(c.subscribers, subscriber)
return subscriber, nil
}
// Unsubscribe implements stats.Channel.
func (c *Channel) Unsubscribe(subscriber chan interface{}) error {
c.access.Lock()
defer c.access.Unlock()
for i, s := range c.subscribers {
if s == subscriber {
// Copy to new memory block to prevent modifying original data
subscribers := make([]chan interface{}, len(c.subscribers)-1)
copy(subscribers[:i], c.subscribers[:i])
copy(subscribers[i:], c.subscribers[i+1:])
c.subscribers = subscribers
}
}
return nil
}
// Publish implements stats.Channel.
func (c *Channel) Publish(ctx context.Context, msg interface{}) {
select { // Early exit if channel closed
case <-c.closed:
return
default:
pub := channelMessage{context: ctx, message: msg}
if c.blocking {
pub.publish(c.channel)
} else {
pub.publishNonBlocking(c.channel)
}
}
}
// Running returns whether the channel is running.
func (c *Channel) Running() bool {
select {
case <-c.closed: // Channel closed
default: // Channel running or not initialized
if c.closed != nil { // Channel initialized
return true
}
}
return false
}
// Start implements common.Runnable.
func (c *Channel) Start() error {
c.access.Lock()
defer c.access.Unlock()
if !c.Running() {
c.closed = make(chan struct{}) // Reset close signal
go func() {
for {
select {
case pub := <-c.channel: // Published message received
for _, sub := range c.Subscribers() { // Concurrency-safe subscribers retrievement
if c.blocking {
pub.broadcast(sub)
} else {
pub.broadcastNonBlocking(sub)
}
}
case <-c.closed: // Channel closed
for _, sub := range c.Subscribers() { // Remove all subscribers
common.Must(c.Unsubscribe(sub))
close(sub)
}
return
}
}
}()
}
return nil
}
// Close implements common.Closable.
func (c *Channel) Close() error {
c.access.Lock()
defer c.access.Unlock()
if c.Running() {
close(c.closed) // Send closed signal
}
return nil
}
// channelMessage is the published message with guaranteed delivery.
// message is discarded only when the context is early cancelled.
type channelMessage struct {
context context.Context
message interface{}
}
func (c channelMessage) publish(publisher chan channelMessage) {
select {
case publisher <- c:
case <-c.context.Done():
}
}
func (c channelMessage) publishNonBlocking(publisher chan channelMessage) {
select {
case publisher <- c:
default: // Create another goroutine to keep sending message
go c.publish(publisher)
}
}
func (c channelMessage) broadcast(subscriber chan interface{}) {
select {
case subscriber <- c.message:
case <-c.context.Done():
}
}
func (c channelMessage) broadcastNonBlocking(subscriber chan interface{}) {
select {
case subscriber <- c.message:
default: // Create another goroutine to keep sending message
go c.broadcast(subscriber)
}
}

405
app/stats/channel_test.go Normal file
View File

@ -0,0 +1,405 @@
package stats_test
import (
"context"
"fmt"
"testing"
"time"
. "v2ray.com/core/app/stats"
"v2ray.com/core/common"
"v2ray.com/core/features/stats"
)
func TestStatsChannel(t *testing.T) {
// At most 2 subscribers could be registered
c := NewChannel(&ChannelConfig{SubscriberLimit: 2, Blocking: true})
a, err := stats.SubscribeRunnableChannel(c)
common.Must(err)
if !c.Running() {
t.Fatal("unexpected failure in running channel after first subscription")
}
b, err := c.Subscribe()
common.Must(err)
// Test that third subscriber is forbidden
_, err = c.Subscribe()
if err == nil {
t.Fatal("unexpected successful subscription")
}
t.Log("expected error: ", err)
stopCh := make(chan struct{})
errCh := make(chan string)
go func() {
c.Publish(context.Background(), 1)
c.Publish(context.Background(), 2)
c.Publish(context.Background(), "3")
c.Publish(context.Background(), []int{4})
stopCh <- struct{}{}
}()
go func() {
if v, ok := (<-a).(int); !ok || v != 1 {
errCh <- fmt.Sprint("unexpected receiving: ", v, ", wanted ", 1)
}
if v, ok := (<-a).(int); !ok || v != 2 {
errCh <- fmt.Sprint("unexpected receiving: ", v, ", wanted ", 2)
}
if v, ok := (<-a).(string); !ok || v != "3" {
errCh <- fmt.Sprint("unexpected receiving: ", v, ", wanted ", "3")
}
if v, ok := (<-a).([]int); !ok || v[0] != 4 {
errCh <- fmt.Sprint("unexpected receiving: ", v, ", wanted ", []int{4})
}
stopCh <- struct{}{}
}()
go func() {
if v, ok := (<-b).(int); !ok || v != 1 {
errCh <- fmt.Sprint("unexpected receiving: ", v, ", wanted ", 1)
}
if v, ok := (<-b).(int); !ok || v != 2 {
errCh <- fmt.Sprint("unexpected receiving: ", v, ", wanted ", 2)
}
if v, ok := (<-b).(string); !ok || v != "3" {
errCh <- fmt.Sprint("unexpected receiving: ", v, ", wanted ", "3")
}
if v, ok := (<-b).([]int); !ok || v[0] != 4 {
errCh <- fmt.Sprint("unexpected receiving: ", v, ", wanted ", []int{4})
}
stopCh <- struct{}{}
}()
timeout := time.After(2 * time.Second)
for i := 0; i < 3; i++ {
select {
case <-timeout:
t.Fatal("Test timeout after 2s")
case e := <-errCh:
t.Fatal(e)
case <-stopCh:
}
}
// Test the unsubscription of channel
common.Must(c.Unsubscribe(b))
// Test the last subscriber will close channel with `UnsubscribeClosableChannel`
common.Must(stats.UnsubscribeClosableChannel(c, a))
if c.Running() {
t.Fatal("unexpected running channel after unsubscribing the last subscriber")
}
}
func TestStatsChannelUnsubcribe(t *testing.T) {
c := NewChannel(&ChannelConfig{Blocking: true})
common.Must(c.Start())
defer c.Close()
a, err := c.Subscribe()
common.Must(err)
defer c.Unsubscribe(a)
b, err := c.Subscribe()
common.Must(err)
pauseCh := make(chan struct{})
stopCh := make(chan struct{})
errCh := make(chan string)
{
var aSet, bSet bool
for _, s := range c.Subscribers() {
if s == a {
aSet = true
}
if s == b {
bSet = true
}
}
if !(aSet && bSet) {
t.Fatal("unexpected subscribers: ", c.Subscribers())
}
}
go func() { // Blocking publish
c.Publish(context.Background(), 1)
<-pauseCh // Wait for `b` goroutine to resume sending message
c.Publish(context.Background(), 2)
}()
go func() {
if v, ok := (<-a).(int); !ok || v != 1 {
errCh <- fmt.Sprint("unexpected receiving: ", v, ", wanted ", 1)
}
if v, ok := (<-a).(int); !ok || v != 2 {
errCh <- fmt.Sprint("unexpected receiving: ", v, ", wanted ", 2)
}
}()
go func() {
if v, ok := (<-b).(int); !ok || v != 1 {
errCh <- fmt.Sprint("unexpected receiving: ", v, ", wanted ", 1)
}
// Unsubscribe `b` while publishing is paused
c.Unsubscribe(b)
{ // Test `b` is not in subscribers
var aSet, bSet bool
for _, s := range c.Subscribers() {
if s == a {
aSet = true
}
if s == b {
bSet = true
}
}
if !(aSet && !bSet) {
errCh <- fmt.Sprint("unexpected subscribers: ", c.Subscribers())
}
}
// Resume publishing progress
close(pauseCh)
// Test `b` is neither closed nor able to receive any data
select {
case v, ok := <-b:
if ok {
errCh <- fmt.Sprint("unexpected data received: ", v)
} else {
errCh <- fmt.Sprint("unexpected closed channel: ", b)
}
default:
}
close(stopCh)
}()
select {
case <-time.After(2 * time.Second):
t.Fatal("Test timeout after 2s")
case e := <-errCh:
t.Fatal(e)
case <-stopCh:
}
}
func TestStatsChannelBlocking(t *testing.T) {
// Do not use buffer so as to create blocking scenario
c := NewChannel(&ChannelConfig{BufferSize: 0, Blocking: true})
common.Must(c.Start())
defer c.Close()
a, err := c.Subscribe()
common.Must(err)
defer c.Unsubscribe(a)
pauseCh := make(chan struct{})
stopCh := make(chan struct{})
errCh := make(chan string)
ctx, cancel := context.WithCancel(context.Background())
// Test blocking channel publishing
go func() {
// Dummy messsage with no subscriber receiving, will block broadcasting goroutine
c.Publish(context.Background(), nil)
<-pauseCh
// Publishing should be blocked here, for last message was not cleared and buffer was full
c.Publish(context.Background(), nil)
pauseCh <- struct{}{}
// Publishing should still be blocked here
c.Publish(ctx, nil)
// Check publishing is done because context is canceled
select {
case <-ctx.Done():
if ctx.Err() != context.Canceled {
errCh <- fmt.Sprint("unexpected error: ", ctx.Err())
}
default:
errCh <- "unexpected non-blocked publishing"
}
close(stopCh)
}()
go func() {
pauseCh <- struct{}{}
select {
case <-pauseCh:
errCh <- "unexpected non-blocked publishing"
case <-time.After(100 * time.Millisecond):
}
// Receive first published message
<-a
select {
case <-pauseCh:
case <-time.After(100 * time.Millisecond):
errCh <- "unexpected blocking publishing"
}
// Manually cancel the context to end publishing
cancel()
}()
select {
case <-time.After(2 * time.Second):
t.Fatal("Test timeout after 2s")
case e := <-errCh:
t.Fatal(e)
case <-stopCh:
}
}
func TestStatsChannelNonBlocking(t *testing.T) {
// Do not use buffer so as to create blocking scenario
c := NewChannel(&ChannelConfig{BufferSize: 0, Blocking: false})
common.Must(c.Start())
defer c.Close()
a, err := c.Subscribe()
common.Must(err)
defer c.Unsubscribe(a)
pauseCh := make(chan struct{})
stopCh := make(chan struct{})
errCh := make(chan string)
ctx, cancel := context.WithCancel(context.Background())
// Test blocking channel publishing
go func() {
c.Publish(context.Background(), nil)
c.Publish(context.Background(), nil)
pauseCh <- struct{}{}
<-pauseCh
c.Publish(ctx, nil)
c.Publish(ctx, nil)
// Check publishing is done because context is canceled
select {
case <-ctx.Done():
if ctx.Err() != context.Canceled {
errCh <- fmt.Sprint("unexpected error: ", ctx.Err())
}
case <-time.After(100 * time.Millisecond):
errCh <- "unexpected non-cancelled publishing"
}
}()
go func() {
// Check publishing won't block even if there is no subscriber receiving message
select {
case <-pauseCh:
case <-time.After(100 * time.Millisecond):
errCh <- "unexpected blocking publishing"
}
// Receive first and second published message
<-a
<-a
pauseCh <- struct{}{}
// Manually cancel the context to end publishing
cancel()
// Check third and forth published message is cancelled and cannot receive
<-time.After(100 * time.Millisecond)
select {
case <-a:
errCh <- "unexpected non-cancelled publishing"
default:
}
select {
case <-a:
errCh <- "unexpected non-cancelled publishing"
default:
}
close(stopCh)
}()
select {
case <-time.After(2 * time.Second):
t.Fatal("Test timeout after 2s")
case e := <-errCh:
t.Fatal(e)
case <-stopCh:
}
}
func TestStatsChannelConcurrency(t *testing.T) {
// Do not use buffer so as to create blocking scenario
c := NewChannel(&ChannelConfig{BufferSize: 0, Blocking: true})
common.Must(c.Start())
defer c.Close()
a, err := c.Subscribe()
common.Must(err)
defer c.Unsubscribe(a)
b, err := c.Subscribe()
common.Must(err)
defer c.Unsubscribe(b)
stopCh := make(chan struct{})
errCh := make(chan string)
go func() { // Blocking publish
c.Publish(context.Background(), 1)
c.Publish(context.Background(), 2)
}()
go func() {
if v, ok := (<-a).(int); !ok || v != 1 {
errCh <- fmt.Sprint("unexpected receiving: ", v, ", wanted ", 1)
}
if v, ok := (<-a).(int); !ok || v != 2 {
errCh <- fmt.Sprint("unexpected receiving: ", v, ", wanted ", 2)
}
}()
go func() {
// Block `b` for a time so as to ensure source channel is trying to send message to `b`.
<-time.After(25 * time.Millisecond)
// This causes concurrency scenario: unsubscribe `b` while trying to send message to it
c.Unsubscribe(b)
// Test `b` is not closed and can still receive data 1:
// Because unsubscribe won't affect the ongoing process of sending message.
select {
case v, ok := <-b:
if v1, ok1 := v.(int); !(ok && ok1 && v1 == 1) {
errCh <- fmt.Sprint("unexpected failure in receiving data: ", 1)
}
default:
errCh <- fmt.Sprint("unexpected block from receiving data: ", 1)
}
// Test `b` is not closed but cannot receive data 2:
// Because in a new round of messaging, `b` has been unsubscribed.
select {
case v, ok := <-b:
if ok {
errCh <- fmt.Sprint("unexpected receiving: ", v)
} else {
errCh <- fmt.Sprint("unexpected closing of channel")
}
default:
}
close(stopCh)
}()
select {
case <-time.After(2 * time.Second):
t.Fatal("Test timeout after 2s")
case e := <-errCh:
t.Fatal(e)
case <-stopCh:
}
}

View File

@ -2,7 +2,7 @@
package command
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen
import (
"context"
@ -63,7 +63,7 @@ func (s *statsServer) QueryStats(ctx context.Context, request *QueryStatsRequest
return nil, newError("QueryStats only works its own stats.Manager.")
}
manager.Visit(func(name string, c feature_stats.Counter) bool {
manager.VisitCounters(func(name string, c feature_stats.Counter) bool {
if matcher.Match(name) {
var value int64
if request.Reset_ {
@ -104,6 +104,8 @@ func (s *statsServer) GetSysStats(ctx context.Context, request *SysStatsRequest)
return response, nil
}
func (s *statsServer) mustEmbedUnimplementedStatsServiceServer() {}
type service struct {
statsManager feature_stats.Manager
}

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@ syntax = "proto3";
package v2ray.core.app.stats.command;
option csharp_namespace = "V2Ray.Core.App.Stats.Command";
option go_package = "command";
option go_package = "v2ray.com/core/app/stats/command";
option java_package = "com.v2ray.core.app.stats.command";
option java_multiple_files = true;
@ -31,8 +31,7 @@ message QueryStatsResponse {
repeated Stat stat = 1;
}
message SysStatsRequest {
}
message SysStatsRequest {}
message SysStatsResponse {
uint32 NumGoroutine = 1;

View File

@ -0,0 +1,169 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package command
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion7
// StatsServiceClient is the client API for StatsService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type StatsServiceClient interface {
GetStats(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error)
QueryStats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error)
GetSysStats(ctx context.Context, in *SysStatsRequest, opts ...grpc.CallOption) (*SysStatsResponse, error)
}
type statsServiceClient struct {
cc grpc.ClientConnInterface
}
func NewStatsServiceClient(cc grpc.ClientConnInterface) StatsServiceClient {
return &statsServiceClient{cc}
}
func (c *statsServiceClient) GetStats(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error) {
out := new(GetStatsResponse)
err := c.cc.Invoke(ctx, "/v2ray.core.app.stats.command.StatsService/GetStats", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *statsServiceClient) QueryStats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error) {
out := new(QueryStatsResponse)
err := c.cc.Invoke(ctx, "/v2ray.core.app.stats.command.StatsService/QueryStats", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *statsServiceClient) GetSysStats(ctx context.Context, in *SysStatsRequest, opts ...grpc.CallOption) (*SysStatsResponse, error) {
out := new(SysStatsResponse)
err := c.cc.Invoke(ctx, "/v2ray.core.app.stats.command.StatsService/GetSysStats", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// StatsServiceServer is the server API for StatsService service.
// All implementations must embed UnimplementedStatsServiceServer
// for forward compatibility
type StatsServiceServer interface {
GetStats(context.Context, *GetStatsRequest) (*GetStatsResponse, error)
QueryStats(context.Context, *QueryStatsRequest) (*QueryStatsResponse, error)
GetSysStats(context.Context, *SysStatsRequest) (*SysStatsResponse, error)
mustEmbedUnimplementedStatsServiceServer()
}
// UnimplementedStatsServiceServer must be embedded to have forward compatible implementations.
type UnimplementedStatsServiceServer struct {
}
func (UnimplementedStatsServiceServer) GetStats(context.Context, *GetStatsRequest) (*GetStatsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetStats not implemented")
}
func (UnimplementedStatsServiceServer) QueryStats(context.Context, *QueryStatsRequest) (*QueryStatsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method QueryStats not implemented")
}
func (UnimplementedStatsServiceServer) GetSysStats(context.Context, *SysStatsRequest) (*SysStatsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetSysStats not implemented")
}
func (UnimplementedStatsServiceServer) mustEmbedUnimplementedStatsServiceServer() {}
// UnsafeStatsServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to StatsServiceServer will
// result in compilation errors.
type UnsafeStatsServiceServer interface {
mustEmbedUnimplementedStatsServiceServer()
}
func RegisterStatsServiceServer(s *grpc.Server, srv StatsServiceServer) {
s.RegisterService(&_StatsService_serviceDesc, srv)
}
func _StatsService_GetStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetStatsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(StatsServiceServer).GetStats(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/v2ray.core.app.stats.command.StatsService/GetStats",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StatsServiceServer).GetStats(ctx, req.(*GetStatsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _StatsService_QueryStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QueryStatsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(StatsServiceServer).QueryStats(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/v2ray.core.app.stats.command.StatsService/QueryStats",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StatsServiceServer).QueryStats(ctx, req.(*QueryStatsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _StatsService_GetSysStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SysStatsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(StatsServiceServer).GetSysStats(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/v2ray.core.app.stats.command.StatsService/GetSysStats",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StatsServiceServer).GetSysStats(ctx, req.(*SysStatsRequest))
}
return interceptor(ctx, in, info, handler)
}
var _StatsService_serviceDesc = grpc.ServiceDesc{
ServiceName: "v2ray.core.app.stats.command.StatsService",
HandlerType: (*StatsServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetStats",
Handler: _StatsService_GetStats_Handler,
},
{
MethodName: "QueryStats",
Handler: _StatsService_QueryStats_Handler,
},
{
MethodName: "GetSysStats",
Handler: _StatsService_GetSysStats_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "app/stats/command/command.proto",
}

View File

@ -54,7 +54,7 @@ func TestGetStats(t *testing.T) {
}
} else {
common.Must(err)
if r := cmp.Diff(resp.Stat, &Stat{Name: tc.name, Value: tc.value}); r != "" {
if r := cmp.Diff(resp.Stat, &Stat{Name: tc.name, Value: tc.value}, cmpopts.IgnoreUnexported(Stat{})); r != "" {
t.Error(r)
}
}
@ -85,7 +85,8 @@ func TestQueryStats(t *testing.T) {
if r := cmp.Diff(resp.Stat, []*Stat{
{Name: "test_counter_2", Value: 2},
{Name: "test_counter_3", Value: 3},
}, cmpopts.SortSlices(func(s1, s2 *Stat) bool { return s1.Name < s2.Name })); r != "" {
}, cmpopts.SortSlices(func(s1, s2 *Stat) bool { return s1.Name < s2.Name }),
cmpopts.IgnoreUnexported(Stat{})); r != "" {
t.Error(r)
}
}

View File

@ -1,15 +0,0 @@
// +build !confonly
package stats
import (
"context"
"v2ray.com/core/common"
)
func init() {
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
return NewManager(ctx, config.(*Config))
}))
}

View File

@ -1,69 +1,225 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.13.0
// source: app/stats/config.proto
package stats
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type Config struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (m *Config) Reset() { *m = Config{} }
func (m *Config) String() string { return proto.CompactTextString(m) }
func (*Config) ProtoMessage() {}
func (x *Config) Reset() {
*x = Config{}
if protoimpl.UnsafeEnabled {
mi := &file_app_stats_config_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Config) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Config) ProtoMessage() {}
func (x *Config) ProtoReflect() protoreflect.Message {
mi := &file_app_stats_config_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
func (*Config) Descriptor() ([]byte, []int) {
return fileDescriptor_d494ded44ceaa50d, []int{0}
return file_app_stats_config_proto_rawDescGZIP(), []int{0}
}
func (m *Config) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Config.Unmarshal(m, b)
}
func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Config.Marshal(b, m, deterministic)
}
func (m *Config) XXX_Merge(src proto.Message) {
xxx_messageInfo_Config.Merge(m, src)
}
func (m *Config) XXX_Size() int {
return xxx_messageInfo_Config.Size(m)
}
func (m *Config) XXX_DiscardUnknown() {
xxx_messageInfo_Config.DiscardUnknown(m)
type ChannelConfig struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Blocking bool `protobuf:"varint,1,opt,name=Blocking,proto3" json:"Blocking,omitempty"`
SubscriberLimit int32 `protobuf:"varint,2,opt,name=SubscriberLimit,proto3" json:"SubscriberLimit,omitempty"`
BufferSize int32 `protobuf:"varint,3,opt,name=BufferSize,proto3" json:"BufferSize,omitempty"`
}
var xxx_messageInfo_Config proto.InternalMessageInfo
func init() {
proto.RegisterType((*Config)(nil), "v2ray.core.app.stats.Config")
func (x *ChannelConfig) Reset() {
*x = ChannelConfig{}
if protoimpl.UnsafeEnabled {
mi := &file_app_stats_config_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func init() {
proto.RegisterFile("v2ray.com/core/app/stats/config.proto", fileDescriptor_d494ded44ceaa50d)
func (x *ChannelConfig) String() string {
return protoimpl.X.MessageStringOf(x)
}
var fileDescriptor_d494ded44ceaa50d = []byte{
// 123 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2d, 0x33, 0x2a, 0x4a,
0xac, 0xd4, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x2c, 0x28, 0xd0, 0x2f,
0x2e, 0x49, 0x2c, 0x29, 0xd6, 0x4f, 0xce, 0xcf, 0x4b, 0xcb, 0x4c, 0xd7, 0x2b, 0x28, 0xca, 0x2f,
0xc9, 0x17, 0x12, 0x81, 0x29, 0x2b, 0x4a, 0xd5, 0x4b, 0x2c, 0x28, 0xd0, 0x03, 0x2b, 0x51, 0xe2,
0xe0, 0x62, 0x73, 0x06, 0xab, 0x72, 0xb2, 0xe2, 0x92, 0x48, 0xce, 0xcf, 0xd5, 0xc3, 0xa6, 0x2a,
0x80, 0x31, 0x8a, 0x15, 0xcc, 0x58, 0xc5, 0x24, 0x12, 0x66, 0x14, 0x94, 0x58, 0xa9, 0xe7, 0x0c,
0x92, 0x77, 0x2c, 0x28, 0xd0, 0x0b, 0x06, 0x09, 0x27, 0xb1, 0x81, 0xad, 0x30, 0x06, 0x04, 0x00,
0x00, 0xff, 0xff, 0x88, 0x24, 0xc6, 0x41, 0x8b, 0x00, 0x00, 0x00,
func (*ChannelConfig) ProtoMessage() {}
func (x *ChannelConfig) ProtoReflect() protoreflect.Message {
mi := &file_app_stats_config_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ChannelConfig.ProtoReflect.Descriptor instead.
func (*ChannelConfig) Descriptor() ([]byte, []int) {
return file_app_stats_config_proto_rawDescGZIP(), []int{1}
}
func (x *ChannelConfig) GetBlocking() bool {
if x != nil {
return x.Blocking
}
return false
}
func (x *ChannelConfig) GetSubscriberLimit() int32 {
if x != nil {
return x.SubscriberLimit
}
return 0
}
func (x *ChannelConfig) GetBufferSize() int32 {
if x != nil {
return x.BufferSize
}
return 0
}
var File_app_stats_config_proto protoreflect.FileDescriptor
var file_app_stats_config_proto_rawDesc = []byte{
0x0a, 0x16, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e,
0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x22, 0x08,
0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x75, 0x0a, 0x0d, 0x43, 0x68, 0x61, 0x6e,
0x6e, 0x65, 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x42, 0x6c, 0x6f,
0x63, 0x6b, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x42, 0x6c, 0x6f,
0x63, 0x6b, 0x69, 0x6e, 0x67, 0x12, 0x28, 0x0a, 0x0f, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
0x62, 0x65, 0x72, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f,
0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12,
0x1e, 0x0a, 0x0a, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20,
0x01, 0x28, 0x05, 0x52, 0x0a, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x53, 0x69, 0x7a, 0x65, 0x42,
0x4d, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72,
0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x50, 0x01, 0x5a, 0x18, 0x76,
0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70,
0x70, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0xaa, 0x02, 0x14, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e,
0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_app_stats_config_proto_rawDescOnce sync.Once
file_app_stats_config_proto_rawDescData = file_app_stats_config_proto_rawDesc
)
func file_app_stats_config_proto_rawDescGZIP() []byte {
file_app_stats_config_proto_rawDescOnce.Do(func() {
file_app_stats_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_stats_config_proto_rawDescData)
})
return file_app_stats_config_proto_rawDescData
}
var file_app_stats_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_app_stats_config_proto_goTypes = []interface{}{
(*Config)(nil), // 0: v2ray.core.app.stats.Config
(*ChannelConfig)(nil), // 1: v2ray.core.app.stats.ChannelConfig
}
var file_app_stats_config_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_app_stats_config_proto_init() }
func file_app_stats_config_proto_init() {
if File_app_stats_config_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_app_stats_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Config); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_app_stats_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ChannelConfig); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_app_stats_config_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_app_stats_config_proto_goTypes,
DependencyIndexes: file_app_stats_config_proto_depIdxs,
MessageInfos: file_app_stats_config_proto_msgTypes,
}.Build()
File_app_stats_config_proto = out.File
file_app_stats_config_proto_rawDesc = nil
file_app_stats_config_proto_goTypes = nil
file_app_stats_config_proto_depIdxs = nil
}

View File

@ -2,10 +2,14 @@ syntax = "proto3";
package v2ray.core.app.stats;
option csharp_namespace = "V2Ray.Core.App.Stats";
option go_package = "stats";
option go_package = "v2ray.com/core/app/stats";
option java_package = "com.v2ray.core.app.stats";
option java_multiple_files = true;
message Config {
message Config {}
message ChannelConfig {
bool Blocking = 1;
int32 SubscriberLimit = 2;
int32 BufferSize = 3;
}

25
app/stats/counter.go Normal file
View File

@ -0,0 +1,25 @@
// +build !confonly
package stats
import "sync/atomic"
// Counter is an implementation of stats.Counter.
type Counter struct {
value int64
}
// Value implements stats.Counter.
func (c *Counter) Value() int64 {
return atomic.LoadInt64(&c.value)
}
// Set implements stats.Counter.
func (c *Counter) Set(newValue int64) int64 {
return atomic.SwapInt64(&c.value, newValue)
}
// Add implements stats.Counter.
func (c *Counter) Add(delta int64) int64 {
return atomic.AddInt64(&c.value, delta)
}

31
app/stats/counter_test.go Normal file
View File

@ -0,0 +1,31 @@
package stats_test
import (
"context"
"testing"
. "v2ray.com/core/app/stats"
"v2ray.com/core/common"
"v2ray.com/core/features/stats"
)
func TestStatsCounter(t *testing.T) {
raw, err := common.CreateObject(context.Background(), &Config{})
common.Must(err)
m := raw.(stats.Manager)
c, err := m.RegisterCounter("test.counter")
common.Must(err)
if v := c.Add(1); v != 1 {
t.Fatal("unpexcted Add(1) return: ", v, ", wanted ", 1)
}
if v := c.Set(0); v != 1 {
t.Fatal("unexpected Set(0) return: ", v, ", wanted ", 1)
}
if v := c.Value(); v != 0 {
t.Fatal("unexpected Value() return: ", v, ", wanted ", 0)
}
}

View File

@ -2,54 +2,41 @@
package stats
//go:generate errorgen
//go:generate go run v2ray.com/core/common/errors/errorgen
import (
"context"
"sync"
"sync/atomic"
"v2ray.com/core/common"
"v2ray.com/core/common/errors"
"v2ray.com/core/features/stats"
)
// Counter is an implementation of stats.Counter.
type Counter struct {
value int64
}
// Value implements stats.Counter.
func (c *Counter) Value() int64 {
return atomic.LoadInt64(&c.value)
}
// Set implements stats.Counter.
func (c *Counter) Set(newValue int64) int64 {
return atomic.SwapInt64(&c.value, newValue)
}
// Add implements stats.Counter.
func (c *Counter) Add(delta int64) int64 {
return atomic.AddInt64(&c.value, delta)
}
// Manager is an implementation of stats.Manager.
type Manager struct {
access sync.RWMutex
counters map[string]*Counter
channels map[string]*Channel
running bool
}
// NewManager creates an instance of Statistics Manager.
func NewManager(ctx context.Context, config *Config) (*Manager, error) {
m := &Manager{
counters: make(map[string]*Counter),
channels: make(map[string]*Channel),
}
return m, nil
}
// Type implements common.HasType.
func (*Manager) Type() interface{} {
return stats.ManagerType()
}
// RegisterCounter implements stats.Manager.
func (m *Manager) RegisterCounter(name string) (stats.Counter, error) {
m.access.Lock()
defer m.access.Unlock()
@ -63,6 +50,19 @@ func (m *Manager) RegisterCounter(name string) (stats.Counter, error) {
return c, nil
}
// UnregisterCounter implements stats.Manager.
func (m *Manager) UnregisterCounter(name string) error {
m.access.Lock()
defer m.access.Unlock()
if _, found := m.counters[name]; found {
newError("remove counter ", name).AtDebug().WriteToLog()
delete(m.counters, name)
}
return nil
}
// GetCounter implements stats.Manager.
func (m *Manager) GetCounter(name string) stats.Counter {
m.access.RLock()
defer m.access.RUnlock()
@ -73,7 +73,8 @@ func (m *Manager) GetCounter(name string) stats.Counter {
return nil
}
func (m *Manager) Visit(visitor func(string, stats.Counter) bool) {
// VisitCounters calls visitor function on all managed counters.
func (m *Manager) VisitCounters(visitor func(string, stats.Counter) bool) {
m.access.RLock()
defer m.access.RUnlock()
@ -84,12 +85,85 @@ func (m *Manager) Visit(visitor func(string, stats.Counter) bool) {
}
}
// RegisterChannel implements stats.Manager.
func (m *Manager) RegisterChannel(name string) (stats.Channel, error) {
m.access.Lock()
defer m.access.Unlock()
if _, found := m.channels[name]; found {
return nil, newError("Channel ", name, " already registered.")
}
newError("create new channel ", name).AtDebug().WriteToLog()
c := NewChannel(&ChannelConfig{BufferSize: 64, Blocking: false})
m.channels[name] = c
if m.running {
return c, c.Start()
}
return c, nil
}
// UnregisterChannel implements stats.Manager.
func (m *Manager) UnregisterChannel(name string) error {
m.access.Lock()
defer m.access.Unlock()
if c, found := m.channels[name]; found {
newError("remove channel ", name).AtDebug().WriteToLog()
delete(m.channels, name)
return c.Close()
}
return nil
}
// GetChannel implements stats.Manager.
func (m *Manager) GetChannel(name string) stats.Channel {
m.access.RLock()
defer m.access.RUnlock()
if c, found := m.channels[name]; found {
return c
}
return nil
}
// Start implements common.Runnable.
func (m *Manager) Start() error {
m.access.Lock()
defer m.access.Unlock()
m.running = true
errs := []error{}
for _, channel := range m.channels {
if err := channel.Start(); err != nil {
errs = append(errs, err)
}
}
if len(errs) != 0 {
return errors.Combine(errs...)
}
return nil
}
// Close implement common.Closable.
func (m *Manager) Close() error {
m.access.Lock()
defer m.access.Unlock()
m.running = false
errs := []error{}
for name, channel := range m.channels {
newError("remove channel ", name).AtDebug().WriteToLog()
delete(m.channels, name)
if err := channel.Close(); err != nil {
errs = append(errs, err)
}
}
if len(errs) != 0 {
return errors.Combine(errs...)
}
return nil
}
func init() {
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
return NewManager(ctx, config.(*Config))
}))
}

View File

@ -3,33 +3,84 @@ package stats_test
import (
"context"
"testing"
"time"
. "v2ray.com/core/app/stats"
"v2ray.com/core/common"
"v2ray.com/core/features/stats"
)
func TestInternface(t *testing.T) {
func TestInterface(t *testing.T) {
_ = (stats.Manager)(new(Manager))
}
func TestStatsCounter(t *testing.T) {
func TestStatsChannelRunnable(t *testing.T) {
raw, err := common.CreateObject(context.Background(), &Config{})
common.Must(err)
m := raw.(stats.Manager)
c, err := m.RegisterCounter("test.counter")
ch1, err := m.RegisterChannel("test.channel.1")
c1 := ch1.(*Channel)
common.Must(err)
if v := c.Add(1); v != 1 {
t.Fatal("unpexcted Add(1) return: ", v, ", wanted ", 1)
if c1.Running() {
t.Fatalf("unexpected running channel: test.channel.%d", 1)
}
if v := c.Set(0); v != 1 {
t.Fatal("unexpected Set(0) return: ", v, ", wanted ", 1)
common.Must(m.Start())
if !c1.Running() {
t.Fatalf("unexpected non-running channel: test.channel.%d", 1)
}
if v := c.Value(); v != 0 {
t.Fatal("unexpected Value() return: ", v, ", wanted ", 0)
ch2, err := m.RegisterChannel("test.channel.2")
c2 := ch2.(*Channel)
common.Must(err)
if !c2.Running() {
t.Fatalf("unexpected non-running channel: test.channel.%d", 2)
}
s1, err := c1.Subscribe()
common.Must(err)
common.Must(c1.Close())
if c1.Running() {
t.Fatalf("unexpected running channel: test.channel.%d", 1)
}
select { // Check all subscribers in closed channel are closed
case _, ok := <-s1:
if ok {
t.Fatalf("unexpected non-closed subscriber in channel: test.channel.%d", 1)
}
case <-time.After(500 * time.Millisecond):
t.Fatalf("unexpected non-closed subscriber in channel: test.channel.%d", 1)
}
if len(c1.Subscribers()) != 0 { // Check subscribers in closed channel are emptied
t.Fatalf("unexpected non-empty subscribers in channel: test.channel.%d", 1)
}
common.Must(m.Close())
if c2.Running() {
t.Fatalf("unexpected running channel: test.channel.%d", 2)
}
ch3, err := m.RegisterChannel("test.channel.3")
c3 := ch3.(*Channel)
common.Must(err)
if c3.Running() {
t.Fatalf("unexpected running channel: test.channel.%d", 3)
}
common.Must(c3.Start())
common.Must(m.UnregisterChannel("test.channel.3"))
if c3.Running() { // Test that unregistering will close the channel.
t.Fatalf("unexpected running channel: test.channel.%d", 3)
}
}

View File

@ -1,16 +0,0 @@
jobs:
- job: ${{ parameters.name }}
timeoutInMinutes: 30
pool:
vmImage: ${{ parameters.vmImage }}
steps:
- checkout: self
- task: GoTool@0
inputs:
version: '1.14'
- script: |
go test -p 1 -v -timeout 30m ./...
workingDirectory: '$(Build.SourcesDirectory)'
displayName: 'Test'

Some files were not shown because too many files have changed in this diff Show More