Compare commits
No commits in common. "master" and "archive" have entirely different histories.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
||||||
如果你遇到的问题不是 V2Ray 的 bug,比如你不清楚要如何配置,请使用[Discussion](https://github.com/v2fly/discussion/issues)进行讨论。
|
如果你遇到的问题不是 V2Ray 的 bug,比如你不清楚要如何配置,请使用[Discussion](https://github.com/v2ray/discussion/issues)进行讨论。
|
||||||
|
|
||||||
此 Issue 会被立即关闭。
|
此 Issue 会被立即关闭。
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
This issue will be closed immediately.
|
This issue will be closed immediately.
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
---
|
---
|
||||||
name: V2Ray 程序问题
|
name: V2Ray程序问题
|
||||||
about: "提交一个 V2Ray 的程序问题报告。"
|
about: "提交一个 V2Ray 的程序问题报告。"
|
||||||
---
|
---
|
||||||
|
|
||||||
|
提交 Issue 之前请先阅读 [Issue 指引](https://github.com/v2ray/v2ray-core/blob/master/.github/SUPPORT.md),然后回答下面的问题,谢谢。
|
||||||
除非特殊情况,请完整填写所有问题。不按模板发的 issue 将直接被关闭。
|
除非特殊情况,请完整填写所有问题。不按模板发的 issue 将直接被关闭。
|
||||||
如果你遇到的问题不是 V2Ray 的 bug,比如你不清楚要如何配置,请使用[Discussion](https://github.com/v2fly/discussion/issues)进行讨论。
|
如果你遇到的问题不是 V2Ray 的 bug,比如你不清楚要如何配置,请使用[Discussion](https://github.com/v2ray/discussion/issues)进行讨论。
|
||||||
|
|
||||||
1) 你正在使用哪个版本的 V2Ray?(如果服务器和客户端使用了不同版本,请注明)
|
1) 你正在使用哪个版本的 V2Ray?(如果服务器和客户端使用了不同版本,请注明)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@ name: Bug report
|
||||||
about: "Create a bug report to help us improve"
|
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.
|
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/v2fly/discussion/issues) first.
|
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)?
|
1) What version of V2Ray are you using (If you deploy different version on server and client, please explicitly point out)?
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
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.
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
name: Feature Request
|
||||||
|
about: "Open a feature request to V2Ray"
|
||||||
|
---
|
||||||
|
|
||||||
|
Please describe the new feature you want in detail.
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
---
|
---
|
||||||
name: Other
|
name: Other
|
||||||
about: "其它问题请使用 https://github.com/v2fly/discussion/issues 进行讨论 / Please discuss other issues at https://github.com/v2fly/discussion/issues"
|
about: "其它问题请使用 https://github.com/v2ray/discussion/issues 进行讨论 / Please discuss other issues at https://github.com/v2ray/discussion/issues"
|
||||||
---
|
---
|
||||||
|
|
||||||
如果你遇到的问题不是 V2Ray 的 bug,比如你不清楚要如何配置,请使用[Discussion](https://github.com/v2fly/discussion/issues)进行讨论。
|
如果你遇到的问题不是 V2Ray 的 bug,比如你不清楚要如何配置,请使用[Discussion](https://github.com/v2ray/discussion/issues)进行讨论。
|
||||||
|
|
||||||
此 Issue 会被立即关闭。
|
此 Issue 会被立即关闭。
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
This issue will be closed immediately.
|
This issue will be closed immediately.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
# 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
|
||||||
|
}
|
||||||
|
|
||||||
|
\`\`\`
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
# 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"
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
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 +0,0 @@
|
||||||
Please Move to https://github.com/v2fly/v2ray-core/pulls
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
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
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
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
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
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
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
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
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
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
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
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 ./...
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
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
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
// 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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
{
|
||||||
|
"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
24
Dockerfile
|
|
@ -1,24 +0,0 @@
|
||||||
############################
|
|
||||||
# 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"]
|
|
||||||
2
LICENSE
2
LICENSE
|
|
@ -1,6 +1,6 @@
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2015-2020 V2Fly Community
|
Copyright (c) 2015-2019 V2Ray
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
||||||
42
README.md
42
README.md
|
|
@ -1,37 +1,31 @@
|
||||||
# Move To https://github.com/v2fly/v2ray-core
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
# Project V
|
# Project V
|
||||||
|
|
||||||
[![GitHub Test Badge][1]][2] [![codecov.io][3]][4] [![GoDoc][5]][6] [![codebeat][7]][8] [![Downloads][9]][10] [![Downloads][11]][12]
|
[![Build Status][1]][2] [![codecov.io][3]][4] [![GoDoc][5]][6] [![codebeat][7]][8] [![Downloads][9]][10]
|
||||||
|
|
||||||
[1]: https://github.com/v2fly/v2ray-core/workflows/Test/badge.svg "GitHub Test Badge"
|
[1]: https://dev.azure.com/v2ray/core/_apis/build/status/v2ray.core "Build Status badge"
|
||||||
[2]: https://github.com/v2fly/v2ray-core/actions "GitHub Actions Page"
|
[2]: https://dev.azure.com/v2ray/core/_build/latest?definitionId=1 "Azure Build Status"
|
||||||
[3]: https://codecov.io/gh/v2fly/v2ray-core/branch/master/graph/badge.svg?branch=master "Coverage Badge"
|
[3]: https://codecov.io/github/v2ray/v2ray-core/coverage.svg?branch=master "Coverage badge"
|
||||||
[4]: https://codecov.io/gh/v2fly/v2ray-core?branch=master "Codecov Status"
|
[4]: https://codecov.io/github/v2ray/v2ray-core?branch=master "Codecov Status"
|
||||||
[5]: https://godoc.org/v2ray.com/core?status.svg "GoDoc Badge"
|
[5]: https://godoc.org/v2ray.com/core?status.svg "GoDoc badge"
|
||||||
[6]: https://godoc.org/v2ray.com/core "GoDoc"
|
[6]: https://godoc.org/v2ray.com/core "GoDoc"
|
||||||
[7]: https://goreportcard.com/badge/github.com/v2fly/v2ray-core "Goreportcard Badge"
|
[7]: https://codebeat.co/badges/f2354ca8-3e24-463d-a2e3-159af73b2477 "Codebeat badge"
|
||||||
[8]: https://goreportcard.com/report/github.com/v2fly/v2ray-core "Goreportcard Result"
|
[8]: https://codebeat.co/projects/github-com-v2ray-v2ray-core-master "Codebeat"
|
||||||
[9]: https://img.shields.io/github/downloads/v2ray/v2ray-core/total.svg "v2ray/v2ray-core downloads count"
|
[9]: https://img.shields.io/github/downloads/v2ray/v2ray-core/total.svg "All releases badge"
|
||||||
[10]: https://github.com/v2ray/v2ray-core/releases "v2ray/v2ray-core release page"
|
[10]: https://github.com/v2ray/v2ray-core/releases/ "All releases number"
|
||||||
[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.v2fly.org/) 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.v2ray.com/) for more information.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
[The MIT License (MIT)](https://raw.githubusercontent.com/v2fly/v2ray-core/master/LICENSE)
|
[The MIT License (MIT)](https://raw.githubusercontent.com/v2ray/v2ray-core/master/LICENSE)
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
This repo relies on the following third-party projects:
|
This repo relies on the following third-party projects:
|
||||||
|
|
||||||
- In production:
|
* In production:
|
||||||
- [gorilla/websocket](https://github.com/gorilla/websocket)
|
* [gorilla/websocket](https://github.com/gorilla/websocket)
|
||||||
- [gRPC](https://google.golang.org/grpc)
|
* [gRPC](https://google.golang.org/grpc)
|
||||||
- For testing only:
|
* For testing only:
|
||||||
- [miekg/dns](https://github.com/miekg/dns)
|
* [miekg/dns](https://github.com/miekg/dns)
|
||||||
- [h12w/socks](https://github.com/h12w/socks)
|
* [h12w/socks](https://github.com/h12w/socks)
|
||||||
|
|
|
||||||
115
SECURITY.md
115
SECURITY.md
|
|
@ -1,115 +0,0 @@
|
||||||
# 安全策略 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-----
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
package commander
|
package commander
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
||||||
|
|
@ -1,174 +1,95 @@
|
||||||
// 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
|
package commander
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
fmt "fmt"
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
math "math"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
serial "v2ray.com/core/common/serial"
|
serial "v2ray.com/core/common/serial"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
var _ = proto.Marshal
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
var _ = fmt.Errorf
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
var _ = math.Inf
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
// of the legacy proto package is being used.
|
// is compatible with the proto package it is being compiled against.
|
||||||
const _ = proto.ProtoPackageIsVersion4
|
// 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
|
||||||
|
|
||||||
// Config is the settings for Commander.
|
// Config is the settings for Commander.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
// Tag of the outbound handler that handles grpc connections.
|
// Tag of the outbound handler that handles grpc connections.
|
||||||
Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
|
Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
|
||||||
// Services that supported by this server. All services must implement Service
|
// Services that supported by this server. All services must implement Service interface.
|
||||||
// interface.
|
|
||||||
Service []*serial.TypedMessage `protobuf:"bytes,2,rep,name=service,proto3" json:"service,omitempty"`
|
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:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) Reset() {
|
func (m *Config) Reset() { *m = Config{} }
|
||||||
*x = Config{}
|
func (m *Config) String() string { return proto.CompactTextString(m) }
|
||||||
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 (*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) {
|
func (*Config) Descriptor() ([]byte, []int) {
|
||||||
return file_app_commander_config_proto_rawDescGZIP(), []int{0}
|
return fileDescriptor_4af9cfd3f0e2019e, []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetTag() string {
|
func (m *Config) XXX_Unmarshal(b []byte) error {
|
||||||
if x != nil {
|
return xxx_messageInfo_Config.Unmarshal(m, b)
|
||||||
return x.Tag
|
}
|
||||||
|
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
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetService() []*serial.TypedMessage {
|
func (m *Config) GetService() []*serial.TypedMessage {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.Service
|
return m.Service
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_app_commander_config_proto protoreflect.FileDescriptor
|
func init() {
|
||||||
|
proto.RegisterType((*Config)(nil), "v2ray.core.app.commander.Config")
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
func init() {
|
||||||
file_app_commander_config_proto_rawDescOnce sync.Once
|
proto.RegisterFile("v2ray.com/core/app/commander/config.proto", fileDescriptor_4af9cfd3f0e2019e)
|
||||||
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 file_app_commander_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
var fileDescriptor_4af9cfd3f0e2019e = []byte{
|
||||||
var file_app_commander_config_proto_goTypes = []interface{}{
|
// 212 bytes of a gzipped FileDescriptorProto
|
||||||
(*Config)(nil), // 0: v2ray.core.app.commander.Config
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2c, 0x33, 0x2a, 0x4a,
|
||||||
(*serial.TypedMessage)(nil), // 1: v2ray.core.common.serial.TypedMessage
|
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,
|
||||||
var file_app_commander_config_proto_depIdxs = []int32{
|
0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x80, 0x29, 0x2d, 0x4a, 0xd5, 0x4b, 0x2c, 0x28, 0xd0,
|
||||||
1, // 0: v2ray.core.app.commander.Config.service:type_name -> v2ray.core.common.serial.TypedMessage
|
0x83, 0x2b, 0x93, 0x32, 0x40, 0x33, 0x04, 0x24, 0x93, 0x9f, 0xa7, 0x5f, 0x9c, 0x5a, 0x94, 0x99,
|
||||||
1, // [1:1] is the sub-list for method output_type
|
0x98, 0xa3, 0x5f, 0x52, 0x59, 0x90, 0x9a, 0x12, 0x9f, 0x9b, 0x5a, 0x5c, 0x9c, 0x98, 0x9e, 0x0a,
|
||||||
1, // [1:1] is the sub-list for method input_type
|
0x31, 0x4b, 0x29, 0x86, 0x8b, 0xcd, 0x19, 0x6c, 0xb6, 0x90, 0x00, 0x17, 0x73, 0x49, 0x62, 0xba,
|
||||||
1, // [1:1] is the sub-list for extension type_name
|
0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x88, 0x29, 0xe4, 0xc0, 0xc5, 0x5e, 0x9c, 0x5a, 0x54,
|
||||||
1, // [1:1] is the sub-list for extension extendee
|
0x96, 0x99, 0x9c, 0x2a, 0xc1, 0xa4, 0xc0, 0xac, 0xc1, 0x6d, 0xa4, 0xa6, 0x87, 0x64, 0x33, 0xc4,
|
||||||
0, // [0:1] is the sub-list for field type_name
|
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,
|
||||||
func init() { file_app_commander_config_proto_init() }
|
0x26, 0x95, 0xc4, 0x06, 0x76, 0xac, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x29, 0x02, 0xa6, 0x19,
|
||||||
func file_app_commander_config_proto_init() {
|
0x25, 0x01, 0x00, 0x00,
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,16 @@ syntax = "proto3";
|
||||||
|
|
||||||
package v2ray.core.app.commander;
|
package v2ray.core.app.commander;
|
||||||
option csharp_namespace = "V2Ray.Core.App.Commander";
|
option csharp_namespace = "V2Ray.Core.App.Commander";
|
||||||
option go_package = "v2ray.com/core/app/commander";
|
option go_package = "commander";
|
||||||
option java_package = "com.v2ray.core.app.commander";
|
option java_package = "com.v2ray.core.app.commander";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
import "common/serial/typed_message.proto";
|
import "v2ray.com/core/common/serial/typed_message.proto";
|
||||||
|
|
||||||
// Config is the settings for Commander.
|
// Config is the settings for Commander.
|
||||||
message Config {
|
message Config {
|
||||||
// Tag of the outbound handler that handles grpc connections.
|
// Tag of the outbound handler that handles grpc connections.
|
||||||
string tag = 1;
|
string tag = 1;
|
||||||
// Services that supported by this server. All services must implement Service
|
// Services that supported by this server. All services must implement Service interface.
|
||||||
// interface.
|
|
||||||
repeated v2ray.core.common.serial.TypedMessage service = 2;
|
repeated v2ray.core.common.serial.TypedMessage service = 2;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,210 +1,112 @@
|
||||||
// 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
|
package dispatcher
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
fmt "fmt"
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
math "math"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
var _ = proto.Marshal
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
var _ = fmt.Errorf
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
var _ = math.Inf
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
// of the legacy proto package is being used.
|
// is compatible with the proto package it is being compiled against.
|
||||||
const _ = proto.ProtoPackageIsVersion4
|
// 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
|
||||||
|
|
||||||
type SessionConfig struct {
|
type SessionConfig struct {
|
||||||
state protoimpl.MessageState
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
sizeCache protoimpl.SizeCache
|
XXX_unrecognized []byte `json:"-"`
|
||||||
unknownFields protoimpl.UnknownFields
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
|
||||||
|
|
||||||
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 (m *SessionConfig) Reset() { *m = SessionConfig{} }
|
||||||
|
func (m *SessionConfig) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SessionConfig) ProtoMessage() {}
|
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) {
|
func (*SessionConfig) Descriptor() ([]byte, []int) {
|
||||||
return file_app_dispatcher_config_proto_rawDescGZIP(), []int{0}
|
return fileDescriptor_90b7c41cce355532, []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 {
|
type Config struct {
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
Settings *SessionConfig `protobuf:"bytes,1,opt,name=settings,proto3" json:"settings,omitempty"`
|
Settings *SessionConfig `protobuf:"bytes,1,opt,name=settings,proto3" json:"settings,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) Reset() {
|
func (m *Config) Reset() { *m = Config{} }
|
||||||
*x = Config{}
|
func (m *Config) String() string { return proto.CompactTextString(m) }
|
||||||
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 (*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) {
|
func (*Config) Descriptor() ([]byte, []int) {
|
||||||
return file_app_dispatcher_config_proto_rawDescGZIP(), []int{1}
|
return fileDescriptor_90b7c41cce355532, []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetSettings() *SessionConfig {
|
func (m *Config) XXX_Unmarshal(b []byte) error {
|
||||||
if x != nil {
|
return xxx_messageInfo_Config.Unmarshal(m, b)
|
||||||
return x.Settings
|
}
|
||||||
|
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
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_app_dispatcher_config_proto protoreflect.FileDescriptor
|
func init() {
|
||||||
|
proto.RegisterType((*SessionConfig)(nil), "v2ray.core.app.dispatcher.SessionConfig")
|
||||||
var file_app_dispatcher_config_proto_rawDesc = []byte{
|
proto.RegisterType((*Config)(nil), "v2ray.core.app.dispatcher.Config")
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
func init() {
|
||||||
file_app_dispatcher_config_proto_rawDescOnce sync.Once
|
proto.RegisterFile("v2ray.com/core/app/dispatcher/config.proto", fileDescriptor_90b7c41cce355532)
|
||||||
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 file_app_dispatcher_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
var fileDescriptor_90b7c41cce355532 = []byte{
|
||||||
var file_app_dispatcher_config_proto_goTypes = []interface{}{
|
// 176 bytes of a gzipped FileDescriptorProto
|
||||||
(*SessionConfig)(nil), // 0: v2ray.core.app.dispatcher.SessionConfig
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2a, 0x33, 0x2a, 0x4a,
|
||||||
(*Config)(nil), // 1: v2ray.core.app.dispatcher.Config
|
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,
|
||||||
var file_app_dispatcher_config_proto_depIdxs = []int32{
|
0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x84, 0xa9, 0x2d, 0x4a, 0xd5, 0x4b, 0x2c, 0x28,
|
||||||
0, // 0: v2ray.core.app.dispatcher.Config.settings:type_name -> v2ray.core.app.dispatcher.SessionConfig
|
0xd0, 0x43, 0xa8, 0x53, 0x12, 0xe5, 0xe2, 0x0d, 0x4e, 0x2d, 0x2e, 0xce, 0xcc, 0xcf, 0x73, 0x06,
|
||||||
1, // [1:1] is the sub-list for method output_type
|
0xeb, 0xf0, 0x62, 0xe1, 0x60, 0x14, 0x60, 0x52, 0xf2, 0xe3, 0x62, 0x83, 0xf0, 0x85, 0x5c, 0xb8,
|
||||||
1, // [1:1] is the sub-list for method input_type
|
0x38, 0x8a, 0x53, 0x4b, 0x4a, 0x32, 0xf3, 0xd2, 0x8b, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d,
|
||||||
1, // [1:1] is the sub-list for extension type_name
|
0x34, 0xf4, 0x70, 0x1a, 0xa7, 0x87, 0x62, 0x56, 0x10, 0x5c, 0xa7, 0x93, 0x27, 0x97, 0x6c, 0x72,
|
||||||
1, // [1:1] is the sub-list for extension extendee
|
0x7e, 0x2e, 0x6e, 0x8d, 0x01, 0x8c, 0x51, 0x5c, 0x08, 0xde, 0x2a, 0x26, 0xc9, 0x30, 0xa3, 0xa0,
|
||||||
0, // [0:1] is the sub-list for field type_name
|
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,
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,13 @@ syntax = "proto3";
|
||||||
|
|
||||||
package v2ray.core.app.dispatcher;
|
package v2ray.core.app.dispatcher;
|
||||||
option csharp_namespace = "V2Ray.Core.App.Dispatcher";
|
option csharp_namespace = "V2Ray.Core.App.Dispatcher";
|
||||||
option go_package = "v2ray.com/core/app/dispatcher";
|
option go_package = "dispatcher";
|
||||||
option java_package = "com.v2ray.core.app.dispatcher";
|
option java_package = "com.v2ray.core.app.dispatcher";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
message SessionConfig {
|
message SessionConfig {
|
||||||
reserved 1;
|
reserved 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message Config {
|
message Config {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
package dispatcher
|
package dispatcher
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -20,7 +20,6 @@ import (
|
||||||
"v2ray.com/core/features/outbound"
|
"v2ray.com/core/features/outbound"
|
||||||
"v2ray.com/core/features/policy"
|
"v2ray.com/core/features/policy"
|
||||||
"v2ray.com/core/features/routing"
|
"v2ray.com/core/features/routing"
|
||||||
routing_session "v2ray.com/core/features/routing/session"
|
|
||||||
"v2ray.com/core/features/stats"
|
"v2ray.com/core/features/stats"
|
||||||
"v2ray.com/core/transport"
|
"v2ray.com/core/transport"
|
||||||
"v2ray.com/core/transport/pipe"
|
"v2ray.com/core/transport/pipe"
|
||||||
|
|
@ -266,8 +265,7 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.router != nil && !skipRoutePick {
|
if d.router != nil && !skipRoutePick {
|
||||||
if route, err := d.router.PickRoute(routing_session.AsRoutingContext(ctx)); err == nil {
|
if tag, err := d.router.PickRoute(ctx); err == nil {
|
||||||
tag := route.GetOutboundTag()
|
|
||||||
if h := d.ohm.GetHandler(tag); h != nil {
|
if h := d.ohm.GetHandler(tag); h != nil {
|
||||||
newError("taking detour [", tag, "] for [", destination, "]").WriteToLog(session.ExportIDToError(ctx))
|
newError("taking detour [", tag, "] for [", destination, "]").WriteToLog(session.ExportIDToError(ctx))
|
||||||
handler = h
|
handler = h
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
package dispatcher
|
package dispatcher
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,23 @@
|
||||||
// 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
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
fmt "fmt"
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
math "math"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
router "v2ray.com/core/app/router"
|
router "v2ray.com/core/app/router"
|
||||||
net "v2ray.com/core/common/net"
|
net "v2ray.com/core/common/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
var _ = proto.Marshal
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
var _ = fmt.Errorf
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
var _ = math.Inf
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
// of the legacy proto package is being used.
|
// is compatible with the proto package it is being compiled against.
|
||||||
const _ = proto.ProtoPackageIsVersion4
|
// 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
|
||||||
|
|
||||||
type DomainMatchingType int32
|
type DomainMatchingType int32
|
||||||
|
|
||||||
|
|
@ -36,623 +28,333 @@ const (
|
||||||
DomainMatchingType_Regex DomainMatchingType = 3
|
DomainMatchingType_Regex DomainMatchingType = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum value maps for DomainMatchingType.
|
var DomainMatchingType_name = map[int32]string{
|
||||||
var (
|
|
||||||
DomainMatchingType_name = map[int32]string{
|
|
||||||
0: "Full",
|
0: "Full",
|
||||||
1: "Subdomain",
|
1: "Subdomain",
|
||||||
2: "Keyword",
|
2: "Keyword",
|
||||||
3: "Regex",
|
3: "Regex",
|
||||||
}
|
}
|
||||||
DomainMatchingType_value = map[string]int32{
|
|
||||||
|
var DomainMatchingType_value = map[string]int32{
|
||||||
"Full": 0,
|
"Full": 0,
|
||||||
"Subdomain": 1,
|
"Subdomain": 1,
|
||||||
"Keyword": 2,
|
"Keyword": 2,
|
||||||
"Regex": 3,
|
"Regex": 3,
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func (x DomainMatchingType) Enum() *DomainMatchingType {
|
|
||||||
p := new(DomainMatchingType)
|
|
||||||
*p = x
|
|
||||||
return p
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x DomainMatchingType) String() string {
|
func (x DomainMatchingType) String() string {
|
||||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
return proto.EnumName(DomainMatchingType_name, int32(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) {
|
func (DomainMatchingType) EnumDescriptor() ([]byte, []int) {
|
||||||
return file_app_dns_config_proto_rawDescGZIP(), []int{0}
|
return fileDescriptor_ed5695198e3def8f, []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
type NameServer struct {
|
type NameServer struct {
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
Address *net.Endpoint `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
|
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"`
|
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"`
|
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"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
}
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
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 (m *NameServer) Reset() { *m = NameServer{} }
|
||||||
|
func (m *NameServer) String() string { return proto.CompactTextString(m) }
|
||||||
func (*NameServer) ProtoMessage() {}
|
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) {
|
func (*NameServer) Descriptor() ([]byte, []int) {
|
||||||
return file_app_dns_config_proto_rawDescGZIP(), []int{0}
|
return fileDescriptor_ed5695198e3def8f, []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *NameServer) GetAddress() *net.Endpoint {
|
func (m *NameServer) XXX_Unmarshal(b []byte) error {
|
||||||
if x != nil {
|
return xxx_messageInfo_NameServer.Unmarshal(m, b)
|
||||||
return x.Address
|
}
|
||||||
|
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
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *NameServer) GetPrioritizedDomain() []*NameServer_PriorityDomain {
|
func (m *NameServer) GetPrioritizedDomain() []*NameServer_PriorityDomain {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.PrioritizedDomain
|
return m.PrioritizedDomain
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *NameServer) GetGeoip() []*router.GeoIP {
|
func (m *NameServer) GetGeoip() []*router.GeoIP {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.Geoip
|
return m.Geoip
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *NameServer) GetOriginalRules() []*NameServer_OriginalRule {
|
type NameServer_PriorityDomain struct {
|
||||||
if x != nil {
|
Type DomainMatchingType `protobuf:"varint,1,opt,name=type,proto3,enum=v2ray.core.app.dns.DomainMatchingType" json:"type,omitempty"`
|
||||||
return x.OriginalRules
|
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
|
||||||
}
|
}
|
||||||
return nil
|
return DomainMatchingType_Full
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *NameServer_PriorityDomain) GetDomain() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Domain
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
state protoimpl.MessageState
|
// Nameservers used by this DNS. Only traditional UDP servers are support at the moment.
|
||||||
sizeCache protoimpl.SizeCache
|
// A special value 'localhost' as a domain address can be set to use DNS on local system.
|
||||||
unknownFields protoimpl.UnknownFields
|
NameServers []*net.Endpoint `protobuf:"bytes,1,rep,name=NameServers,proto3" json:"NameServers,omitempty"` // Deprecated: Do not use.
|
||||||
|
|
||||||
// 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 list used by this DNS client.
|
||||||
NameServer []*NameServer `protobuf:"bytes,5,rep,name=name_server,json=nameServer,proto3" json:"name_server,omitempty"`
|
NameServer []*NameServer `protobuf:"bytes,5,rep,name=name_server,json=nameServer,proto3" json:"name_server,omitempty"`
|
||||||
// Static hosts. Domain to IP.
|
// Static hosts. Domain to IP.
|
||||||
// Deprecated. Use static_hosts.
|
// 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.
|
||||||
// Deprecated: Do not use.
|
// Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes (IPv6).
|
||||||
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"`
|
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"`
|
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 is the inbound tag of DNS client.
|
||||||
Tag string `protobuf:"bytes,6,opt,name=tag,proto3" json:"tag,omitempty"`
|
Tag string `protobuf:"bytes,6,opt,name=tag,proto3" json:"tag,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) Reset() {
|
func (m *Config) Reset() { *m = Config{} }
|
||||||
*x = Config{}
|
func (m *Config) String() string { return proto.CompactTextString(m) }
|
||||||
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 (*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) {
|
func (*Config) Descriptor() ([]byte, []int) {
|
||||||
return file_app_dns_config_proto_rawDescGZIP(), []int{1}
|
return fileDescriptor_ed5695198e3def8f, []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.
|
// Deprecated: Do not use.
|
||||||
func (x *Config) GetNameServers() []*net.Endpoint {
|
func (m *Config) GetNameServers() []*net.Endpoint {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.NameServers
|
return m.NameServers
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetNameServer() []*NameServer {
|
func (m *Config) GetNameServer() []*NameServer {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.NameServer
|
return m.NameServer
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Do not use.
|
// Deprecated: Do not use.
|
||||||
func (x *Config) GetHosts() map[string]*net.IPOrDomain {
|
func (m *Config) GetHosts() map[string]*net.IPOrDomain {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.Hosts
|
return m.Hosts
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetClientIp() []byte {
|
func (m *Config) GetClientIp() []byte {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.ClientIp
|
return m.ClientIp
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetStaticHosts() []*Config_HostMapping {
|
func (m *Config) GetStaticHosts() []*Config_HostMapping {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.StaticHosts
|
return m.StaticHosts
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetTag() string {
|
func (m *Config) GetTag() string {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.Tag
|
return m.Tag
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
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"`
|
|
||||||
}
|
|
||||||
|
|
||||||
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 (x *NameServer_PriorityDomain) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*NameServer_PriorityDomain) ProtoMessage() {}
|
|
||||||
|
|
||||||
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 (x *NameServer_PriorityDomain) GetDomain() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Domain
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
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"`
|
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"`
|
Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"`
|
||||||
Ip [][]byte `protobuf:"bytes,3,rep,name=ip,proto3" json:"ip,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
|
// ProxiedDomain indicates the mapped domain has the same IP address on this domain. V2Ray will use this domain for IP queries.
|
||||||
// domain. V2Ray will use this domain for IP queries. This field is only
|
// This field is only effective if ip is empty.
|
||||||
// effective if ip is empty.
|
|
||||||
ProxiedDomain string `protobuf:"bytes,4,opt,name=proxied_domain,json=proxiedDomain,proto3" json:"proxied_domain,omitempty"`
|
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 (x *Config_HostMapping) Reset() {
|
func (m *Config_HostMapping) Reset() { *m = Config_HostMapping{} }
|
||||||
*x = Config_HostMapping{}
|
func (m *Config_HostMapping) String() string { return proto.CompactTextString(m) }
|
||||||
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 (*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) {
|
func (*Config_HostMapping) Descriptor() ([]byte, []int) {
|
||||||
return file_app_dns_config_proto_rawDescGZIP(), []int{1, 1}
|
return fileDescriptor_ed5695198e3def8f, []int{1, 1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config_HostMapping) GetType() DomainMatchingType {
|
func (m *Config_HostMapping) XXX_Unmarshal(b []byte) error {
|
||||||
if x != nil {
|
return xxx_messageInfo_Config_HostMapping.Unmarshal(m, b)
|
||||||
return x.Type
|
}
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Config_HostMapping proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *Config_HostMapping) GetType() DomainMatchingType {
|
||||||
|
if m != nil {
|
||||||
|
return m.Type
|
||||||
}
|
}
|
||||||
return DomainMatchingType_Full
|
return DomainMatchingType_Full
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config_HostMapping) GetDomain() string {
|
func (m *Config_HostMapping) GetDomain() string {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.Domain
|
return m.Domain
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config_HostMapping) GetIp() [][]byte {
|
func (m *Config_HostMapping) GetIp() [][]byte {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.Ip
|
return m.Ip
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config_HostMapping) GetProxiedDomain() string {
|
func (m *Config_HostMapping) GetProxiedDomain() string {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.ProxiedDomain
|
return m.ProxiedDomain
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_app_dns_config_proto protoreflect.FileDescriptor
|
func init() {
|
||||||
|
proto.RegisterEnum("v2ray.core.app.dns.DomainMatchingType", DomainMatchingType_name, DomainMatchingType_value)
|
||||||
var file_app_dns_config_proto_rawDesc = []byte{
|
proto.RegisterType((*NameServer)(nil), "v2ray.core.app.dns.NameServer")
|
||||||
0x0a, 0x14, 0x61, 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
|
proto.RegisterType((*NameServer_PriorityDomain)(nil), "v2ray.core.app.dns.NameServer.PriorityDomain")
|
||||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f,
|
proto.RegisterType((*Config)(nil), "v2ray.core.app.dns.Config")
|
||||||
0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x1a, 0x18, 0x63, 0x6f, 0x6d, 0x6d,
|
proto.RegisterMapType((map[string]*net.IPOrDomain)(nil), "v2ray.core.app.dns.Config.HostsEntry")
|
||||||
0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x2e, 0x70,
|
proto.RegisterType((*Config_HostMapping)(nil), "v2ray.core.app.dns.Config.HostMapping")
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
func init() {
|
||||||
file_app_dns_config_proto_rawDescOnce sync.Once
|
proto.RegisterFile("v2ray.com/core/app/dns/config.proto", fileDescriptor_ed5695198e3def8f)
|
||||||
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 file_app_dns_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
var fileDescriptor_ed5695198e3def8f = []byte{
|
||||||
var file_app_dns_config_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
// 583 bytes of a gzipped FileDescriptorProto
|
||||||
var file_app_dns_config_proto_goTypes = []interface{}{
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xdf, 0x6e, 0xd3, 0x3e,
|
||||||
(DomainMatchingType)(0), // 0: v2ray.core.app.dns.DomainMatchingType
|
0x18, 0xfd, 0x25, 0xfd, 0xb3, 0xf5, 0xcb, 0x56, 0xf5, 0xe7, 0x8b, 0x29, 0x2a, 0x08, 0xc6, 0xd0,
|
||||||
(*NameServer)(nil), // 1: v2ray.core.app.dns.NameServer
|
0x46, 0x05, 0xc2, 0x91, 0x02, 0x12, 0xb0, 0x9b, 0x89, 0x6d, 0x05, 0x2a, 0x34, 0xa8, 0x3c, 0xc4,
|
||||||
(*Config)(nil), // 2: v2ray.core.app.dns.Config
|
0x05, 0x20, 0x55, 0x5e, 0x62, 0x32, 0x8b, 0xc6, 0xb6, 0x1c, 0x77, 0x2c, 0x3c, 0x09, 0xcf, 0xc0,
|
||||||
(*NameServer_PriorityDomain)(nil), // 3: v2ray.core.app.dns.NameServer.PriorityDomain
|
0x4b, 0x70, 0xc1, 0x8b, 0xa1, 0xda, 0x19, 0xed, 0xb6, 0x0e, 0xb8, 0xe1, 0xce, 0x7f, 0xce, 0xf9,
|
||||||
(*NameServer_OriginalRule)(nil), // 4: v2ray.core.app.dns.NameServer.OriginalRule
|
0xce, 0xf9, 0x8e, 0xbf, 0x04, 0x6e, 0x9f, 0xc4, 0x9a, 0x96, 0x38, 0x91, 0x79, 0x94, 0x48, 0xcd,
|
||||||
nil, // 5: v2ray.core.app.dns.Config.HostsEntry
|
0x22, 0xaa, 0x54, 0x94, 0x8a, 0x22, 0x4a, 0xa4, 0xf8, 0xc8, 0x33, 0xac, 0xb4, 0x34, 0x12, 0xa1,
|
||||||
(*Config_HostMapping)(nil), // 6: v2ray.core.app.dns.Config.HostMapping
|
0x33, 0x90, 0x66, 0x98, 0x2a, 0x85, 0x53, 0x51, 0x74, 0xef, 0x5c, 0x20, 0x26, 0x32, 0xcf, 0xa5,
|
||||||
(*net.Endpoint)(nil), // 7: v2ray.core.common.net.Endpoint
|
0x88, 0x04, 0x33, 0x11, 0x4d, 0x53, 0xcd, 0x8a, 0xc2, 0x91, 0xbb, 0xf7, 0xae, 0x06, 0xa6, 0xac,
|
||||||
(*router.GeoIP)(nil), // 8: v2ray.core.app.router.GeoIP
|
0x30, 0x5c, 0x50, 0xc3, 0xa5, 0xa8, 0xc0, 0x5b, 0x0b, 0xec, 0x68, 0x39, 0x31, 0x4c, 0x9f, 0x73,
|
||||||
(*net.IPOrDomain)(nil), // 9: v2ray.core.common.net.IPOrDomain
|
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,
|
||||||
var file_app_dns_config_proto_depIdxs = []int32{
|
0x45, 0xaa, 0x24, 0x17, 0x86, 0x9c, 0xe1, 0xd1, 0x07, 0x40, 0x4a, 0x73, 0xa9, 0xb9, 0xe1, 0x5f,
|
||||||
7, // 0: v2ray.core.app.dns.NameServer.address:type_name -> v2ray.core.common.net.Endpoint
|
0x58, 0x3a, 0x4a, 0x65, 0x4e, 0xb9, 0x08, 0xfd, 0xf5, 0x5a, 0x2f, 0x88, 0xef, 0xe3, 0xcb, 0x8d,
|
||||||
3, // 1: v2ray.core.app.dns.NameServer.prioritized_domain:type_name -> v2ray.core.app.dns.NameServer.PriorityDomain
|
0xe3, 0x99, 0x2c, 0x1e, 0x3a, 0x62, 0xb9, 0x6f, 0x49, 0xe4, 0xff, 0xb9, 0x42, 0xee, 0x08, 0xc5,
|
||||||
8, // 2: v2ray.core.app.dns.NameServer.geoip:type_name -> v2ray.core.app.router.GeoIP
|
0xd0, 0xc8, 0x98, 0xe4, 0x2a, 0xac, 0xd9, 0x82, 0xd7, 0x2f, 0x16, 0x74, 0xbd, 0xe1, 0xe7, 0x4c,
|
||||||
4, // 3: v2ray.core.app.dns.NameServer.original_rules:type_name -> v2ray.core.app.dns.NameServer.OriginalRule
|
0x0e, 0x86, 0xc4, 0x41, 0xbb, 0x29, 0xb4, 0xcf, 0x17, 0x46, 0xdb, 0x50, 0x37, 0xa5, 0x62, 0xb6,
|
||||||
7, // 4: v2ray.core.app.dns.Config.NameServers:type_name -> v2ray.core.common.net.Endpoint
|
0xb7, 0x76, 0xbc, 0xb5, 0xc8, 0x95, 0x43, 0x1e, 0x50, 0x93, 0x1c, 0x73, 0x91, 0xbd, 0x29, 0x15,
|
||||||
1, // 5: v2ray.core.app.dns.Config.name_server:type_name -> v2ray.core.app.dns.NameServer
|
0x23, 0x96, 0x83, 0xd6, 0xa0, 0xf9, 0xab, 0x27, 0xaf, 0xd7, 0x22, 0xd5, 0x6e, 0xe3, 0x47, 0x1d,
|
||||||
5, // 6: v2ray.core.app.dns.Config.Hosts:type_name -> v2ray.core.app.dns.Config.HostsEntry
|
0x9a, 0x7b, 0x36, 0x52, 0xd4, 0x87, 0x60, 0xd6, 0xd4, 0x34, 0xc1, 0xda, 0x5f, 0x24, 0xb8, 0xeb,
|
||||||
6, // 7: v2ray.core.app.dns.Config.static_hosts:type_name -> v2ray.core.app.dns.Config.HostMapping
|
0x87, 0x1e, 0x99, 0xe7, 0xa1, 0x1d, 0x08, 0x04, 0xcd, 0xd9, 0xa8, 0xb0, 0xfb, 0xb0, 0x61, 0xcb,
|
||||||
0, // 8: v2ray.core.app.dns.NameServer.PriorityDomain.type:type_name -> v2ray.core.app.dns.DomainMatchingType
|
0xdc, 0xf8, 0x7d, 0x84, 0x04, 0xc4, 0xec, 0x15, 0x77, 0xa0, 0xf1, 0x42, 0x16, 0xa6, 0xa8, 0xd2,
|
||||||
9, // 9: v2ray.core.app.dns.Config.HostsEntry.value:type_name -> v2ray.core.common.net.IPOrDomain
|
0xdf, 0x5c, 0x44, 0x75, 0x96, 0xb1, 0xc5, 0xf5, 0x85, 0xd1, 0xa5, 0xf5, 0xe1, 0x78, 0xe8, 0x1a,
|
||||||
0, // 10: v2ray.core.app.dns.Config.HostMapping.type:type_name -> v2ray.core.app.dns.DomainMatchingType
|
0xb4, 0x92, 0x31, 0x67, 0xc2, 0x8c, 0x6c, 0xe2, 0x5e, 0x6f, 0x85, 0x2c, 0xbb, 0x83, 0x81, 0x42,
|
||||||
11, // [11:11] is the sub-list for method output_type
|
0x03, 0x58, 0x29, 0x0c, 0x35, 0x3c, 0x19, 0x1d, 0x5b, 0x91, 0xba, 0x15, 0xd9, 0xfa, 0x83, 0xc8,
|
||||||
11, // [11:11] is the sub-list for method input_type
|
0x01, 0x55, 0x8a, 0x8b, 0x8c, 0x04, 0x8e, 0xeb, 0x74, 0x3a, 0x50, 0x33, 0x34, 0x0b, 0x9b, 0x36,
|
||||||
11, // [11:11] is the sub-list for extension type_name
|
0xd0, 0xe9, 0xb2, 0xfb, 0x1e, 0x60, 0x66, 0x69, 0x7a, 0xff, 0x89, 0x95, 0xf6, 0xb9, 0x5a, 0x64,
|
||||||
11, // [11:11] is the sub-list for extension extendee
|
0xba, 0x44, 0x8f, 0xa0, 0x71, 0x42, 0xc7, 0x13, 0x66, 0x1f, 0x21, 0x88, 0x6f, 0x5d, 0x11, 0xee,
|
||||||
0, // [0:11] is the sub-list for field type_name
|
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,
|
||||||
func init() { file_app_dns_config_proto_init() }
|
0x59, 0x0a, 0x2d, 0x43, 0xfd, 0xd9, 0x64, 0x3c, 0xee, 0xfc, 0x87, 0x56, 0xa1, 0x75, 0x38, 0x39,
|
||||||
func file_app_dns_config_proto_init() {
|
0x72, 0x15, 0x3a, 0x1e, 0x0a, 0x60, 0xe9, 0x25, 0x2b, 0x3f, 0x4b, 0x9d, 0x76, 0x7c, 0xd4, 0x82,
|
||||||
if File_app_dns_config_proto != nil {
|
0x06, 0x61, 0x19, 0x3b, 0xed, 0xd4, 0x76, 0x1f, 0xc2, 0x5a, 0x22, 0xf3, 0x05, 0x8d, 0x0c, 0xbd,
|
||||||
return
|
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,
|
||||||
if !protoimpl.UnsafeEnabled {
|
0x2a, 0x66, 0x8a, 0xc4, 0x04, 0x00, 0x00,
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@ syntax = "proto3";
|
||||||
|
|
||||||
package v2ray.core.app.dns;
|
package v2ray.core.app.dns;
|
||||||
option csharp_namespace = "V2Ray.Core.App.Dns";
|
option csharp_namespace = "V2Ray.Core.App.Dns";
|
||||||
option go_package = "v2ray.com/core/app/dns";
|
option go_package = "dns";
|
||||||
option java_package = "com.v2ray.core.app.dns";
|
option java_package = "com.v2ray.core.app.dns";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
import "common/net/address.proto";
|
import "v2ray.com/core/common/net/address.proto";
|
||||||
import "common/net/destination.proto";
|
import "v2ray.com/core/common/net/destination.proto";
|
||||||
import "app/router/config.proto";
|
import "v2ray.com/core/app/router/config.proto";
|
||||||
|
|
||||||
message NameServer {
|
message NameServer {
|
||||||
v2ray.core.common.net.Endpoint address = 1;
|
v2ray.core.common.net.Endpoint address = 1;
|
||||||
|
|
@ -18,14 +18,8 @@ message NameServer {
|
||||||
string domain = 2;
|
string domain = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message OriginalRule {
|
|
||||||
string rule = 1;
|
|
||||||
uint32 size = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
repeated PriorityDomain prioritized_domain = 2;
|
repeated PriorityDomain prioritized_domain = 2;
|
||||||
repeated v2ray.core.app.router.GeoIP geoip = 3;
|
repeated v2ray.core.app.router.GeoIP geoip = 3;
|
||||||
repeated OriginalRule original_rules = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DomainMatchingType {
|
enum DomainMatchingType {
|
||||||
|
|
@ -36,9 +30,8 @@ enum DomainMatchingType {
|
||||||
}
|
}
|
||||||
|
|
||||||
message Config {
|
message Config {
|
||||||
// Nameservers used by this DNS. Only traditional UDP servers are support at
|
// Nameservers used by this DNS. Only traditional UDP servers are support at the moment.
|
||||||
// the moment. A special value 'localhost' as a domain address can be set to
|
// A special value 'localhost' as a domain address can be set to use DNS on local system.
|
||||||
// use DNS on local system.
|
|
||||||
repeated v2ray.core.common.net.Endpoint NameServers = 1 [deprecated = true];
|
repeated v2ray.core.common.net.Endpoint NameServers = 1 [deprecated = true];
|
||||||
|
|
||||||
// NameServer list used by this DNS client.
|
// NameServer list used by this DNS client.
|
||||||
|
|
@ -48,8 +41,7 @@ message Config {
|
||||||
// Deprecated. Use static_hosts.
|
// Deprecated. Use static_hosts.
|
||||||
map<string, v2ray.core.common.net.IPOrDomain> Hosts = 2 [deprecated = true];
|
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
|
// Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes (IPv6).
|
||||||
// (IPv6).
|
|
||||||
bytes client_ip = 3;
|
bytes client_ip = 3;
|
||||||
|
|
||||||
message HostMapping {
|
message HostMapping {
|
||||||
|
|
@ -58,9 +50,8 @@ message Config {
|
||||||
|
|
||||||
repeated bytes ip = 3;
|
repeated bytes ip = 3;
|
||||||
|
|
||||||
// ProxiedDomain indicates the mapped domain has the same IP address on this
|
// ProxiedDomain indicates the mapped domain has the same IP address on this domain. V2Ray will use this domain for IP queries.
|
||||||
// domain. V2Ray will use this domain for IP queries. This field is only
|
// This field is only effective if ip is empty.
|
||||||
// effective if ip is empty.
|
|
||||||
string proxied_domain = 4;
|
string proxied_domain = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Package dns is an implementation of core.DNS feature.
|
// Package dns is an implementation of core.DNS feature.
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,14 @@ import (
|
||||||
"golang.org/x/net/dns/dnsmessage"
|
"golang.org/x/net/dns/dnsmessage"
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
|
v2net "v2ray.com/core/common/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_parseResponse(t *testing.T) {
|
func Test_parseResponse(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
payload []byte
|
||||||
|
}
|
||||||
|
|
||||||
var p [][]byte
|
var p [][]byte
|
||||||
|
|
||||||
ans := new(dns.Msg)
|
ans := new(dns.Msg)
|
||||||
|
|
@ -51,7 +56,7 @@ func Test_parseResponse(t *testing.T) {
|
||||||
wantErr bool
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
{"empty",
|
{"empty",
|
||||||
&IPRecord{0, []net.Address(nil), time.Time{}, dnsmessage.RCodeSuccess},
|
&IPRecord{0, []v2net.Address(nil), time.Time{}, dnsmessage.RCodeSuccess},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{"error",
|
{"error",
|
||||||
|
|
@ -59,12 +64,12 @@ func Test_parseResponse(t *testing.T) {
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{"a record",
|
{"a record",
|
||||||
&IPRecord{1, []net.Address{net.ParseAddress("8.8.8.8"), net.ParseAddress("8.8.4.4")},
|
&IPRecord{1, []v2net.Address{v2net.ParseAddress("8.8.8.8"), v2net.ParseAddress("8.8.4.4")},
|
||||||
time.Time{}, dnsmessage.RCodeSuccess},
|
time.Time{}, dnsmessage.RCodeSuccess},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{"aaaa record",
|
{"aaaa record",
|
||||||
&IPRecord{2, []net.Address{net.ParseAddress("2001::123:8888"), net.ParseAddress("2001::123:8844")}, time.Time{}, dnsmessage.RCodeSuccess},
|
&IPRecord{2, []v2net.Address{v2net.ParseAddress("2001::123:8888"), v2net.ParseAddress("2001::123:8844")}, time.Time{}, dnsmessage.RCodeSuccess},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ import (
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
dns_feature "v2ray.com/core/features/dns"
|
||||||
|
|
||||||
"golang.org/x/net/dns/dnsmessage"
|
"golang.org/x/net/dns/dnsmessage"
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
|
|
@ -21,14 +23,13 @@ import (
|
||||||
"v2ray.com/core/common/session"
|
"v2ray.com/core/common/session"
|
||||||
"v2ray.com/core/common/signal/pubsub"
|
"v2ray.com/core/common/signal/pubsub"
|
||||||
"v2ray.com/core/common/task"
|
"v2ray.com/core/common/task"
|
||||||
dns_feature "v2ray.com/core/features/dns"
|
|
||||||
"v2ray.com/core/features/routing"
|
"v2ray.com/core/features/routing"
|
||||||
"v2ray.com/core/transport/internet"
|
"v2ray.com/core/transport/internet"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DoHNameServer implemented DNS over HTTPS (RFC8484) Wire Format,
|
// DoHNameServer implimented DNS over HTTPS (RFC8484) Wire Format,
|
||||||
// which is compatible with traditional dns over udp(RFC1035),
|
// which is compatiable with traditional dns over udp(RFC1035),
|
||||||
// thus most of the DOH implementation is copied from udpns.go
|
// thus most of the DOH implimentation is copied from udpns.go
|
||||||
type DoHNameServer struct {
|
type DoHNameServer struct {
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
ips map[string]record
|
ips map[string]record
|
||||||
|
|
@ -47,17 +48,16 @@ func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher, clientIP net.
|
||||||
newError("DNS: created Remote DOH client for ", url.String()).AtInfo().WriteToLog()
|
newError("DNS: created Remote DOH client for ", url.String()).AtInfo().WriteToLog()
|
||||||
s := baseDOHNameServer(url, "DOH", clientIP)
|
s := baseDOHNameServer(url, "DOH", clientIP)
|
||||||
|
|
||||||
// Dispatched connection will be closed (interrupted) after each request
|
// Dispatched connection will be closed (interupted) after each request
|
||||||
// This makes DOH inefficient without a keep-alived connection
|
// This makes DOH inefficient without a keeped-alive connection
|
||||||
// See: core/app/proxyman/outbound/handler.go:113
|
// See: core/app/proxyman/outbound/handler.go:113
|
||||||
// Using mux (https request wrapped in a stream layer) improves the situation.
|
// Using mux (https request wrapped in a stream layer) improves the situation.
|
||||||
// Recommend to use NewDoHLocalNameServer (DOHL:) if v2ray instance is running on
|
// Recommand to use NewDoHLocalNameServer (DOHL:) if v2ray instance is running on
|
||||||
// a normal network eg. the server side of v2ray
|
// a normal network eg. the server side of v2ray
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
MaxIdleConns: 30,
|
MaxIdleConns: 30,
|
||||||
IdleConnTimeout: 90 * time.Second,
|
IdleConnTimeout: 90 * time.Second,
|
||||||
TLSHandshakeTimeout: 30 * time.Second,
|
TLSHandshakeTimeout: 30 * time.Second,
|
||||||
ForceAttemptHTTP2: true,
|
|
||||||
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
dest, err := net.ParseDestination(network + ":" + addr)
|
dest, err := net.ParseDestination(network + ":" + addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -90,7 +90,6 @@ func NewDoHLocalNameServer(url *url.URL, clientIP net.IP) *DoHNameServer {
|
||||||
s := baseDOHNameServer(url, "DOHL", clientIP)
|
s := baseDOHNameServer(url, "DOHL", clientIP)
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
IdleConnTimeout: 90 * time.Second,
|
IdleConnTimeout: 90 * time.Second,
|
||||||
ForceAttemptHTTP2: true,
|
|
||||||
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
dest, err := net.ParseDestination(network + ":" + addr)
|
dest, err := net.ParseDestination(network + ":" + addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -192,7 +191,7 @@ func (s *DoHNameServer) updateIP(req *dnsRequest, ipRec *IPRecord) {
|
||||||
updated = true
|
updated = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newError(s.name, " got answer: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed).AtInfo().WriteToLog()
|
newError(s.name, " got answere: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed).AtInfo().WriteToLog()
|
||||||
|
|
||||||
if updated {
|
if updated {
|
||||||
s.ips[req.domain] = rec
|
s.ips[req.domain] = rec
|
||||||
|
|
@ -220,11 +219,13 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPO
|
||||||
if d, ok := ctx.Deadline(); ok {
|
if d, ok := ctx.Deadline(); ok {
|
||||||
deadline = d
|
deadline = d
|
||||||
} else {
|
} else {
|
||||||
deadline = time.Now().Add(time.Second * 5)
|
deadline = time.Now().Add(time.Second * 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, req := range reqs {
|
for _, req := range reqs {
|
||||||
|
|
||||||
go func(r *dnsRequest) {
|
go func(r *dnsRequest) {
|
||||||
|
|
||||||
// generate new context for each req, using same context
|
// generate new context for each req, using same context
|
||||||
// may cause reqs all aborted if any one encounter an error
|
// may cause reqs all aborted if any one encounter an error
|
||||||
dnsCtx := context.Background()
|
dnsCtx := context.Background()
|
||||||
|
|
@ -242,18 +243,13 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPO
|
||||||
// forced to use mux for DOH
|
// forced to use mux for DOH
|
||||||
dnsCtx = session.ContextWithMuxPrefered(dnsCtx, true)
|
dnsCtx = session.ContextWithMuxPrefered(dnsCtx, true)
|
||||||
|
|
||||||
var cancel context.CancelFunc
|
dnsCtx, cancel := context.WithDeadline(dnsCtx, deadline)
|
||||||
dnsCtx, cancel = context.WithDeadline(dnsCtx, deadline)
|
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
b, err := dns.PackMessage(r.msg)
|
b, _ := 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())
|
resp, err := s.dohHTTPSContext(dnsCtx, b.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newError("failed to retrieve response").Base(err).AtError().WriteToLog()
|
newError("failed to retrive response").Base(err).AtError().WriteToLog()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rec, err := parseResponse(resp)
|
rec, err := parseResponse(resp)
|
||||||
|
|
@ -267,6 +263,7 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPO
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DoHNameServer) dohHTTPSContext(ctx context.Context, b []byte) ([]byte, error) {
|
func (s *DoHNameServer) dohHTTPSContext(ctx context.Context, b []byte) ([]byte, error) {
|
||||||
|
|
||||||
body := bytes.NewBuffer(b)
|
body := bytes.NewBuffer(b)
|
||||||
req, err := http.NewRequest("POST", s.dohURL, body)
|
req, err := http.NewRequest("POST", s.dohURL, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -106,14 +106,11 @@ func filterIP(ips []net.Address, option IPOption) []net.Address {
|
||||||
|
|
||||||
// LookupIP returns IP address for the given domain, if exists in this StaticHosts.
|
// LookupIP returns IP address for the given domain, if exists in this StaticHosts.
|
||||||
func (h *StaticHosts) LookupIP(domain string, option IPOption) []net.Address {
|
func (h *StaticHosts) LookupIP(domain string, option IPOption) []net.Address {
|
||||||
indices := h.matchers.Match(domain)
|
id := h.matchers.Match(domain)
|
||||||
if len(indices) == 0 {
|
if id == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
ips := []net.Address{}
|
ips := h.ips[id]
|
||||||
for _, id := range indices {
|
|
||||||
ips = append(ips, h.ips[id]...)
|
|
||||||
}
|
|
||||||
if len(ips) == 1 && ips[0].Family().IsDomain() {
|
if len(ips) == 1 && ips[0].Family().IsDomain() {
|
||||||
return ips
|
return ips
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,10 @@
|
||||||
|
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -30,21 +29,14 @@ import (
|
||||||
type Server struct {
|
type Server struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
hosts *StaticHosts
|
hosts *StaticHosts
|
||||||
|
clients []Client
|
||||||
clientIP net.IP
|
clientIP net.IP
|
||||||
clients []Client // clientIdx -> Client
|
|
||||||
ipIndexMap []*MultiGeoIPMatcher // clientIdx -> *MultiGeoIPMatcher
|
|
||||||
domainRules [][]string // clientIdx -> domainRuleIdx -> DomainRule
|
|
||||||
domainMatcher strmatcher.IndexMatcher
|
domainMatcher strmatcher.IndexMatcher
|
||||||
matcherInfos []DomainMatcherInfo // matcherIdx -> DomainMatcherInfo
|
domainIndexMap map[uint32]uint32
|
||||||
|
ipIndexMap map[uint32]*MultiGeoIPMatcher
|
||||||
tag string
|
tag string
|
||||||
}
|
}
|
||||||
|
|
||||||
// DomainMatcherInfo contains information attached to index returned by Server.domainMatcher
|
|
||||||
type DomainMatcherInfo struct {
|
|
||||||
clientIdx uint16
|
|
||||||
domainRuleIdx uint16
|
|
||||||
}
|
|
||||||
|
|
||||||
// MultiGeoIPMatcher for match
|
// MultiGeoIPMatcher for match
|
||||||
type MultiGeoIPMatcher struct {
|
type MultiGeoIPMatcher struct {
|
||||||
matchers []*router.GeoIPMatcher
|
matchers []*router.GeoIPMatcher
|
||||||
|
|
@ -94,27 +86,10 @@ func New(ctx context.Context, config *Config) (*Server, error) {
|
||||||
}
|
}
|
||||||
server.hosts = hosts
|
server.hosts = hosts
|
||||||
|
|
||||||
addNameServer := func(ns *NameServer) int {
|
addNameServer := func(endpoint *net.Endpoint) int {
|
||||||
endpoint := ns.Address
|
|
||||||
address := endpoint.Address.AsAddress()
|
address := endpoint.Address.AsAddress()
|
||||||
if address.Family().IsDomain() && address.Domain() == "localhost" {
|
if address.Family().IsDomain() && address.Domain() == "localhost" {
|
||||||
server.clients = append(server.clients, NewLocalNameServer())
|
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://") {
|
} else if address.Family().IsDomain() && strings.HasPrefix(address.Domain(), "https+local://") {
|
||||||
// URI schemed string treated as domain
|
// URI schemed string treated as domain
|
||||||
// DOH Local mode
|
// DOH Local mode
|
||||||
|
|
@ -123,7 +98,8 @@ func New(ctx context.Context, config *Config) (*Server, error) {
|
||||||
log.Fatalln(newError("DNS config error").Base(err))
|
log.Fatalln(newError("DNS config error").Base(err))
|
||||||
}
|
}
|
||||||
server.clients = append(server.clients, NewDoHLocalNameServer(u, server.clientIP))
|
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
|
// DOH Remote mode
|
||||||
u, err := url.Parse(address.Domain())
|
u, err := url.Parse(address.Domain())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -155,66 +131,33 @@ func New(ctx context.Context, config *Config) (*Server, error) {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
server.ipIndexMap = append(server.ipIndexMap, nil)
|
|
||||||
return len(server.clients) - 1
|
return len(server.clients) - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(config.NameServers) > 0 {
|
if len(config.NameServers) > 0 {
|
||||||
features.PrintDeprecatedFeatureWarning("simple DNS server")
|
features.PrintDeprecatedFeatureWarning("simple DNS server")
|
||||||
for _, destPB := range config.NameServers {
|
for _, destPB := range config.NameServers {
|
||||||
addNameServer(&NameServer{Address: destPB})
|
addNameServer(destPB)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(config.NameServer) > 0 {
|
if len(config.NameServer) > 0 {
|
||||||
clientIndices := []int{}
|
|
||||||
domainRuleCount := 0
|
|
||||||
for _, ns := range config.NameServer {
|
|
||||||
idx := addNameServer(ns)
|
|
||||||
clientIndices = append(clientIndices, idx)
|
|
||||||
domainRuleCount += len(ns.PrioritizedDomain)
|
|
||||||
}
|
|
||||||
|
|
||||||
domainRules := make([][]string, len(server.clients))
|
|
||||||
domainMatcher := &strmatcher.MatcherGroup{}
|
domainMatcher := &strmatcher.MatcherGroup{}
|
||||||
matcherInfos := make([]DomainMatcherInfo, domainRuleCount+1) // matcher index starts from 1
|
domainIndexMap := make(map[uint32]uint32)
|
||||||
|
ipIndexMap := make(map[uint32]*MultiGeoIPMatcher)
|
||||||
var geoIPMatcherContainer router.GeoIPMatcherContainer
|
var geoIPMatcherContainer router.GeoIPMatcherContainer
|
||||||
for nidx, ns := range config.NameServer {
|
|
||||||
idx := clientIndices[nidx]
|
|
||||||
|
|
||||||
// Establish domain rule matcher
|
for _, ns := range config.NameServer {
|
||||||
rules := []string{}
|
idx := addNameServer(ns.Address)
|
||||||
ruleCurr := 0
|
|
||||||
ruleIter := 0
|
|
||||||
for _, domain := range ns.PrioritizedDomain {
|
for _, domain := range ns.PrioritizedDomain {
|
||||||
matcher, err := toStrMatcher(domain.Type, domain.Domain)
|
matcher, err := toStrMatcher(domain.Type, domain.Domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("failed to create prioritized domain").Base(err).AtWarning()
|
return nil, newError("failed to create prioritized domain").Base(err).AtWarning()
|
||||||
}
|
}
|
||||||
midx := domainMatcher.Add(matcher)
|
midx := domainMatcher.Add(matcher)
|
||||||
if midx >= uint32(len(matcherInfos)) { // This rarely happens according to current matcher's implementation
|
domainIndexMap[midx] = uint32(idx)
|
||||||
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
|
// only add to ipIndexMap if GeoIP is configured
|
||||||
if len(ns.Geoip) > 0 {
|
if len(ns.Geoip) > 0 {
|
||||||
|
|
@ -227,17 +170,17 @@ func New(ctx context.Context, config *Config) (*Server, error) {
|
||||||
matchers = append(matchers, matcher)
|
matchers = append(matchers, matcher)
|
||||||
}
|
}
|
||||||
matcher := &MultiGeoIPMatcher{matchers: matchers}
|
matcher := &MultiGeoIPMatcher{matchers: matchers}
|
||||||
server.ipIndexMap[idx] = matcher
|
ipIndexMap[uint32(idx)] = matcher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
server.domainRules = domainRules
|
|
||||||
server.domainMatcher = domainMatcher
|
server.domainMatcher = domainMatcher
|
||||||
server.matcherInfos = matcherInfos
|
server.domainIndexMap = domainIndexMap
|
||||||
|
server.ipIndexMap = ipIndexMap
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(server.clients) == 0 {
|
if len(server.clients) == 0 {
|
||||||
server.clients = append(server.clients, NewLocalNameServer())
|
server.clients = append(server.clients, NewLocalNameServer())
|
||||||
server.ipIndexMap = append(server.ipIndexMap, nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return server, nil
|
return server, nil
|
||||||
|
|
@ -264,12 +207,9 @@ func (s *Server) IsOwnLink(ctx context.Context) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match check dns ip match geoip
|
// Match check dns ip match geoip
|
||||||
func (s *Server) Match(idx int, client Client, domain string, ips []net.IP) ([]net.IP, error) {
|
func (s *Server) Match(idx uint32, client Client, domain string, ips []net.IP) ([]net.IP, error) {
|
||||||
var matcher *MultiGeoIPMatcher
|
matcher, exist := s.ipIndexMap[idx]
|
||||||
if idx < len(s.ipIndexMap) {
|
if !exist {
|
||||||
matcher = s.ipIndexMap[idx]
|
|
||||||
}
|
|
||||||
if matcher == nil {
|
|
||||||
return ips, nil
|
return ips, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -291,7 +231,7 @@ func (s *Server) Match(idx int, client Client, domain string, ips []net.IP) ([]n
|
||||||
return newIps, nil
|
return newIps, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) queryIPTimeout(idx int, client Client, domain string, option IPOption) ([]net.IP, error) {
|
func (s *Server) queryIPTimeout(idx uint32, client Client, domain string, option IPOption) ([]net.IP, error) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*4)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*4)
|
||||||
if len(s.tag) > 0 {
|
if len(s.tag) > 0 {
|
||||||
ctx = session.ContextWithInbound(ctx, &session.Inbound{
|
ctx = session.ContextWithInbound(ctx, &session.Inbound{
|
||||||
|
|
@ -367,6 +307,11 @@ func (s *Server) lookupIPInternal(domain string, option IPOption) ([]net.IP, err
|
||||||
domain = domain[:len(domain)-1]
|
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)
|
ips := s.lookupStatic(domain, option, 0)
|
||||||
if ips != nil && ips[0].Family().IsIP() {
|
if ips != nil && ips[0].Family().IsIP() {
|
||||||
newError("returning ", len(ips), " IPs for domain ", domain).WriteToLog()
|
newError("returning ", len(ips), " IPs for domain ", domain).WriteToLog()
|
||||||
|
|
@ -382,25 +327,10 @@ func (s *Server) lookupIPInternal(domain string, option IPOption) ([]net.IP, err
|
||||||
var lastErr error
|
var lastErr error
|
||||||
var matchedClient Client
|
var matchedClient Client
|
||||||
if s.domainMatcher != nil {
|
if s.domainMatcher != nil {
|
||||||
indices := s.domainMatcher.Match(domain)
|
idx := s.domainMatcher.Match(domain)
|
||||||
domainRules := []string{}
|
if idx > 0 {
|
||||||
matchingDNS := []string{}
|
matchedClient = s.clients[s.domainIndexMap[idx]]
|
||||||
for _, idx := range indices {
|
ips, err := s.queryIPTimeout(s.domainIndexMap[idx], matchedClient, domain, option)
|
||||||
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 {
|
if len(ips) > 0 {
|
||||||
return ips, nil
|
return ips, nil
|
||||||
}
|
}
|
||||||
|
|
@ -420,7 +350,7 @@ func (s *Server) lookupIPInternal(domain string, option IPOption) ([]net.IP, err
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
ips, err := s.queryIPTimeout(idx, client, domain, option)
|
ips, err := s.queryIPTimeout(uint32(idx), client, domain, option)
|
||||||
if len(ips) > 0 {
|
if len(ips) > 0 {
|
||||||
return ips, nil
|
return ips, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,6 @@ func (*staticHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
|
||||||
rr, _ := dns.NewRR("google.com. IN A 8.8.4.4")
|
rr, _ := dns.NewRR("google.com. IN A 8.8.4.4")
|
||||||
ans.Answer = append(ans.Answer, rr)
|
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 {
|
} else if q.Name == "facebook.com." && q.Qtype == dns.TypeA {
|
||||||
rr, _ := dns.NewRR("facebook.com. IN A 9.9.9.9")
|
rr, _ := dns.NewRR("facebook.com. IN A 9.9.9.9")
|
||||||
ans.Answer = append(ans.Answer, rr)
|
ans.Answer = append(ans.Answer, rr)
|
||||||
|
|
@ -69,27 +63,6 @@ func (*staticHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
|
||||||
ans.Answer = append(ans.Answer, rr)
|
ans.Answer = append(ans.Answer, rr)
|
||||||
} else if q.Name == "notexist.google.com." && q.Qtype == dns.TypeAAAA {
|
} else if q.Name == "notexist.google.com." && q.Qtype == dns.TypeAAAA {
|
||||||
ans.MsgHdr.Rcode = dns.RcodeNameError
|
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)
|
w.WriteMsg(ans)
|
||||||
|
|
@ -564,395 +537,3 @@ func TestIPMatch(t *testing.T) {
|
||||||
t.Error("DNS query doesn't finish in 2 seconds.")
|
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.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ func (s *ClassicNameServer) HandleResponse(ctx context.Context, packet *udp_prot
|
||||||
|
|
||||||
ipRec, err := parseResponse(packet.Payload.Bytes())
|
ipRec, err := parseResponse(packet.Payload.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newError(s.name, " fail to parse responded DNS udp").AtError().WriteToLog()
|
newError(s.name, " fail to parse responsed DNS udp").AtError().WriteToLog()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,7 +134,7 @@ func (s *ClassicNameServer) HandleResponse(ctx context.Context, packet *udp_prot
|
||||||
}
|
}
|
||||||
|
|
||||||
elapsed := time.Since(req.start)
|
elapsed := time.Since(req.start)
|
||||||
newError(s.name, " got answer: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed).AtInfo().WriteToLog()
|
newError(s.name, " got answere: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed).AtInfo().WriteToLog()
|
||||||
if len(req.domain) > 0 && (rec.A != nil || rec.AAAA != nil) {
|
if len(req.domain) > 0 && (rec.A != nil || rec.AAAA != nil) {
|
||||||
s.updateIP(req.domain, rec)
|
s.updateIP(req.domain, rec)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
package command
|
package command
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -33,8 +33,6 @@ func (s *LoggerServer) RestartLogger(ctx context.Context, request *RestartLogger
|
||||||
return &RestartLoggerResponse{}, nil
|
return &RestartLoggerResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LoggerServer) mustEmbedUnimplementedLoggerServiceServer() {}
|
|
||||||
|
|
||||||
type service struct {
|
type service struct {
|
||||||
v *core.Instance
|
v *core.Instance
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,259 +1,213 @@
|
||||||
// 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
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
context "context"
|
||||||
|
fmt "fmt"
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
grpc "google.golang.org/grpc"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
math "math"
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
var _ = proto.Marshal
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
var _ = fmt.Errorf
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
var _ = math.Inf
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
// of the legacy proto package is being used.
|
// is compatible with the proto package it is being compiled against.
|
||||||
const _ = proto.ProtoPackageIsVersion4
|
// 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
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
state protoimpl.MessageState
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
sizeCache protoimpl.SizeCache
|
XXX_unrecognized []byte `json:"-"`
|
||||||
unknownFields protoimpl.UnknownFields
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
|
||||||
|
|
||||||
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 (m *Config) Reset() { *m = Config{} }
|
||||||
|
func (m *Config) String() string { return proto.CompactTextString(m) }
|
||||||
func (*Config) ProtoMessage() {}
|
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) {
|
func (*Config) Descriptor() ([]byte, []int) {
|
||||||
return file_app_log_command_config_proto_rawDescGZIP(), []int{0}
|
return fileDescriptor_46d95b63a682e4a6, []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 {
|
type RestartLoggerRequest struct {
|
||||||
state protoimpl.MessageState
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
sizeCache protoimpl.SizeCache
|
XXX_unrecognized []byte `json:"-"`
|
||||||
unknownFields protoimpl.UnknownFields
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
|
||||||
|
|
||||||
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 (m *RestartLoggerRequest) Reset() { *m = RestartLoggerRequest{} }
|
||||||
|
func (m *RestartLoggerRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*RestartLoggerRequest) ProtoMessage() {}
|
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) {
|
func (*RestartLoggerRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_app_log_command_config_proto_rawDescGZIP(), []int{1}
|
return fileDescriptor_46d95b63a682e4a6, []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 {
|
type RestartLoggerResponse struct {
|
||||||
state protoimpl.MessageState
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
sizeCache protoimpl.SizeCache
|
XXX_unrecognized []byte `json:"-"`
|
||||||
unknownFields protoimpl.UnknownFields
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
|
||||||
|
|
||||||
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 (m *RestartLoggerResponse) Reset() { *m = RestartLoggerResponse{} }
|
||||||
|
func (m *RestartLoggerResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*RestartLoggerResponse) ProtoMessage() {}
|
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) {
|
func (*RestartLoggerResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_app_log_command_config_proto_rawDescGZIP(), []int{2}
|
return fileDescriptor_46d95b63a682e4a6, []int{2}
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_app_log_command_config_proto protoreflect.FileDescriptor
|
func (m *RestartLoggerResponse) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_RestartLoggerResponse.Unmarshal(m, b)
|
||||||
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,
|
func (m *RestartLoggerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
0x64, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1a,
|
return xxx_messageInfo_RestartLoggerResponse.Marshal(b, m, deterministic)
|
||||||
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,
|
func (m *RestartLoggerResponse) XXX_Merge(src proto.Message) {
|
||||||
0x6e, 0x66, 0x69, 0x67, 0x22, 0x16, 0x0a, 0x14, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x4c,
|
xxx_messageInfo_RestartLoggerResponse.Merge(m, src)
|
||||||
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,
|
func (m *RestartLoggerResponse) XXX_Size() int {
|
||||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x87, 0x01, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72,
|
return xxx_messageInfo_RestartLoggerResponse.Size(m)
|
||||||
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,
|
func (m *RestartLoggerResponse) XXX_DiscardUnknown() {
|
||||||
0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x2e, 0x63, 0x6f,
|
xxx_messageInfo_RestartLoggerResponse.DiscardUnknown(m)
|
||||||
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 (
|
var xxx_messageInfo_RestartLoggerResponse proto.InternalMessageInfo
|
||||||
file_app_log_command_config_proto_rawDescOnce sync.Once
|
|
||||||
file_app_log_command_config_proto_rawDescData = file_app_log_command_config_proto_rawDesc
|
|
||||||
)
|
|
||||||
|
|
||||||
func file_app_log_command_config_proto_rawDescGZIP() []byte {
|
func init() {
|
||||||
file_app_log_command_config_proto_rawDescOnce.Do(func() {
|
proto.RegisterType((*Config)(nil), "v2ray.core.app.log.command.Config")
|
||||||
file_app_log_command_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_log_command_config_proto_rawDescData)
|
proto.RegisterType((*RestartLoggerRequest)(nil), "v2ray.core.app.log.command.RestartLoggerRequest")
|
||||||
})
|
proto.RegisterType((*RestartLoggerResponse)(nil), "v2ray.core.app.log.command.RestartLoggerResponse")
|
||||||
return file_app_log_command_config_proto_rawDescData
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_app_log_command_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
func init() {
|
||||||
var file_app_log_command_config_proto_goTypes = []interface{}{
|
proto.RegisterFile("v2ray.com/core/app/log/command/config.proto", fileDescriptor_46d95b63a682e4a6)
|
||||||
(*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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_app_log_command_config_proto_init() }
|
var fileDescriptor_46d95b63a682e4a6 = []byte{
|
||||||
func file_app_log_command_config_proto_init() {
|
// 210 bytes of a gzipped FileDescriptorProto
|
||||||
if File_app_log_command_config_proto != nil {
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2e, 0x33, 0x2a, 0x4a,
|
||||||
return
|
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
|
||||||
}
|
}
|
||||||
if !protoimpl.UnsafeEnabled {
|
return out, nil
|
||||||
file_app_log_command_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
}
|
||||||
switch v := v.(*Config); i {
|
|
||||||
case 0:
|
// LoggerServiceServer is the server API for LoggerService service.
|
||||||
return &v.state
|
type LoggerServiceServer interface {
|
||||||
case 1:
|
RestartLogger(context.Context, *RestartLoggerRequest) (*RestartLoggerResponse, error)
|
||||||
return &v.sizeCache
|
}
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
func RegisterLoggerServiceServer(s *grpc.Server, srv LoggerServiceServer) {
|
||||||
default:
|
s.RegisterService(&_LoggerService_serviceDesc, srv)
|
||||||
return nil
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
file_app_log_command_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
info := &grpc.UnaryServerInfo{
|
||||||
switch v := v.(*RestartLoggerRequest); i {
|
Server: srv,
|
||||||
case 0:
|
FullMethod: "/v2ray.core.app.log.command.LoggerService/RestartLogger",
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LoggerServiceServer).RestartLogger(ctx, req.(*RestartLoggerRequest))
|
||||||
}
|
}
|
||||||
file_app_log_command_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
return interceptor(ctx, in, info, handler)
|
||||||
switch v := v.(*RestartLoggerResponse); i {
|
}
|
||||||
case 0:
|
|
||||||
return &v.state
|
var _LoggerService_serviceDesc = grpc.ServiceDesc{
|
||||||
case 1:
|
ServiceName: "v2ray.core.app.log.command.LoggerService",
|
||||||
return &v.sizeCache
|
HandlerType: (*LoggerServiceServer)(nil),
|
||||||
case 2:
|
Methods: []grpc.MethodDesc{
|
||||||
return &v.unknownFields
|
{
|
||||||
default:
|
MethodName: "RestartLogger",
|
||||||
return nil
|
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,
|
|
||||||
},
|
},
|
||||||
GoTypes: file_app_log_command_config_proto_goTypes,
|
},
|
||||||
DependencyIndexes: file_app_log_command_config_proto_depIdxs,
|
Streams: []grpc.StreamDesc{},
|
||||||
MessageInfos: file_app_log_command_config_proto_msgTypes,
|
Metadata: "v2ray.com/core/app/log/command/config.proto",
|
||||||
}.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
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,16 @@ syntax = "proto3";
|
||||||
|
|
||||||
package v2ray.core.app.log.command;
|
package v2ray.core.app.log.command;
|
||||||
option csharp_namespace = "V2Ray.Core.App.Log.Command";
|
option csharp_namespace = "V2Ray.Core.App.Log.Command";
|
||||||
option go_package = "v2ray.com/core/app/log/command";
|
option go_package = "command";
|
||||||
option java_package = "com.v2ray.core.app.log.command";
|
option java_package = "com.v2ray.core.app.log.command";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
message Config {}
|
message Config {
|
||||||
|
}
|
||||||
|
|
||||||
message RestartLoggerRequest {}
|
message RestartLoggerRequest {}
|
||||||
|
|
||||||
message RestartLoggerResponse {}
|
message RestartLoggerResponse{}
|
||||||
|
|
||||||
service LoggerService {
|
service LoggerService {
|
||||||
rpc RestartLogger(RestartLoggerRequest) returns (RestartLoggerResponse) {}
|
rpc RestartLogger(RestartLoggerRequest) returns (RestartLoggerResponse) {}
|
||||||
|
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
||||||
// 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",
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +1,22 @@
|
||||||
// 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
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
fmt "fmt"
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
math "math"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
log "v2ray.com/core/common/log"
|
log "v2ray.com/core/common/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
var _ = proto.Marshal
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
var _ = fmt.Errorf
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
var _ = math.Inf
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
// of the legacy proto package is being used.
|
// is compatible with the proto package it is being compiled against.
|
||||||
const _ = proto.ProtoPackageIsVersion4
|
// 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
|
||||||
|
|
||||||
type LogType int32
|
type LogType int32
|
||||||
|
|
||||||
|
|
@ -35,231 +27,128 @@ const (
|
||||||
LogType_Event LogType = 3
|
LogType_Event LogType = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum value maps for LogType.
|
var LogType_name = map[int32]string{
|
||||||
var (
|
|
||||||
LogType_name = map[int32]string{
|
|
||||||
0: "None",
|
0: "None",
|
||||||
1: "Console",
|
1: "Console",
|
||||||
2: "File",
|
2: "File",
|
||||||
3: "Event",
|
3: "Event",
|
||||||
}
|
}
|
||||||
LogType_value = map[string]int32{
|
|
||||||
|
var LogType_value = map[string]int32{
|
||||||
"None": 0,
|
"None": 0,
|
||||||
"Console": 1,
|
"Console": 1,
|
||||||
"File": 2,
|
"File": 2,
|
||||||
"Event": 3,
|
"Event": 3,
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func (x LogType) Enum() *LogType {
|
|
||||||
p := new(LogType)
|
|
||||||
*p = x
|
|
||||||
return p
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x LogType) String() string {
|
func (x LogType) String() string {
|
||||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
return proto.EnumName(LogType_name, int32(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) {
|
func (LogType) EnumDescriptor() ([]byte, []int) {
|
||||||
return file_app_log_config_proto_rawDescGZIP(), []int{0}
|
return fileDescriptor_92dfeade43d9e989, []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
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"`
|
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"`
|
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"`
|
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"`
|
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"`
|
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:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) Reset() {
|
func (m *Config) Reset() { *m = Config{} }
|
||||||
*x = Config{}
|
func (m *Config) String() string { return proto.CompactTextString(m) }
|
||||||
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 (*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) {
|
func (*Config) Descriptor() ([]byte, []int) {
|
||||||
return file_app_log_config_proto_rawDescGZIP(), []int{0}
|
return fileDescriptor_92dfeade43d9e989, []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetErrorLogType() LogType {
|
func (m *Config) XXX_Unmarshal(b []byte) error {
|
||||||
if x != nil {
|
return xxx_messageInfo_Config.Unmarshal(m, b)
|
||||||
return x.ErrorLogType
|
}
|
||||||
|
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
|
||||||
}
|
}
|
||||||
return LogType_None
|
return LogType_None
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetErrorLogLevel() log.Severity {
|
func (m *Config) GetErrorLogLevel() log.Severity {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.ErrorLogLevel
|
return m.ErrorLogLevel
|
||||||
}
|
}
|
||||||
return log.Severity_Unknown
|
return log.Severity_Unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetErrorLogPath() string {
|
func (m *Config) GetErrorLogPath() string {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.ErrorLogPath
|
return m.ErrorLogPath
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetAccessLogType() LogType {
|
func (m *Config) GetAccessLogType() LogType {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.AccessLogType
|
return m.AccessLogType
|
||||||
}
|
}
|
||||||
return LogType_None
|
return LogType_None
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetAccessLogPath() string {
|
func (m *Config) GetAccessLogPath() string {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.AccessLogPath
|
return m.AccessLogPath
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_app_log_config_proto protoreflect.FileDescriptor
|
func init() {
|
||||||
|
proto.RegisterEnum("v2ray.core.app.log.LogType", LogType_name, LogType_value)
|
||||||
var file_app_log_config_proto_rawDesc = []byte{
|
proto.RegisterType((*Config)(nil), "v2ray.core.app.log.Config")
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
func init() {
|
||||||
file_app_log_config_proto_rawDescOnce sync.Once
|
proto.RegisterFile("v2ray.com/core/app/log/config.proto", fileDescriptor_92dfeade43d9e989)
|
||||||
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 file_app_log_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
var fileDescriptor_92dfeade43d9e989 = []byte{
|
||||||
var file_app_log_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
// 306 bytes of a gzipped FileDescriptorProto
|
||||||
var file_app_log_config_proto_goTypes = []interface{}{
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xcd, 0x4a, 0xfb, 0x40,
|
||||||
(LogType)(0), // 0: v2ray.core.app.log.LogType
|
0x14, 0x47, 0xff, 0x49, 0xbf, 0xfe, 0x1d, 0x6d, 0x1b, 0x66, 0x21, 0x45, 0x17, 0x16, 0x15, 0x29,
|
||||||
(*Config)(nil), // 1: v2ray.core.app.log.Config
|
0x2e, 0x26, 0x50, 0xf5, 0x01, 0x6a, 0x50, 0x37, 0x45, 0x4a, 0x14, 0x17, 0x6e, 0xca, 0x38, 0x5c,
|
||||||
(log.Severity)(0), // 2: v2ray.core.common.log.Severity
|
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,
|
||||||
var file_app_log_config_proto_depIdxs = []int32{
|
0xa0, 0x81, 0x90, 0x6b, 0x1d, 0x2a, 0x94, 0xa1, 0xc0, 0xec, 0x2d, 0x91, 0x4c, 0x1b, 0xb4, 0x48,
|
||||||
0, // 0: v2ray.core.app.log.Config.error_log_type:type_name -> v2ray.core.app.log.LogType
|
0x69, 0x7d, 0x64, 0x80, 0x71, 0xad, 0x99, 0x42, 0x79, 0xf8, 0x1d, 0x14, 0x98, 0xa6, 0x98, 0x39,
|
||||||
2, // 1: v2ray.core.app.log.Config.error_log_level:type_name -> v2ray.core.common.log.Severity
|
0x56, 0xe1, 0x16, 0x3c, 0x79, 0xf7, 0x49, 0x37, 0x72, 0x26, 0x3a, 0x27, 0x43, 0x30, 0x06, 0xcd,
|
||||||
0, // 2: v2ray.core.app.log.Config.access_log_type:type_name -> v2ray.core.app.log.LogType
|
0x4a, 0xa1, 0x5c, 0xd9, 0x52, 0xc3, 0xd8, 0x9b, 0x78, 0xd3, 0xe1, 0xec, 0x88, 0xfd, 0x94, 0xb3,
|
||||||
3, // [3:3] is the sub-list for method output_type
|
0x05, 0xca, 0xa7, 0x52, 0x43, 0xbc, 0xef, 0x90, 0xed, 0x13, 0xbd, 0x27, 0xa3, 0x46, 0xa1, 0xa0,
|
||||||
3, // [3:3] is the sub-list for method input_type
|
0x00, 0x35, 0xf6, 0x9d, 0xe3, 0x78, 0xd7, 0xb1, 0x09, 0x71, 0x9a, 0x47, 0x28, 0xc0, 0x24, 0xb6,
|
||||||
3, // [3:3] is the sub-list for extension type_name
|
0x8c, 0x07, 0xb5, 0x67, 0x51, 0x51, 0xf4, 0x6c, 0xb7, 0x45, 0x73, 0xbb, 0x1e, 0xb7, 0x26, 0xde,
|
||||||
3, // [3:3] is the sub-list for extension extendee
|
0xb4, 0xdf, 0xcc, 0x2d, 0xb9, 0x5d, 0xd3, 0x88, 0x8c, 0xb8, 0x10, 0x90, 0xe7, 0x4d, 0x72, 0xfb,
|
||||||
0, // [0:3] is the sub-list for field type_name
|
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,
|
||||||
func init() { file_app_log_config_proto_init() }
|
0x16, 0x90, 0xd9, 0xa0, 0x75, 0x73, 0x45, 0x0e, 0x04, 0xa6, 0xbf, 0xf4, 0x2c, 0xbd, 0x97, 0x96,
|
||||||
func file_app_log_config_proto_init() {
|
0x42, 0xf9, 0xe1, 0xd3, 0xe7, 0x59, 0xcc, 0x4b, 0x16, 0x55, 0xdf, 0xe6, 0x5a, 0x57, 0x9d, 0xaf,
|
||||||
if File_app_log_config_proto != nil {
|
0x5d, 0xf7, 0x77, 0x2e, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x33, 0xd5, 0x99, 0x3f, 0xfd, 0x01,
|
||||||
return
|
0x00, 0x00,
|
||||||
}
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@ syntax = "proto3";
|
||||||
|
|
||||||
package v2ray.core.app.log;
|
package v2ray.core.app.log;
|
||||||
option csharp_namespace = "V2Ray.Core.App.Log";
|
option csharp_namespace = "V2Ray.Core.App.Log";
|
||||||
option go_package = "v2ray.com/core/app/log";
|
option go_package = "log";
|
||||||
option java_package = "com.v2ray.core.app.log";
|
option java_package = "com.v2ray.core.app.log";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
import "common/log/log.proto";
|
import "v2ray.com/core/common/log/log.proto";
|
||||||
|
|
||||||
enum LogType {
|
enum LogType {
|
||||||
None = 0;
|
None = 0;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
package log
|
package log
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ func (p *Policy) overrideWith(another *Policy) {
|
||||||
p.Timeout.overrideWith(another.Timeout)
|
p.Timeout.overrideWith(another.Timeout)
|
||||||
}
|
}
|
||||||
if another.Stats != nil && p.Stats == nil {
|
if another.Stats != nil && p.Stats == nil {
|
||||||
p.Stats = &Policy_Stats{}
|
p.Stats = new(Policy_Stats)
|
||||||
p.Stats = another.Stats
|
*p.Stats = *another.Stats
|
||||||
}
|
}
|
||||||
if another.Buffer != nil {
|
if another.Buffer != nil {
|
||||||
p.Buffer = &Policy_Buffer{
|
p.Buffer = &Policy_Buffer{
|
||||||
|
|
@ -86,8 +86,6 @@ func (p *SystemPolicy) ToCorePolicy() policy.System {
|
||||||
Stats: policy.SystemStats{
|
Stats: policy.SystemStats{
|
||||||
InboundUplink: p.Stats.InboundUplink,
|
InboundUplink: p.Stats.InboundUplink,
|
||||||
InboundDownlink: p.Stats.InboundDownlink,
|
InboundDownlink: p.Stats.InboundDownlink,
|
||||||
OutboundUplink: p.Stats.OutboundUplink,
|
|
||||||
OutboundDownlink: p.Stats.OutboundDownlink,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,7 +2,7 @@ syntax = "proto3";
|
||||||
|
|
||||||
package v2ray.core.app.policy;
|
package v2ray.core.app.policy;
|
||||||
option csharp_namespace = "V2Ray.Core.App.Policy";
|
option csharp_namespace = "V2Ray.Core.App.Policy";
|
||||||
option go_package = "v2ray.com/core/app/policy";
|
option go_package = "policy";
|
||||||
option java_package = "com.v2ray.core.app.policy";
|
option java_package = "com.v2ray.core.app.policy";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
|
|
@ -38,8 +38,6 @@ message SystemPolicy {
|
||||||
message Stats {
|
message Stats {
|
||||||
bool inbound_uplink = 1;
|
bool inbound_uplink = 1;
|
||||||
bool inbound_downlink = 2;
|
bool inbound_downlink = 2;
|
||||||
bool outbound_uplink = 3;
|
|
||||||
bool outbound_downlink = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Stats stats = 1;
|
Stats stats = 1;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Package policy is an implementation of policy.Manager feature.
|
// Package policy is an implementation of policy.Manager feature.
|
||||||
package policy
|
package policy
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,6 @@ func (s *handlerServer) AlterOutbound(ctx context.Context, request *AlterOutboun
|
||||||
return &AlterOutboundResponse{}, operation.ApplyOutbound(ctx, handler)
|
return &AlterOutboundResponse{}, operation.ApplyOutbound(ctx, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *handlerServer) mustEmbedUnimplementedHandlerServiceServer() {}
|
|
||||||
|
|
||||||
type service struct {
|
type service struct {
|
||||||
v *core.Instance
|
v *core.Instance
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,13 +2,13 @@ syntax = "proto3";
|
||||||
|
|
||||||
package v2ray.core.app.proxyman.command;
|
package v2ray.core.app.proxyman.command;
|
||||||
option csharp_namespace = "V2Ray.Core.App.Proxyman.Command";
|
option csharp_namespace = "V2Ray.Core.App.Proxyman.Command";
|
||||||
option go_package = "v2ray.com/core/app/proxyman/command";
|
option go_package = "command";
|
||||||
option java_package = "com.v2ray.core.app.proxyman.command";
|
option java_package = "com.v2ray.core.app.proxyman.command";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
import "common/protocol/user.proto";
|
import "v2ray.com/core/common/protocol/user.proto";
|
||||||
import "common/serial/typed_message.proto";
|
import "v2ray.com/core/common/serial/typed_message.proto";
|
||||||
import "config.proto";
|
import "v2ray.com/core/config.proto";
|
||||||
|
|
||||||
message AddUserOperation {
|
message AddUserOperation {
|
||||||
v2ray.core.common.protocol.User user = 1;
|
v2ray.core.common.protocol.User user = 1;
|
||||||
|
|
@ -22,7 +22,9 @@ message AddInboundRequest {
|
||||||
core.InboundHandlerConfig inbound = 1;
|
core.InboundHandlerConfig inbound = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message AddInboundResponse {}
|
message AddInboundResponse{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
message RemoveInboundRequest {
|
message RemoveInboundRequest {
|
||||||
string tag = 1;
|
string tag = 1;
|
||||||
|
|
@ -35,26 +37,31 @@ message AlterInboundRequest {
|
||||||
v2ray.core.common.serial.TypedMessage operation = 2;
|
v2ray.core.common.serial.TypedMessage operation = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message AlterInboundResponse {}
|
message AlterInboundResponse {
|
||||||
|
}
|
||||||
|
|
||||||
message AddOutboundRequest {
|
message AddOutboundRequest {
|
||||||
core.OutboundHandlerConfig outbound = 1;
|
core.OutboundHandlerConfig outbound = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message AddOutboundResponse {}
|
message AddOutboundResponse {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
message RemoveOutboundRequest {
|
message RemoveOutboundRequest {
|
||||||
string tag = 1;
|
string tag = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RemoveOutboundResponse {}
|
message RemoveOutboundResponse {
|
||||||
|
}
|
||||||
|
|
||||||
message AlterOutboundRequest {
|
message AlterOutboundRequest {
|
||||||
string tag = 1;
|
string tag = 1;
|
||||||
v2ray.core.common.serial.TypedMessage operation = 2;
|
v2ray.core.common.serial.TypedMessage operation = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message AlterOutboundResponse {}
|
message AlterOutboundResponse {
|
||||||
|
}
|
||||||
|
|
||||||
service HandlerService {
|
service HandlerService {
|
||||||
rpc AddInbound(AddInboundRequest) returns (AddInboundResponse) {}
|
rpc AddInbound(AddInboundRequest) returns (AddInboundResponse) {}
|
||||||
|
|
|
||||||
|
|
@ -1,277 +0,0 @@
|
||||||
// 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",
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
package command
|
package command
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,16 +2,17 @@ syntax = "proto3";
|
||||||
|
|
||||||
package v2ray.core.app.proxyman;
|
package v2ray.core.app.proxyman;
|
||||||
option csharp_namespace = "V2Ray.Core.App.Proxyman";
|
option csharp_namespace = "V2Ray.Core.App.Proxyman";
|
||||||
option go_package = "v2ray.com/core/app/proxyman";
|
option go_package = "proxyman";
|
||||||
option java_package = "com.v2ray.core.app.proxyman";
|
option java_package = "com.v2ray.core.app.proxyman";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
import "common/net/address.proto";
|
import "v2ray.com/core/common/net/address.proto";
|
||||||
import "common/net/port.proto";
|
import "v2ray.com/core/common/net/port.proto";
|
||||||
import "transport/internet/config.proto";
|
import "v2ray.com/core/transport/internet/config.proto";
|
||||||
import "common/serial/typed_message.proto";
|
import "v2ray.com/core/common/serial/typed_message.proto";
|
||||||
|
|
||||||
message InboundConfig {}
|
message InboundConfig {
|
||||||
|
}
|
||||||
|
|
||||||
message AllocationStrategy {
|
message AllocationStrategy {
|
||||||
enum Type {
|
enum Type {
|
||||||
|
|
@ -35,6 +36,7 @@ message AllocationStrategy {
|
||||||
// Default value is 3 if unset.
|
// Default value is 3 if unset.
|
||||||
AllocationStrategyConcurrency concurrency = 2;
|
AllocationStrategyConcurrency concurrency = 2;
|
||||||
|
|
||||||
|
|
||||||
message AllocationStrategyRefresh {
|
message AllocationStrategyRefresh {
|
||||||
uint32 value = 1;
|
uint32 value = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -79,7 +81,9 @@ message InboundHandlerConfig {
|
||||||
v2ray.core.common.serial.TypedMessage proxy_settings = 3;
|
v2ray.core.common.serial.TypedMessage proxy_settings = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message OutboundConfig {}
|
message OutboundConfig {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
message SenderConfig {
|
message SenderConfig {
|
||||||
// Send traffic through the given IP. Only IP is allowed.
|
// Send traffic through the given IP. Only IP is allowed.
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,6 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *
|
||||||
sniffingConfig: receiverConfig.GetEffectiveSniffingSettings(),
|
sniffingConfig: receiverConfig.GetEffectiveSniffingSettings(),
|
||||||
uplinkCounter: uplinkCounter,
|
uplinkCounter: uplinkCounter,
|
||||||
downlinkCounter: downlinkCounter,
|
downlinkCounter: downlinkCounter,
|
||||||
ctx: ctx,
|
|
||||||
}
|
}
|
||||||
h.workers = append(h.workers, worker)
|
h.workers = append(h.workers, worker)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,6 @@ type DynamicInboundHandler struct {
|
||||||
lastRefresh time.Time
|
lastRefresh time.Time
|
||||||
mux *mux.Server
|
mux *mux.Server
|
||||||
task *task.Periodic
|
task *task.Periodic
|
||||||
|
|
||||||
ctx context.Context
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDynamicInboundHandler(ctx context.Context, tag string, receiverConfig *proxyman.ReceiverConfig, proxyConfig interface{}) (*DynamicInboundHandler, error) {
|
func NewDynamicInboundHandler(ctx context.Context, tag string, receiverConfig *proxyman.ReceiverConfig, proxyConfig interface{}) (*DynamicInboundHandler, error) {
|
||||||
|
|
@ -41,7 +39,6 @@ func NewDynamicInboundHandler(ctx context.Context, tag string, receiverConfig *p
|
||||||
portsInUse: make(map[net.Port]bool),
|
portsInUse: make(map[net.Port]bool),
|
||||||
mux: mux.NewServer(ctx),
|
mux: mux.NewServer(ctx),
|
||||||
v: v,
|
v: v,
|
||||||
ctx: ctx,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mss, err := internet.ToMemoryStreamConfig(receiverConfig.StreamSettings)
|
mss, err := internet.ToMemoryStreamConfig(receiverConfig.StreamSettings)
|
||||||
|
|
@ -137,7 +134,6 @@ func (h *DynamicInboundHandler) refresh() error {
|
||||||
sniffingConfig: h.receiverConfig.GetEffectiveSniffingSettings(),
|
sniffingConfig: h.receiverConfig.GetEffectiveSniffingSettings(),
|
||||||
uplinkCounter: uplinkCounter,
|
uplinkCounter: uplinkCounter,
|
||||||
downlinkCounter: downlinkCounter,
|
downlinkCounter: downlinkCounter,
|
||||||
ctx: h.ctx,
|
|
||||||
}
|
}
|
||||||
if err := worker.Start(); err != nil {
|
if err := worker.Start(); err != nil {
|
||||||
newError("failed to create TCP worker").Base(err).AtWarning().WriteToLog()
|
newError("failed to create TCP worker").Base(err).AtWarning().WriteToLog()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package inbound
|
package inbound
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -150,13 +150,6 @@ func NewHandler(ctx context.Context, config *core.InboundHandlerConfig) (inbound
|
||||||
return nil, newError("not a ReceiverConfig").AtError()
|
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
|
allocStrategy := receiverSettings.AllocationStrategy
|
||||||
if allocStrategy == nil || allocStrategy.Type == proxyman.AllocationStrategy_Always {
|
if allocStrategy == nil || allocStrategy.Type == proxyman.AllocationStrategy_Always {
|
||||||
return NewAlwaysOnInboundHandler(ctx, tag, receiverSettings, proxySettings)
|
return NewAlwaysOnInboundHandler(ctx, tag, receiverSettings, proxySettings)
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,6 @@ type tcpWorker struct {
|
||||||
downlinkCounter stats.Counter
|
downlinkCounter stats.Counter
|
||||||
|
|
||||||
hub internet.Listener
|
hub internet.Listener
|
||||||
|
|
||||||
ctx context.Context
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTProxyType(s *internet.MemoryStreamConfig) internet.SocketConfig_TProxyMode {
|
func getTProxyType(s *internet.MemoryStreamConfig) internet.SocketConfig_TProxyMode {
|
||||||
|
|
@ -55,7 +53,7 @@ func getTProxyType(s *internet.MemoryStreamConfig) internet.SocketConfig_TProxyM
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *tcpWorker) callback(conn internet.Connection) {
|
func (w *tcpWorker) callback(conn internet.Connection) {
|
||||||
ctx, cancel := context.WithCancel(w.ctx)
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
sid := session.NewID()
|
sid := session.NewID()
|
||||||
ctx = session.ContextWithID(ctx, sid)
|
ctx = session.ContextWithID(ctx, sid)
|
||||||
|
|
||||||
|
|
@ -92,8 +90,8 @@ func (w *tcpWorker) callback(conn internet.Connection) {
|
||||||
if w.uplinkCounter != nil || w.downlinkCounter != nil {
|
if w.uplinkCounter != nil || w.downlinkCounter != nil {
|
||||||
conn = &internet.StatCouterConnection{
|
conn = &internet.StatCouterConnection{
|
||||||
Connection: conn,
|
Connection: conn,
|
||||||
ReadCounter: w.uplinkCounter,
|
Uplink: w.uplinkCounter,
|
||||||
WriteCounter: w.downlinkCounter,
|
Downlink: w.downlinkCounter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := w.proxy.Process(ctx, net.Network_TCP, conn, w.dispatcher); err != nil {
|
if err := w.proxy.Process(ctx, net.Network_TCP, conn, w.dispatcher); err != nil {
|
||||||
|
|
@ -200,7 +198,7 @@ func (c *udpConn) RemoteAddr() net.Addr {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *udpConn) LocalAddr() net.Addr {
|
func (c *udpConn) LocalAddr() net.Addr {
|
||||||
return c.local
|
return c.remote
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*udpConn) SetDeadline(time.Time) error {
|
func (*udpConn) SetDeadline(time.Time) error {
|
||||||
|
|
@ -332,7 +330,7 @@ func (w *udpWorker) clean() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for addr, conn := range w.activeConn {
|
for addr, conn := range w.activeConn {
|
||||||
if nowSec-atomic.LoadInt64(&conn.lastActivityTime) > 8 { //TODO Timeout too small
|
if nowSec-atomic.LoadInt64(&conn.lastActivityTime) > 8 {
|
||||||
delete(w.activeConn, addr)
|
delete(w.activeConn, addr)
|
||||||
conn.Close() // nolint: errcheck
|
conn.Close() // nolint: errcheck
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@ import (
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/common/session"
|
"v2ray.com/core/common/session"
|
||||||
"v2ray.com/core/features/outbound"
|
"v2ray.com/core/features/outbound"
|
||||||
"v2ray.com/core/features/policy"
|
|
||||||
"v2ray.com/core/features/stats"
|
|
||||||
"v2ray.com/core/proxy"
|
"v2ray.com/core/proxy"
|
||||||
"v2ray.com/core/transport"
|
"v2ray.com/core/transport"
|
||||||
"v2ray.com/core/transport/internet"
|
"v2ray.com/core/transport/internet"
|
||||||
|
|
@ -19,31 +17,6 @@ import (
|
||||||
"v2ray.com/core/transport/pipe"
|
"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.
|
// Handler is an implements of outbound.Handler.
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
tag string
|
tag string
|
||||||
|
|
@ -52,19 +25,14 @@ type Handler struct {
|
||||||
proxy proxy.Outbound
|
proxy proxy.Outbound
|
||||||
outboundManager outbound.Manager
|
outboundManager outbound.Manager
|
||||||
mux *mux.ClientManager
|
mux *mux.ClientManager
|
||||||
uplinkCounter stats.Counter
|
|
||||||
downlinkCounter stats.Counter
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHandler create a new Handler based on the given configuration.
|
// NewHandler create a new Handler based on the given configuration.
|
||||||
func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbound.Handler, error) {
|
func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbound.Handler, error) {
|
||||||
v := core.MustFromContext(ctx)
|
v := core.MustFromContext(ctx)
|
||||||
uplinkCounter, downlinkCounter := getStatCounter(v, config.Tag)
|
|
||||||
h := &Handler{
|
h := &Handler{
|
||||||
tag: config.Tag,
|
tag: config.Tag,
|
||||||
outboundManager: v.GetFeature(outbound.ManagerType()).(outbound.Manager),
|
outboundManager: v.GetFeature(outbound.ManagerType()).(outbound.Manager),
|
||||||
uplinkCounter: uplinkCounter,
|
|
||||||
downlinkCounter: downlinkCounter,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.SenderSettings != nil {
|
if config.SenderSettings != nil {
|
||||||
|
|
@ -176,11 +144,11 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (internet.Conn
|
||||||
conn := net.NewConnection(net.ConnectionInputMulti(uplinkWriter), net.ConnectionOutputMulti(downlinkReader))
|
conn := net.NewConnection(net.ConnectionInputMulti(uplinkWriter), net.ConnectionOutputMulti(downlinkReader))
|
||||||
|
|
||||||
if config := tls.ConfigFromStreamSettings(h.streamSettings); config != nil {
|
if config := tls.ConfigFromStreamSettings(h.streamSettings); config != nil {
|
||||||
tlsConfig := config.GetTLSConfig(tls.WithDestination(dest))
|
tlsConfig := config.GetTLSConfig(tls.WithDestination(dest), tls.WithNextProto("h2"))
|
||||||
conn = tls.Client(conn, tlsConfig)
|
conn = tls.Client(conn, tlsConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
return h.getStatCouterConnection(conn), nil
|
return conn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
newError("failed to get outbound handler with tag: ", tag).AtWarning().WriteToLog(session.ExportIDToError(ctx))
|
newError("failed to get outbound handler with tag: ", tag).AtWarning().WriteToLog(session.ExportIDToError(ctx))
|
||||||
|
|
@ -196,19 +164,7 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (internet.Conn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := internet.Dial(ctx, dest, h.streamSettings)
|
return 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.
|
// GetOutbound implements proxy.GetOutbound.
|
||||||
|
|
|
||||||
|
|
@ -1,80 +1,13 @@
|
||||||
package outbound_test
|
package outbound_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"v2ray.com/core"
|
|
||||||
"v2ray.com/core/app/policy"
|
|
||||||
. "v2ray.com/core/app/proxyman/outbound"
|
. "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/features/outbound"
|
||||||
"v2ray.com/core/proxy/freedom"
|
|
||||||
"v2ray.com/core/transport/internet"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInterfaces(t *testing.T) {
|
func TestInterfaces(t *testing.T) {
|
||||||
_ = (outbound.Handler)(new(Handler))
|
_ = (outbound.Handler)(new(Handler))
|
||||||
_ = (outbound.Manager)(new(Manager))
|
_ = (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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package outbound
|
package outbound
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,21 @@
|
||||||
// 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
|
package reverse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
fmt "fmt"
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
math "math"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
var _ = proto.Marshal
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
var _ = fmt.Errorf
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
var _ = math.Inf
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
// of the legacy proto package is being used.
|
// is compatible with the proto package it is being compiled against.
|
||||||
const _ = proto.ProtoPackageIsVersion4
|
// 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
|
||||||
|
|
||||||
type Control_State int32
|
type Control_State int32
|
||||||
|
|
||||||
|
|
@ -32,409 +24,244 @@ const (
|
||||||
Control_DRAIN Control_State = 1
|
Control_DRAIN Control_State = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum value maps for Control_State.
|
var Control_State_name = map[int32]string{
|
||||||
var (
|
|
||||||
Control_State_name = map[int32]string{
|
|
||||||
0: "ACTIVE",
|
0: "ACTIVE",
|
||||||
1: "DRAIN",
|
1: "DRAIN",
|
||||||
}
|
}
|
||||||
Control_State_value = map[string]int32{
|
|
||||||
|
var Control_State_value = map[string]int32{
|
||||||
"ACTIVE": 0,
|
"ACTIVE": 0,
|
||||||
"DRAIN": 1,
|
"DRAIN": 1,
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func (x Control_State) Enum() *Control_State {
|
|
||||||
p := new(Control_State)
|
|
||||||
*p = x
|
|
||||||
return p
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x Control_State) String() string {
|
func (x Control_State) String() string {
|
||||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
return proto.EnumName(Control_State_name, int32(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) {
|
func (Control_State) EnumDescriptor() ([]byte, []int) {
|
||||||
return file_app_reverse_config_proto_rawDescGZIP(), []int{0, 0}
|
return fileDescriptor_829a0eeb60380cbc, []int{0, 0}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Control struct {
|
type Control struct {
|
||||||
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"`
|
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"`
|
Random []byte `protobuf:"bytes,99,opt,name=random,proto3" json:"random,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Control) Reset() {
|
func (m *Control) Reset() { *m = Control{} }
|
||||||
*x = Control{}
|
func (m *Control) String() string { return proto.CompactTextString(m) }
|
||||||
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 (*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) {
|
func (*Control) Descriptor() ([]byte, []int) {
|
||||||
return file_app_reverse_config_proto_rawDescGZIP(), []int{0}
|
return fileDescriptor_829a0eeb60380cbc, []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Control) GetState() Control_State {
|
func (m *Control) XXX_Unmarshal(b []byte) error {
|
||||||
if x != nil {
|
return xxx_messageInfo_Control.Unmarshal(m, b)
|
||||||
return x.State
|
}
|
||||||
|
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
|
||||||
}
|
}
|
||||||
return Control_ACTIVE
|
return Control_ACTIVE
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Control) GetRandom() []byte {
|
func (m *Control) GetRandom() []byte {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.Random
|
return m.Random
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type BridgeConfig struct {
|
type BridgeConfig struct {
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
|
Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
|
||||||
Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,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 (x *BridgeConfig) Reset() {
|
func (m *BridgeConfig) Reset() { *m = BridgeConfig{} }
|
||||||
*x = BridgeConfig{}
|
func (m *BridgeConfig) String() string { return proto.CompactTextString(m) }
|
||||||
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 (*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) {
|
func (*BridgeConfig) Descriptor() ([]byte, []int) {
|
||||||
return file_app_reverse_config_proto_rawDescGZIP(), []int{1}
|
return fileDescriptor_829a0eeb60380cbc, []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *BridgeConfig) GetTag() string {
|
func (m *BridgeConfig) XXX_Unmarshal(b []byte) error {
|
||||||
if x != nil {
|
return xxx_messageInfo_BridgeConfig.Unmarshal(m, b)
|
||||||
return x.Tag
|
}
|
||||||
|
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
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *BridgeConfig) GetDomain() string {
|
func (m *BridgeConfig) GetDomain() string {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.Domain
|
return m.Domain
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type PortalConfig struct {
|
type PortalConfig struct {
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
|
Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
|
||||||
Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,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 (x *PortalConfig) Reset() {
|
func (m *PortalConfig) Reset() { *m = PortalConfig{} }
|
||||||
*x = PortalConfig{}
|
func (m *PortalConfig) String() string { return proto.CompactTextString(m) }
|
||||||
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 (*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) {
|
func (*PortalConfig) Descriptor() ([]byte, []int) {
|
||||||
return file_app_reverse_config_proto_rawDescGZIP(), []int{2}
|
return fileDescriptor_829a0eeb60380cbc, []int{2}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PortalConfig) GetTag() string {
|
func (m *PortalConfig) XXX_Unmarshal(b []byte) error {
|
||||||
if x != nil {
|
return xxx_messageInfo_PortalConfig.Unmarshal(m, b)
|
||||||
return x.Tag
|
}
|
||||||
|
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
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PortalConfig) GetDomain() string {
|
func (m *PortalConfig) GetDomain() string {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.Domain
|
return m.Domain
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
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"`
|
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"`
|
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:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) Reset() {
|
func (m *Config) Reset() { *m = Config{} }
|
||||||
*x = Config{}
|
func (m *Config) String() string { return proto.CompactTextString(m) }
|
||||||
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 (*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) {
|
func (*Config) Descriptor() ([]byte, []int) {
|
||||||
return file_app_reverse_config_proto_rawDescGZIP(), []int{3}
|
return fileDescriptor_829a0eeb60380cbc, []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetBridgeConfig() []*BridgeConfig {
|
func (m *Config) XXX_Unmarshal(b []byte) error {
|
||||||
if x != nil {
|
return xxx_messageInfo_Config.Unmarshal(m, b)
|
||||||
return x.BridgeConfig
|
}
|
||||||
|
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
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetPortalConfig() []*PortalConfig {
|
func (m *Config) GetPortalConfig() []*PortalConfig {
|
||||||
if x != nil {
|
if m != nil {
|
||||||
return x.PortalConfig
|
return m.PortalConfig
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_app_reverse_config_proto protoreflect.FileDescriptor
|
func init() {
|
||||||
|
proto.RegisterEnum("v2ray.core.app.reverse.Control_State", Control_State_name, Control_State_value)
|
||||||
var file_app_reverse_config_proto_rawDesc = []byte{
|
proto.RegisterType((*Control)(nil), "v2ray.core.app.reverse.Control")
|
||||||
0x0a, 0x18, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x2f, 0x63, 0x6f,
|
proto.RegisterType((*BridgeConfig)(nil), "v2ray.core.app.reverse.BridgeConfig")
|
||||||
0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x76, 0x32, 0x72, 0x61,
|
proto.RegisterType((*PortalConfig)(nil), "v2ray.core.app.reverse.PortalConfig")
|
||||||
0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x65, 0x76, 0x65, 0x72,
|
proto.RegisterType((*Config)(nil), "v2ray.core.app.reverse.Config")
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
func init() {
|
||||||
file_app_reverse_config_proto_rawDescOnce sync.Once
|
proto.RegisterFile("v2ray.com/core/app/reverse/config.proto", fileDescriptor_829a0eeb60380cbc)
|
||||||
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 file_app_reverse_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
var fileDescriptor_829a0eeb60380cbc = []byte{
|
||||||
var file_app_reverse_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
// 310 bytes of a gzipped FileDescriptorProto
|
||||||
var file_app_reverse_config_proto_goTypes = []interface{}{
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xc1, 0x4b, 0xfb, 0x30,
|
||||||
(Control_State)(0), // 0: v2ray.core.app.reverse.Control.State
|
0x14, 0xc7, 0x7f, 0xd9, 0x58, 0xc7, 0xde, 0xaf, 0x93, 0x91, 0xc3, 0xe8, 0x41, 0x64, 0x0c, 0xc5,
|
||||||
(*Control)(nil), // 1: v2ray.core.app.reverse.Control
|
0x9d, 0x52, 0xa8, 0x17, 0xc1, 0xd3, 0xd6, 0x79, 0xe8, 0x45, 0x46, 0x94, 0x1d, 0xbc, 0x48, 0xd6,
|
||||||
(*BridgeConfig)(nil), // 2: v2ray.core.app.reverse.BridgeConfig
|
0xc5, 0x52, 0x58, 0xfb, 0x42, 0x16, 0x86, 0xbd, 0xf8, 0xa7, 0xf8, 0x07, 0xf8, 0x57, 0x4a, 0xd3,
|
||||||
(*PortalConfig)(nil), // 3: v2ray.core.app.reverse.PortalConfig
|
0x14, 0x7a, 0x50, 0xc1, 0xdb, 0x7b, 0xc9, 0xe7, 0xf3, 0xf2, 0x4d, 0x02, 0xd7, 0xa7, 0x48, 0x8b,
|
||||||
(*Config)(nil), // 4: v2ray.core.app.reverse.Config
|
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,
|
||||||
var file_app_reverse_config_proto_depIdxs = []int32{
|
0xcd, 0xdf, 0x61, 0x18, 0x63, 0x69, 0x34, 0x1e, 0xe8, 0x1d, 0x0c, 0x8e, 0x46, 0x18, 0x19, 0x90,
|
||||||
0, // 0: v2ray.core.app.reverse.Control.state:type_name -> v2ray.core.app.reverse.Control.State
|
0x19, 0x59, 0x9c, 0x45, 0x57, 0xec, 0x7b, 0x85, 0x39, 0x9e, 0x3d, 0xd6, 0x30, 0x6f, 0x1c, 0x3a,
|
||||||
2, // 1: v2ray.core.app.reverse.Config.bridge_config:type_name -> v2ray.core.app.reverse.BridgeConfig
|
0x05, 0x4f, 0x8b, 0x72, 0x8f, 0x45, 0x90, 0xce, 0xc8, 0xc2, 0xe7, 0xae, 0x9b, 0x5f, 0xc0, 0xc0,
|
||||||
3, // 2: v2ray.core.app.reverse.Config.portal_config:type_name -> v2ray.core.app.reverse.PortalConfig
|
0x72, 0x14, 0xc0, 0x5b, 0xc6, 0x4f, 0xc9, 0xf6, 0x7e, 0xf2, 0x8f, 0x8e, 0x60, 0xb0, 0xe6, 0xcb,
|
||||||
3, // [3:3] is the sub-list for method output_type
|
0xe4, 0x61, 0x42, 0xe6, 0xb7, 0xe0, 0xaf, 0x74, 0xbe, 0xcf, 0x64, 0x6c, 0xd3, 0xd2, 0x09, 0xf4,
|
||||||
3, // [3:3] is the sub-list for method input_type
|
0x8d, 0xc8, 0x6c, 0x84, 0x11, 0xaf, 0xcb, 0x7a, 0xf2, 0x1e, 0x0b, 0x91, 0x97, 0x41, 0xcf, 0x2e,
|
||||||
3, // [3:3] is the sub-list for extension type_name
|
0xba, 0xae, 0x36, 0x37, 0xa8, 0x8d, 0x38, 0xfc, 0xd9, 0xfc, 0x20, 0xe0, 0x39, 0x29, 0x81, 0xf1,
|
||||||
3, // [3:3] is the sub-list for extension extendee
|
0xce, 0x1e, 0xff, 0xd2, 0xbc, 0x56, 0x40, 0x66, 0xfd, 0xc5, 0xff, 0xe8, 0xf2, 0xa7, 0xbb, 0x77,
|
||||||
0, // [0:3] is the sub-list for field type_name
|
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,
|
||||||
func init() { file_app_reverse_config_proto_init() }
|
0x14, 0x6f, 0xb6, 0x76, 0x9e, 0xfd, 0xf9, 0x9b, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x83,
|
||||||
func file_app_reverse_config_proto_init() {
|
0x30, 0xdb, 0x24, 0x02, 0x00, 0x00,
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ syntax = "proto3";
|
||||||
|
|
||||||
package v2ray.core.app.reverse;
|
package v2ray.core.app.reverse;
|
||||||
option csharp_namespace = "V2Ray.Core.Proxy.Reverse";
|
option csharp_namespace = "V2Ray.Core.Proxy.Reverse";
|
||||||
option go_package = "v2ray.com/core/app/reverse";
|
option go_package = "reverse";
|
||||||
option java_package = "com.v2ray.core.proxy.reverse";
|
option java_package = "com.v2ray.core.proxy.reverse";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
|
|
@ -19,6 +19,7 @@ message Control {
|
||||||
message BridgeConfig {
|
message BridgeConfig {
|
||||||
string tag = 1;
|
string tag = 1;
|
||||||
string domain = 2;
|
string domain = 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message PortalConfig {
|
message PortalConfig {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
package reverse
|
package reverse
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
||||||
|
|
@ -1,95 +0,0 @@
|
||||||
// +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
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
@ -1,534 +0,0 @@
|
||||||
// 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
|
|
||||||
}
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
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 {}
|
|
||||||
|
|
@ -1,161 +0,0 @@
|
||||||
// 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",
|
|
||||||
}
|
|
||||||
|
|
@ -1,361 +0,0 @@
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,94 +0,0 @@
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
package command
|
|
||||||
|
|
||||||
import "v2ray.com/core/common/errors"
|
|
||||||
|
|
||||||
type errPathObjHolder struct{}
|
|
||||||
|
|
||||||
func newError(values ...interface{}) *errors.Error {
|
|
||||||
return errors.New(values...).WithPathObj(errPathObjHolder{})
|
|
||||||
}
|
|
||||||
|
|
@ -10,11 +10,10 @@ import (
|
||||||
|
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/common/strmatcher"
|
"v2ray.com/core/common/strmatcher"
|
||||||
"v2ray.com/core/features/routing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Condition interface {
|
type Condition interface {
|
||||||
Apply(ctx routing.Context) bool
|
Apply(ctx *Context) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConditionChan []Condition
|
type ConditionChan []Condition
|
||||||
|
|
@ -29,8 +28,7 @@ func (v *ConditionChan) Add(cond Condition) *ConditionChan {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply applies all conditions registered in this chan.
|
func (v *ConditionChan) Apply(ctx *Context) bool {
|
||||||
func (v *ConditionChan) Apply(ctx routing.Context) bool {
|
|
||||||
for _, cond := range *v {
|
for _, cond := range *v {
|
||||||
if !cond.Apply(ctx) {
|
if !cond.Apply(ctx) {
|
||||||
return false
|
return false
|
||||||
|
|
@ -84,21 +82,39 @@ func NewDomainMatcher(domains []*Domain) (*DomainMatcher, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *DomainMatcher) ApplyDomain(domain string) bool {
|
func (m *DomainMatcher) ApplyDomain(domain string) bool {
|
||||||
return len(m.matchers.Match(domain)) > 0
|
return m.matchers.Match(domain) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply implements Condition.
|
func (m *DomainMatcher) Apply(ctx *Context) bool {
|
||||||
func (m *DomainMatcher) Apply(ctx routing.Context) bool {
|
if ctx.Outbound == nil || !ctx.Outbound.Target.IsValid() {
|
||||||
domain := ctx.GetTargetDomain()
|
|
||||||
if len(domain) == 0 {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return m.ApplyDomain(domain)
|
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()
|
||||||
}
|
}
|
||||||
|
|
||||||
type MultiGeoIPMatcher struct {
|
type MultiGeoIPMatcher struct {
|
||||||
matchers []*GeoIPMatcher
|
matchers []*GeoIPMatcher
|
||||||
onSource bool
|
ipFunc func(*Context) []net.IP
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMultiGeoIPMatcher(geoips []*GeoIP, onSource bool) (*MultiGeoIPMatcher, error) {
|
func NewMultiGeoIPMatcher(geoips []*GeoIP, onSource bool) (*MultiGeoIPMatcher, error) {
|
||||||
|
|
@ -113,20 +129,20 @@ func NewMultiGeoIPMatcher(geoips []*GeoIP, onSource bool) (*MultiGeoIPMatcher, e
|
||||||
|
|
||||||
matcher := &MultiGeoIPMatcher{
|
matcher := &MultiGeoIPMatcher{
|
||||||
matchers: matchers,
|
matchers: matchers,
|
||||||
onSource: onSource,
|
}
|
||||||
|
|
||||||
|
if onSource {
|
||||||
|
matcher.ipFunc = getIPsFromSource
|
||||||
|
} else {
|
||||||
|
matcher.ipFunc = getIPsFromTarget
|
||||||
}
|
}
|
||||||
|
|
||||||
return matcher, nil
|
return matcher, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply implements Condition.
|
func (m *MultiGeoIPMatcher) Apply(ctx *Context) bool {
|
||||||
func (m *MultiGeoIPMatcher) Apply(ctx routing.Context) bool {
|
ips := m.ipFunc(ctx)
|
||||||
var ips []net.IP
|
|
||||||
if m.onSource {
|
|
||||||
ips = ctx.GetSourceIPs()
|
|
||||||
} else {
|
|
||||||
ips = ctx.GetTargetIPs()
|
|
||||||
}
|
|
||||||
for _, ip := range ips {
|
for _, ip := range ips {
|
||||||
for _, matcher := range m.matchers {
|
for _, matcher := range m.matchers {
|
||||||
if matcher.Match(ip) {
|
if matcher.Match(ip) {
|
||||||
|
|
@ -139,24 +155,19 @@ func (m *MultiGeoIPMatcher) Apply(ctx routing.Context) bool {
|
||||||
|
|
||||||
type PortMatcher struct {
|
type PortMatcher struct {
|
||||||
port net.MemoryPortList
|
port net.MemoryPortList
|
||||||
onSource bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPortMatcher create a new port matcher that can match source or destination port
|
func NewPortMatcher(list *net.PortList) *PortMatcher {
|
||||||
func NewPortMatcher(list *net.PortList, onSource bool) *PortMatcher {
|
|
||||||
return &PortMatcher{
|
return &PortMatcher{
|
||||||
port: net.PortListFromProto(list),
|
port: net.PortListFromProto(list),
|
||||||
onSource: onSource,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply implements Condition.
|
func (v *PortMatcher) Apply(ctx *Context) bool {
|
||||||
func (v *PortMatcher) Apply(ctx routing.Context) bool {
|
if ctx.Outbound == nil || !ctx.Outbound.Target.IsValid() {
|
||||||
if v.onSource {
|
return false
|
||||||
return v.port.Contains(ctx.GetSourcePort())
|
|
||||||
} else {
|
|
||||||
return v.port.Contains(ctx.GetTargetPort())
|
|
||||||
}
|
}
|
||||||
|
return v.port.Contains(ctx.Outbound.Target.Port)
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetworkMatcher struct {
|
type NetworkMatcher struct {
|
||||||
|
|
@ -171,9 +182,11 @@ func NewNetworkMatcher(network []net.Network) NetworkMatcher {
|
||||||
return matcher
|
return matcher
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply implements Condition.
|
func (v NetworkMatcher) Apply(ctx *Context) bool {
|
||||||
func (v NetworkMatcher) Apply(ctx routing.Context) bool {
|
if ctx.Outbound == nil || !ctx.Outbound.Target.IsValid() {
|
||||||
return v.list[int(ctx.GetNetwork())]
|
return false
|
||||||
|
}
|
||||||
|
return v.list[int(ctx.Outbound.Target.Network)]
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserMatcher struct {
|
type UserMatcher struct {
|
||||||
|
|
@ -192,14 +205,17 @@ func NewUserMatcher(users []string) *UserMatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply implements Condition.
|
func (v *UserMatcher) Apply(ctx *Context) bool {
|
||||||
func (v *UserMatcher) Apply(ctx routing.Context) bool {
|
if ctx.Inbound == nil {
|
||||||
user := ctx.GetUser()
|
return false
|
||||||
if len(user) == 0 {
|
}
|
||||||
|
|
||||||
|
user := ctx.Inbound.User
|
||||||
|
if user == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for _, u := range v.user {
|
for _, u := range v.user {
|
||||||
if u == user {
|
if u == user.Email {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -222,12 +238,11 @@ func NewInboundTagMatcher(tags []string) *InboundTagMatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply implements Condition.
|
func (v *InboundTagMatcher) Apply(ctx *Context) bool {
|
||||||
func (v *InboundTagMatcher) Apply(ctx routing.Context) bool {
|
if ctx.Inbound == nil || len(ctx.Inbound.Tag) == 0 {
|
||||||
tag := ctx.GetInboundTag()
|
|
||||||
if len(tag) == 0 {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
tag := ctx.Inbound.Tag
|
||||||
for _, t := range v.tags {
|
for _, t := range v.tags {
|
||||||
if t == tag {
|
if t == tag {
|
||||||
return true
|
return true
|
||||||
|
|
@ -254,17 +269,18 @@ func NewProtocolMatcher(protocols []string) *ProtocolMatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply implements Condition.
|
func (m *ProtocolMatcher) Apply(ctx *Context) bool {
|
||||||
func (m *ProtocolMatcher) Apply(ctx routing.Context) bool {
|
if ctx.Content == nil {
|
||||||
protocol := ctx.GetProtocol()
|
|
||||||
if len(protocol) == 0 {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protocol := ctx.Content.Protocol
|
||||||
for _, p := range m.protocols {
|
for _, p := range m.protocols {
|
||||||
if strings.HasPrefix(protocol, p) {
|
if strings.HasPrefix(protocol, p) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -278,7 +294,10 @@ func NewAttributeMatcher(code string) (*AttributeMatcher, error) {
|
||||||
return nil, newError("attr rule").Base(err)
|
return nil, newError("attr rule").Base(err)
|
||||||
}
|
}
|
||||||
p, err := starlark.FileProgram(starFile, func(name string) bool {
|
p, err := starlark.FileProgram(starFile, func(name string) bool {
|
||||||
return name == "attrs"
|
if name == "attrs" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -288,11 +307,17 @@ func NewAttributeMatcher(code string) (*AttributeMatcher, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match implements attributes matching.
|
func (m *AttributeMatcher) Match(attrs map[string]interface{}) bool {
|
||||||
func (m *AttributeMatcher) Match(attrs map[string]string) bool {
|
|
||||||
attrsDict := new(starlark.Dict)
|
attrsDict := new(starlark.Dict)
|
||||||
for key, value := range attrs {
|
for key, value := range attrs {
|
||||||
attrsDict.SetKey(starlark.String(key), starlark.String(value))
|
var starValue starlark.Value
|
||||||
|
switch value := value.(type) {
|
||||||
|
case string:
|
||||||
|
starValue = starlark.String(value)
|
||||||
|
}
|
||||||
|
if starValue != nil {
|
||||||
|
attrsDict.SetKey(starlark.String(key), starValue)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
predefined := make(starlark.StringDict)
|
predefined := make(starlark.StringDict)
|
||||||
|
|
@ -309,11 +334,9 @@ func (m *AttributeMatcher) Match(attrs map[string]string) bool {
|
||||||
return satisfied != nil && bool(satisfied.Truth())
|
return satisfied != nil && bool(satisfied.Truth())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply implements Condition.
|
func (m *AttributeMatcher) Apply(ctx *Context) bool {
|
||||||
func (m *AttributeMatcher) Apply(ctx routing.Context) bool {
|
if ctx.Content == nil {
|
||||||
attributes := ctx.GetAttributes()
|
|
||||||
if attributes == nil {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return m.Match(attributes)
|
return m.Match(ctx.Content.Attributes)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,8 @@ func init() {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
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")))
|
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")))
|
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geosite.dat"), filepath.Join(wd, "..", "..", "release", "config", "geosite.dat")))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGeoIPMatcherContainer(t *testing.T) {
|
func TestGeoIPMatcherContainer(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -17,41 +17,27 @@ import (
|
||||||
"v2ray.com/core/common/protocol"
|
"v2ray.com/core/common/protocol"
|
||||||
"v2ray.com/core/common/protocol/http"
|
"v2ray.com/core/common/protocol/http"
|
||||||
"v2ray.com/core/common/session"
|
"v2ray.com/core/common/session"
|
||||||
"v2ray.com/core/features/routing"
|
|
||||||
routing_session "v2ray.com/core/features/routing/session"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
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")))
|
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")))
|
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geosite.dat"), filepath.Join(wd, "..", "..", "release", "config", "geosite.dat")))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func withBackground() routing.Context {
|
func withOutbound(outbound *session.Outbound) *Context {
|
||||||
return &routing_session.Context{}
|
return &Context{Outbound: outbound}
|
||||||
}
|
}
|
||||||
|
|
||||||
func withOutbound(outbound *session.Outbound) routing.Context {
|
func withInbound(inbound *session.Inbound) *Context {
|
||||||
return &routing_session.Context{Outbound: outbound}
|
return &Context{Inbound: inbound}
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
func TestRoutingRule(t *testing.T) {
|
||||||
type ruleTest struct {
|
type ruleTest struct {
|
||||||
input routing.Context
|
input *Context
|
||||||
output bool
|
output bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,7 +88,7 @@ func TestRoutingRule(t *testing.T) {
|
||||||
output: false,
|
output: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: withBackground(),
|
input: &Context{},
|
||||||
output: false,
|
output: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -138,7 +124,7 @@ func TestRoutingRule(t *testing.T) {
|
||||||
output: true,
|
output: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: withBackground(),
|
input: &Context{},
|
||||||
output: false,
|
output: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -178,7 +164,7 @@ func TestRoutingRule(t *testing.T) {
|
||||||
output: true,
|
output: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: withBackground(),
|
input: &Context{},
|
||||||
output: false,
|
output: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -219,7 +205,7 @@ func TestRoutingRule(t *testing.T) {
|
||||||
output: false,
|
output: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: withBackground(),
|
input: &Context{},
|
||||||
output: false,
|
output: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -230,7 +216,7 @@ func TestRoutingRule(t *testing.T) {
|
||||||
},
|
},
|
||||||
test: []ruleTest{
|
test: []ruleTest{
|
||||||
{
|
{
|
||||||
input: withContent(&session.Content{Protocol: (&http.SniffHeader{}).Protocol()}),
|
input: &Context{Content: &session.Content{Protocol: (&http.SniffHeader{}).Protocol()}},
|
||||||
output: true,
|
output: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -278,34 +264,6 @@ 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{
|
rule: &RoutingRule{
|
||||||
Protocol: []string{"http"},
|
Protocol: []string{"http"},
|
||||||
|
|
@ -313,7 +271,7 @@ func TestRoutingRule(t *testing.T) {
|
||||||
},
|
},
|
||||||
test: []ruleTest{
|
test: []ruleTest{
|
||||||
{
|
{
|
||||||
input: withContent(&session.Content{Protocol: "http/1.1", Attributes: map[string]string{":path": "/test/1"}}),
|
input: &Context{Content: &session.Content{Protocol: "http/1.1", Attributes: map[string]interface{}{":path": "/test/1"}}},
|
||||||
output: true,
|
output: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ package router
|
||||||
import (
|
import (
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/features/outbound"
|
"v2ray.com/core/features/outbound"
|
||||||
"v2ray.com/core/features/routing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CIDRList is an alias of []*CIDR to provide sort.Interface.
|
// CIDRList is an alias of []*CIDR to provide sort.Interface.
|
||||||
|
|
@ -60,8 +59,7 @@ func (r *Rule) GetTag() (string, error) {
|
||||||
return r.Tag, nil
|
return r.Tag, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply checks rule matching of current routing context.
|
func (r *Rule) Apply(ctx *Context) bool {
|
||||||
func (r *Rule) Apply(ctx routing.Context) bool {
|
|
||||||
return r.Condition.Apply(ctx)
|
return r.Condition.Apply(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,13 +83,9 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if rr.PortList != nil {
|
if rr.PortList != nil {
|
||||||
conds.Add(NewPortMatcher(rr.PortList, false))
|
conds.Add(NewPortMatcher(rr.PortList))
|
||||||
} else if rr.PortRange != nil {
|
} else if rr.PortRange != nil {
|
||||||
conds.Add(NewPortMatcher(&net.PortList{Range: []*net.PortRange{rr.PortRange}}, false))
|
conds.Add(NewPortMatcher(&net.PortList{Range: []*net.PortRange{rr.PortRange}}))
|
||||||
}
|
|
||||||
|
|
||||||
if rr.SourcePortList != nil {
|
|
||||||
conds.Add(NewPortMatcher(rr.SourcePortList, true))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(rr.Networks) > 0 {
|
if len(rr.Networks) > 0 {
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,12 +2,12 @@ syntax = "proto3";
|
||||||
|
|
||||||
package v2ray.core.app.router;
|
package v2ray.core.app.router;
|
||||||
option csharp_namespace = "V2Ray.Core.App.Router";
|
option csharp_namespace = "V2Ray.Core.App.Router";
|
||||||
option go_package = "v2ray.com/core/app/router";
|
option go_package = "router";
|
||||||
option java_package = "com.v2ray.core.app.router";
|
option java_package = "com.v2ray.core.app.router";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
import "common/net/port.proto";
|
import "v2ray.com/core/common/net/port.proto";
|
||||||
import "common/net/network.proto";
|
import "v2ray.com/core/common/net/network.proto";
|
||||||
|
|
||||||
// Domain for routing decision.
|
// Domain for routing decision.
|
||||||
message Domain {
|
message Domain {
|
||||||
|
|
@ -65,7 +65,7 @@ message GeoSite {
|
||||||
repeated Domain domain = 2;
|
repeated Domain domain = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GeoSiteList {
|
message GeoSiteList{
|
||||||
repeated GeoSite entry = 1;
|
repeated GeoSite entry = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,6 +78,7 @@ message RoutingRule {
|
||||||
string balancing_tag = 12;
|
string balancing_tag = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// List of domains for target domain matching.
|
// List of domains for target domain matching.
|
||||||
repeated Domain domain = 2;
|
repeated Domain domain = 2;
|
||||||
|
|
||||||
|
|
@ -85,14 +86,13 @@ message RoutingRule {
|
||||||
// Deprecated. Use geoip below.
|
// Deprecated. Use geoip below.
|
||||||
repeated CIDR cidr = 3 [deprecated = true];
|
repeated CIDR cidr = 3 [deprecated = true];
|
||||||
|
|
||||||
// List of GeoIPs for target IP address matching. If this entry exists, the
|
// List of GeoIPs for target IP address matching. If this entry exists, the cidr above will have no effect.
|
||||||
// cidr above will have no effect. GeoIP fields with the same country code are
|
// GeoIP fields with the same country code are supposed to contain exactly same content. They will be merged during runtime.
|
||||||
// supposed to contain exactly same content. They will be merged during
|
// For customized GeoIPs, please leave country code empty.
|
||||||
// runtime. For customized GeoIPs, please leave country code empty.
|
|
||||||
repeated GeoIP geoip = 10;
|
repeated GeoIP geoip = 10;
|
||||||
|
|
||||||
// A range of port [from, to]. If the destination port is in this range, this
|
// A range of port [from, to]. If the destination port is in this range, this rule takes effect.
|
||||||
// rule takes effect. Deprecated. Use port_list.
|
// Deprecated. Use port_list.
|
||||||
v2ray.core.common.net.PortRange port_range = 4 [deprecated = true];
|
v2ray.core.common.net.PortRange port_range = 4 [deprecated = true];
|
||||||
|
|
||||||
// List of ports.
|
// List of ports.
|
||||||
|
|
@ -107,13 +107,9 @@ message RoutingRule {
|
||||||
// List of CIDRs for source IP address matching.
|
// List of CIDRs for source IP address matching.
|
||||||
repeated CIDR source_cidr = 6 [deprecated = true];
|
repeated CIDR source_cidr = 6 [deprecated = true];
|
||||||
|
|
||||||
// List of GeoIPs for source IP address matching. If this entry exists, the
|
// List of GeoIPs for source IP address matching. If this entry exists, the source_cidr above will have no effect.
|
||||||
// source_cidr above will have no effect.
|
|
||||||
repeated GeoIP source_geoip = 11;
|
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 user_email = 7;
|
||||||
repeated string inbound_tag = 8;
|
repeated string inbound_tag = 8;
|
||||||
repeated string protocol = 9;
|
repeated string protocol = 9;
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,32 @@
|
||||||
|
|
||||||
package router
|
package router
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
|
"v2ray.com/core/common/net"
|
||||||
|
"v2ray.com/core/common/session"
|
||||||
"v2ray.com/core/features/dns"
|
"v2ray.com/core/features/dns"
|
||||||
"v2ray.com/core/features/outbound"
|
"v2ray.com/core/features/outbound"
|
||||||
"v2ray.com/core/features/routing"
|
"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.
|
// Router is an implementation of routing.Router.
|
||||||
type Router struct {
|
type Router struct {
|
||||||
domainStrategy Config_DomainStrategy
|
domainStrategy Config_DomainStrategy
|
||||||
|
|
@ -23,13 +36,6 @@ type Router struct {
|
||||||
dns dns.Client
|
dns dns.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route is an implementation of routing.Route.
|
|
||||||
type Route struct {
|
|
||||||
routing.Context
|
|
||||||
outboundGroupTags []string
|
|
||||||
outboundTag string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init initializes the Router.
|
// Init initializes the Router.
|
||||||
func (r *Router) Init(config *Config, d dns.Client, ohm outbound.Manager) error {
|
func (r *Router) Init(config *Config, d dns.Client, ohm outbound.Manager) error {
|
||||||
r.domainStrategy = config.DomainStrategy
|
r.domainStrategy = config.DomainStrategy
|
||||||
|
|
@ -68,44 +74,50 @@ func (r *Router) Init(config *Config, d dns.Client, ohm outbound.Manager) error
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PickRoute implements routing.Router.
|
func (r *Router) PickRoute(ctx context.Context) (string, error) {
|
||||||
func (r *Router) PickRoute(ctx routing.Context) (routing.Route, error) {
|
rule, err := r.pickRouteInternal(ctx)
|
||||||
rule, ctx, err := r.pickRouteInternal(ctx)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return "", err
|
||||||
}
|
}
|
||||||
tag, err := rule.GetTag()
|
return 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) {
|
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),
|
||||||
|
}
|
||||||
|
|
||||||
if r.domainStrategy == Config_IpOnDemand {
|
if r.domainStrategy == Config_IpOnDemand {
|
||||||
ctx = routing_dns.ContextWithDNSClient(ctx, r.dns)
|
sessionContext.dnsClient = r.dns
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rule := range r.rules {
|
for _, rule := range r.rules {
|
||||||
if rule.Apply(ctx) {
|
if rule.Apply(sessionContext) {
|
||||||
return rule, ctx, nil
|
return rule, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.domainStrategy != Config_IpIfNonMatch || len(ctx.GetTargetDomain()) == 0 {
|
if r.domainStrategy != Config_IpIfNonMatch || !isDomainOutbound(sessionContext.Outbound) {
|
||||||
return nil, ctx, common.ErrNoClue
|
return nil, common.ErrNoClue
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = routing_dns.ContextWithDNSClient(ctx, r.dns)
|
sessionContext.dnsClient = r.dns
|
||||||
|
|
||||||
// Try applying rules again if we have IPs.
|
// Try applying rules again if we have IPs.
|
||||||
for _, rule := range r.rules {
|
for _, rule := range r.rules {
|
||||||
if rule.Apply(ctx) {
|
if rule.Apply(sessionContext) {
|
||||||
return rule, ctx, nil
|
return rule, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, ctx, common.ErrNoClue
|
return nil, common.ErrNoClue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start implements common.Runnable.
|
// Start implements common.Runnable.
|
||||||
|
|
@ -123,24 +135,36 @@ func (*Router) Type() interface{} {
|
||||||
return routing.RouterType()
|
return routing.RouterType()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOutboundGroupTags implements routing.Route.
|
type Context struct {
|
||||||
func (r *Route) GetOutboundGroupTags() []string {
|
Inbound *session.Inbound
|
||||||
return r.outboundGroupTags
|
Outbound *session.Outbound
|
||||||
|
Content *session.Content
|
||||||
|
|
||||||
|
dnsClient dns.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOutboundTag implements routing.Route.
|
func (c *Context) GetTargetIPs() []net.IP {
|
||||||
func (r *Route) GetOutboundTag() string {
|
if c.Outbound == nil || !c.Outbound.Target.IsValid() {
|
||||||
return r.outboundTag
|
return nil
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}))
|
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
|
||||||
|
}
|
||||||
|
newError("resolve ip for ", domain).Base(err).WriteToLog()
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/common/session"
|
"v2ray.com/core/common/session"
|
||||||
"v2ray.com/core/features/outbound"
|
"v2ray.com/core/features/outbound"
|
||||||
routing_session "v2ray.com/core/features/routing/session"
|
|
||||||
"v2ray.com/core/testing/mocks"
|
"v2ray.com/core/testing/mocks"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -45,9 +44,9 @@ func TestSimpleRouter(t *testing.T) {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)})
|
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)})
|
||||||
route, err := r.PickRoute(routing_session.AsRoutingContext(ctx))
|
tag, err := r.PickRoute(ctx)
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
if tag := route.GetOutboundTag(); tag != "test" {
|
if tag != "test" {
|
||||||
t.Error("expect tag 'test', bug actually ", tag)
|
t.Error("expect tag 'test', bug actually ", tag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,9 +85,9 @@ func TestSimpleBalancer(t *testing.T) {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)})
|
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)})
|
||||||
route, err := r.PickRoute(routing_session.AsRoutingContext(ctx))
|
tag, err := r.PickRoute(ctx)
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
if tag := route.GetOutboundTag(); tag != "test" {
|
if tag != "test" {
|
||||||
t.Error("expect tag 'test', bug actually ", tag)
|
t.Error("expect tag 'test', bug actually ", tag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -121,9 +120,9 @@ func TestIPOnDemand(t *testing.T) {
|
||||||
common.Must(r.Init(config, mockDns, nil))
|
common.Must(r.Init(config, mockDns, nil))
|
||||||
|
|
||||||
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)})
|
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)})
|
||||||
route, err := r.PickRoute(routing_session.AsRoutingContext(ctx))
|
tag, err := r.PickRoute(ctx)
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
if tag := route.GetOutboundTag(); tag != "test" {
|
if tag != "test" {
|
||||||
t.Error("expect tag 'test', bug actually ", tag)
|
t.Error("expect tag 'test', bug actually ", tag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -156,9 +155,9 @@ func TestIPIfNonMatchDomain(t *testing.T) {
|
||||||
common.Must(r.Init(config, mockDns, nil))
|
common.Must(r.Init(config, mockDns, nil))
|
||||||
|
|
||||||
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)})
|
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)})
|
||||||
route, err := r.PickRoute(routing_session.AsRoutingContext(ctx))
|
tag, err := r.PickRoute(ctx)
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
if tag := route.GetOutboundTag(); tag != "test" {
|
if tag != "test" {
|
||||||
t.Error("expect tag 'test', bug actually ", tag)
|
t.Error("expect tag 'test', bug actually ", tag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -190,9 +189,9 @@ func TestIPIfNonMatchIP(t *testing.T) {
|
||||||
common.Must(r.Init(config, mockDns, nil))
|
common.Must(r.Init(config, mockDns, nil))
|
||||||
|
|
||||||
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.LocalHostIP, 80)})
|
ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.LocalHostIP, 80)})
|
||||||
route, err := r.PickRoute(routing_session.AsRoutingContext(ctx))
|
tag, err := r.PickRoute(ctx)
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
if tag := route.GetOutboundTag(); tag != "test" {
|
if tag != "test" {
|
||||||
t.Error("expect tag 'test', bug actually ", tag)
|
t.Error("expect tag 'test', bug actually ", tag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,174 +0,0 @@
|
||||||
// +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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,405 +0,0 @@
|
||||||
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:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
package command
|
package command
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -63,7 +63,7 @@ func (s *statsServer) QueryStats(ctx context.Context, request *QueryStatsRequest
|
||||||
return nil, newError("QueryStats only works its own stats.Manager.")
|
return nil, newError("QueryStats only works its own stats.Manager.")
|
||||||
}
|
}
|
||||||
|
|
||||||
manager.VisitCounters(func(name string, c feature_stats.Counter) bool {
|
manager.Visit(func(name string, c feature_stats.Counter) bool {
|
||||||
if matcher.Match(name) {
|
if matcher.Match(name) {
|
||||||
var value int64
|
var value int64
|
||||||
if request.Reset_ {
|
if request.Reset_ {
|
||||||
|
|
@ -104,8 +104,6 @@ func (s *statsServer) GetSysStats(ctx context.Context, request *SysStatsRequest)
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *statsServer) mustEmbedUnimplementedStatsServiceServer() {}
|
|
||||||
|
|
||||||
type service struct {
|
type service struct {
|
||||||
statsManager feature_stats.Manager
|
statsManager feature_stats.Manager
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,7 +2,7 @@ syntax = "proto3";
|
||||||
|
|
||||||
package v2ray.core.app.stats.command;
|
package v2ray.core.app.stats.command;
|
||||||
option csharp_namespace = "V2Ray.Core.App.Stats.Command";
|
option csharp_namespace = "V2Ray.Core.App.Stats.Command";
|
||||||
option go_package = "v2ray.com/core/app/stats/command";
|
option go_package = "command";
|
||||||
option java_package = "com.v2ray.core.app.stats.command";
|
option java_package = "com.v2ray.core.app.stats.command";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
|
|
@ -31,7 +31,8 @@ message QueryStatsResponse {
|
||||||
repeated Stat stat = 1;
|
repeated Stat stat = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SysStatsRequest {}
|
message SysStatsRequest {
|
||||||
|
}
|
||||||
|
|
||||||
message SysStatsResponse {
|
message SysStatsResponse {
|
||||||
uint32 NumGoroutine = 1;
|
uint32 NumGoroutine = 1;
|
||||||
|
|
|
||||||
|
|
@ -1,169 +0,0 @@
|
||||||
// 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",
|
|
||||||
}
|
|
||||||
|
|
@ -54,7 +54,7 @@ func TestGetStats(t *testing.T) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
if r := cmp.Diff(resp.Stat, &Stat{Name: tc.name, Value: tc.value}, cmpopts.IgnoreUnexported(Stat{})); r != "" {
|
if r := cmp.Diff(resp.Stat, &Stat{Name: tc.name, Value: tc.value}); r != "" {
|
||||||
t.Error(r)
|
t.Error(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -85,8 +85,7 @@ func TestQueryStats(t *testing.T) {
|
||||||
if r := cmp.Diff(resp.Stat, []*Stat{
|
if r := cmp.Diff(resp.Stat, []*Stat{
|
||||||
{Name: "test_counter_2", Value: 2},
|
{Name: "test_counter_2", Value: 2},
|
||||||
{Name: "test_counter_3", Value: 3},
|
{Name: "test_counter_3", Value: 3},
|
||||||
}, cmpopts.SortSlices(func(s1, s2 *Stat) bool { return s1.Name < s2.Name }),
|
}, cmpopts.SortSlices(func(s1, s2 *Stat) bool { return s1.Name < s2.Name })); r != "" {
|
||||||
cmpopts.IgnoreUnexported(Stat{})); r != "" {
|
|
||||||
t.Error(r)
|
t.Error(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
// +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))
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
@ -1,225 +1,69 @@
|
||||||
// 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
|
package stats
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
fmt "fmt"
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
math "math"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
var _ = proto.Marshal
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
var _ = fmt.Errorf
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
var _ = math.Inf
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
// of the legacy proto package is being used.
|
// is compatible with the proto package it is being compiled against.
|
||||||
const _ = proto.ProtoPackageIsVersion4
|
// 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
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
state protoimpl.MessageState
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
sizeCache protoimpl.SizeCache
|
XXX_unrecognized []byte `json:"-"`
|
||||||
unknownFields protoimpl.UnknownFields
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
|
||||||
|
|
||||||
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 (m *Config) Reset() { *m = Config{} }
|
||||||
|
func (m *Config) String() string { return proto.CompactTextString(m) }
|
||||||
func (*Config) ProtoMessage() {}
|
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) {
|
func (*Config) Descriptor() ([]byte, []int) {
|
||||||
return file_app_stats_config_proto_rawDescGZIP(), []int{0}
|
return fileDescriptor_d494ded44ceaa50d, []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChannelConfig struct {
|
func (m *Config) XXX_Unmarshal(b []byte) error {
|
||||||
state protoimpl.MessageState
|
return xxx_messageInfo_Config.Unmarshal(m, b)
|
||||||
sizeCache protoimpl.SizeCache
|
}
|
||||||
unknownFields protoimpl.UnknownFields
|
func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_Config.Marshal(b, m, deterministic)
|
||||||
Blocking bool `protobuf:"varint,1,opt,name=Blocking,proto3" json:"Blocking,omitempty"`
|
}
|
||||||
SubscriberLimit int32 `protobuf:"varint,2,opt,name=SubscriberLimit,proto3" json:"SubscriberLimit,omitempty"`
|
func (m *Config) XXX_Merge(src proto.Message) {
|
||||||
BufferSize int32 `protobuf:"varint,3,opt,name=BufferSize,proto3" json:"BufferSize,omitempty"`
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ChannelConfig) Reset() {
|
var xxx_messageInfo_Config proto.InternalMessageInfo
|
||||||
*x = ChannelConfig{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
func init() {
|
||||||
mi := &file_app_stats_config_proto_msgTypes[1]
|
proto.RegisterType((*Config)(nil), "v2ray.core.app.stats.Config")
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ChannelConfig) String() string {
|
func init() {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
proto.RegisterFile("v2ray.com/core/app/stats/config.proto", fileDescriptor_d494ded44ceaa50d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*ChannelConfig) ProtoMessage() {}
|
var fileDescriptor_d494ded44ceaa50d = []byte{
|
||||||
|
// 123 bytes of a gzipped FileDescriptorProto
|
||||||
func (x *ChannelConfig) ProtoReflect() protoreflect.Message {
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2d, 0x33, 0x2a, 0x4a,
|
||||||
mi := &file_app_stats_config_proto_msgTypes[1]
|
0xac, 0xd4, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x2c, 0x28, 0xd0, 0x2f,
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
0x2e, 0x49, 0x2c, 0x29, 0xd6, 0x4f, 0xce, 0xcf, 0x4b, 0xcb, 0x4c, 0xd7, 0x2b, 0x28, 0xca, 0x2f,
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
0xc9, 0x17, 0x12, 0x81, 0x29, 0x2b, 0x4a, 0xd5, 0x4b, 0x2c, 0x28, 0xd0, 0x03, 0x2b, 0x51, 0xe2,
|
||||||
if ms.LoadMessageInfo() == nil {
|
0xe0, 0x62, 0x73, 0x06, 0xab, 0x72, 0xb2, 0xe2, 0x92, 0x48, 0xce, 0xcf, 0xd5, 0xc3, 0xa6, 0x2a,
|
||||||
ms.StoreMessageInfo(mi)
|
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,
|
||||||
return ms
|
0x00, 0xff, 0xff, 0x88, 0x24, 0xc6, 0x41, 0x8b, 0x00, 0x00, 0x00,
|
||||||
}
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,10 @@ syntax = "proto3";
|
||||||
|
|
||||||
package v2ray.core.app.stats;
|
package v2ray.core.app.stats;
|
||||||
option csharp_namespace = "V2Ray.Core.App.Stats";
|
option csharp_namespace = "V2Ray.Core.App.Stats";
|
||||||
option go_package = "v2ray.com/core/app/stats";
|
option go_package = "stats";
|
||||||
option java_package = "com.v2ray.core.app.stats";
|
option java_package = "com.v2ray.core.app.stats";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
message Config {}
|
message Config {
|
||||||
|
|
||||||
message ChannelConfig {
|
|
||||||
bool Blocking = 1;
|
|
||||||
int32 SubscriberLimit = 2;
|
|
||||||
int32 BufferSize = 3;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
// +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)
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -2,41 +2,54 @@
|
||||||
|
|
||||||
package stats
|
package stats
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate errorgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
"v2ray.com/core/common"
|
|
||||||
"v2ray.com/core/common/errors"
|
|
||||||
"v2ray.com/core/features/stats"
|
"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.
|
// Manager is an implementation of stats.Manager.
|
||||||
type Manager struct {
|
type Manager struct {
|
||||||
access sync.RWMutex
|
access sync.RWMutex
|
||||||
counters map[string]*Counter
|
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) {
|
func NewManager(ctx context.Context, config *Config) (*Manager, error) {
|
||||||
m := &Manager{
|
m := &Manager{
|
||||||
counters: make(map[string]*Counter),
|
counters: make(map[string]*Counter),
|
||||||
channels: make(map[string]*Channel),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type implements common.HasType.
|
|
||||||
func (*Manager) Type() interface{} {
|
func (*Manager) Type() interface{} {
|
||||||
return stats.ManagerType()
|
return stats.ManagerType()
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterCounter implements stats.Manager.
|
|
||||||
func (m *Manager) RegisterCounter(name string) (stats.Counter, error) {
|
func (m *Manager) RegisterCounter(name string) (stats.Counter, error) {
|
||||||
m.access.Lock()
|
m.access.Lock()
|
||||||
defer m.access.Unlock()
|
defer m.access.Unlock()
|
||||||
|
|
@ -50,19 +63,6 @@ func (m *Manager) RegisterCounter(name string) (stats.Counter, error) {
|
||||||
return c, nil
|
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 {
|
func (m *Manager) GetCounter(name string) stats.Counter {
|
||||||
m.access.RLock()
|
m.access.RLock()
|
||||||
defer m.access.RUnlock()
|
defer m.access.RUnlock()
|
||||||
|
|
@ -73,8 +73,7 @@ func (m *Manager) GetCounter(name string) stats.Counter {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// VisitCounters calls visitor function on all managed counters.
|
func (m *Manager) Visit(visitor func(string, stats.Counter) bool) {
|
||||||
func (m *Manager) VisitCounters(visitor func(string, stats.Counter) bool) {
|
|
||||||
m.access.RLock()
|
m.access.RLock()
|
||||||
defer m.access.RUnlock()
|
defer m.access.RUnlock()
|
||||||
|
|
||||||
|
|
@ -85,85 +84,12 @@ func (m *Manager) VisitCounters(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.
|
// Start implements common.Runnable.
|
||||||
func (m *Manager) Start() error {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close implement common.Closable.
|
// Close implement common.Closable.
|
||||||
func (m *Manager) Close() error {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
|
|
||||||
return NewManager(ctx, config.(*Config))
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
@ -3,84 +3,33 @@ package stats_test
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
. "v2ray.com/core/app/stats"
|
. "v2ray.com/core/app/stats"
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/features/stats"
|
"v2ray.com/core/features/stats"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInterface(t *testing.T) {
|
func TestInternface(t *testing.T) {
|
||||||
_ = (stats.Manager)(new(Manager))
|
_ = (stats.Manager)(new(Manager))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStatsChannelRunnable(t *testing.T) {
|
func TestStatsCounter(t *testing.T) {
|
||||||
raw, err := common.CreateObject(context.Background(), &Config{})
|
raw, err := common.CreateObject(context.Background(), &Config{})
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
m := raw.(stats.Manager)
|
m := raw.(stats.Manager)
|
||||||
|
c, err := m.RegisterCounter("test.counter")
|
||||||
ch1, err := m.RegisterChannel("test.channel.1")
|
|
||||||
c1 := ch1.(*Channel)
|
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
if c1.Running() {
|
if v := c.Add(1); v != 1 {
|
||||||
t.Fatalf("unexpected running channel: test.channel.%d", 1)
|
t.Fatal("unpexcted Add(1) return: ", v, ", wanted ", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
common.Must(m.Start())
|
if v := c.Set(0); v != 1 {
|
||||||
|
t.Fatal("unexpected Set(0) return: ", v, ", wanted ", 1)
|
||||||
if !c1.Running() {
|
|
||||||
t.Fatalf("unexpected non-running channel: test.channel.%d", 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ch2, err := m.RegisterChannel("test.channel.2")
|
if v := c.Value(); v != 0 {
|
||||||
c2 := ch2.(*Channel)
|
t.Fatal("unexpected Value() return: ", v, ", wanted ", 0)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
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
Loading…
Reference in New Issue