mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-08-23 10:06:48 +08:00
Compare commits
8 Commits
grpc/block
...
issue-temp
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8a647c1d8e | ||
![]() |
ea3be76fd5 | ||
![]() |
7abb02ab44 | ||
![]() |
18574aca47 | ||
![]() |
769bed9dbc | ||
![]() |
1233bd5031 | ||
![]() |
039c8e63e7 | ||
![]() |
29db059a87 |
92
.github/ISSUE_TEMPLATE/bug-en.md
vendored
Normal file
92
.github/ISSUE_TEMPLATE/bug-en.md
vendored
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
---
|
||||||
|
name: Bug Report
|
||||||
|
about: Create a bug report of Xray.
|
||||||
|
title: '[Bug] <bug you are reporting>'
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- Thanks for your reporting.
|
||||||
|
1. Please make sure you are submitting a bug of Xray-Core instead of acquiring usage or bug in third-party programs. If you are not sure, please contact us in our official Telegram group.
|
||||||
|
2. Bug: **An error, flaw or fault in a program ** that causes it to produce an incorrect or unexpected result. (Reference: Wikipedia)
|
||||||
|
3. Please check existing Issues and Discussions first and read the documentation in detail. Duplicated issues will be closed.
|
||||||
|
4. Please don't report issue like "I can't use a feature". It's probably your own mistake.
|
||||||
|
5. You should fully complete the following contents or this issue may not be handled.
|
||||||
|
6. Please *make sure* the content you are submitting does not contain your private information.
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
<!-- A clear and concise description of what the bug is. -->
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
<!-- Steps to reproduce the bug: -->
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
|
4.
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
<!-- A clear and concise description of what you expected to happen. -->
|
||||||
|
|
||||||
|
**Client Log**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
```
|
||||||
|
Please paste your client log here:
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
**Server Log**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
```
|
||||||
|
Please paste your server log here:
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
**Client config**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
```json
|
||||||
|
Please paste your client config file here:
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
**Server Config**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
```json
|
||||||
|
Please paste your server config file here:
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
**Client Information**
|
||||||
|
- OS: [e.g. Windows 10]
|
||||||
|
- Xray version [e.g. 1.3.1]
|
||||||
|
- Xray installing approach:[e.g. Xray-install]
|
||||||
|
|
||||||
|
**Server Information**
|
||||||
|
- OS: [e.g. Windows 10]
|
||||||
|
- Xray version [e.g. 1.3.1]
|
||||||
|
- Xray installing approach:[e.g. Xray-install]
|
||||||
|
|
||||||
|
**Additional Information**
|
||||||
|
<!-- Add any other information about the problem here. -->
|
91
.github/ISSUE_TEMPLATE/bug-zh-CN.md
vendored
Normal file
91
.github/ISSUE_TEMPLATE/bug-zh-CN.md
vendored
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
---
|
||||||
|
name: Bug 反馈
|
||||||
|
about: 这是 Xray 的一个 bug。
|
||||||
|
title: '[Bug] 你发现的bug'
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- 感谢您的反馈!
|
||||||
|
1. 请先确认您提交的是 Xray-Core 的 Bug,而非使用咨询,抑或是第三方程序的 Bug。如果您不确定,请在 Telegram 群中反馈。
|
||||||
|
2. Bug:软件运行中因为 **程序本身有错误** 而造成的功能不正常。(Reference: Wikipedia)
|
||||||
|
3. 请先查询已有的 Issues 与 Discussions ,并且详细阅读文档的相关内容。如果您提出的是已知的问题,此 issue 将有可能被关闭。
|
||||||
|
4. 请不要轻易提出类似“不能使用某功能”的问题。这往往是你自己的问题。
|
||||||
|
5. 您需要完整地完成下列内容,否则此 issue 可能不会被处理。
|
||||||
|
6. 请 *务必* 确保不包含任何个人隐私信息。
|
||||||
|
-->
|
||||||
|
|
||||||
|
**问题描述**
|
||||||
|
<!-- 请清晰简洁地描述此问题。-->
|
||||||
|
|
||||||
|
**复现方式**
|
||||||
|
<!-- 复现此步骤的过程: -->
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
|
4.
|
||||||
|
|
||||||
|
**预期行为**
|
||||||
|
<!-- 请清晰简洁地描述您期望的的行为。-->
|
||||||
|
|
||||||
|
**客户端日志**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
```
|
||||||
|
请删除此行,并在此处粘贴客户端日志
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
**服务端日志**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
```
|
||||||
|
请删除此行,并在此处粘贴服务端日志
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
**客户端配置**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
```json
|
||||||
|
请删除此行,并在此处粘贴客户端配置
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
**服务端配置**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
```json
|
||||||
|
请删除此行,并在此处粘贴服务端日志
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
**客户端环境**
|
||||||
|
- 系统与版本: [如 Windows 10]
|
||||||
|
- Xray 版本 [如 1.3.1]
|
||||||
|
- Xray 安装方式:[如 Xray-install]
|
||||||
|
|
||||||
|
**服务端环境**
|
||||||
|
- 系统与版本: [如 Windows 10]
|
||||||
|
- Xray 版本 [如 1.3.1]
|
||||||
|
- Xray 安装方式:[如 Xray-install]
|
||||||
|
|
||||||
|
**附加信息**
|
||||||
|
<!-- 如果您有额外的信息,请在此处说明。-->
|
9
.github/ISSUE_TEMPLATE/config.yaml
vendored
Normal file
9
.github/ISSUE_TEMPLATE/config.yaml
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
contact_links:
|
||||||
|
- name: 加入 Telegram 群组 / Join Telegram Group
|
||||||
|
url: https://t.me/projectXray
|
||||||
|
- name: 官方文档 / Official Document
|
||||||
|
url: https://xtls.github.io/
|
||||||
|
- name: 安装脚本 / Installing Script
|
||||||
|
url: https://github.com/XTLS/Xray-install
|
||||||
|
- name: 示例配置 / Example Config
|
||||||
|
url: https://github.com/XTLS/Xray-examples
|
32
.github/ISSUE_TEMPLATE/feature-en.md
vendored
Normal file
32
.github/ISSUE_TEMPLATE/feature-en.md
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
name: Feature Request
|
||||||
|
about: Suggest an idea for Xray
|
||||||
|
title: '[Feature] your idea'
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- Thanks for your support!
|
||||||
|
1. Please confirm that you are submitting a feature request.
|
||||||
|
2. We do not recommend any inexperienced users to request a new feature.
|
||||||
|
3. Please check existing Issues and Discussions first and read the documentation in detail. Duplicated issues will be closed
|
||||||
|
4. To be clear: none of developers is obliged to meet your needs. In particular, features that do not make any sense.
|
||||||
|
5. You should fully complete the following contents.
|
||||||
|
-->
|
||||||
|
|
||||||
|
**What's your idea?**
|
||||||
|
<!-- A clear and concise description of your idea. -->
|
||||||
|
|
||||||
|
**Is it related to an issue?**
|
||||||
|
<!-- Please specify here if yes. -->
|
||||||
|
|
||||||
|
**What's your solution?**
|
||||||
|
<!-- Describe the solution you'd like. -->
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
|
4.
|
||||||
|
|
||||||
|
**Is there any additional information?**
|
||||||
|
<!-- Add any other information here. -->
|
32
.github/ISSUE_TEMPLATE/feature-zh-CN.md
vendored
Normal file
32
.github/ISSUE_TEMPLATE/feature-zh-CN.md
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
name: 功能请求
|
||||||
|
about: 希望 Xray 添加一个新功能。
|
||||||
|
title: '[Feature] 你的想法'
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- 感谢您的反馈!
|
||||||
|
1. 请先确认您提交的是功能请求。
|
||||||
|
2. 我们不建议缺少经验的用户提出功能请求。
|
||||||
|
3. 请先查询已有的 Issues 与 Discussions ,并且详细阅读文档的相关内容。重复的 issue 将有可能被关闭。
|
||||||
|
4. 需要向您明确一点:任何开发者均没有义务满足您的需求。特别是不合理或没有意义的功能。
|
||||||
|
5. 您需要完整地完成下列内容,否则此 issue 可能不会被处理。
|
||||||
|
-->
|
||||||
|
|
||||||
|
**您的想法是什么?**
|
||||||
|
<!-- 请清晰简洁地描述您预期中的功能。-->
|
||||||
|
|
||||||
|
**是否与已知的 issue 相关?**
|
||||||
|
<!-- 如果是,请在此注明 -->
|
||||||
|
|
||||||
|
**您认为应如何实现此功能?**
|
||||||
|
<!-- 请清晰简洁地描述如何实现此功能。-->
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
|
4.
|
||||||
|
|
||||||
|
**有没有额外的信息?**
|
||||||
|
<!-- 如果您有额外的信息,请在此处说明。-->
|
17
.github/ISSUE_TEMPLATE/question-en.md
vendored
Normal file
17
.github/ISSUE_TEMPLATE/question-en.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
name: Question
|
||||||
|
about: Question of Xray.
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- Thanks for your support!
|
||||||
|
1. Issue is **NOT** a proper place to ask a question, otherwise your issue may be closed.
|
||||||
|
2. Please check existing Issues, Discussions and documentation in detail first. You may find the answers you want before you ask the question.
|
||||||
|
3. If it is still not resolved, please give feedback in the our official Telegram group or Discussions.
|
||||||
|
4. Wherever you ask a question, please *make sure* the content does not contain your private information.
|
||||||
|
5. We highly recommend you to read https://github.com/tvvocold/How-To-Ask-Questions-The-Smart-Way.
|
||||||
|
-->
|
||||||
|
|
17
.github/ISSUE_TEMPLATE/question-zh-CN.md
vendored
Normal file
17
.github/ISSUE_TEMPLATE/question-zh-CN.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
name: 使用疑问
|
||||||
|
about: 使用 Xray 时的疑问。
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- 感谢您的支持!
|
||||||
|
1. Issue **不是**用来提问的, 否则将可能会被 close。
|
||||||
|
2. 请先查询已有的 issue、discussion ,并且详细阅读文档的相关内容。那里可能有您需要的答案。
|
||||||
|
3. 如果仍未解决,请在官方 Telegram 群中或 Discussion 区反馈。
|
||||||
|
4. 无论在何处提问,请 *务必确保* 其不包含任何个人隐私信息。
|
||||||
|
5. 我们强烈推荐您阅读 https://github.com/tvvocold/How-To-Ask-Questions-The-Smart-Way。
|
||||||
|
-->
|
||||||
|
|
@@ -23,9 +23,8 @@
|
|||||||
- [Xray4Magisk](https://github.com/CerteKim/Xray4Magisk)
|
- [Xray4Magisk](https://github.com/CerteKim/Xray4Magisk)
|
||||||
- [Xray_For_Magisk](https://github.com/E7KMbb/Xray_For_Magisk)
|
- [Xray_For_Magisk](https://github.com/E7KMbb/Xray_For_Magisk)
|
||||||
- Homebrew
|
- Homebrew
|
||||||
- `brew install xray`
|
- [Repository 0](https://github.com/N4FA/homebrew-xray)
|
||||||
- [(Tap) Repository 0](https://github.com/N4FA/homebrew-xray)
|
- [Repository 1](https://github.com/xiruizhao/homebrew-xray)
|
||||||
- [(Tap) Repository 1](https://github.com/xiruizhao/homebrew-xray)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -40,6 +39,7 @@
|
|||||||
- [luci-app-xray](https://github.com/yichya/luci-app-xray) ([openwrt-xray](https://github.com/yichya/openwrt-xray))
|
- [luci-app-xray](https://github.com/yichya/luci-app-xray) ([openwrt-xray](https://github.com/yichya/openwrt-xray))
|
||||||
- Windows
|
- Windows
|
||||||
- [v2rayN](https://github.com/2dust/v2rayN)
|
- [v2rayN](https://github.com/2dust/v2rayN)
|
||||||
|
- [Qv2ray](https://github.com/Qv2ray/Qv2ray)
|
||||||
- [Netch (NetFilter & TUN/TAP)](https://github.com/NetchX/Netch)
|
- [Netch (NetFilter & TUN/TAP)](https://github.com/NetchX/Netch)
|
||||||
- Android
|
- Android
|
||||||
- [v2rayNG](https://github.com/2dust/v2rayNG)
|
- [v2rayNG](https://github.com/2dust/v2rayNG)
|
||||||
|
@@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/xtls/xray-core/common/protocol"
|
"github.com/xtls/xray-core/common/protocol"
|
||||||
"github.com/xtls/xray-core/common/session"
|
"github.com/xtls/xray-core/common/session"
|
||||||
"github.com/xtls/xray-core/core"
|
"github.com/xtls/xray-core/core"
|
||||||
"github.com/xtls/xray-core/features/dns"
|
|
||||||
"github.com/xtls/xray-core/features/outbound"
|
"github.com/xtls/xray-core/features/outbound"
|
||||||
"github.com/xtls/xray-core/features/policy"
|
"github.com/xtls/xray-core/features/policy"
|
||||||
"github.com/xtls/xray-core/features/routing"
|
"github.com/xtls/xray-core/features/routing"
|
||||||
@@ -176,28 +175,17 @@ func (d *DefaultDispatcher) getLink(ctx context.Context) (*transport.Link, *tran
|
|||||||
return inboundLink, outboundLink
|
return inboundLink, outboundLink
|
||||||
}
|
}
|
||||||
|
|
||||||
func shouldOverride(ctx context.Context, result SniffResult, request session.SniffingRequest, destination net.Destination) bool {
|
func shouldOverride(result SniffResult, request session.SniffingRequest) bool {
|
||||||
domain := result.Domain()
|
domain := result.Domain()
|
||||||
for _, d := range request.ExcludeForDomain {
|
for _, d := range request.ExcludeForDomain {
|
||||||
if strings.ToLower(domain) == d {
|
if domain == d {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var fakeDNSEngine dns.FakeDNSEngine
|
|
||||||
core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) {
|
protocol := result.Protocol()
|
||||||
fakeDNSEngine = fdns
|
|
||||||
})
|
|
||||||
protocolString := result.Protocol()
|
|
||||||
if resComp, ok := result.(SnifferResultComposite); ok {
|
|
||||||
protocolString = resComp.ProtocolForDomainResult()
|
|
||||||
}
|
|
||||||
for _, p := range request.OverrideDestinationForProtocol {
|
for _, p := range request.OverrideDestinationForProtocol {
|
||||||
if strings.HasPrefix(protocolString, p) {
|
if strings.HasPrefix(protocol, p) {
|
||||||
return true
|
|
||||||
}
|
|
||||||
if fakeDNSEngine != nil && protocolString != "bittorrent" && p == "fakedns" &&
|
|
||||||
destination.Address.Family().IsIP() && fakeDNSEngine.GetFakeIPRange().Contains(destination.Address.IP()) {
|
|
||||||
newError("Using sniffer ", protocolString, " since the fake DNS missed").WriteToLog(session.ExportIDToError(ctx))
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,33 +210,19 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin
|
|||||||
ctx = session.ContextWithContent(ctx, content)
|
ctx = session.ContextWithContent(ctx, content)
|
||||||
}
|
}
|
||||||
sniffingRequest := content.SniffingRequest
|
sniffingRequest := content.SniffingRequest
|
||||||
switch {
|
if destination.Network != net.Network_TCP || !sniffingRequest.Enabled {
|
||||||
case !sniffingRequest.Enabled:
|
|
||||||
go d.routedDispatch(ctx, outbound, destination)
|
go d.routedDispatch(ctx, outbound, destination)
|
||||||
case destination.Network != net.Network_TCP:
|
} else {
|
||||||
// Only metadata sniff will be used for non tcp connection
|
|
||||||
result, err := sniffer(ctx, nil, true)
|
|
||||||
if err == nil {
|
|
||||||
content.Protocol = result.Protocol()
|
|
||||||
if shouldOverride(ctx, result, sniffingRequest, destination) {
|
|
||||||
domain := result.Domain()
|
|
||||||
newError("sniffed domain: ", domain).WriteToLog(session.ExportIDToError(ctx))
|
|
||||||
destination.Address = net.ParseAddress(domain)
|
|
||||||
ob.Target = destination
|
|
||||||
}
|
|
||||||
}
|
|
||||||
go d.routedDispatch(ctx, outbound, destination)
|
|
||||||
default:
|
|
||||||
go func() {
|
go func() {
|
||||||
cReader := &cachedReader{
|
cReader := &cachedReader{
|
||||||
reader: outbound.Reader.(*pipe.Reader),
|
reader: outbound.Reader.(*pipe.Reader),
|
||||||
}
|
}
|
||||||
outbound.Reader = cReader
|
outbound.Reader = cReader
|
||||||
result, err := sniffer(ctx, cReader, sniffingRequest.MetadataOnly)
|
result, err := sniffer(ctx, cReader)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
content.Protocol = result.Protocol()
|
content.Protocol = result.Protocol()
|
||||||
}
|
}
|
||||||
if err == nil && shouldOverride(ctx, result, sniffingRequest, destination) {
|
if err == nil && shouldOverride(result, sniffingRequest) {
|
||||||
domain := result.Domain()
|
domain := result.Domain()
|
||||||
newError("sniffed domain: ", domain).WriteToLog(session.ExportIDToError(ctx))
|
newError("sniffed domain: ", domain).WriteToLog(session.ExportIDToError(ctx))
|
||||||
destination.Address = net.ParseAddress(domain)
|
destination.Address = net.ParseAddress(domain)
|
||||||
@@ -260,50 +234,34 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin
|
|||||||
return inbound, nil
|
return inbound, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool) (SniffResult, error) {
|
func sniffer(ctx context.Context, cReader *cachedReader) (SniffResult, error) {
|
||||||
payload := buf.New()
|
payload := buf.New()
|
||||||
defer payload.Release()
|
defer payload.Release()
|
||||||
|
|
||||||
sniffer := NewSniffer(ctx)
|
sniffer := NewSniffer()
|
||||||
|
totalAttempt := 0
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return nil, ctx.Err()
|
||||||
|
default:
|
||||||
|
totalAttempt++
|
||||||
|
if totalAttempt > 2 {
|
||||||
|
return nil, errSniffingTimeout
|
||||||
|
}
|
||||||
|
|
||||||
metaresult, metadataErr := sniffer.SniffMetadata(ctx)
|
cReader.Cache(payload)
|
||||||
|
if !payload.IsEmpty() {
|
||||||
if metadataOnly {
|
result, err := sniffer.Sniff(payload.Bytes())
|
||||||
return metaresult, metadataErr
|
if err != common.ErrNoClue {
|
||||||
}
|
return result, err
|
||||||
|
|
||||||
contentResult, contentErr := func() (SniffResult, error) {
|
|
||||||
totalAttempt := 0
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
return nil, ctx.Err()
|
|
||||||
default:
|
|
||||||
totalAttempt++
|
|
||||||
if totalAttempt > 2 {
|
|
||||||
return nil, errSniffingTimeout
|
|
||||||
}
|
|
||||||
|
|
||||||
cReader.Cache(payload)
|
|
||||||
if !payload.IsEmpty() {
|
|
||||||
result, err := sniffer.Sniff(ctx, payload.Bytes())
|
|
||||||
if err != common.ErrNoClue {
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if payload.IsFull() {
|
|
||||||
return nil, errUnknownContent
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if payload.IsFull() {
|
||||||
|
return nil, errUnknownContent
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
if contentErr != nil && metadataErr == nil {
|
|
||||||
return metaresult, nil
|
|
||||||
}
|
}
|
||||||
if contentErr == nil && metadataErr == nil {
|
|
||||||
return CompositeResult(metaresult, contentResult), nil
|
|
||||||
}
|
|
||||||
return contentResult, contentErr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.Link, destination net.Destination) {
|
func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.Link, destination net.Destination) {
|
||||||
|
@@ -1,49 +0,0 @@
|
|||||||
package dispatcher
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
|
||||||
"github.com/xtls/xray-core/common/net"
|
|
||||||
"github.com/xtls/xray-core/common/session"
|
|
||||||
"github.com/xtls/xray-core/core"
|
|
||||||
"github.com/xtls/xray-core/features/dns"
|
|
||||||
)
|
|
||||||
|
|
||||||
// newFakeDNSSniffer Create a Fake DNS metadata sniffer
|
|
||||||
func newFakeDNSSniffer(ctx context.Context) (protocolSnifferWithMetadata, error) {
|
|
||||||
var fakeDNSEngine dns.FakeDNSEngine
|
|
||||||
err := core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) {
|
|
||||||
fakeDNSEngine = fdns
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return protocolSnifferWithMetadata{}, err
|
|
||||||
}
|
|
||||||
if fakeDNSEngine == nil {
|
|
||||||
errNotInit := newError("FakeDNSEngine is not initialized, but such a sniffer is used").AtError()
|
|
||||||
return protocolSnifferWithMetadata{}, errNotInit
|
|
||||||
}
|
|
||||||
return protocolSnifferWithMetadata{protocolSniffer: func(ctx context.Context, bytes []byte) (SniffResult, error) {
|
|
||||||
Target := session.OutboundFromContext(ctx).Target
|
|
||||||
if Target.Network == net.Network_TCP || Target.Network == net.Network_UDP {
|
|
||||||
domainFromFakeDNS := fakeDNSEngine.GetDomainFromFakeDNS(Target.Address)
|
|
||||||
if domainFromFakeDNS != "" {
|
|
||||||
newError("fake dns got domain: ", domainFromFakeDNS, " for ip: ", Target.Address.String()).WriteToLog(session.ExportIDToError(ctx))
|
|
||||||
return &fakeDNSSniffResult{domainName: domainFromFakeDNS}, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, common.ErrNoClue
|
|
||||||
}, metadataSniffer: true}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type fakeDNSSniffResult struct {
|
|
||||||
domainName string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fakeDNSSniffResult) Protocol() string {
|
|
||||||
return "fakedns"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f fakeDNSSniffResult) Domain() string {
|
|
||||||
return f.domainName
|
|
||||||
}
|
|
@@ -1,8 +1,6 @@
|
|||||||
package dispatcher
|
package dispatcher
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/protocol/bittorrent"
|
"github.com/xtls/xray-core/common/protocol/bittorrent"
|
||||||
"github.com/xtls/xray-core/common/protocol/http"
|
"github.com/xtls/xray-core/common/protocol/http"
|
||||||
@@ -14,46 +12,30 @@ type SniffResult interface {
|
|||||||
Domain() string
|
Domain() string
|
||||||
}
|
}
|
||||||
|
|
||||||
type protocolSniffer func(context.Context, []byte) (SniffResult, error)
|
type protocolSniffer func([]byte) (SniffResult, error)
|
||||||
|
|
||||||
type protocolSnifferWithMetadata struct {
|
|
||||||
protocolSniffer protocolSniffer
|
|
||||||
// A Metadata sniffer will be invoked on connection establishment only, with nil body,
|
|
||||||
// for both TCP and UDP connections
|
|
||||||
// It will not be shown as a traffic type for routing unless there is no other successful sniffing.
|
|
||||||
metadataSniffer bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type Sniffer struct {
|
type Sniffer struct {
|
||||||
sniffer []protocolSnifferWithMetadata
|
sniffer []protocolSniffer
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSniffer(ctx context.Context) *Sniffer {
|
func NewSniffer() *Sniffer {
|
||||||
ret := &Sniffer{
|
return &Sniffer{
|
||||||
sniffer: []protocolSnifferWithMetadata{
|
sniffer: []protocolSniffer{
|
||||||
{func(c context.Context, b []byte) (SniffResult, error) { return http.SniffHTTP(b) }, false},
|
func(b []byte) (SniffResult, error) { return http.SniffHTTP(b) },
|
||||||
{func(c context.Context, b []byte) (SniffResult, error) { return tls.SniffTLS(b) }, false},
|
func(b []byte) (SniffResult, error) { return tls.SniffTLS(b) },
|
||||||
{func(c context.Context, b []byte) (SniffResult, error) { return bittorrent.SniffBittorrent(b) }, false},
|
func(b []byte) (SniffResult, error) { return bittorrent.SniffBittorrent(b) },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if sniffer, err := newFakeDNSSniffer(ctx); err == nil {
|
|
||||||
ret.sniffer = append(ret.sniffer, sniffer)
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var errUnknownContent = newError("unknown content")
|
var errUnknownContent = newError("unknown content")
|
||||||
|
|
||||||
func (s *Sniffer) Sniff(c context.Context, payload []byte) (SniffResult, error) {
|
func (s *Sniffer) Sniff(payload []byte) (SniffResult, error) {
|
||||||
var pendingSniffer []protocolSnifferWithMetadata
|
var pendingSniffer []protocolSniffer
|
||||||
for _, si := range s.sniffer {
|
for _, s := range s.sniffer {
|
||||||
s := si.protocolSniffer
|
result, err := s(payload)
|
||||||
if si.metadataSniffer {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
result, err := s(c, payload)
|
|
||||||
if err == common.ErrNoClue {
|
if err == common.ErrNoClue {
|
||||||
pendingSniffer = append(pendingSniffer, si)
|
pendingSniffer = append(pendingSniffer, s)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,55 +51,3 @@ func (s *Sniffer) Sniff(c context.Context, payload []byte) (SniffResult, error)
|
|||||||
|
|
||||||
return nil, errUnknownContent
|
return nil, errUnknownContent
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sniffer) SniffMetadata(c context.Context) (SniffResult, error) {
|
|
||||||
var pendingSniffer []protocolSnifferWithMetadata
|
|
||||||
for _, si := range s.sniffer {
|
|
||||||
s := si.protocolSniffer
|
|
||||||
if !si.metadataSniffer {
|
|
||||||
pendingSniffer = append(pendingSniffer, si)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
result, err := s(c, nil)
|
|
||||||
if err == common.ErrNoClue {
|
|
||||||
pendingSniffer = append(pendingSniffer, si)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if err == nil && result != nil {
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(pendingSniffer) > 0 {
|
|
||||||
s.sniffer = pendingSniffer
|
|
||||||
return nil, common.ErrNoClue
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, errUnknownContent
|
|
||||||
}
|
|
||||||
|
|
||||||
func CompositeResult(domainResult SniffResult, protocolResult SniffResult) SniffResult {
|
|
||||||
return &compositeResult{domainResult: domainResult, protocolResult: protocolResult}
|
|
||||||
}
|
|
||||||
|
|
||||||
type compositeResult struct {
|
|
||||||
domainResult SniffResult
|
|
||||||
protocolResult SniffResult
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c compositeResult) Protocol() string {
|
|
||||||
return c.protocolResult.Protocol()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c compositeResult) Domain() string {
|
|
||||||
return c.domainResult.Domain()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c compositeResult) ProtocolForDomainResult() string {
|
|
||||||
return c.domainResult.Protocol()
|
|
||||||
}
|
|
||||||
|
|
||||||
type SnifferResultComposite interface {
|
|
||||||
ProtocolForDomainResult() string
|
|
||||||
}
|
|
||||||
|
@@ -68,6 +68,4 @@ message Config {
|
|||||||
|
|
||||||
// Tag is the inbound tag of DNS client.
|
// Tag is the inbound tag of DNS client.
|
||||||
string tag = 6;
|
string tag = 6;
|
||||||
|
|
||||||
reserved 7;
|
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,6 @@ package dns
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
@@ -14,7 +13,7 @@ import (
|
|||||||
|
|
||||||
// Fqdn normalize domain make sure it ends with '.'
|
// Fqdn normalize domain make sure it ends with '.'
|
||||||
func Fqdn(domain string) string {
|
func Fqdn(domain string) string {
|
||||||
if len(domain) > 0 && strings.HasSuffix(domain, ".") {
|
if len(domain) > 0 && domain[len(domain)-1] == '.' {
|
||||||
return domain
|
return domain
|
||||||
}
|
}
|
||||||
return domain + "."
|
return domain + "."
|
||||||
@@ -113,7 +112,7 @@ func genEDNS0Options(clientIP net.IP) *dnsmessage.Resource {
|
|||||||
return opt
|
return opt
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildReqMsgs(domain string, option dns_feature.IPOption, reqIDGen func() uint16, reqOpts *dnsmessage.Resource) []*dnsRequest {
|
func buildReqMsgs(domain string, option IPOption, reqIDGen func() uint16, reqOpts *dnsmessage.Resource) []*dnsRequest {
|
||||||
qA := dnsmessage.Question{
|
qA := dnsmessage.Question{
|
||||||
Name: dnsmessage.MustNewName(domain),
|
Name: dnsmessage.MustNewName(domain),
|
||||||
Type: dnsmessage.TypeA,
|
Type: dnsmessage.TypeA,
|
||||||
|
@@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
dns_feature "github.com/xtls/xray-core/features/dns"
|
|
||||||
"golang.org/x/net/dns/dnsmessage"
|
"golang.org/x/net/dns/dnsmessage"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -93,7 +92,7 @@ func Test_buildReqMsgs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
type args struct {
|
type args struct {
|
||||||
domain string
|
domain string
|
||||||
option dns_feature.IPOption
|
option IPOption
|
||||||
reqOpts *dnsmessage.Resource
|
reqOpts *dnsmessage.Resource
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
@@ -101,26 +100,10 @@ func Test_buildReqMsgs(t *testing.T) {
|
|||||||
args args
|
args args
|
||||||
want int
|
want int
|
||||||
}{
|
}{
|
||||||
{"dual stack", args{"test.com", dns_feature.IPOption{
|
{"dual stack", args{"test.com", IPOption{true, true}, nil}, 2},
|
||||||
IPv4Enable: true,
|
{"ipv4 only", args{"test.com", IPOption{true, false}, nil}, 1},
|
||||||
IPv6Enable: true,
|
{"ipv6 only", args{"test.com", IPOption{false, true}, nil}, 1},
|
||||||
FakeEnable: false,
|
{"none/error", args{"test.com", IPOption{false, false}, nil}, 0},
|
||||||
}, nil}, 2},
|
|
||||||
{"ipv4 only", args{"test.com", dns_feature.IPOption{
|
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: false,
|
|
||||||
FakeEnable: false,
|
|
||||||
}, nil}, 1},
|
|
||||||
{"ipv6 only", args{"test.com", dns_feature.IPOption{
|
|
||||||
IPv4Enable: false,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
}, nil}, 1},
|
|
||||||
{"none/error", args{"test.com", dns_feature.IPOption{
|
|
||||||
IPv4Enable: false,
|
|
||||||
IPv6Enable: false,
|
|
||||||
FakeEnable: false,
|
|
||||||
}, nil}, 0},
|
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
@@ -13,7 +13,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/log"
|
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/net/cnc"
|
"github.com/xtls/xray-core/common/net/cnc"
|
||||||
"github.com/xtls/xray-core/common/protocol/dns"
|
"github.com/xtls/xray-core/common/protocol/dns"
|
||||||
@@ -48,57 +47,6 @@ func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher, clientIP net.
|
|||||||
s := baseDOHNameServer(url, "DOH", clientIP)
|
s := baseDOHNameServer(url, "DOH", clientIP)
|
||||||
|
|
||||||
s.dispatcher = dispatcher
|
s.dispatcher = dispatcher
|
||||||
tr := &http.Transport{
|
|
||||||
MaxIdleConns: 30,
|
|
||||||
IdleConnTimeout: 90 * time.Second,
|
|
||||||
TLSHandshakeTimeout: 30 * time.Second,
|
|
||||||
ForceAttemptHTTP2: true,
|
|
||||||
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
|
||||||
dispatcherCtx := context.Background()
|
|
||||||
|
|
||||||
dest, err := net.ParseDestination(network + ":" + addr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatcherCtx = session.ContextWithContent(dispatcherCtx, session.ContentFromContext(ctx))
|
|
||||||
dispatcherCtx = session.ContextWithInbound(dispatcherCtx, session.InboundFromContext(ctx))
|
|
||||||
dispatcherCtx = log.ContextWithAccessMessage(dispatcherCtx, &log.AccessMessage{
|
|
||||||
From: "DoH",
|
|
||||||
To: s.dohURL,
|
|
||||||
Status: log.AccessAccepted,
|
|
||||||
Reason: "",
|
|
||||||
})
|
|
||||||
|
|
||||||
link, err := s.dispatcher.Dispatch(dispatcherCtx, dest)
|
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
return nil, ctx.Err()
|
|
||||||
default:
|
|
||||||
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
cc := common.ChainedClosable{}
|
|
||||||
if cw, ok := link.Writer.(common.Closable); ok {
|
|
||||||
cc = append(cc, cw)
|
|
||||||
}
|
|
||||||
if cr, ok := link.Reader.(common.Closable); ok {
|
|
||||||
cc = append(cc, cr)
|
|
||||||
}
|
|
||||||
return cnc.NewConnection(
|
|
||||||
cnc.ConnectionInputMulti(link.Writer),
|
|
||||||
cnc.ConnectionOutputMulti(link.Reader),
|
|
||||||
cnc.ConnectionOnClose(cc),
|
|
||||||
), nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
s.httpClient = &http.Client{
|
|
||||||
Timeout: time.Second * 180,
|
|
||||||
Transport: tr,
|
|
||||||
}
|
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
@@ -116,12 +64,6 @@ func NewDoHLocalNameServer(url *url.URL, clientIP net.IP) *DoHNameServer {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
conn, err := internet.DialSystem(ctx, dest, nil)
|
conn, err := internet.DialSystem(ctx, dest, nil)
|
||||||
log.Record(&log.AccessMessage{
|
|
||||||
From: "DoH",
|
|
||||||
To: s.dohURL,
|
|
||||||
Status: log.AccessAccepted,
|
|
||||||
Detour: "local",
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -235,7 +177,7 @@ func (s *DoHNameServer) newReqID() uint16 {
|
|||||||
return uint16(atomic.AddUint32(&s.reqID, 1))
|
return uint16(atomic.AddUint32(&s.reqID, 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option dns_feature.IPOption) {
|
func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPOption) {
|
||||||
newError(s.name, " querying: ", domain).AtInfo().WriteToLog(session.ExportIDToError(ctx))
|
newError(s.name, " querying: ", domain).AtInfo().WriteToLog(session.ExportIDToError(ctx))
|
||||||
|
|
||||||
if s.name+"." == "DOH//"+domain {
|
if s.name+"." == "DOH//"+domain {
|
||||||
@@ -307,6 +249,41 @@ func (s *DoHNameServer) dohHTTPSContext(ctx context.Context, b []byte) ([]byte,
|
|||||||
|
|
||||||
hc := s.httpClient
|
hc := s.httpClient
|
||||||
|
|
||||||
|
// Dispatched connection will be closed (interrupted) after each request
|
||||||
|
// This makes DOH inefficient without a keep-alived connection
|
||||||
|
// See: core/app/proxyman/outbound/handler.go:113
|
||||||
|
// Using mux (https request wrapped in a stream layer) improves the situation.
|
||||||
|
// Recommend to use NewDoHLocalNameServer (DOHL:) if xray instance is running on
|
||||||
|
// a normal network eg. the server side of xray
|
||||||
|
|
||||||
|
if s.dispatcher != nil {
|
||||||
|
tr := &http.Transport{
|
||||||
|
MaxIdleConns: 30,
|
||||||
|
IdleConnTimeout: 90 * time.Second,
|
||||||
|
TLSHandshakeTimeout: 30 * time.Second,
|
||||||
|
ForceAttemptHTTP2: true,
|
||||||
|
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
|
dest, err := net.ParseDestination(network + ":" + addr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
link, err := s.dispatcher.Dispatch(ctx, dest)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return cnc.NewConnection(
|
||||||
|
cnc.ConnectionInputMulti(link.Writer),
|
||||||
|
cnc.ConnectionOutputMulti(link.Reader),
|
||||||
|
), nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
hc = &http.Client{
|
||||||
|
Timeout: time.Second * 180,
|
||||||
|
Transport: tr,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := hc.Do(req.WithContext(ctx))
|
resp, err := hc.Do(req.WithContext(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -321,7 +298,7 @@ func (s *DoHNameServer) dohHTTPSContext(ctx context.Context, b []byte) ([]byte,
|
|||||||
return ioutil.ReadAll(resp.Body)
|
return ioutil.ReadAll(resp.Body)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, error) {
|
func (s *DoHNameServer) findIPsForDomain(domain string, option IPOption) ([]net.IP, error) {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
record, found := s.ips[domain]
|
record, found := s.ips[domain]
|
||||||
s.RUnlock()
|
s.RUnlock()
|
||||||
@@ -364,13 +341,12 @@ func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOpt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// QueryIP is called from dns.Server->queryIPTimeout
|
// QueryIP is called from dns.Server->queryIPTimeout
|
||||||
func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, option dns_feature.IPOption) ([]net.IP, error) { // nolint: dupl
|
func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, option IPOption) ([]net.IP, error) {
|
||||||
fqdn := Fqdn(domain)
|
fqdn := Fqdn(domain)
|
||||||
|
|
||||||
ips, err := s.findIPsForDomain(fqdn, option)
|
ips, err := s.findIPsForDomain(fqdn, option)
|
||||||
if err != errRecordNotFound {
|
if err != errRecordNotFound {
|
||||||
newError(s.name, " cache HIT ", domain, " -> ", ips).Base(err).AtDebug().WriteToLog()
|
newError(s.name, " cache HIT ", domain, " -> ", ips).Base(err).AtDebug().WriteToLog()
|
||||||
log.Record(&log.DNSLog{s.name, domain, ips, log.DNSCacheHit, 0, err})
|
|
||||||
return ips, err
|
return ips, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,12 +377,10 @@ func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, option dns_f
|
|||||||
close(done)
|
close(done)
|
||||||
}()
|
}()
|
||||||
s.sendQuery(ctx, fqdn, option)
|
s.sendQuery(ctx, fqdn, option)
|
||||||
start := time.Now()
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
ips, err := s.findIPsForDomain(fqdn, option)
|
ips, err := s.findIPsForDomain(fqdn, option)
|
||||||
if err != errRecordNotFound {
|
if err != errRecordNotFound {
|
||||||
log.Record(&log.DNSLog{s.name, domain, ips, log.DNSQueried, time.Since(start), err})
|
|
||||||
return ips, err
|
return ips, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,9 +0,0 @@
|
|||||||
package fakedns
|
|
||||||
|
|
||||||
import "github.com/xtls/xray-core/common/errors"
|
|
||||||
|
|
||||||
type errPathObjHolder struct{}
|
|
||||||
|
|
||||||
func newError(values ...interface{}) *errors.Error {
|
|
||||||
return errors.New(values...).WithPathObj(errPathObjHolder{})
|
|
||||||
}
|
|
@@ -1,134 +0,0 @@
|
|||||||
package fakedns
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"math"
|
|
||||||
"math/big"
|
|
||||||
gonet "net"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
|
||||||
"github.com/xtls/xray-core/common/cache"
|
|
||||||
"github.com/xtls/xray-core/common/net"
|
|
||||||
"github.com/xtls/xray-core/features/dns"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Holder struct {
|
|
||||||
domainToIP cache.Lru
|
|
||||||
ipRange *gonet.IPNet
|
|
||||||
|
|
||||||
config *FakeDnsPool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*Holder) Type() interface{} {
|
|
||||||
return (*dns.FakeDNSEngine)(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fkdns *Holder) Start() error {
|
|
||||||
return fkdns.initializeFromConfig()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fkdns *Holder) Close() error {
|
|
||||||
fkdns.domainToIP = nil
|
|
||||||
fkdns.ipRange = nil
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewFakeDNSHolder() (*Holder, error) {
|
|
||||||
var fkdns *Holder
|
|
||||||
var err error
|
|
||||||
|
|
||||||
if fkdns, err = NewFakeDNSHolderConfigOnly(nil); err != nil {
|
|
||||||
return nil, newError("Unable to create Fake Dns Engine").Base(err).AtError()
|
|
||||||
}
|
|
||||||
err = fkdns.initialize(dns.FakeIPPool, 65535)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return fkdns, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewFakeDNSHolderConfigOnly(conf *FakeDnsPool) (*Holder, error) {
|
|
||||||
return &Holder{nil, nil, conf}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fkdns *Holder) initializeFromConfig() error {
|
|
||||||
return fkdns.initialize(fkdns.config.IpPool, int(fkdns.config.LruSize))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fkdns *Holder) initialize(ipPoolCidr string, lruSize int) error {
|
|
||||||
var ipRange *gonet.IPNet
|
|
||||||
var err error
|
|
||||||
|
|
||||||
if _, ipRange, err = gonet.ParseCIDR(ipPoolCidr); err != nil {
|
|
||||||
return newError("Unable to parse CIDR for Fake DNS IP assignment").Base(err).AtError()
|
|
||||||
}
|
|
||||||
|
|
||||||
ones, bits := ipRange.Mask.Size()
|
|
||||||
rooms := bits - ones
|
|
||||||
if math.Log2(float64(lruSize)) >= float64(rooms) {
|
|
||||||
return newError("LRU size is bigger than subnet size").AtError()
|
|
||||||
}
|
|
||||||
fkdns.domainToIP = cache.NewLru(lruSize)
|
|
||||||
fkdns.ipRange = ipRange
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetFakeIPForDomain check and generate a fake IP for a domain name
|
|
||||||
func (fkdns *Holder) GetFakeIPForDomain(domain string) []net.Address {
|
|
||||||
if v, ok := fkdns.domainToIP.Get(domain); ok {
|
|
||||||
return []net.Address{v.(net.Address)}
|
|
||||||
}
|
|
||||||
var currentTimeMillis = uint64(time.Now().UnixNano() / 1e6)
|
|
||||||
ones, bits := fkdns.ipRange.Mask.Size()
|
|
||||||
rooms := bits - ones
|
|
||||||
if rooms < 64 {
|
|
||||||
currentTimeMillis %= (uint64(1) << rooms)
|
|
||||||
}
|
|
||||||
var bigIntIP = big.NewInt(0).SetBytes(fkdns.ipRange.IP)
|
|
||||||
bigIntIP = bigIntIP.Add(bigIntIP, new(big.Int).SetUint64(currentTimeMillis))
|
|
||||||
var ip net.Address
|
|
||||||
for {
|
|
||||||
ip = net.IPAddress(bigIntIP.Bytes())
|
|
||||||
|
|
||||||
// if we run for a long time, we may go back to beginning and start seeing the IP in use
|
|
||||||
if _, ok := fkdns.domainToIP.PeekKeyFromValue(ip); !ok {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
bigIntIP = bigIntIP.Add(bigIntIP, big.NewInt(1))
|
|
||||||
if !fkdns.ipRange.Contains(bigIntIP.Bytes()) {
|
|
||||||
bigIntIP = big.NewInt(0).SetBytes(fkdns.ipRange.IP)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fkdns.domainToIP.Put(domain, ip)
|
|
||||||
return []net.Address{ip}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetDomainFromFakeDNS check if an IP is a fake IP and have corresponding domain name
|
|
||||||
func (fkdns *Holder) GetDomainFromFakeDNS(ip net.Address) string {
|
|
||||||
if !ip.Family().IsIP() || !fkdns.ipRange.Contains(ip.IP()) {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
if k, ok := fkdns.domainToIP.GetKeyFromValue(ip); ok {
|
|
||||||
return k.(string)
|
|
||||||
}
|
|
||||||
newError("A fake ip request to ", ip, ", however there is no matching domain name in fake DNS").AtInfo().WriteToLog()
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetFakeIPRange return fake IP range from configuration
|
|
||||||
func (fkdns *Holder) GetFakeIPRange() *gonet.IPNet {
|
|
||||||
return fkdns.ipRange
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
common.Must(common.RegisterConfig((*FakeDnsPool)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
|
|
||||||
var f *Holder
|
|
||||||
var err error
|
|
||||||
if f, err = NewFakeDNSHolderConfigOnly(config.(*FakeDnsPool)); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return f, nil
|
|
||||||
}))
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
package fakedns
|
|
||||||
|
|
||||||
//go:generate go run github.com/xtls/xray-core/common/errors/errorgen
|
|
@@ -1,164 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// protoc-gen-go v1.25.0
|
|
||||||
// protoc v3.13.0
|
|
||||||
// source: app/dns/fakedns/fakedns.proto
|
|
||||||
|
|
||||||
package fakedns
|
|
||||||
|
|
||||||
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"
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
type FakeDnsPool struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
IpPool string `protobuf:"bytes,1,opt,name=ip_pool,json=ipPool,proto3" json:"ip_pool,omitempty"` //CIDR of IP pool used as fake DNS IP
|
|
||||||
LruSize int64 `protobuf:"varint,2,opt,name=lruSize,proto3" json:"lruSize,omitempty"` //Size of Pool for remembering relationship between domain name and IP address
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *FakeDnsPool) Reset() {
|
|
||||||
*x = FakeDnsPool{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_app_dns_fakedns_fakedns_proto_msgTypes[0]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *FakeDnsPool) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*FakeDnsPool) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *FakeDnsPool) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_app_dns_fakedns_fakedns_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 FakeDnsPool.ProtoReflect.Descriptor instead.
|
|
||||||
func (*FakeDnsPool) Descriptor() ([]byte, []int) {
|
|
||||||
return file_app_dns_fakedns_fakedns_proto_rawDescGZIP(), []int{0}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *FakeDnsPool) GetIpPool() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.IpPool
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *FakeDnsPool) GetLruSize() int64 {
|
|
||||||
if x != nil {
|
|
||||||
return x.LruSize
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_app_dns_fakedns_fakedns_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
var file_app_dns_fakedns_fakedns_proto_rawDesc = []byte{
|
|
||||||
0x0a, 0x1d, 0x61, 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0x2f, 0x66, 0x61, 0x6b, 0x65, 0x64, 0x6e,
|
|
||||||
0x73, 0x2f, 0x66, 0x61, 0x6b, 0x65, 0x64, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
|
||||||
0x1a, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e,
|
|
||||||
0x64, 0x6e, 0x73, 0x2e, 0x66, 0x61, 0x6b, 0x65, 0x64, 0x6e, 0x73, 0x22, 0x40, 0x0a, 0x0b, 0x46,
|
|
||||||
0x61, 0x6b, 0x65, 0x44, 0x6e, 0x73, 0x50, 0x6f, 0x6f, 0x6c, 0x12, 0x17, 0x0a, 0x07, 0x69, 0x70,
|
|
||||||
0x5f, 0x70, 0x6f, 0x6f, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x69, 0x70, 0x50,
|
|
||||||
0x6f, 0x6f, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x72, 0x75, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x02,
|
|
||||||
0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x6c, 0x72, 0x75, 0x53, 0x69, 0x7a, 0x65, 0x42, 0x5f, 0x0a,
|
|
||||||
0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e,
|
|
||||||
0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x66, 0x61, 0x6b, 0x65, 0x64, 0x6e, 0x73, 0x50,
|
|
||||||
0x01, 0x5a, 0x1e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x72,
|
|
||||||
0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0x2f, 0x66, 0x61, 0x6b, 0x65, 0x64, 0x6e,
|
|
||||||
0x73, 0xaa, 0x02, 0x1a, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41,
|
|
||||||
0x70, 0x70, 0x2e, 0x44, 0x6e, 0x73, 0x2e, 0x46, 0x61, 0x6b, 0x65, 0x64, 0x6e, 0x73, 0x62, 0x06,
|
|
||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
file_app_dns_fakedns_fakedns_proto_rawDescOnce sync.Once
|
|
||||||
file_app_dns_fakedns_fakedns_proto_rawDescData = file_app_dns_fakedns_fakedns_proto_rawDesc
|
|
||||||
)
|
|
||||||
|
|
||||||
func file_app_dns_fakedns_fakedns_proto_rawDescGZIP() []byte {
|
|
||||||
file_app_dns_fakedns_fakedns_proto_rawDescOnce.Do(func() {
|
|
||||||
file_app_dns_fakedns_fakedns_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_dns_fakedns_fakedns_proto_rawDescData)
|
|
||||||
})
|
|
||||||
return file_app_dns_fakedns_fakedns_proto_rawDescData
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_app_dns_fakedns_fakedns_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
|
||||||
var file_app_dns_fakedns_fakedns_proto_goTypes = []interface{}{
|
|
||||||
(*FakeDnsPool)(nil), // 0: xray.app.dns.fakedns.FakeDnsPool
|
|
||||||
}
|
|
||||||
var file_app_dns_fakedns_fakedns_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_dns_fakedns_fakedns_proto_init() }
|
|
||||||
func file_app_dns_fakedns_fakedns_proto_init() {
|
|
||||||
if File_app_dns_fakedns_fakedns_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !protoimpl.UnsafeEnabled {
|
|
||||||
file_app_dns_fakedns_fakedns_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*FakeDnsPool); 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_fakedns_fakedns_proto_rawDesc,
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 1,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 0,
|
|
||||||
},
|
|
||||||
GoTypes: file_app_dns_fakedns_fakedns_proto_goTypes,
|
|
||||||
DependencyIndexes: file_app_dns_fakedns_fakedns_proto_depIdxs,
|
|
||||||
MessageInfos: file_app_dns_fakedns_fakedns_proto_msgTypes,
|
|
||||||
}.Build()
|
|
||||||
File_app_dns_fakedns_fakedns_proto = out.File
|
|
||||||
file_app_dns_fakedns_fakedns_proto_rawDesc = nil
|
|
||||||
file_app_dns_fakedns_fakedns_proto_goTypes = nil
|
|
||||||
file_app_dns_fakedns_fakedns_proto_depIdxs = nil
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
package xray.app.dns.fakedns;
|
|
||||||
option csharp_namespace = "Xray.App.Dns.Fakedns";
|
|
||||||
option go_package = "github.com/xtls/xray-core/app/dns/fakedns";
|
|
||||||
option java_package = "com.xray.app.dns.fakedns";
|
|
||||||
option java_multiple_files = true;
|
|
||||||
|
|
||||||
message FakeDnsPool{
|
|
||||||
string ip_pool = 1; //CIDR of IP pool used as fake DNS IP
|
|
||||||
int64 lruSize = 2; //Size of Pool for remembering relationship between domain name and IP address
|
|
||||||
}
|
|
@@ -1,105 +0,0 @@
|
|||||||
package fakedns
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
|
||||||
"github.com/xtls/xray-core/common/net"
|
|
||||||
"github.com/xtls/xray-core/common/uuid"
|
|
||||||
"github.com/xtls/xray-core/features/dns"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
ipPrefix = "198.18."
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestNewFakeDnsHolder(_ *testing.T) {
|
|
||||||
_, err := NewFakeDNSHolder()
|
|
||||||
common.Must(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFakeDnsHolderCreateMapping(t *testing.T) {
|
|
||||||
fkdns, err := NewFakeDNSHolder()
|
|
||||||
common.Must(err)
|
|
||||||
|
|
||||||
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
|
||||||
assert.Equal(t, ipPrefix, addr[0].IP().String()[0:len(ipPrefix)])
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFakeDnsHolderCreateMappingMany(t *testing.T) {
|
|
||||||
fkdns, err := NewFakeDNSHolder()
|
|
||||||
common.Must(err)
|
|
||||||
|
|
||||||
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
|
||||||
assert.Equal(t, ipPrefix, addr[0].IP().String()[0:len(ipPrefix)])
|
|
||||||
|
|
||||||
addr2 := fkdns.GetFakeIPForDomain("fakednstest2.example.com")
|
|
||||||
assert.Equal(t, ipPrefix, addr2[0].IP().String()[0:len(ipPrefix)])
|
|
||||||
assert.NotEqual(t, addr[0].IP().String(), addr2[0].IP().String())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFakeDnsHolderCreateMappingManyAndResolve(t *testing.T) {
|
|
||||||
fkdns, err := NewFakeDNSHolder()
|
|
||||||
common.Must(err)
|
|
||||||
|
|
||||||
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
|
||||||
addr2 := fkdns.GetFakeIPForDomain("fakednstest2.example.com")
|
|
||||||
|
|
||||||
{
|
|
||||||
result := fkdns.GetDomainFromFakeDNS(addr[0])
|
|
||||||
assert.Equal(t, "fakednstest.example.com", result)
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
result := fkdns.GetDomainFromFakeDNS(addr2[0])
|
|
||||||
assert.Equal(t, "fakednstest2.example.com", result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFakeDnsHolderCreateMappingManySingleDomain(t *testing.T) {
|
|
||||||
fkdns, err := NewFakeDNSHolder()
|
|
||||||
common.Must(err)
|
|
||||||
|
|
||||||
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
|
||||||
addr2 := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
|
||||||
assert.Equal(t, addr[0].IP().String(), addr2[0].IP().String())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFakeDnsHolderCreateMappingAndRollOver(t *testing.T) {
|
|
||||||
fkdns, err := NewFakeDNSHolderConfigOnly(&FakeDnsPool{
|
|
||||||
IpPool: dns.FakeIPPool,
|
|
||||||
LruSize: 256,
|
|
||||||
})
|
|
||||||
common.Must(err)
|
|
||||||
|
|
||||||
err = fkdns.Start()
|
|
||||||
|
|
||||||
common.Must(err)
|
|
||||||
|
|
||||||
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
|
||||||
addr2 := fkdns.GetFakeIPForDomain("fakednstest2.example.com")
|
|
||||||
|
|
||||||
for i := 0; i <= 8192; i++ {
|
|
||||||
{
|
|
||||||
result := fkdns.GetDomainFromFakeDNS(addr[0])
|
|
||||||
assert.Equal(t, "fakednstest.example.com", result)
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
result := fkdns.GetDomainFromFakeDNS(addr2[0])
|
|
||||||
assert.Equal(t, "fakednstest2.example.com", result)
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
uuid := uuid.New()
|
|
||||||
domain := uuid.String() + ".fakednstest.example.com"
|
|
||||||
tempAddr := fkdns.GetFakeIPForDomain(domain)
|
|
||||||
rsaddr := tempAddr[0].IP().String()
|
|
||||||
|
|
||||||
result := fkdns.GetDomainFromFakeDNS(net.ParseAddress(rsaddr))
|
|
||||||
assert.Equal(t, domain, result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -5,7 +5,6 @@ import (
|
|||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/strmatcher"
|
"github.com/xtls/xray-core/common/strmatcher"
|
||||||
"github.com/xtls/xray-core/features"
|
"github.com/xtls/xray-core/features"
|
||||||
"github.com/xtls/xray-core/features/dns"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// StaticHosts represents static domain-ip mapping in DNS server.
|
// StaticHosts represents static domain-ip mapping in DNS server.
|
||||||
@@ -93,7 +92,7 @@ func NewStaticHosts(hosts []*Config_HostMapping, legacy map[string]*net.IPOrDoma
|
|||||||
return sh, nil
|
return sh, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func filterIP(ips []net.Address, option dns.IPOption) []net.Address {
|
func filterIP(ips []net.Address, option IPOption) []net.Address {
|
||||||
filtered := make([]net.Address, 0, len(ips))
|
filtered := make([]net.Address, 0, len(ips))
|
||||||
for _, ip := range ips {
|
for _, ip := range ips {
|
||||||
if (ip.Family().IsIPv4() && option.IPv4Enable) || (ip.Family().IsIPv6() && option.IPv6Enable) {
|
if (ip.Family().IsIPv4() && option.IPv4Enable) || (ip.Family().IsIPv6() && option.IPv6Enable) {
|
||||||
@@ -107,7 +106,7 @@ func filterIP(ips []net.Address, option dns.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 dns.IPOption) []net.Address {
|
func (h *StaticHosts) LookupIP(domain string, option IPOption) []net.Address {
|
||||||
indices := h.matchers.Match(domain)
|
indices := h.matchers.Match(domain)
|
||||||
if len(indices) == 0 {
|
if len(indices) == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
@@ -8,7 +8,6 @@ import (
|
|||||||
. "github.com/xtls/xray-core/app/dns"
|
. "github.com/xtls/xray-core/app/dns"
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/features/dns"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStaticHosts(t *testing.T) {
|
func TestStaticHosts(t *testing.T) {
|
||||||
@@ -40,7 +39,7 @@ func TestStaticHosts(t *testing.T) {
|
|||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
{
|
{
|
||||||
ips := hosts.LookupIP("example.com", dns.IPOption{
|
ips := hosts.LookupIP("example.com", IPOption{
|
||||||
IPv4Enable: true,
|
IPv4Enable: true,
|
||||||
IPv6Enable: true,
|
IPv6Enable: true,
|
||||||
})
|
})
|
||||||
@@ -53,7 +52,7 @@ func TestStaticHosts(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ips := hosts.LookupIP("www.example.cn", dns.IPOption{
|
ips := hosts.LookupIP("www.example.cn", IPOption{
|
||||||
IPv4Enable: true,
|
IPv4Enable: true,
|
||||||
IPv6Enable: true,
|
IPv6Enable: true,
|
||||||
})
|
})
|
||||||
@@ -66,7 +65,7 @@ func TestStaticHosts(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ips := hosts.LookupIP("baidu.com", dns.IPOption{
|
ips := hosts.LookupIP("baidu.com", IPOption{
|
||||||
IPv4Enable: false,
|
IPv4Enable: false,
|
||||||
IPv6Enable: true,
|
IPv6Enable: true,
|
||||||
})
|
})
|
||||||
|
@@ -4,26 +4,39 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/features/dns"
|
|
||||||
"github.com/xtls/xray-core/features/dns/localdns"
|
"github.com/xtls/xray-core/features/dns/localdns"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// IPOption is an object for IP query options.
|
||||||
|
type IPOption struct {
|
||||||
|
IPv4Enable bool
|
||||||
|
IPv6Enable bool
|
||||||
|
}
|
||||||
|
|
||||||
// Client is the interface for DNS client.
|
// Client is the interface for DNS client.
|
||||||
type Client interface {
|
type Client interface {
|
||||||
// Name of the Client.
|
// Name of the Client.
|
||||||
Name() string
|
Name() string
|
||||||
|
|
||||||
// QueryIP sends IP queries to its configured server.
|
// QueryIP sends IP queries to its configured server.
|
||||||
QueryIP(ctx context.Context, domain string, option dns.IPOption) ([]net.IP, error)
|
QueryIP(ctx context.Context, domain string, option IPOption) ([]net.IP, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type LocalNameServer struct {
|
type LocalNameServer struct {
|
||||||
client *localdns.Client
|
client *localdns.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LocalNameServer) QueryIP(_ context.Context, domain string, option dns.IPOption) ([]net.IP, error) {
|
func (s *LocalNameServer) QueryIP(ctx context.Context, domain string, option IPOption) ([]net.IP, error) {
|
||||||
if option.IPv4Enable || option.IPv6Enable {
|
if option.IPv4Enable && option.IPv6Enable {
|
||||||
return s.client.LookupIP(domain, option)
|
return s.client.LookupIP(domain)
|
||||||
|
}
|
||||||
|
|
||||||
|
if option.IPv4Enable {
|
||||||
|
return s.client.LookupIPv4(domain)
|
||||||
|
}
|
||||||
|
|
||||||
|
if option.IPv6Enable {
|
||||||
|
return s.client.LookupIPv6(domain)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, newError("neither IPv4 nor IPv6 is enabled")
|
return nil, newError("neither IPv4 nor IPv6 is enabled")
|
||||||
|
@@ -1,41 +0,0 @@
|
|||||||
package dns
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common/net"
|
|
||||||
"github.com/xtls/xray-core/core"
|
|
||||||
"github.com/xtls/xray-core/features/dns"
|
|
||||||
)
|
|
||||||
|
|
||||||
type FakeDNSServer struct {
|
|
||||||
fakeDNSEngine dns.FakeDNSEngine
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewFakeDNSServer() *FakeDNSServer {
|
|
||||||
return &FakeDNSServer{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (FakeDNSServer) Name() string {
|
|
||||||
return "FakeDNS"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *FakeDNSServer) QueryIP(ctx context.Context, domain string, _ dns.IPOption) ([]net.IP, error) {
|
|
||||||
if f.fakeDNSEngine == nil {
|
|
||||||
if err := core.RequireFeatures(ctx, func(fd dns.FakeDNSEngine) {
|
|
||||||
f.fakeDNSEngine = fd
|
|
||||||
}); err != nil {
|
|
||||||
return nil, newError("Unable to locate a fake DNS Engine").Base(err).AtError()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ips := f.fakeDNSEngine.GetFakeIPForDomain(domain)
|
|
||||||
|
|
||||||
netIP := toNetIP(ips)
|
|
||||||
if netIP == nil {
|
|
||||||
return nil, newError("Unable to convert IP to net ip").AtError()
|
|
||||||
}
|
|
||||||
|
|
||||||
newError(f.Name(), " got answer: ", domain, " -> ", ips).AtInfo().WriteToLog()
|
|
||||||
|
|
||||||
return netIP, nil
|
|
||||||
}
|
|
@@ -7,16 +7,14 @@ import (
|
|||||||
|
|
||||||
. "github.com/xtls/xray-core/app/dns"
|
. "github.com/xtls/xray-core/app/dns"
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
dns_feature "github.com/xtls/xray-core/features/dns"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLocalNameServer(t *testing.T) {
|
func TestLocalNameServer(t *testing.T) {
|
||||||
s := NewLocalNameServer()
|
s := NewLocalNameServer()
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
|
||||||
ips, err := s.QueryIP(ctx, "google.com", dns_feature.IPOption{
|
ips, err := s.QueryIP(ctx, "google.com", IPOption{
|
||||||
IPv4Enable: true,
|
IPv4Enable: true,
|
||||||
IPv6Enable: true,
|
IPv6Enable: true,
|
||||||
FakeEnable: false,
|
|
||||||
})
|
})
|
||||||
cancel()
|
cancel()
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
@@ -22,7 +22,6 @@ import (
|
|||||||
"github.com/xtls/xray-core/features"
|
"github.com/xtls/xray-core/features"
|
||||||
"github.com/xtls/xray-core/features/dns"
|
"github.com/xtls/xray-core/features/dns"
|
||||||
"github.com/xtls/xray-core/features/routing"
|
"github.com/xtls/xray-core/features/routing"
|
||||||
"github.com/xtls/xray-core/transport/internet"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server is a DNS rely server.
|
// Server is a DNS rely server.
|
||||||
@@ -30,8 +29,7 @@ type Server struct {
|
|||||||
sync.Mutex
|
sync.Mutex
|
||||||
hosts *StaticHosts
|
hosts *StaticHosts
|
||||||
clientIP net.IP
|
clientIP net.IP
|
||||||
clients []Client // clientIdx -> Client
|
clients []Client // clientIdx -> Client
|
||||||
ctx context.Context
|
|
||||||
ipIndexMap []*MultiGeoIPMatcher // clientIdx -> *MultiGeoIPMatcher
|
ipIndexMap []*MultiGeoIPMatcher // clientIdx -> *MultiGeoIPMatcher
|
||||||
domainRules [][]string // clientIdx -> domainRuleIdx -> DomainRule
|
domainRules [][]string // clientIdx -> domainRuleIdx -> DomainRule
|
||||||
domainMatcher strmatcher.IndexMatcher
|
domainMatcher strmatcher.IndexMatcher
|
||||||
@@ -76,7 +74,6 @@ func generateRandomTag() string {
|
|||||||
func New(ctx context.Context, config *Config) (*Server, error) {
|
func New(ctx context.Context, config *Config) (*Server, error) {
|
||||||
server := &Server{
|
server := &Server{
|
||||||
clients: make([]Client, 0, len(config.NameServers)+len(config.NameServer)),
|
clients: make([]Client, 0, len(config.NameServers)+len(config.NameServer)),
|
||||||
ctx: ctx,
|
|
||||||
tag: config.Tag,
|
tag: config.Tag,
|
||||||
}
|
}
|
||||||
if server.tag == "" {
|
if server.tag == "" {
|
||||||
@@ -146,9 +143,6 @@ func New(ctx context.Context, config *Config) (*Server, error) {
|
|||||||
server.clients[idx] = c
|
server.clients[idx] = c
|
||||||
}))
|
}))
|
||||||
|
|
||||||
case address.Family().IsDomain() && address.Domain() == "fakedns":
|
|
||||||
server.clients = append(server.clients, NewFakeDNSServer())
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// UDP classic DNS mode
|
// UDP classic DNS mode
|
||||||
dest := endpoint.AsDestination()
|
dest := endpoint.AsDestination()
|
||||||
@@ -300,14 +294,13 @@ 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 dns.IPOption) ([]net.IP, error) {
|
func (s *Server) queryIPTimeout(idx int, client Client, domain string, option IPOption) ([]net.IP, error) {
|
||||||
ctx, cancel := context.WithTimeout(s.ctx, 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{
|
||||||
Tag: s.tag,
|
Tag: s.tag,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
ctx = internet.ContextWithLookupDomain(ctx, domain)
|
|
||||||
ips, err := client.QueryIP(ctx, domain, option)
|
ips, err := client.QueryIP(ctx, domain, option)
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
@@ -319,7 +312,31 @@ func (s *Server) queryIPTimeout(idx int, client Client, domain string, option dn
|
|||||||
return ips, err
|
return ips, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) lookupStatic(domain string, option dns.IPOption, depth int32) []net.Address {
|
// LookupIP implements dns.Client.
|
||||||
|
func (s *Server) LookupIP(domain string) ([]net.IP, error) {
|
||||||
|
return s.lookupIPInternal(domain, IPOption{
|
||||||
|
IPv4Enable: true,
|
||||||
|
IPv6Enable: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// LookupIPv4 implements dns.IPv4Lookup.
|
||||||
|
func (s *Server) LookupIPv4(domain string) ([]net.IP, error) {
|
||||||
|
return s.lookupIPInternal(domain, IPOption{
|
||||||
|
IPv4Enable: true,
|
||||||
|
IPv6Enable: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// LookupIPv6 implements dns.IPv6Lookup.
|
||||||
|
func (s *Server) LookupIPv6(domain string) ([]net.IP, error) {
|
||||||
|
return s.lookupIPInternal(domain, IPOption{
|
||||||
|
IPv4Enable: false,
|
||||||
|
IPv6Enable: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) lookupStatic(domain string, option IPOption, depth int32) []net.Address {
|
||||||
ips := s.hosts.LookupIP(domain, option)
|
ips := s.hosts.LookupIP(domain, option)
|
||||||
if ips == nil {
|
if ips == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -343,14 +360,14 @@ func toNetIP(ips []net.Address) []net.IP {
|
|||||||
return netips
|
return netips
|
||||||
}
|
}
|
||||||
|
|
||||||
// LookupIP implements dns.Client.
|
func (s *Server) lookupIPInternal(domain string, option IPOption) ([]net.IP, error) {
|
||||||
func (s *Server) LookupIP(domain string, option dns.IPOption) ([]net.IP, error) {
|
|
||||||
if domain == "" {
|
if domain == "" {
|
||||||
return nil, newError("empty domain name")
|
return nil, newError("empty domain name")
|
||||||
}
|
}
|
||||||
|
domain = strings.ToLower(domain)
|
||||||
|
|
||||||
// normalize the FQDN form query
|
// normalize the FQDN form query
|
||||||
if strings.HasSuffix(domain, ".") {
|
if domain[len(domain)-1] == '.' {
|
||||||
domain = domain[:len(domain)-1]
|
domain = domain[:len(domain)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,10 +404,6 @@ func (s *Server) LookupIP(domain string, option dns.IPOption) ([]net.IP, error)
|
|||||||
for _, idx := range indices {
|
for _, idx := range indices {
|
||||||
clientIdx := int(s.matcherInfos[idx].clientIdx)
|
clientIdx := int(s.matcherInfos[idx].clientIdx)
|
||||||
matchedClient = s.clients[clientIdx]
|
matchedClient = s.clients[clientIdx]
|
||||||
if !option.FakeEnable && strings.EqualFold(matchedClient.Name(), "FakeDNS") {
|
|
||||||
newError("skip DNS resolution for domain ", domain, " at server ", matchedClient.Name()).AtDebug().WriteToLog()
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
ips, err := s.queryIPTimeout(clientIdx, matchedClient, domain, option)
|
ips, err := s.queryIPTimeout(clientIdx, matchedClient, domain, option)
|
||||||
if len(ips) > 0 {
|
if len(ips) > 0 {
|
||||||
return ips, nil
|
return ips, nil
|
||||||
@@ -410,10 +423,7 @@ func (s *Server) LookupIP(domain string, option dns.IPOption) ([]net.IP, error)
|
|||||||
newError("domain ", domain, " at server ", client.Name(), " idx:", idx, " already lookup failed, just ignore").AtDebug().WriteToLog()
|
newError("domain ", domain, " at server ", client.Name(), " idx:", idx, " already lookup failed, just ignore").AtDebug().WriteToLog()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !option.FakeEnable && strings.EqualFold(client.Name(), "FakeDNS") {
|
|
||||||
newError("skip DNS resolution for domain ", domain, " at server ", client.Name()).AtDebug().WriteToLog()
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
ips, err := s.queryIPTimeout(idx, client, domain, option)
|
ips, err := s.queryIPTimeout(idx, client, domain, option)
|
||||||
if len(ips) > 0 {
|
if len(ips) > 0 {
|
||||||
return ips, nil
|
return ips, nil
|
||||||
|
@@ -101,8 +101,8 @@ func (*staticHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
|
|||||||
rr, _ := dns.NewRR("localhost-b. IN A 127.0.0.4")
|
rr, _ := dns.NewRR("localhost-b. IN A 127.0.0.4")
|
||||||
ans.Answer = append(ans.Answer, rr)
|
ans.Answer = append(ans.Answer, rr)
|
||||||
|
|
||||||
case q.Name == "Mijia\\ Cloud." && q.Qtype == dns.TypeA:
|
case q.Name == "mijia\\ cloud." && q.Qtype == dns.TypeA:
|
||||||
rr, _ := dns.NewRR("Mijia\\ Cloud. IN A 127.0.0.1")
|
rr, _ := dns.NewRR("mijia\\ cloud. IN A 127.0.0.1")
|
||||||
ans.Answer = append(ans.Answer, rr)
|
ans.Answer = append(ans.Answer, rr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,11 +154,7 @@ func TestUDPServerSubnet(t *testing.T) {
|
|||||||
|
|
||||||
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
||||||
|
|
||||||
ips, err := client.LookupIP("google.com", feature_dns.IPOption{
|
ips, err := client.LookupIP("google.com")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -213,11 +209,7 @@ func TestUDPServer(t *testing.T) {
|
|||||||
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
||||||
|
|
||||||
{
|
{
|
||||||
ips, err := client.LookupIP("google.com", feature_dns.IPOption{
|
ips, err := client.LookupIP("google.com")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -228,11 +220,7 @@ func TestUDPServer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ips, err := client.LookupIP("facebook.com", feature_dns.IPOption{
|
ips, err := client.LookupIP("facebook.com")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -243,11 +231,7 @@ func TestUDPServer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
_, err := client.LookupIP("notexist.google.com", feature_dns.IPOption{
|
_, err := client.LookupIP("notexist.google.com")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("nil error")
|
t.Fatal("nil error")
|
||||||
}
|
}
|
||||||
@@ -257,11 +241,8 @@ func TestUDPServer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ips, err := client.LookupIP("ipv4only.google.com", feature_dns.IPOption{
|
clientv6 := client.(feature_dns.IPv6Lookup)
|
||||||
IPv4Enable: false,
|
ips, err := clientv6.LookupIPv6("ipv4only.google.com")
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != feature_dns.ErrEmptyResponse {
|
if err != feature_dns.ErrEmptyResponse {
|
||||||
t.Fatal("error: ", err)
|
t.Fatal("error: ", err)
|
||||||
}
|
}
|
||||||
@@ -273,11 +254,7 @@ func TestUDPServer(t *testing.T) {
|
|||||||
dnsServer.Shutdown()
|
dnsServer.Shutdown()
|
||||||
|
|
||||||
{
|
{
|
||||||
ips, err := client.LookupIP("google.com", feature_dns.IPOption{
|
ips, err := client.LookupIP("google.com")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -354,11 +331,7 @@ func TestPrioritizedDomain(t *testing.T) {
|
|||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
{
|
{
|
||||||
ips, err := client.LookupIP("google.com", feature_dns.IPOption{
|
ips, err := client.LookupIP("google.com")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -417,12 +390,10 @@ func TestUDPServerIPv6(t *testing.T) {
|
|||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
||||||
|
client6 := client.(feature_dns.IPv6Lookup)
|
||||||
|
|
||||||
{
|
{
|
||||||
ips, err := client.LookupIP("ipv6.google.com", feature_dns.IPOption{
|
ips, err := client6.LookupIPv6("ipv6.google.com")
|
||||||
IPv4Enable: false,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -485,11 +456,7 @@ func TestStaticHostDomain(t *testing.T) {
|
|||||||
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
||||||
|
|
||||||
{
|
{
|
||||||
ips, err := client.LookupIP("example.com", feature_dns.IPOption{
|
ips, err := client.LookupIP("example.com")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -596,11 +563,7 @@ func TestIPMatch(t *testing.T) {
|
|||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
{
|
{
|
||||||
ips, err := client.LookupIP("google.com", feature_dns.IPOption{
|
ips, err := client.LookupIP("google.com")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -719,11 +682,7 @@ func TestLocalDomain(t *testing.T) {
|
|||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
{ // Will match dotless:
|
{ // Will match dotless:
|
||||||
ips, err := client.LookupIP("hostname", feature_dns.IPOption{
|
ips, err := client.LookupIP("hostname")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -734,11 +693,7 @@ func TestLocalDomain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // Will match domain:local
|
{ // Will match domain:local
|
||||||
ips, err := client.LookupIP("hostname.local", feature_dns.IPOption{
|
ips, err := client.LookupIP("hostname.local")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -749,11 +704,7 @@ func TestLocalDomain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // Will match static ip
|
{ // Will match static ip
|
||||||
ips, err := client.LookupIP("hostnamestatic", feature_dns.IPOption{
|
ips, err := client.LookupIP("hostnamestatic")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -764,11 +715,7 @@ func TestLocalDomain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // Will match domain replacing
|
{ // Will match domain replacing
|
||||||
ips, err := client.LookupIP("hostnamealias", feature_dns.IPOption{
|
ips, err := client.LookupIP("hostnamealias")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -779,11 +726,7 @@ func TestLocalDomain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // Will match dotless:localhost, but not expectIPs: 127.0.0.2, 127.0.0.3, then matches at dotless:
|
{ // Will match dotless:localhost, but not expectIPs: 127.0.0.2, 127.0.0.3, then matches at dotless:
|
||||||
ips, err := client.LookupIP("localhost", feature_dns.IPOption{
|
ips, err := client.LookupIP("localhost")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -794,11 +737,7 @@ func TestLocalDomain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3
|
{ // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3
|
||||||
ips, err := client.LookupIP("localhost-a", feature_dns.IPOption{
|
ips, err := client.LookupIP("localhost-a")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -809,11 +748,7 @@ func TestLocalDomain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3
|
{ // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3
|
||||||
ips, err := client.LookupIP("localhost-b", feature_dns.IPOption{
|
ips, err := client.LookupIP("localhost-b")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -824,11 +759,7 @@ func TestLocalDomain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // Will match dotless:
|
{ // Will match dotless:
|
||||||
ips, err := client.LookupIP("Mijia Cloud", feature_dns.IPOption{
|
ips, err := client.LookupIP("Mijia Cloud")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -990,11 +921,7 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) {
|
|||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
{ // Will match server 1,2 and server 1 returns expected ip
|
{ // Will match server 1,2 and server 1 returns expected ip
|
||||||
ips, err := client.LookupIP("google.com", feature_dns.IPOption{
|
ips, err := client.LookupIP("google.com")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -1005,11 +932,8 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // Will match server 1,2 and server 1 returns unexpected ip, then server 2 returns expected one
|
{ // Will match server 1,2 and server 1 returns unexpected ip, then server 2 returns expected one
|
||||||
ips, err := client.LookupIP("ipv6.google.com", feature_dns.IPOption{
|
clientv4 := client.(feature_dns.IPv4Lookup)
|
||||||
IPv4Enable: true,
|
ips, err := clientv4.LookupIPv4("ipv6.google.com")
|
||||||
IPv6Enable: false,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -1020,11 +944,7 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // Will match server 3,1,2 and server 3 returns expected one
|
{ // Will match server 3,1,2 and server 3 returns expected one
|
||||||
ips, err := client.LookupIP("api.google.com", feature_dns.IPOption{
|
ips, err := client.LookupIP("api.google.com")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@@ -1035,11 +955,7 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // Will match server 4,3,1,2 and server 4 returns expected one
|
{ // Will match server 4,3,1,2 and server 4 returns expected one
|
||||||
ips, err := client.LookupIP("v2.api.google.com", feature_dns.IPOption{
|
ips, err := client.LookupIP("v2.api.google.com")
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
|
@@ -2,14 +2,12 @@ package dns
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/xtls/xray-core/transport/internet"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/log"
|
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/protocol/dns"
|
"github.com/xtls/xray-core/common/protocol/dns"
|
||||||
udp_proto "github.com/xtls/xray-core/common/protocol/udp"
|
udp_proto "github.com/xtls/xray-core/common/protocol/udp"
|
||||||
@@ -54,7 +52,7 @@ func NewClassicNameServer(address net.Destination, dispatcher routing.Dispatcher
|
|||||||
Execute: s.Cleanup,
|
Execute: s.Cleanup,
|
||||||
}
|
}
|
||||||
s.udpServer = udp.NewDispatcher(dispatcher, s.HandleResponse)
|
s.udpServer = udp.NewDispatcher(dispatcher, s.HandleResponse)
|
||||||
newError("DNS: created UDP client initialized for ", address.NetAddr()).AtInfo().WriteToLog()
|
newError("DNS: created udp client inited for ", address.NetAddr()).AtInfo().WriteToLog()
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +178,7 @@ func (s *ClassicNameServer) addPendingRequest(req *dnsRequest) {
|
|||||||
s.requests[id] = *req
|
s.requests[id] = *req
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ClassicNameServer) sendQuery(ctx context.Context, domain string, option dns_feature.IPOption) {
|
func (s *ClassicNameServer) sendQuery(ctx context.Context, domain string, option IPOption) {
|
||||||
newError(s.name, " querying DNS for: ", domain).AtDebug().WriteToLog(session.ExportIDToError(ctx))
|
newError(s.name, " querying DNS for: ", domain).AtDebug().WriteToLog(session.ExportIDToError(ctx))
|
||||||
|
|
||||||
reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(s.clientIP))
|
reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(s.clientIP))
|
||||||
@@ -192,21 +190,14 @@ func (s *ClassicNameServer) sendQuery(ctx context.Context, domain string, option
|
|||||||
if inbound := session.InboundFromContext(ctx); inbound != nil {
|
if inbound := session.InboundFromContext(ctx); inbound != nil {
|
||||||
udpCtx = session.ContextWithInbound(udpCtx, inbound)
|
udpCtx = session.ContextWithInbound(udpCtx, inbound)
|
||||||
}
|
}
|
||||||
udpCtx = internet.ContextWithLookupDomain(udpCtx, internet.LookupDomainFromContext(ctx))
|
|
||||||
udpCtx = session.ContextWithContent(udpCtx, &session.Content{
|
udpCtx = session.ContextWithContent(udpCtx, &session.Content{
|
||||||
Protocol: "dns",
|
Protocol: "dns",
|
||||||
})
|
})
|
||||||
udpCtx = log.ContextWithAccessMessage(udpCtx, &log.AccessMessage{
|
|
||||||
From: "DNS",
|
|
||||||
To: s.address,
|
|
||||||
Status: log.AccessAccepted,
|
|
||||||
Reason: "",
|
|
||||||
})
|
|
||||||
s.udpServer.Dispatch(udpCtx, s.address, b)
|
s.udpServer.Dispatch(udpCtx, s.address, b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ClassicNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, error) {
|
func (s *ClassicNameServer) findIPsForDomain(domain string, option IPOption) ([]net.IP, error) {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
record, found := s.ips[domain]
|
record, found := s.ips[domain]
|
||||||
s.RUnlock()
|
s.RUnlock()
|
||||||
@@ -244,14 +235,12 @@ func (s *ClassicNameServer) findIPsForDomain(domain string, option dns_feature.I
|
|||||||
return nil, dns_feature.ErrEmptyResponse
|
return nil, dns_feature.ErrEmptyResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryIP implements Server.
|
func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, option IPOption) ([]net.IP, error) {
|
||||||
func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, option dns_feature.IPOption) ([]net.IP, error) {
|
|
||||||
fqdn := Fqdn(domain)
|
fqdn := Fqdn(domain)
|
||||||
|
|
||||||
ips, err := s.findIPsForDomain(fqdn, option)
|
ips, err := s.findIPsForDomain(fqdn, option)
|
||||||
if err != errRecordNotFound {
|
if err != errRecordNotFound {
|
||||||
newError(s.name, " cache HIT ", domain, " -> ", ips).Base(err).AtDebug().WriteToLog()
|
newError(s.name, " cache HIT ", domain, " -> ", ips).Base(err).AtDebug().WriteToLog()
|
||||||
log.Record(&log.DNSLog{s.name, domain, ips, log.DNSCacheHit, 0, err})
|
|
||||||
return ips, err
|
return ips, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,12 +271,10 @@ func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, option d
|
|||||||
close(done)
|
close(done)
|
||||||
}()
|
}()
|
||||||
s.sendQuery(ctx, fqdn, option)
|
s.sendQuery(ctx, fqdn, option)
|
||||||
start := time.Now()
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
ips, err := s.findIPsForDomain(fqdn, option)
|
ips, err := s.findIPsForDomain(fqdn, option)
|
||||||
if err != errRecordNotFound {
|
if err != errRecordNotFound {
|
||||||
log.Record(&log.DNSLog{s.name, domain, ips, log.DNSQueried, time.Since(start), err})
|
|
||||||
return ips, err
|
return ips, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -88,7 +88,6 @@ type Config struct {
|
|||||||
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=xray.app.log.LogType" json:"access_log_type,omitempty"`
|
AccessLogType LogType `protobuf:"varint,4,opt,name=access_log_type,json=accessLogType,proto3,enum=xray.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"`
|
||||||
EnableDnsLog bool `protobuf:"varint,6,opt,name=enable_dns_log,json=enableDnsLog,proto3" json:"enable_dns_log,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) Reset() {
|
func (x *Config) Reset() {
|
||||||
@@ -158,20 +157,13 @@ func (x *Config) GetAccessLogPath() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Config) GetEnableDnsLog() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.EnableDnsLog
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_app_log_config_proto protoreflect.FileDescriptor
|
var File_app_log_config_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_app_log_config_proto_rawDesc = []byte{
|
var file_app_log_config_proto_rawDesc = []byte{
|
||||||
0x0a, 0x14, 0x61, 0x70, 0x70, 0x2f, 0x6c, 0x6f, 0x67, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
|
0x0a, 0x14, 0x61, 0x70, 0x70, 0x2f, 0x6c, 0x6f, 0x67, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
|
||||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70,
|
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70,
|
||||||
0x2e, 0x6c, 0x6f, 0x67, 0x1a, 0x14, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6c, 0x6f, 0x67,
|
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, 0xbb, 0x02, 0x0a, 0x06, 0x43,
|
0x2f, 0x6c, 0x6f, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x95, 0x02, 0x0a, 0x06, 0x43,
|
||||||
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3b, 0x0a, 0x0e, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6c,
|
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3b, 0x0a, 0x0e, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6c,
|
||||||
0x6f, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e,
|
0x6f, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e,
|
||||||
0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x2e, 0x4c, 0x6f, 0x67,
|
0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x2e, 0x4c, 0x6f, 0x67,
|
||||||
@@ -189,17 +181,15 @@ var file_app_log_config_proto_rawDesc = []byte{
|
|||||||
0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x26, 0x0a, 0x0f, 0x61, 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,
|
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,
|
0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x50, 0x61,
|
||||||
0x74, 0x68, 0x12, 0x24, 0x0a, 0x0e, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x64, 0x6e, 0x73,
|
0x74, 0x68, 0x2a, 0x35, 0x0a, 0x07, 0x4c, 0x6f, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a,
|
||||||
0x5f, 0x6c, 0x6f, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x65, 0x6e, 0x61, 0x62,
|
0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x73, 0x6f,
|
||||||
0x6c, 0x65, 0x44, 0x6e, 0x73, 0x4c, 0x6f, 0x67, 0x2a, 0x35, 0x0a, 0x07, 0x4c, 0x6f, 0x67, 0x54,
|
0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x10, 0x02, 0x12, 0x09,
|
||||||
0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0b, 0x0a,
|
0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x10, 0x03, 0x42, 0x46, 0x0a, 0x10, 0x63, 0x6f, 0x6d,
|
||||||
0x07, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x69,
|
0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x50, 0x01, 0x5a,
|
||||||
0x6c, 0x65, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x10, 0x03, 0x42,
|
0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73,
|
||||||
0x46, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e,
|
0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x6c,
|
||||||
0x6c, 0x6f, 0x67, 0x50, 0x01, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
0x6f, 0x67, 0xaa, 0x02, 0x0c, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x4c, 0x6f,
|
||||||
0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65,
|
0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x2f, 0x61, 0x70, 0x70, 0x2f, 0x6c, 0x6f, 0x67, 0xaa, 0x02, 0x0c, 0x58, 0x72, 0x61, 0x79, 0x2e,
|
|
||||||
0x41, 0x70, 0x70, 0x2e, 0x4c, 0x6f, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@@ -22,5 +22,4 @@ message Config {
|
|||||||
|
|
||||||
LogType access_log_type = 4;
|
LogType access_log_type = 4;
|
||||||
string access_log_path = 5;
|
string access_log_path = 5;
|
||||||
bool enable_dns_log = 6;
|
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,6 @@ type Instance struct {
|
|||||||
accessLogger log.Handler
|
accessLogger log.Handler
|
||||||
errorLogger log.Handler
|
errorLogger log.Handler
|
||||||
active bool
|
active bool
|
||||||
dns bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new log.Instance based on the given config.
|
// New creates a new log.Instance based on the given config.
|
||||||
@@ -25,7 +24,6 @@ func New(ctx context.Context, config *Config) (*Instance, error) {
|
|||||||
g := &Instance{
|
g := &Instance{
|
||||||
config: config,
|
config: config,
|
||||||
active: false,
|
active: false,
|
||||||
dns: config.EnableDnsLog,
|
|
||||||
}
|
}
|
||||||
log.RegisterHandler(g)
|
log.RegisterHandler(g)
|
||||||
|
|
||||||
@@ -105,10 +103,6 @@ func (g *Instance) Handle(msg log.Message) {
|
|||||||
if g.accessLogger != nil {
|
if g.accessLogger != nil {
|
||||||
g.accessLogger.Handle(msg)
|
g.accessLogger.Handle(msg)
|
||||||
}
|
}
|
||||||
case *log.DNSLog:
|
|
||||||
if g.dns && g.accessLogger != nil {
|
|
||||||
g.accessLogger.Handle(msg)
|
|
||||||
}
|
|
||||||
case *log.GeneralMessage:
|
case *log.GeneralMessage:
|
||||||
if g.errorLogger != nil && msg.Severity <= g.config.ErrorLogLevel {
|
if g.errorLogger != nil && msg.Severity <= g.config.ErrorLogLevel {
|
||||||
g.errorLogger.Handle(msg)
|
g.errorLogger.Handle(msg)
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.25.0
|
// protoc-gen-go v1.25.0
|
||||||
// protoc (unknown)
|
// protoc v3.14.0
|
||||||
// source: app/proxyman/config.proto
|
// source: app/proxyman/config.proto
|
||||||
|
|
||||||
package proxyman
|
package proxyman
|
||||||
@@ -239,12 +239,9 @@ type SniffingConfig struct {
|
|||||||
// Whether or not to enable content sniffing on an inbound connection.
|
// Whether or not to enable content sniffing on an inbound connection.
|
||||||
Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"`
|
Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"`
|
||||||
// Override target destination if sniff'ed protocol is in the given list.
|
// Override target destination if sniff'ed protocol is in the given list.
|
||||||
// Supported values are "http", "tls", "fakedns".
|
// Supported values are "http", "tls".
|
||||||
DestinationOverride []string `protobuf:"bytes,2,rep,name=destination_override,json=destinationOverride,proto3" json:"destination_override,omitempty"`
|
DestinationOverride []string `protobuf:"bytes,2,rep,name=destination_override,json=destinationOverride,proto3" json:"destination_override,omitempty"`
|
||||||
DomainsExcluded []string `protobuf:"bytes,3,rep,name=domains_excluded,json=domainsExcluded,proto3" json:"domains_excluded,omitempty"`
|
DomainsExcluded []string `protobuf:"bytes,3,rep,name=domains_excluded,json=domainsExcluded,proto3" json:"domains_excluded,omitempty"`
|
||||||
// Whether should only try to sniff metadata without waiting for client input.
|
|
||||||
// Can be used to support SMTP like protocol where server send the first message.
|
|
||||||
MetadataOnly bool `protobuf:"varint,4,opt,name=metadata_only,json=metadataOnly,proto3" json:"metadata_only,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SniffingConfig) Reset() {
|
func (x *SniffingConfig) Reset() {
|
||||||
@@ -300,13 +297,6 @@ func (x *SniffingConfig) GetDomainsExcluded() []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SniffingConfig) GetMetadataOnly() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.MetadataOnly
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
type ReceiverConfig struct {
|
type ReceiverConfig struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
@@ -774,7 +764,7 @@ var file_app_proxyman_config_proto_rawDesc = []byte{
|
|||||||
0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x2c, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12,
|
0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x2c, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12,
|
||||||
0x0a, 0x0a, 0x06, 0x41, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x52,
|
0x0a, 0x0a, 0x06, 0x41, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x52,
|
||||||
0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x78, 0x74, 0x65, 0x72,
|
0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x78, 0x74, 0x65, 0x72,
|
||||||
0x6e, 0x61, 0x6c, 0x10, 0x02, 0x22, 0xad, 0x01, 0x0a, 0x0e, 0x53, 0x6e, 0x69, 0x66, 0x66, 0x69,
|
0x6e, 0x61, 0x6c, 0x10, 0x02, 0x22, 0x88, 0x01, 0x0a, 0x0e, 0x53, 0x6e, 0x69, 0x66, 0x66, 0x69,
|
||||||
0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62,
|
0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62,
|
||||||
0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c,
|
0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c,
|
||||||
0x65, 0x64, 0x12, 0x31, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f,
|
0x65, 0x64, 0x12, 0x31, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f,
|
||||||
@@ -783,88 +773,86 @@ var file_app_proxyman_config_proto_rawDesc = []byte{
|
|||||||
0x72, 0x72, 0x69, 0x64, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73,
|
0x72, 0x72, 0x69, 0x64, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73,
|
||||||
0x5f, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52,
|
0x5f, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52,
|
||||||
0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x45, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x64,
|
0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x45, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x64,
|
||||||
0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x6f, 0x6e, 0x6c,
|
0x22, 0x90, 0x04, 0x0a, 0x0e, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e,
|
||||||
0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
|
0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, 0x0a, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x72, 0x61, 0x6e, 0x67,
|
||||||
0x61, 0x4f, 0x6e, 0x6c, 0x79, 0x22, 0x90, 0x04, 0x0a, 0x0e, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76,
|
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63,
|
||||||
0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, 0x0a, 0x70, 0x6f, 0x72, 0x74,
|
0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x61,
|
||||||
0x5f, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78,
|
0x6e, 0x67, 0x65, 0x52, 0x09, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x33,
|
||||||
0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x50,
|
0x0a, 0x06, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b,
|
||||||
0x6f, 0x72, 0x74, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x09, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x61,
|
0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74,
|
||||||
0x6e, 0x67, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x18, 0x02, 0x20,
|
0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x06, 0x6c, 0x69, 0x73,
|
||||||
0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f,
|
0x74, 0x65, 0x6e, 0x12, 0x56, 0x0a, 0x13, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f,
|
||||||
0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e,
|
0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b,
|
||||||
0x52, 0x06, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x12, 0x56, 0x0a, 0x13, 0x61, 0x6c, 0x6c, 0x6f,
|
0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78,
|
||||||
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18,
|
0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53,
|
||||||
0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70,
|
0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x12, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74,
|
||||||
0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61,
|
0x69, 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x4e, 0x0a, 0x0f, 0x73,
|
||||||
0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x12, 0x61, 0x6c,
|
0x74, 0x72, 0x65, 0x61, 0x6d, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x04,
|
||||||
0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79,
|
0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e,
|
||||||
0x12, 0x4e, 0x0a, 0x0f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69,
|
0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53,
|
||||||
0x6e, 0x67, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79,
|
0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x73, 0x74, 0x72,
|
||||||
0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72,
|
0x65, 0x61, 0x6d, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x40, 0x0a, 0x1c, 0x72,
|
||||||
0x6e, 0x65, 0x74, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
|
0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x5f, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f,
|
||||||
0x52, 0x0e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73,
|
0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28,
|
||||||
0x12, 0x40, 0x0a, 0x1c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x5f, 0x6f, 0x72, 0x69, 0x67,
|
0x08, 0x52, 0x1a, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e,
|
||||||
0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
0x61, 0x6c, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4e, 0x0a,
|
||||||
0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x4f,
|
0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65,
|
||||||
0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69,
|
0x18, 0x07, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70,
|
||||||
0x6f, 0x6e, 0x12, 0x4e, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x76, 0x65,
|
0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x4b, 0x6e, 0x6f, 0x77, 0x6e,
|
||||||
0x72, 0x72, 0x69, 0x64, 0x65, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x78, 0x72,
|
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0e, 0x64,
|
||||||
0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e,
|
0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x12, 0x4e, 0x0a,
|
||||||
0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, 0x42, 0x02,
|
0x11, 0x73, 0x6e, 0x69, 0x66, 0x66, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e,
|
||||||
0x18, 0x01, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69,
|
0x67, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e,
|
||||||
0x64, 0x65, 0x12, 0x4e, 0x0a, 0x11, 0x73, 0x6e, 0x69, 0x66, 0x66, 0x69, 0x6e, 0x67, 0x5f, 0x73,
|
0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x53, 0x6e, 0x69,
|
||||||
0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e,
|
0x66, 0x66, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x73, 0x6e, 0x69,
|
||||||
0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61,
|
0x66, 0x66, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x4a, 0x04, 0x08,
|
||||||
0x6e, 0x2e, 0x53, 0x6e, 0x69, 0x66, 0x66, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
|
0x06, 0x10, 0x07, 0x22, 0xc0, 0x01, 0x0a, 0x14, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48,
|
||||||
0x52, 0x10, 0x73, 0x6e, 0x69, 0x66, 0x66, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e,
|
0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03,
|
||||||
0x67, 0x73, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x22, 0xc0, 0x01, 0x0a, 0x14, 0x49, 0x6e, 0x62,
|
0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x4d,
|
||||||
0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69,
|
0x0a, 0x11, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69,
|
||||||
0x67, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
|
0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79,
|
||||||
0x74, 0x61, 0x67, 0x12, 0x4d, 0x0a, 0x11, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x5f,
|
0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54,
|
||||||
0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20,
|
0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x10, 0x72, 0x65, 0x63,
|
||||||
0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72,
|
0x65, 0x69, 0x76, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x47, 0x0a,
|
||||||
0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
|
||||||
0x52, 0x10, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e,
|
|
||||||
0x67, 0x73, 0x12, 0x47, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74,
|
|
||||||
0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61,
|
|
||||||
0x79, 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, 0x0d, 0x70, 0x72,
|
|
||||||
0x6f, 0x78, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x10, 0x0a, 0x0e, 0x4f,
|
|
||||||
0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0xb0, 0x02,
|
|
||||||
0x0a, 0x0c, 0x53, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x2d,
|
|
||||||
0x0a, 0x03, 0x76, 0x69, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, 0x72,
|
|
||||||
0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50,
|
|
||||||
0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x03, 0x76, 0x69, 0x61, 0x12, 0x4e, 0x0a,
|
|
||||||
0x0f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73,
|
|
||||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72,
|
|
||||||
0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74,
|
|
||||||
0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x73,
|
|
||||||
0x74, 0x72, 0x65, 0x61, 0x6d, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x4b, 0x0a,
|
|
||||||
0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18,
|
0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18,
|
||||||
0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61,
|
0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d,
|
||||||
0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e,
|
0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64,
|
||||||
0x50, 0x72, 0x6f, 0x78, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x70, 0x72, 0x6f,
|
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x53, 0x65,
|
||||||
0x78, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x54, 0x0a, 0x12, 0x6d, 0x75,
|
0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x10, 0x0a, 0x0e, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75,
|
||||||
0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73,
|
0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0xb0, 0x02, 0x0a, 0x0c, 0x53, 0x65, 0x6e,
|
||||||
0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70,
|
0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x2d, 0x0a, 0x03, 0x76, 0x69, 0x61,
|
||||||
0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f,
|
||||||
0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x11, 0x6d,
|
0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, 0x6d,
|
||||||
0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73,
|
0x61, 0x69, 0x6e, 0x52, 0x03, 0x76, 0x69, 0x61, 0x12, 0x4e, 0x0a, 0x0f, 0x73, 0x74, 0x72, 0x65,
|
||||||
0x22, 0x50, 0x0a, 0x12, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67,
|
0x61, 0x6d, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||||
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65,
|
0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f,
|
||||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64,
|
0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x74, 0x72, 0x65,
|
||||||
0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18,
|
0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d,
|
||||||
0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e,
|
0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x4b, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78,
|
||||||
0x63, 0x79, 0x2a, 0x23, 0x0a, 0x0e, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f,
|
0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b,
|
||||||
0x63, 0x6f, 0x6c, 0x73, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x00, 0x12, 0x07,
|
0x32, 0x24, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72,
|
||||||
0x0a, 0x03, 0x54, 0x4c, 0x53, 0x10, 0x01, 0x42, 0x55, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x78,
|
0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79,
|
||||||
0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e,
|
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x53, 0x65, 0x74,
|
||||||
0x50, 0x01, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78,
|
0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x54, 0x0a, 0x12, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c,
|
||||||
0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70,
|
0x65, 0x78, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||||
0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0xaa, 0x02, 0x11, 0x58, 0x72, 0x61,
|
0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f,
|
||||||
0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x62, 0x06,
|
0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69,
|
||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x11, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70,
|
||||||
|
0x6c, 0x65, 0x78, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x50, 0x0a, 0x12, 0x4d,
|
||||||
|
0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69,
|
||||||
|
0x67, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||||
|
0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x63,
|
||||||
|
0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d,
|
||||||
|
0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x2a, 0x23, 0x0a,
|
||||||
|
0x0e, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, 0x12,
|
||||||
|
0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x4c, 0x53,
|
||||||
|
0x10, 0x01, 0x42, 0x55, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61,
|
||||||
|
0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x50, 0x01, 0x5a, 0x26, 0x67,
|
||||||
|
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78,
|
||||||
|
0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x72, 0x6f,
|
||||||
|
0x78, 0x79, 0x6d, 0x61, 0x6e, 0xaa, 0x02, 0x11, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70,
|
||||||
|
0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||||
|
0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@@ -54,13 +54,9 @@ message SniffingConfig {
|
|||||||
bool enabled = 1;
|
bool enabled = 1;
|
||||||
|
|
||||||
// Override target destination if sniff'ed protocol is in the given list.
|
// Override target destination if sniff'ed protocol is in the given list.
|
||||||
// Supported values are "http", "tls", "fakedns".
|
// Supported values are "http", "tls".
|
||||||
repeated string destination_override = 2;
|
repeated string destination_override = 2;
|
||||||
repeated string domains_excluded = 3;
|
repeated string domains_excluded = 3;
|
||||||
|
|
||||||
// Whether should only try to sniff metadata without waiting for client input.
|
|
||||||
// Can be used to support SMTP like protocol where server send the first message.
|
|
||||||
bool metadata_only = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message ReceiverConfig {
|
message ReceiverConfig {
|
||||||
|
@@ -133,7 +133,6 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *
|
|||||||
address: address,
|
address: address,
|
||||||
port: net.Port(port),
|
port: net.Port(port),
|
||||||
dispatcher: h.mux,
|
dispatcher: h.mux,
|
||||||
sniffingConfig: receiverConfig.GetEffectiveSniffingSettings(),
|
|
||||||
uplinkCounter: uplinkCounter,
|
uplinkCounter: uplinkCounter,
|
||||||
downlinkCounter: downlinkCounter,
|
downlinkCounter: downlinkCounter,
|
||||||
stream: mss,
|
stream: mss,
|
||||||
|
@@ -153,7 +153,6 @@ func (h *DynamicInboundHandler) refresh() error {
|
|||||||
address: address,
|
address: address,
|
||||||
port: port,
|
port: port,
|
||||||
dispatcher: h.mux,
|
dispatcher: h.mux,
|
||||||
sniffingConfig: h.receiverConfig.GetEffectiveSniffingSettings(),
|
|
||||||
uplinkCounter: uplinkCounter,
|
uplinkCounter: uplinkCounter,
|
||||||
downlinkCounter: downlinkCounter,
|
downlinkCounter: downlinkCounter,
|
||||||
stream: h.streamSettings,
|
stream: h.streamSettings,
|
||||||
|
@@ -98,7 +98,6 @@ func (w *tcpWorker) callback(conn internet.Connection) {
|
|||||||
content.SniffingRequest.Enabled = w.sniffingConfig.Enabled
|
content.SniffingRequest.Enabled = w.sniffingConfig.Enabled
|
||||||
content.SniffingRequest.OverrideDestinationForProtocol = w.sniffingConfig.DestinationOverride
|
content.SniffingRequest.OverrideDestinationForProtocol = w.sniffingConfig.DestinationOverride
|
||||||
content.SniffingRequest.ExcludeForDomain = w.sniffingConfig.DomainsExcluded
|
content.SniffingRequest.ExcludeForDomain = w.sniffingConfig.DomainsExcluded
|
||||||
content.SniffingRequest.MetadataOnly = w.sniffingConfig.MetadataOnly
|
|
||||||
}
|
}
|
||||||
ctx = session.ContextWithContent(ctx, content)
|
ctx = session.ContextWithContent(ctx, content)
|
||||||
|
|
||||||
@@ -236,7 +235,6 @@ type udpWorker struct {
|
|||||||
tag string
|
tag string
|
||||||
stream *internet.MemoryStreamConfig
|
stream *internet.MemoryStreamConfig
|
||||||
dispatcher routing.Dispatcher
|
dispatcher routing.Dispatcher
|
||||||
sniffingConfig *proxyman.SniffingConfig
|
|
||||||
uplinkCounter stats.Counter
|
uplinkCounter stats.Counter
|
||||||
downlinkCounter stats.Counter
|
downlinkCounter stats.Counter
|
||||||
|
|
||||||
@@ -299,7 +297,7 @@ func (w *udpWorker) callback(b *buf.Buffer, source net.Destination, originalDest
|
|||||||
common.Must(w.checker.Start())
|
common.Must(w.checker.Start())
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
ctx := w.ctx
|
ctx := context.Background()
|
||||||
sid := session.NewID()
|
sid := session.NewID()
|
||||||
ctx = session.ContextWithID(ctx, sid)
|
ctx = session.ContextWithID(ctx, sid)
|
||||||
|
|
||||||
@@ -313,13 +311,6 @@ func (w *udpWorker) callback(b *buf.Buffer, source net.Destination, originalDest
|
|||||||
Gateway: net.UDPDestination(w.address, w.port),
|
Gateway: net.UDPDestination(w.address, w.port),
|
||||||
Tag: w.tag,
|
Tag: w.tag,
|
||||||
})
|
})
|
||||||
content := new(session.Content)
|
|
||||||
if w.sniffingConfig != nil {
|
|
||||||
content.SniffingRequest.Enabled = w.sniffingConfig.Enabled
|
|
||||||
content.SniffingRequest.OverrideDestinationForProtocol = w.sniffingConfig.DestinationOverride
|
|
||||||
content.SniffingRequest.MetadataOnly = w.sniffingConfig.MetadataOnly
|
|
||||||
}
|
|
||||||
ctx = session.ContextWithContent(ctx, content)
|
|
||||||
if err := w.proxy.Process(ctx, net.Network_UDP, conn, w.dispatcher); err != nil {
|
if err := w.proxy.Process(ctx, net.Network_UDP, conn, w.dispatcher); err != nil {
|
||||||
newError("connection ends").Base(err).WriteToLog(session.ExportIDToError(ctx))
|
newError("connection ends").Base(err).WriteToLog(session.ExportIDToError(ctx))
|
||||||
}
|
}
|
||||||
@@ -460,7 +451,6 @@ func (w *dsWorker) callback(conn internet.Connection) {
|
|||||||
content.SniffingRequest.Enabled = w.sniffingConfig.Enabled
|
content.SniffingRequest.Enabled = w.sniffingConfig.Enabled
|
||||||
content.SniffingRequest.OverrideDestinationForProtocol = w.sniffingConfig.DestinationOverride
|
content.SniffingRequest.OverrideDestinationForProtocol = w.sniffingConfig.DestinationOverride
|
||||||
content.SniffingRequest.ExcludeForDomain = w.sniffingConfig.DomainsExcluded
|
content.SniffingRequest.ExcludeForDomain = w.sniffingConfig.DomainsExcluded
|
||||||
content.SniffingRequest.MetadataOnly = w.sniffingConfig.MetadataOnly
|
|
||||||
}
|
}
|
||||||
ctx = session.ContextWithContent(ctx, content)
|
ctx = session.ContextWithContent(ctx, content)
|
||||||
|
|
||||||
|
@@ -66,24 +66,6 @@ type DomainMatcher struct {
|
|||||||
matchers strmatcher.IndexMatcher
|
matchers strmatcher.IndexMatcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMphMatcherGroup(domains []*Domain) (*DomainMatcher, error) {
|
|
||||||
g := strmatcher.NewMphMatcherGroup()
|
|
||||||
for _, d := range domains {
|
|
||||||
matcherType, f := matcherTypeMap[d.Type]
|
|
||||||
if !f {
|
|
||||||
return nil, newError("unsupported domain type", d.Type)
|
|
||||||
}
|
|
||||||
_, err := g.AddPattern(d.Value, matcherType)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g.Build()
|
|
||||||
return &DomainMatcher{
|
|
||||||
matchers: g,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewDomainMatcher(domains []*Domain) (*DomainMatcher, error) {
|
func NewDomainMatcher(domains []*Domain) (*DomainMatcher, error) {
|
||||||
g := new(strmatcher.MatcherGroup)
|
g := new(strmatcher.MatcherGroup)
|
||||||
for _, d := range domains {
|
for _, d := range domains {
|
||||||
@@ -100,7 +82,7 @@ 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(strings.ToLower(domain))) > 0
|
return len(m.matchers.Match(domain)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply implements Condition.
|
// Apply implements Condition.
|
||||||
@@ -109,7 +91,7 @@ func (m *DomainMatcher) Apply(ctx routing.Context) bool {
|
|||||||
if len(domain) == 0 {
|
if len(domain) == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return m.ApplyDomain(domain)
|
return m.ApplyDomain(strings.ToLower(domain))
|
||||||
}
|
}
|
||||||
|
|
||||||
type MultiGeoIPMatcher struct {
|
type MultiGeoIPMatcher struct {
|
||||||
|
@@ -359,9 +359,6 @@ func TestChinaSites(t *testing.T) {
|
|||||||
matcher, err := NewDomainMatcher(domains)
|
matcher, err := NewDomainMatcher(domains)
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
acMatcher, err := NewMphMatcherGroup(domains)
|
|
||||||
common.Must(err)
|
|
||||||
|
|
||||||
type TestCase struct {
|
type TestCase struct {
|
||||||
Domain string
|
Domain string
|
||||||
Output bool
|
Output bool
|
||||||
@@ -390,96 +387,9 @@ func TestChinaSites(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
r1 := matcher.ApplyDomain(testCase.Domain)
|
r := matcher.ApplyDomain(testCase.Domain)
|
||||||
r2 := acMatcher.ApplyDomain(testCase.Domain)
|
if r != testCase.Output {
|
||||||
if r1 != testCase.Output {
|
t.Error("expected output ", testCase.Output, " for domain ", testCase.Domain, " but got ", r)
|
||||||
t.Error("DomainMatcher expected output ", testCase.Output, " for domain ", testCase.Domain, " but got ", r1)
|
|
||||||
} else if r2 != testCase.Output {
|
|
||||||
t.Error("ACDomainMatcher expected output ", testCase.Output, " for domain ", testCase.Domain, " but got ", r2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkMphDomainMatcher(b *testing.B) {
|
|
||||||
domains, err := loadGeoSite("CN")
|
|
||||||
common.Must(err)
|
|
||||||
|
|
||||||
matcher, err := NewMphMatcherGroup(domains)
|
|
||||||
common.Must(err)
|
|
||||||
|
|
||||||
type TestCase struct {
|
|
||||||
Domain string
|
|
||||||
Output bool
|
|
||||||
}
|
|
||||||
testCases := []TestCase{
|
|
||||||
{
|
|
||||||
Domain: "163.com",
|
|
||||||
Output: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Domain: "163.com",
|
|
||||||
Output: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Domain: "164.com",
|
|
||||||
Output: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Domain: "164.com",
|
|
||||||
Output: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < 1024; i++ {
|
|
||||||
testCases = append(testCases, TestCase{Domain: strconv.Itoa(i) + ".not-exists.com", Output: false})
|
|
||||||
}
|
|
||||||
|
|
||||||
b.ResetTimer()
|
|
||||||
for i := 0; i < b.N; i++ {
|
|
||||||
for _, testCase := range testCases {
|
|
||||||
_ = matcher.ApplyDomain(testCase.Domain)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkDomainMatcher(b *testing.B) {
|
|
||||||
domains, err := loadGeoSite("CN")
|
|
||||||
common.Must(err)
|
|
||||||
|
|
||||||
matcher, err := NewDomainMatcher(domains)
|
|
||||||
common.Must(err)
|
|
||||||
|
|
||||||
type TestCase struct {
|
|
||||||
Domain string
|
|
||||||
Output bool
|
|
||||||
}
|
|
||||||
testCases := []TestCase{
|
|
||||||
{
|
|
||||||
Domain: "163.com",
|
|
||||||
Output: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Domain: "163.com",
|
|
||||||
Output: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Domain: "164.com",
|
|
||||||
Output: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Domain: "164.com",
|
|
||||||
Output: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < 1024; i++ {
|
|
||||||
testCases = append(testCases, TestCase{Domain: strconv.Itoa(i) + ".not-exists.com", Output: false})
|
|
||||||
}
|
|
||||||
|
|
||||||
b.ResetTimer()
|
|
||||||
for i := 0; i < b.N; i++ {
|
|
||||||
for _, testCase := range testCases {
|
|
||||||
_ = matcher.ApplyDomain(testCase.Domain)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -67,24 +67,11 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
|
|||||||
conds := NewConditionChan()
|
conds := NewConditionChan()
|
||||||
|
|
||||||
if len(rr.Domain) > 0 {
|
if len(rr.Domain) > 0 {
|
||||||
switch rr.DomainMatcher {
|
matcher, err := NewDomainMatcher(rr.Domain)
|
||||||
case "linear":
|
if err != nil {
|
||||||
matcher, err := NewDomainMatcher(rr.Domain)
|
return nil, newError("failed to build domain condition").Base(err)
|
||||||
if err != nil {
|
|
||||||
return nil, newError("failed to build domain condition").Base(err)
|
|
||||||
}
|
|
||||||
conds.Add(matcher)
|
|
||||||
case "mph", "hybrid":
|
|
||||||
fallthrough
|
|
||||||
default:
|
|
||||||
matcher, err := NewMphMatcherGroup(rr.Domain)
|
|
||||||
if err != nil {
|
|
||||||
return nil, newError("failed to build domain condition with MphDomainMatcher").Base(err)
|
|
||||||
}
|
|
||||||
newError("MphDomainMatcher is enabled for ", len(rr.Domain), " domain rule(s)").AtDebug().WriteToLog()
|
|
||||||
conds.Add(matcher)
|
|
||||||
}
|
}
|
||||||
|
conds.Add(matcher)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(rr.UserEmail) > 0 {
|
if len(rr.UserEmail) > 0 {
|
||||||
|
@@ -1,12 +1,13 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.26.0
|
// protoc-gen-go v1.25.0
|
||||||
// protoc v3.15.8
|
// protoc v3.14.0
|
||||||
// source: app/router/config.proto
|
// source: app/router/config.proto
|
||||||
|
|
||||||
package router
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
proto "github.com/golang/protobuf/proto"
|
||||||
net "github.com/xtls/xray-core/common/net"
|
net "github.com/xtls/xray-core/common/net"
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
@@ -21,6 +22,10 @@ const (
|
|||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
_ = 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
|
||||||
|
|
||||||
// Type of domain value.
|
// Type of domain value.
|
||||||
type Domain_Type int32
|
type Domain_Type int32
|
||||||
|
|
||||||
@@ -510,7 +515,6 @@ type RoutingRule struct {
|
|||||||
InboundTag []string `protobuf:"bytes,8,rep,name=inbound_tag,json=inboundTag,proto3" json:"inbound_tag,omitempty"`
|
InboundTag []string `protobuf:"bytes,8,rep,name=inbound_tag,json=inboundTag,proto3" json:"inbound_tag,omitempty"`
|
||||||
Protocol []string `protobuf:"bytes,9,rep,name=protocol,proto3" json:"protocol,omitempty"`
|
Protocol []string `protobuf:"bytes,9,rep,name=protocol,proto3" json:"protocol,omitempty"`
|
||||||
Attributes string `protobuf:"bytes,15,opt,name=attributes,proto3" json:"attributes,omitempty"`
|
Attributes string `protobuf:"bytes,15,opt,name=attributes,proto3" json:"attributes,omitempty"`
|
||||||
DomainMatcher string `protobuf:"bytes,17,opt,name=domain_matcher,json=domainMatcher,proto3" json:"domain_matcher,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *RoutingRule) Reset() {
|
func (x *RoutingRule) Reset() {
|
||||||
@@ -668,13 +672,6 @@ func (x *RoutingRule) GetAttributes() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *RoutingRule) GetDomainMatcher() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.DomainMatcher
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type isRoutingRule_TargetTag interface {
|
type isRoutingRule_TargetTag interface {
|
||||||
isRoutingRule_TargetTag()
|
isRoutingRule_TargetTag()
|
||||||
}
|
}
|
||||||
@@ -949,7 +946,7 @@ var file_app_router_config_proto_rawDesc = []byte{
|
|||||||
0x74, 0x12, 0x2e, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b,
|
0x74, 0x12, 0x2e, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b,
|
||||||
0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74,
|
0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74,
|
||||||
0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72,
|
0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72,
|
||||||
0x79, 0x22, 0xb5, 0x06, 0x0a, 0x0b, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c,
|
0x79, 0x22, 0x8e, 0x06, 0x0a, 0x0b, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c,
|
||||||
0x65, 0x12, 0x12, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00,
|
0x65, 0x12, 0x12, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00,
|
||||||
0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x25, 0x0a, 0x0d, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69,
|
0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x25, 0x0a, 0x0d, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69,
|
||||||
0x6e, 0x67, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0c,
|
0x6e, 0x67, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0c,
|
||||||
@@ -997,38 +994,36 @@ var file_app_router_config_proto_rawDesc = []byte{
|
|||||||
0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74,
|
0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74,
|
||||||
0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74,
|
0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74,
|
||||||
0x65, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62,
|
0x65, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62,
|
||||||
0x75, 0x74, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x6d,
|
0x75, 0x74, 0x65, 0x73, 0x42, 0x0c, 0x0a, 0x0a, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x74,
|
||||||
0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x6f,
|
0x61, 0x67, 0x22, 0x4e, 0x0a, 0x0d, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52,
|
||||||
0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x42, 0x0c, 0x0a, 0x0a, 0x74,
|
0x75, 0x6c, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||||
0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x74, 0x61, 0x67, 0x22, 0x4e, 0x0a, 0x0d, 0x42, 0x61, 0x6c,
|
0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x2b, 0x0a, 0x11, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e,
|
||||||
0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61,
|
0x64, 0x5f, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09,
|
||||||
0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x2b, 0x0a, 0x11,
|
0x52, 0x10, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74,
|
||||||
0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f,
|
0x6f, 0x72, 0x22, 0x9b, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4f, 0x0a,
|
||||||
0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e,
|
0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79,
|
||||||
0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x22, 0x9b, 0x02, 0x0a, 0x06, 0x43, 0x6f,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70,
|
||||||
0x6e, 0x66, 0x69, 0x67, 0x12, 0x4f, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73,
|
0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e,
|
||||||
0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e,
|
0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e,
|
||||||
0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e,
|
0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x30,
|
||||||
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72,
|
0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78,
|
||||||
0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72,
|
0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x52,
|
||||||
0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20,
|
0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65,
|
||||||
0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72,
|
0x12, 0x45, 0x0a, 0x0e, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x75,
|
||||||
0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c,
|
0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e,
|
||||||
0x65, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x0e, 0x62, 0x61, 0x6c, 0x61, 0x6e,
|
0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e,
|
||||||
0x63, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32,
|
0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x0d, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63,
|
||||||
0x1e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65,
|
0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x47, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69,
|
||||||
0x72, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52,
|
0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x73, 0x49,
|
||||||
0x0d, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x47,
|
0x73, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x73, 0x65, 0x49, 0x70, 0x10, 0x01, 0x12, 0x10,
|
||||||
0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79,
|
0x0a, 0x0c, 0x49, 0x70, 0x49, 0x66, 0x4e, 0x6f, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x10, 0x02,
|
||||||
0x12, 0x08, 0x0a, 0x04, 0x41, 0x73, 0x49, 0x73, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x73,
|
0x12, 0x0e, 0x0a, 0x0a, 0x49, 0x70, 0x4f, 0x6e, 0x44, 0x65, 0x6d, 0x61, 0x6e, 0x64, 0x10, 0x03,
|
||||||
0x65, 0x49, 0x70, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x70, 0x49, 0x66, 0x4e, 0x6f, 0x6e,
|
0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70,
|
||||||
0x4d, 0x61, 0x74, 0x63, 0x68, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x49, 0x70, 0x4f, 0x6e, 0x44,
|
0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x50, 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75,
|
||||||
0x65, 0x6d, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78,
|
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d,
|
||||||
0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x50, 0x01,
|
0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0xaa,
|
||||||
0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c,
|
0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65,
|
||||||
0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f,
|
0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0xaa, 0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70,
|
|
||||||
0x70, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@@ -119,8 +119,6 @@ message RoutingRule {
|
|||||||
repeated string protocol = 9;
|
repeated string protocol = 9;
|
||||||
|
|
||||||
string attributes = 15;
|
string attributes = 15;
|
||||||
|
|
||||||
string domain_matcher = 17;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message BalancingRule {
|
message BalancingRule {
|
||||||
|
@@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/session"
|
"github.com/xtls/xray-core/common/session"
|
||||||
"github.com/xtls/xray-core/features/dns"
|
|
||||||
"github.com/xtls/xray-core/features/outbound"
|
"github.com/xtls/xray-core/features/outbound"
|
||||||
routing_session "github.com/xtls/xray-core/features/routing/session"
|
routing_session "github.com/xtls/xray-core/features/routing/session"
|
||||||
"github.com/xtls/xray-core/testing/mocks"
|
"github.com/xtls/xray-core/testing/mocks"
|
||||||
@@ -116,11 +115,7 @@ func TestIPOnDemand(t *testing.T) {
|
|||||||
defer mockCtl.Finish()
|
defer mockCtl.Finish()
|
||||||
|
|
||||||
mockDNS := mocks.NewDNSClient(mockCtl)
|
mockDNS := mocks.NewDNSClient(mockCtl)
|
||||||
mockDNS.EXPECT().LookupIP(gomock.Eq("example.com"), dns.IPOption{
|
mockDNS.EXPECT().LookupIP(gomock.Eq("example.com")).Return([]net.IP{{192, 168, 0, 1}}, nil).AnyTimes()
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
}).Return([]net.IP{{192, 168, 0, 1}}, nil).AnyTimes()
|
|
||||||
|
|
||||||
r := new(Router)
|
r := new(Router)
|
||||||
common.Must(r.Init(config, mockDNS, nil))
|
common.Must(r.Init(config, mockDNS, nil))
|
||||||
@@ -155,11 +150,7 @@ func TestIPIfNonMatchDomain(t *testing.T) {
|
|||||||
defer mockCtl.Finish()
|
defer mockCtl.Finish()
|
||||||
|
|
||||||
mockDNS := mocks.NewDNSClient(mockCtl)
|
mockDNS := mocks.NewDNSClient(mockCtl)
|
||||||
mockDNS.EXPECT().LookupIP(gomock.Eq("example.com"), dns.IPOption{
|
mockDNS.EXPECT().LookupIP(gomock.Eq("example.com")).Return([]net.IP{{192, 168, 0, 1}}, nil).AnyTimes()
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
}).Return([]net.IP{{192, 168, 0, 1}}, nil).AnyTimes()
|
|
||||||
|
|
||||||
r := new(Router)
|
r := new(Router)
|
||||||
common.Must(r.Init(config, mockDNS, nil))
|
common.Must(r.Init(config, mockDNS, nil))
|
||||||
|
@@ -31,22 +31,6 @@ func New() *Buffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewExisted(b []byte) *Buffer {
|
|
||||||
if cap(b) < Size {
|
|
||||||
panic("Invalid buffer")
|
|
||||||
}
|
|
||||||
|
|
||||||
oLen := len(b)
|
|
||||||
if oLen < Size {
|
|
||||||
b = b[:Size]
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Buffer{
|
|
||||||
v: b,
|
|
||||||
end: int32(oLen),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// StackNew creates a new Buffer object on stack.
|
// StackNew creates a new Buffer object on stack.
|
||||||
// This method is for buffers that is released in the same function.
|
// This method is for buffers that is released in the same function.
|
||||||
func StackNew() Buffer {
|
func StackNew() Buffer {
|
||||||
|
85
common/cache/lru.go
vendored
85
common/cache/lru.go
vendored
@@ -1,85 +0,0 @@
|
|||||||
package cache
|
|
||||||
|
|
||||||
import (
|
|
||||||
"container/list"
|
|
||||||
sync "sync"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Lru simple, fast lru cache implementation
|
|
||||||
type Lru interface {
|
|
||||||
Get(key interface{}) (value interface{}, ok bool)
|
|
||||||
GetKeyFromValue(value interface{}) (key interface{}, ok bool)
|
|
||||||
PeekKeyFromValue(value interface{}) (key interface{}, ok bool) // Peek means check but NOT bring to top
|
|
||||||
Put(key, value interface{})
|
|
||||||
}
|
|
||||||
|
|
||||||
type lru struct {
|
|
||||||
capacity int
|
|
||||||
doubleLinkedlist *list.List
|
|
||||||
keyToElement *sync.Map
|
|
||||||
valueToElement *sync.Map
|
|
||||||
mu *sync.Mutex
|
|
||||||
}
|
|
||||||
|
|
||||||
type lruElement struct {
|
|
||||||
key interface{}
|
|
||||||
value interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewLru init a lru cache
|
|
||||||
func NewLru(cap int) Lru {
|
|
||||||
return lru{
|
|
||||||
capacity: cap,
|
|
||||||
doubleLinkedlist: list.New(),
|
|
||||||
keyToElement: new(sync.Map),
|
|
||||||
valueToElement: new(sync.Map),
|
|
||||||
mu: new(sync.Mutex),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l lru) Get(key interface{}) (value interface{}, ok bool) {
|
|
||||||
if v, ok := l.keyToElement.Load(key); ok {
|
|
||||||
element := v.(*list.Element)
|
|
||||||
l.doubleLinkedlist.MoveBefore(element, l.doubleLinkedlist.Front())
|
|
||||||
return element.Value.(lruElement).value, true
|
|
||||||
}
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l lru) GetKeyFromValue(value interface{}) (key interface{}, ok bool) {
|
|
||||||
if k, ok := l.valueToElement.Load(value); ok {
|
|
||||||
element := k.(*list.Element)
|
|
||||||
l.doubleLinkedlist.MoveBefore(element, l.doubleLinkedlist.Front())
|
|
||||||
return element.Value.(lruElement).key, true
|
|
||||||
}
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l lru) PeekKeyFromValue(value interface{}) (key interface{}, ok bool) {
|
|
||||||
if k, ok := l.valueToElement.Load(value); ok {
|
|
||||||
element := k.(*list.Element)
|
|
||||||
return element.Value.(lruElement).key, true
|
|
||||||
}
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l lru) Put(key, value interface{}) {
|
|
||||||
e := lruElement{key, value}
|
|
||||||
if v, ok := l.keyToElement.Load(key); ok {
|
|
||||||
element := v.(*list.Element)
|
|
||||||
element.Value = e
|
|
||||||
l.doubleLinkedlist.MoveBefore(element, l.doubleLinkedlist.Front())
|
|
||||||
} else {
|
|
||||||
l.mu.Lock()
|
|
||||||
element := l.doubleLinkedlist.PushFront(e)
|
|
||||||
l.keyToElement.Store(key, element)
|
|
||||||
l.valueToElement.Store(value, element)
|
|
||||||
if l.doubleLinkedlist.Len() > l.capacity {
|
|
||||||
toBeRemove := l.doubleLinkedlist.Back()
|
|
||||||
l.doubleLinkedlist.Remove(toBeRemove)
|
|
||||||
l.keyToElement.Delete(toBeRemove.Value.(lruElement).key)
|
|
||||||
l.valueToElement.Delete(toBeRemove.Value.(lruElement).value)
|
|
||||||
}
|
|
||||||
l.mu.Unlock()
|
|
||||||
}
|
|
||||||
}
|
|
86
common/cache/lru_test.go
vendored
86
common/cache/lru_test.go
vendored
@@ -1,86 +0,0 @@
|
|||||||
package cache_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
. "github.com/xtls/xray-core/common/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestLruReplaceValue(t *testing.T) {
|
|
||||||
lru := NewLru(2)
|
|
||||||
lru.Put(2, 6)
|
|
||||||
lru.Put(1, 5)
|
|
||||||
lru.Put(1, 2)
|
|
||||||
v, _ := lru.Get(1)
|
|
||||||
if v != 2 {
|
|
||||||
t.Error("should get 2", v)
|
|
||||||
}
|
|
||||||
v, _ = lru.Get(2)
|
|
||||||
if v != 6 {
|
|
||||||
t.Error("should get 6", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLruRemoveOld(t *testing.T) {
|
|
||||||
lru := NewLru(2)
|
|
||||||
v, ok := lru.Get(2)
|
|
||||||
if ok {
|
|
||||||
t.Error("should get nil", v)
|
|
||||||
}
|
|
||||||
lru.Put(1, 1)
|
|
||||||
lru.Put(2, 2)
|
|
||||||
v, _ = lru.Get(1)
|
|
||||||
if v != 1 {
|
|
||||||
t.Error("should get 1", v)
|
|
||||||
}
|
|
||||||
lru.Put(3, 3)
|
|
||||||
v, ok = lru.Get(2)
|
|
||||||
if ok {
|
|
||||||
t.Error("should get nil", v)
|
|
||||||
}
|
|
||||||
lru.Put(4, 4)
|
|
||||||
v, ok = lru.Get(1)
|
|
||||||
if ok {
|
|
||||||
t.Error("should get nil", v)
|
|
||||||
}
|
|
||||||
v, _ = lru.Get(3)
|
|
||||||
if v != 3 {
|
|
||||||
t.Error("should get 3", v)
|
|
||||||
}
|
|
||||||
v, _ = lru.Get(4)
|
|
||||||
if v != 4 {
|
|
||||||
t.Error("should get 4", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetKeyFromValue(t *testing.T) {
|
|
||||||
lru := NewLru(2)
|
|
||||||
lru.Put(3, 3)
|
|
||||||
lru.Put(2, 2)
|
|
||||||
lru.GetKeyFromValue(3)
|
|
||||||
lru.Put(1, 1)
|
|
||||||
v, ok := lru.GetKeyFromValue(2)
|
|
||||||
if ok {
|
|
||||||
t.Error("should get nil", v)
|
|
||||||
}
|
|
||||||
v, _ = lru.GetKeyFromValue(3)
|
|
||||||
if v != 3 {
|
|
||||||
t.Error("should get 3", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPeekKeyFromValue(t *testing.T) {
|
|
||||||
lru := NewLru(2)
|
|
||||||
lru.Put(3, 3)
|
|
||||||
lru.Put(2, 2)
|
|
||||||
lru.PeekKeyFromValue(3)
|
|
||||||
lru.Put(1, 1)
|
|
||||||
v, ok := lru.PeekKeyFromValue(3)
|
|
||||||
if ok {
|
|
||||||
t.Error("should get nil", v)
|
|
||||||
}
|
|
||||||
v, _ = lru.PeekKeyFromValue(2)
|
|
||||||
if v != 2 {
|
|
||||||
t.Error("should get 2", v)
|
|
||||||
}
|
|
||||||
}
|
|
@@ -40,8 +40,10 @@ func (err *Error) pkgPath() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
path := reflect.TypeOf(err.pathObj).PkgPath()
|
path := reflect.TypeOf(err.pathObj).PkgPath()
|
||||||
if len(path) >= trim {
|
for i := 0; i < len(path); i++ {
|
||||||
return path[trim:]
|
if path[i] == '/' {
|
||||||
|
return path[trim:]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
@@ -1,59 +0,0 @@
|
|||||||
package log
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DNSLog struct {
|
|
||||||
Server string
|
|
||||||
Domain string
|
|
||||||
Result []net.IP
|
|
||||||
Status dnsStatus
|
|
||||||
Elapsed time.Duration
|
|
||||||
Error error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *DNSLog) String() string {
|
|
||||||
builder := &strings.Builder{}
|
|
||||||
|
|
||||||
// Server got answer: domain -> [ip1, ip2] 23ms
|
|
||||||
builder.WriteString(l.Server)
|
|
||||||
builder.WriteString(" ")
|
|
||||||
builder.WriteString(string(l.Status))
|
|
||||||
builder.WriteString(" ")
|
|
||||||
builder.WriteString(l.Domain)
|
|
||||||
builder.WriteString(" -> [")
|
|
||||||
builder.WriteString(joinNetIP(l.Result))
|
|
||||||
builder.WriteString("]")
|
|
||||||
|
|
||||||
if l.Elapsed > 0 {
|
|
||||||
builder.WriteString(" ")
|
|
||||||
builder.WriteString(l.Elapsed.String())
|
|
||||||
}
|
|
||||||
if l.Error != nil {
|
|
||||||
builder.WriteString(" <")
|
|
||||||
builder.WriteString(l.Error.Error())
|
|
||||||
builder.WriteString(">")
|
|
||||||
}
|
|
||||||
return builder.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
type dnsStatus string
|
|
||||||
|
|
||||||
var (
|
|
||||||
DNSQueried = dnsStatus("got answer:")
|
|
||||||
DNSCacheHit = dnsStatus("cache HIT:")
|
|
||||||
)
|
|
||||||
|
|
||||||
func joinNetIP(ips []net.IP) string {
|
|
||||||
if len(ips) == 0 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
sips := make([]string, 0, len(ips))
|
|
||||||
for _, ip := range ips {
|
|
||||||
sips = append(sips, ip.String())
|
|
||||||
}
|
|
||||||
return strings.Join(sips, ", ")
|
|
||||||
}
|
|
@@ -102,7 +102,7 @@ func ReadClientHello(data []byte, h *SniffHeader) error {
|
|||||||
return errNotClientHello
|
return errNotClientHello
|
||||||
}
|
}
|
||||||
if nameType == 0 {
|
if nameType == 0 {
|
||||||
serverName := string(d[:nameLen])
|
serverName := strings.ToLower(string(d[:nameLen]))
|
||||||
// An SNI value may not include a
|
// An SNI value may not include a
|
||||||
// trailing dot. See
|
// trailing dot. See
|
||||||
// https://tools.ietf.org/html/rfc6066#section-3.
|
// https://tools.ietf.org/html/rfc6066#section-3.
|
||||||
|
@@ -63,7 +63,6 @@ type SniffingRequest struct {
|
|||||||
ExcludeForDomain []string
|
ExcludeForDomain []string
|
||||||
OverrideDestinationForProtocol []string
|
OverrideDestinationForProtocol []string
|
||||||
Enabled bool
|
Enabled bool
|
||||||
MetadataOnly bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Content is the metadata of the connection content.
|
// Content is the metadata of the connection content.
|
||||||
|
@@ -1,243 +0,0 @@
|
|||||||
package strmatcher
|
|
||||||
|
|
||||||
import (
|
|
||||||
"container/list"
|
|
||||||
)
|
|
||||||
|
|
||||||
const validCharCount = 53
|
|
||||||
|
|
||||||
type MatchType struct {
|
|
||||||
matchType Type
|
|
||||||
exist bool
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
TrieEdge bool = true
|
|
||||||
FailEdge bool = false
|
|
||||||
)
|
|
||||||
|
|
||||||
type Edge struct {
|
|
||||||
edgeType bool
|
|
||||||
nextNode int
|
|
||||||
}
|
|
||||||
|
|
||||||
type ACAutomaton struct {
|
|
||||||
trie [][validCharCount]Edge
|
|
||||||
fail []int
|
|
||||||
exists []MatchType
|
|
||||||
count int
|
|
||||||
}
|
|
||||||
|
|
||||||
func newNode() [validCharCount]Edge {
|
|
||||||
var s [validCharCount]Edge
|
|
||||||
for i := range s {
|
|
||||||
s[i] = Edge{
|
|
||||||
edgeType: FailEdge,
|
|
||||||
nextNode: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
var char2Index = []int{
|
|
||||||
'A': 0,
|
|
||||||
'a': 0,
|
|
||||||
'B': 1,
|
|
||||||
'b': 1,
|
|
||||||
'C': 2,
|
|
||||||
'c': 2,
|
|
||||||
'D': 3,
|
|
||||||
'd': 3,
|
|
||||||
'E': 4,
|
|
||||||
'e': 4,
|
|
||||||
'F': 5,
|
|
||||||
'f': 5,
|
|
||||||
'G': 6,
|
|
||||||
'g': 6,
|
|
||||||
'H': 7,
|
|
||||||
'h': 7,
|
|
||||||
'I': 8,
|
|
||||||
'i': 8,
|
|
||||||
'J': 9,
|
|
||||||
'j': 9,
|
|
||||||
'K': 10,
|
|
||||||
'k': 10,
|
|
||||||
'L': 11,
|
|
||||||
'l': 11,
|
|
||||||
'M': 12,
|
|
||||||
'm': 12,
|
|
||||||
'N': 13,
|
|
||||||
'n': 13,
|
|
||||||
'O': 14,
|
|
||||||
'o': 14,
|
|
||||||
'P': 15,
|
|
||||||
'p': 15,
|
|
||||||
'Q': 16,
|
|
||||||
'q': 16,
|
|
||||||
'R': 17,
|
|
||||||
'r': 17,
|
|
||||||
'S': 18,
|
|
||||||
's': 18,
|
|
||||||
'T': 19,
|
|
||||||
't': 19,
|
|
||||||
'U': 20,
|
|
||||||
'u': 20,
|
|
||||||
'V': 21,
|
|
||||||
'v': 21,
|
|
||||||
'W': 22,
|
|
||||||
'w': 22,
|
|
||||||
'X': 23,
|
|
||||||
'x': 23,
|
|
||||||
'Y': 24,
|
|
||||||
'y': 24,
|
|
||||||
'Z': 25,
|
|
||||||
'z': 25,
|
|
||||||
'!': 26,
|
|
||||||
'$': 27,
|
|
||||||
'&': 28,
|
|
||||||
'\'': 29,
|
|
||||||
'(': 30,
|
|
||||||
')': 31,
|
|
||||||
'*': 32,
|
|
||||||
'+': 33,
|
|
||||||
',': 34,
|
|
||||||
';': 35,
|
|
||||||
'=': 36,
|
|
||||||
':': 37,
|
|
||||||
'%': 38,
|
|
||||||
'-': 39,
|
|
||||||
'.': 40,
|
|
||||||
'_': 41,
|
|
||||||
'~': 42,
|
|
||||||
'0': 43,
|
|
||||||
'1': 44,
|
|
||||||
'2': 45,
|
|
||||||
'3': 46,
|
|
||||||
'4': 47,
|
|
||||||
'5': 48,
|
|
||||||
'6': 49,
|
|
||||||
'7': 50,
|
|
||||||
'8': 51,
|
|
||||||
'9': 52,
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewACAutomaton() *ACAutomaton {
|
|
||||||
var ac = new(ACAutomaton)
|
|
||||||
ac.trie = append(ac.trie, newNode())
|
|
||||||
ac.fail = append(ac.fail, 0)
|
|
||||||
ac.exists = append(ac.exists, MatchType{
|
|
||||||
matchType: Full,
|
|
||||||
exist: false,
|
|
||||||
})
|
|
||||||
return ac
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ac *ACAutomaton) Add(domain string, t Type) {
|
|
||||||
var node = 0
|
|
||||||
for i := len(domain) - 1; i >= 0; i-- {
|
|
||||||
var idx = char2Index[domain[i]]
|
|
||||||
if ac.trie[node][idx].nextNode == 0 {
|
|
||||||
ac.count++
|
|
||||||
if len(ac.trie) < ac.count+1 {
|
|
||||||
ac.trie = append(ac.trie, newNode())
|
|
||||||
ac.fail = append(ac.fail, 0)
|
|
||||||
ac.exists = append(ac.exists, MatchType{
|
|
||||||
matchType: Full,
|
|
||||||
exist: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
ac.trie[node][idx] = Edge{
|
|
||||||
edgeType: TrieEdge,
|
|
||||||
nextNode: ac.count,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
node = ac.trie[node][idx].nextNode
|
|
||||||
}
|
|
||||||
ac.exists[node] = MatchType{
|
|
||||||
matchType: t,
|
|
||||||
exist: true,
|
|
||||||
}
|
|
||||||
switch t {
|
|
||||||
case Domain:
|
|
||||||
ac.exists[node] = MatchType{
|
|
||||||
matchType: Full,
|
|
||||||
exist: true,
|
|
||||||
}
|
|
||||||
var idx = char2Index['.']
|
|
||||||
if ac.trie[node][idx].nextNode == 0 {
|
|
||||||
ac.count++
|
|
||||||
if len(ac.trie) < ac.count+1 {
|
|
||||||
ac.trie = append(ac.trie, newNode())
|
|
||||||
ac.fail = append(ac.fail, 0)
|
|
||||||
ac.exists = append(ac.exists, MatchType{
|
|
||||||
matchType: Full,
|
|
||||||
exist: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
ac.trie[node][idx] = Edge{
|
|
||||||
edgeType: TrieEdge,
|
|
||||||
nextNode: ac.count,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
node = ac.trie[node][idx].nextNode
|
|
||||||
ac.exists[node] = MatchType{
|
|
||||||
matchType: t,
|
|
||||||
exist: true,
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ac *ACAutomaton) Build() {
|
|
||||||
var queue = list.New()
|
|
||||||
for i := 0; i < validCharCount; i++ {
|
|
||||||
if ac.trie[0][i].nextNode != 0 {
|
|
||||||
queue.PushBack(ac.trie[0][i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for {
|
|
||||||
var front = queue.Front()
|
|
||||||
if front == nil {
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
var node = front.Value.(Edge).nextNode
|
|
||||||
queue.Remove(front)
|
|
||||||
for i := 0; i < validCharCount; i++ {
|
|
||||||
if ac.trie[node][i].nextNode != 0 {
|
|
||||||
ac.fail[ac.trie[node][i].nextNode] = ac.trie[ac.fail[node]][i].nextNode
|
|
||||||
queue.PushBack(ac.trie[node][i])
|
|
||||||
} else {
|
|
||||||
ac.trie[node][i] = Edge{
|
|
||||||
edgeType: FailEdge,
|
|
||||||
nextNode: ac.trie[ac.fail[node]][i].nextNode,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ac *ACAutomaton) Match(s string) bool {
|
|
||||||
var node = 0
|
|
||||||
var fullMatch = true
|
|
||||||
// 1. the match string is all through trie edge. FULL MATCH or DOMAIN
|
|
||||||
// 2. the match string is through a fail edge. NOT FULL MATCH
|
|
||||||
// 2.1 Through a fail edge, but there exists a valid node. SUBSTR
|
|
||||||
for i := len(s) - 1; i >= 0; i-- {
|
|
||||||
var idx = char2Index[s[i]]
|
|
||||||
fullMatch = fullMatch && ac.trie[node][idx].edgeType
|
|
||||||
node = ac.trie[node][idx].nextNode
|
|
||||||
switch ac.exists[node].matchType {
|
|
||||||
case Substr:
|
|
||||||
return true
|
|
||||||
case Domain:
|
|
||||||
if fullMatch {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fullMatch && ac.exists[node].exist
|
|
||||||
}
|
|
@@ -8,19 +8,6 @@ import (
|
|||||||
. "github.com/xtls/xray-core/common/strmatcher"
|
. "github.com/xtls/xray-core/common/strmatcher"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BenchmarkACAutomaton(b *testing.B) {
|
|
||||||
ac := NewACAutomaton()
|
|
||||||
for i := 1; i <= 1024; i++ {
|
|
||||||
ac.Add(strconv.Itoa(i)+".v2ray.com", Domain)
|
|
||||||
}
|
|
||||||
ac.Build()
|
|
||||||
|
|
||||||
b.ResetTimer()
|
|
||||||
for i := 0; i < b.N; i++ {
|
|
||||||
_ = ac.Match("0.v2ray.com")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkDomainMatcherGroup(b *testing.B) {
|
func BenchmarkDomainMatcherGroup(b *testing.B) {
|
||||||
g := new(DomainMatcherGroup)
|
g := new(DomainMatcherGroup)
|
||||||
|
|
||||||
|
@@ -1,301 +0,0 @@
|
|||||||
package strmatcher
|
|
||||||
|
|
||||||
import (
|
|
||||||
"math/bits"
|
|
||||||
"regexp"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PrimeRK is the prime base used in Rabin-Karp algorithm.
|
|
||||||
const PrimeRK = 16777619
|
|
||||||
|
|
||||||
// calculate the rolling murmurHash of given string
|
|
||||||
func RollingHash(s string) uint32 {
|
|
||||||
h := uint32(0)
|
|
||||||
for i := len(s) - 1; i >= 0; i-- {
|
|
||||||
h = h*PrimeRK + uint32(s[i])
|
|
||||||
}
|
|
||||||
return h
|
|
||||||
}
|
|
||||||
|
|
||||||
// A MphMatcherGroup is divided into three parts:
|
|
||||||
// 1. `full` and `domain` patterns are matched by Rabin-Karp algorithm and minimal perfect hash table;
|
|
||||||
// 2. `substr` patterns are matched by ac automaton;
|
|
||||||
// 3. `regex` patterns are matched with the regex library.
|
|
||||||
type MphMatcherGroup struct {
|
|
||||||
ac *ACAutomaton
|
|
||||||
otherMatchers []matcherEntry
|
|
||||||
rules []string
|
|
||||||
level0 []uint32
|
|
||||||
level0Mask int
|
|
||||||
level1 []uint32
|
|
||||||
level1Mask int
|
|
||||||
count uint32
|
|
||||||
ruleMap *map[string]uint32
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *MphMatcherGroup) AddFullOrDomainPattern(pattern string, t Type) {
|
|
||||||
h := RollingHash(pattern)
|
|
||||||
switch t {
|
|
||||||
case Domain:
|
|
||||||
(*g.ruleMap)["."+pattern] = h*PrimeRK + uint32('.')
|
|
||||||
fallthrough
|
|
||||||
case Full:
|
|
||||||
(*g.ruleMap)[pattern] = h
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewMphMatcherGroup() *MphMatcherGroup {
|
|
||||||
return &MphMatcherGroup{
|
|
||||||
ac: nil,
|
|
||||||
otherMatchers: nil,
|
|
||||||
rules: nil,
|
|
||||||
level0: nil,
|
|
||||||
level0Mask: 0,
|
|
||||||
level1: nil,
|
|
||||||
level1Mask: 0,
|
|
||||||
count: 1,
|
|
||||||
ruleMap: &map[string]uint32{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddPattern adds a pattern to MphMatcherGroup
|
|
||||||
func (g *MphMatcherGroup) AddPattern(pattern string, t Type) (uint32, error) {
|
|
||||||
switch t {
|
|
||||||
case Substr:
|
|
||||||
if g.ac == nil {
|
|
||||||
g.ac = NewACAutomaton()
|
|
||||||
}
|
|
||||||
g.ac.Add(pattern, t)
|
|
||||||
case Full, Domain:
|
|
||||||
pattern = strings.ToLower(pattern)
|
|
||||||
g.AddFullOrDomainPattern(pattern, t)
|
|
||||||
case Regex:
|
|
||||||
r, err := regexp.Compile(pattern)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
g.otherMatchers = append(g.otherMatchers, matcherEntry{
|
|
||||||
m: ®exMatcher{pattern: r},
|
|
||||||
id: g.count,
|
|
||||||
})
|
|
||||||
default:
|
|
||||||
panic("Unknown type")
|
|
||||||
}
|
|
||||||
return g.count, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build builds a minimal perfect hash table and ac automaton from insert rules
|
|
||||||
func (g *MphMatcherGroup) Build() {
|
|
||||||
if g.ac != nil {
|
|
||||||
g.ac.Build()
|
|
||||||
}
|
|
||||||
keyLen := len(*g.ruleMap)
|
|
||||||
if keyLen == 0 {
|
|
||||||
keyLen = 1
|
|
||||||
(*g.ruleMap)["empty___"] = RollingHash("empty___")
|
|
||||||
}
|
|
||||||
g.level0 = make([]uint32, nextPow2(keyLen/4))
|
|
||||||
g.level0Mask = len(g.level0) - 1
|
|
||||||
g.level1 = make([]uint32, nextPow2(keyLen))
|
|
||||||
g.level1Mask = len(g.level1) - 1
|
|
||||||
var sparseBuckets = make([][]int, len(g.level0))
|
|
||||||
var ruleIdx int
|
|
||||||
for rule, hash := range *g.ruleMap {
|
|
||||||
n := int(hash) & g.level0Mask
|
|
||||||
g.rules = append(g.rules, rule)
|
|
||||||
sparseBuckets[n] = append(sparseBuckets[n], ruleIdx)
|
|
||||||
ruleIdx++
|
|
||||||
}
|
|
||||||
g.ruleMap = nil
|
|
||||||
var buckets []indexBucket
|
|
||||||
for n, vals := range sparseBuckets {
|
|
||||||
if len(vals) > 0 {
|
|
||||||
buckets = append(buckets, indexBucket{n, vals})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sort.Sort(bySize(buckets))
|
|
||||||
|
|
||||||
occ := make([]bool, len(g.level1))
|
|
||||||
var tmpOcc []int
|
|
||||||
for _, bucket := range buckets {
|
|
||||||
var seed = uint32(0)
|
|
||||||
for {
|
|
||||||
findSeed := true
|
|
||||||
tmpOcc = tmpOcc[:0]
|
|
||||||
for _, i := range bucket.vals {
|
|
||||||
n := int(strhashFallback(unsafe.Pointer(&g.rules[i]), uintptr(seed))) & g.level1Mask
|
|
||||||
if occ[n] {
|
|
||||||
for _, n := range tmpOcc {
|
|
||||||
occ[n] = false
|
|
||||||
}
|
|
||||||
seed++
|
|
||||||
findSeed = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
occ[n] = true
|
|
||||||
tmpOcc = append(tmpOcc, n)
|
|
||||||
g.level1[n] = uint32(i)
|
|
||||||
}
|
|
||||||
if findSeed {
|
|
||||||
g.level0[bucket.n] = seed
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func nextPow2(v int) int {
|
|
||||||
if v <= 1 {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
const MaxUInt = ^uint(0)
|
|
||||||
n := (MaxUInt >> bits.LeadingZeros(uint(v))) + 1
|
|
||||||
return int(n)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lookup searches for s in t and returns its index and whether it was found.
|
|
||||||
func (g *MphMatcherGroup) Lookup(h uint32, s string) bool {
|
|
||||||
i0 := int(h) & g.level0Mask
|
|
||||||
seed := g.level0[i0]
|
|
||||||
i1 := int(strhashFallback(unsafe.Pointer(&s), uintptr(seed))) & g.level1Mask
|
|
||||||
n := g.level1[i1]
|
|
||||||
return s == g.rules[int(n)]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Match implements IndexMatcher.Match.
|
|
||||||
func (g *MphMatcherGroup) Match(pattern string) []uint32 {
|
|
||||||
result := []uint32{}
|
|
||||||
hash := uint32(0)
|
|
||||||
for i := len(pattern) - 1; i >= 0; i-- {
|
|
||||||
hash = hash*PrimeRK + uint32(pattern[i])
|
|
||||||
if pattern[i] == '.' {
|
|
||||||
if g.Lookup(hash, pattern[i:]) {
|
|
||||||
result = append(result, 1)
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if g.Lookup(hash, pattern) {
|
|
||||||
result = append(result, 1)
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
if g.ac != nil && g.ac.Match(pattern) {
|
|
||||||
result = append(result, 1)
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
for _, e := range g.otherMatchers {
|
|
||||||
if e.m.Match(pattern) {
|
|
||||||
result = append(result, e.id)
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type indexBucket struct {
|
|
||||||
n int
|
|
||||||
vals []int
|
|
||||||
}
|
|
||||||
|
|
||||||
type bySize []indexBucket
|
|
||||||
|
|
||||||
func (s bySize) Len() int { return len(s) }
|
|
||||||
func (s bySize) Less(i, j int) bool { return len(s[i].vals) > len(s[j].vals) }
|
|
||||||
func (s bySize) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
|
||||||
|
|
||||||
type stringStruct struct {
|
|
||||||
str unsafe.Pointer
|
|
||||||
len int
|
|
||||||
}
|
|
||||||
|
|
||||||
func strhashFallback(a unsafe.Pointer, h uintptr) uintptr {
|
|
||||||
x := (*stringStruct)(a)
|
|
||||||
return memhashFallback(x.str, h, uintptr(x.len))
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Constants for multiplication: four random odd 64-bit numbers.
|
|
||||||
m1 = 16877499708836156737
|
|
||||||
m2 = 2820277070424839065
|
|
||||||
m3 = 9497967016996688599
|
|
||||||
m4 = 15839092249703872147
|
|
||||||
)
|
|
||||||
|
|
||||||
var hashkey = [4]uintptr{1, 1, 1, 1}
|
|
||||||
|
|
||||||
func memhashFallback(p unsafe.Pointer, seed, s uintptr) uintptr {
|
|
||||||
h := uint64(seed + s*hashkey[0])
|
|
||||||
tail:
|
|
||||||
switch {
|
|
||||||
case s == 0:
|
|
||||||
case s < 4:
|
|
||||||
h ^= uint64(*(*byte)(p))
|
|
||||||
h ^= uint64(*(*byte)(add(p, s>>1))) << 8
|
|
||||||
h ^= uint64(*(*byte)(add(p, s-1))) << 16
|
|
||||||
h = rotl31(h*m1) * m2
|
|
||||||
case s <= 8:
|
|
||||||
h ^= uint64(readUnaligned32(p))
|
|
||||||
h ^= uint64(readUnaligned32(add(p, s-4))) << 32
|
|
||||||
h = rotl31(h*m1) * m2
|
|
||||||
case s <= 16:
|
|
||||||
h ^= readUnaligned64(p)
|
|
||||||
h = rotl31(h*m1) * m2
|
|
||||||
h ^= readUnaligned64(add(p, s-8))
|
|
||||||
h = rotl31(h*m1) * m2
|
|
||||||
case s <= 32:
|
|
||||||
h ^= readUnaligned64(p)
|
|
||||||
h = rotl31(h*m1) * m2
|
|
||||||
h ^= readUnaligned64(add(p, 8))
|
|
||||||
h = rotl31(h*m1) * m2
|
|
||||||
h ^= readUnaligned64(add(p, s-16))
|
|
||||||
h = rotl31(h*m1) * m2
|
|
||||||
h ^= readUnaligned64(add(p, s-8))
|
|
||||||
h = rotl31(h*m1) * m2
|
|
||||||
default:
|
|
||||||
v1 := h
|
|
||||||
v2 := uint64(seed * hashkey[1])
|
|
||||||
v3 := uint64(seed * hashkey[2])
|
|
||||||
v4 := uint64(seed * hashkey[3])
|
|
||||||
for s >= 32 {
|
|
||||||
v1 ^= readUnaligned64(p)
|
|
||||||
v1 = rotl31(v1*m1) * m2
|
|
||||||
p = add(p, 8)
|
|
||||||
v2 ^= readUnaligned64(p)
|
|
||||||
v2 = rotl31(v2*m2) * m3
|
|
||||||
p = add(p, 8)
|
|
||||||
v3 ^= readUnaligned64(p)
|
|
||||||
v3 = rotl31(v3*m3) * m4
|
|
||||||
p = add(p, 8)
|
|
||||||
v4 ^= readUnaligned64(p)
|
|
||||||
v4 = rotl31(v4*m4) * m1
|
|
||||||
p = add(p, 8)
|
|
||||||
s -= 32
|
|
||||||
}
|
|
||||||
h = v1 ^ v2 ^ v3 ^ v4
|
|
||||||
goto tail
|
|
||||||
}
|
|
||||||
|
|
||||||
h ^= h >> 29
|
|
||||||
h *= m3
|
|
||||||
h ^= h >> 32
|
|
||||||
return uintptr(h)
|
|
||||||
}
|
|
||||||
func add(p unsafe.Pointer, x uintptr) unsafe.Pointer {
|
|
||||||
return unsafe.Pointer(uintptr(p) + x)
|
|
||||||
}
|
|
||||||
func readUnaligned32(p unsafe.Pointer) uint32 {
|
|
||||||
q := (*[4]byte)(p)
|
|
||||||
return uint32(q[0]) | uint32(q[1])<<8 | uint32(q[2])<<16 | uint32(q[3])<<24
|
|
||||||
}
|
|
||||||
|
|
||||||
func rotl31(x uint64) uint64 {
|
|
||||||
return (x << 31) | (x >> (64 - 31))
|
|
||||||
}
|
|
||||||
func readUnaligned64(p unsafe.Pointer) uint64 {
|
|
||||||
q := (*[8]byte)(p)
|
|
||||||
return uint64(q[0]) | uint64(q[1])<<8 | uint64(q[2])<<16 | uint64(q[3])<<24 | uint64(q[4])<<32 | uint64(q[5])<<40 | uint64(q[6])<<48 | uint64(q[7])<<56
|
|
||||||
}
|
|
@@ -27,7 +27,6 @@ const (
|
|||||||
|
|
||||||
// New creates a new Matcher based on the given pattern.
|
// New creates a new Matcher based on the given pattern.
|
||||||
func (t Type) New(pattern string) (Matcher, error) {
|
func (t Type) New(pattern string) (Matcher, error) {
|
||||||
// 1. regex matching is case-sensitive
|
|
||||||
switch t {
|
switch t {
|
||||||
case Full:
|
case Full:
|
||||||
return fullMatcher(pattern), nil
|
return fullMatcher(pattern), nil
|
||||||
|
@@ -91,172 +91,3 @@ func TestMatcherGroup(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestACAutomaton(t *testing.T) {
|
|
||||||
cases1 := []struct {
|
|
||||||
pattern string
|
|
||||||
mType Type
|
|
||||||
input string
|
|
||||||
output bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
pattern: "xtls.github.io",
|
|
||||||
mType: Domain,
|
|
||||||
input: "www.xtls.github.io",
|
|
||||||
output: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "xtls.github.io",
|
|
||||||
mType: Domain,
|
|
||||||
input: "xtls.github.io",
|
|
||||||
output: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "xtls.github.io",
|
|
||||||
mType: Domain,
|
|
||||||
input: "www.xtis.github.io",
|
|
||||||
output: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "xtls.github.io",
|
|
||||||
mType: Domain,
|
|
||||||
input: "tls.github.io",
|
|
||||||
output: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "xtls.github.io",
|
|
||||||
mType: Domain,
|
|
||||||
input: "xxtls.github.io",
|
|
||||||
output: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "xtls.github.io",
|
|
||||||
mType: Full,
|
|
||||||
input: "xtls.github.io",
|
|
||||||
output: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "xtls.github.io",
|
|
||||||
mType: Full,
|
|
||||||
input: "xxtls.github.io",
|
|
||||||
output: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, test := range cases1 {
|
|
||||||
var ac = NewACAutomaton()
|
|
||||||
ac.Add(test.pattern, test.mType)
|
|
||||||
ac.Build()
|
|
||||||
if m := ac.Match(test.input); m != test.output {
|
|
||||||
t.Error("unexpected output: ", m, " for test case ", test)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
cases2Input := []struct {
|
|
||||||
pattern string
|
|
||||||
mType Type
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
pattern: "163.com",
|
|
||||||
mType: Domain,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "m.126.com",
|
|
||||||
mType: Full,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "3.com",
|
|
||||||
mType: Full,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "google.com",
|
|
||||||
mType: Substr,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "vgoogle.com",
|
|
||||||
mType: Substr,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
var ac = NewACAutomaton()
|
|
||||||
for _, test := range cases2Input {
|
|
||||||
ac.Add(test.pattern, test.mType)
|
|
||||||
}
|
|
||||||
ac.Build()
|
|
||||||
cases2Output := []struct {
|
|
||||||
pattern string
|
|
||||||
res bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
pattern: "126.com",
|
|
||||||
res: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "m.163.com",
|
|
||||||
res: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "mm163.com",
|
|
||||||
res: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "m.126.com",
|
|
||||||
res: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "163.com",
|
|
||||||
res: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "63.com",
|
|
||||||
res: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "oogle.com",
|
|
||||||
res: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "vvgoogle.com",
|
|
||||||
res: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, test := range cases2Output {
|
|
||||||
if m := ac.Match(test.pattern); m != test.res {
|
|
||||||
t.Error("unexpected output: ", m, " for test case ", test)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
cases3Input := []struct {
|
|
||||||
pattern string
|
|
||||||
mType Type
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
pattern: "video.google.com",
|
|
||||||
mType: Domain,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: "gle.com",
|
|
||||||
mType: Domain,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
var ac = NewACAutomaton()
|
|
||||||
for _, test := range cases3Input {
|
|
||||||
ac.Add(test.pattern, test.mType)
|
|
||||||
}
|
|
||||||
ac.Build()
|
|
||||||
cases3Output := []struct {
|
|
||||||
pattern string
|
|
||||||
res bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
pattern: "google.com",
|
|
||||||
res: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, test := range cases3Output {
|
|
||||||
if m := ac.Match(test.pattern); m != test.res {
|
|
||||||
t.Error("unexpected output: ", m, " for test case ", test)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -80,25 +80,14 @@ func getFormat(filename string) string {
|
|||||||
func LoadConfig(formatName string, input interface{}) (*Config, error) {
|
func LoadConfig(formatName string, input interface{}) (*Config, error) {
|
||||||
switch v := input.(type) {
|
switch v := input.(type) {
|
||||||
case cmdarg.Arg:
|
case cmdarg.Arg:
|
||||||
|
|
||||||
formats := make([]string, len(v))
|
formats := make([]string, len(v))
|
||||||
hasProtobuf := false
|
hasProtobuf := false
|
||||||
for i, file := range v {
|
for i, file := range v {
|
||||||
var f string
|
f := getFormat(file)
|
||||||
|
if f == "" {
|
||||||
if formatName == "auto" {
|
|
||||||
if file != "stdin:" {
|
|
||||||
f = getFormat(file)
|
|
||||||
} else {
|
|
||||||
f = "json"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
f = formatName
|
f = formatName
|
||||||
}
|
}
|
||||||
|
|
||||||
if f == "" {
|
|
||||||
return nil, newError("Failed to get format of ", file).AtWarning()
|
|
||||||
}
|
|
||||||
|
|
||||||
if f == "protobuf" {
|
if f == "protobuf" {
|
||||||
hasProtobuf = true
|
hasProtobuf = true
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.25.0
|
// protoc-gen-go v1.25.0
|
||||||
// protoc v3.15.6
|
// protoc v3.14.0
|
||||||
// source: core/config.proto
|
// source: core/config.proto
|
||||||
|
|
||||||
package core
|
package core
|
||||||
@@ -9,7 +9,7 @@ package core
|
|||||||
import (
|
import (
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
serial "github.com/xtls/xray-core/common/serial"
|
serial "github.com/xtls/xray-core/common/serial"
|
||||||
global "github.com/xtls/xray-core/transport/global"
|
transport "github.com/xtls/xray-core/transport"
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
@@ -48,7 +48,7 @@ type Config struct {
|
|||||||
// config. Date to remove: 2020-01-13
|
// config. Date to remove: 2020-01-13
|
||||||
//
|
//
|
||||||
// Deprecated: Do not use.
|
// Deprecated: Do not use.
|
||||||
Transport *global.Config `protobuf:"bytes,5,opt,name=transport,proto3" json:"transport,omitempty"`
|
Transport *transport.Config `protobuf:"bytes,5,opt,name=transport,proto3" json:"transport,omitempty"`
|
||||||
// Configuration for extensions. The config may not work if corresponding
|
// Configuration for extensions. The config may not work if corresponding
|
||||||
// extension is not loaded into Xray. Xray will ignore such config during
|
// extension is not loaded into Xray. Xray will ignore such config during
|
||||||
// initialization.
|
// initialization.
|
||||||
@@ -109,7 +109,7 @@ func (x *Config) GetApp() []*serial.TypedMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Do not use.
|
// Deprecated: Do not use.
|
||||||
func (x *Config) GetTransport() *global.Config {
|
func (x *Config) GetTransport() *transport.Config {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Transport
|
return x.Transport
|
||||||
}
|
}
|
||||||
@@ -283,60 +283,59 @@ var file_core_config_proto_rawDesc = []byte{
|
|||||||
0x6f, 0x74, 0x6f, 0x12, 0x09, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x1a, 0x21,
|
0x6f, 0x74, 0x6f, 0x12, 0x09, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x1a, 0x21,
|
||||||
0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2f, 0x74, 0x79,
|
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,
|
0x70, 0x65, 0x64, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||||
0x6f, 0x1a, 0x1d, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x67, 0x6c, 0x6f,
|
0x6f, 0x1a, 0x16, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x63, 0x6f, 0x6e,
|
||||||
0x62, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb5, 0x02, 0x0a, 0x06, 0x43, 0x6f,
|
||||||
0x22, 0xb5, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, 0x07, 0x69,
|
0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, 0x07, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x18,
|
||||||
0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x78,
|
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72,
|
||||||
0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64,
|
0x65, 0x2e, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72,
|
||||||
0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x07, 0x69,
|
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x07, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12,
|
||||||
0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x3c, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75,
|
0x3c, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28,
|
||||||
0x6e, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e,
|
0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4f, 0x75,
|
||||||
0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e,
|
0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e,
|
||||||
0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x6f, 0x75, 0x74, 0x62,
|
0x66, 0x69, 0x67, 0x52, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x32, 0x0a,
|
||||||
0x6f, 0x75, 0x6e, 0x64, 0x12, 0x32, 0x0a, 0x03, 0x61, 0x70, 0x70, 0x18, 0x04, 0x20, 0x03, 0x28,
|
0x03, 0x61, 0x70, 0x70, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61,
|
||||||
0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e,
|
0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e,
|
||||||
0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73,
|
0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x03, 0x61, 0x70,
|
||||||
0x61, 0x67, 0x65, 0x52, 0x03, 0x61, 0x70, 0x70, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e,
|
0x70, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x05,
|
||||||
0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72,
|
0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e,
|
||||||
0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x43, 0x6f, 0x6e,
|
0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x42, 0x02, 0x18, 0x01,
|
||||||
0x66, 0x69, 0x67, 0x42, 0x02, 0x18, 0x01, 0x52, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f,
|
0x52, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x3e, 0x0a, 0x09, 0x65,
|
||||||
0x72, 0x74, 0x12, 0x3e, 0x0a, 0x09, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18,
|
0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20,
|
||||||
0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 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, 0x09, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69,
|
|
||||||
0x6f, 0x6e, 0x4a, 0x04, 0x08, 0x03, 0x10, 0x04, 0x22, 0xc0, 0x01, 0x0a, 0x14, 0x49, 0x6e, 0x62,
|
|
||||||
0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 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, 0x4d, 0x0a, 0x11, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x5f,
|
|
||||||
0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20,
|
|
||||||
0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72,
|
0x2e, 0x78, 0x72, 0x61, 0x79, 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,
|
0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
||||||
0x52, 0x10, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e,
|
0x52, 0x09, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4a, 0x04, 0x08, 0x03, 0x10,
|
||||||
0x67, 0x73, 0x12, 0x47, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74,
|
0x04, 0x22, 0xc0, 0x01, 0x0a, 0x14, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e,
|
||||||
0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61,
|
0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61,
|
||||||
0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e,
|
0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x4d, 0x0a, 0x11,
|
||||||
0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0d, 0x70, 0x72,
|
0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67,
|
||||||
0x6f, 0x78, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0xef, 0x01, 0x0a, 0x15,
|
0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63,
|
||||||
0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43,
|
0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70,
|
||||||
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01,
|
0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x10, 0x72, 0x65, 0x63, 0x65, 0x69,
|
||||||
0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x49, 0x0a, 0x0f, 0x73, 0x65, 0x6e, 0x64, 0x65,
|
0x76, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x47, 0x0a, 0x0e, 0x70,
|
||||||
0x72, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
|
0x72, 0x6f, 0x78, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20,
|
||||||
0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73,
|
0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f,
|
||||||
0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61,
|
0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65,
|
||||||
0x67, 0x65, 0x52, 0x0e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e,
|
0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x53, 0x65, 0x74, 0x74,
|
||||||
0x67, 0x73, 0x12, 0x47, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74,
|
0x69, 0x6e, 0x67, 0x73, 0x22, 0xef, 0x01, 0x0a, 0x15, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e,
|
||||||
0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61,
|
0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10,
|
||||||
0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e,
|
0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67,
|
||||||
0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0d, 0x70, 0x72,
|
0x12, 0x49, 0x0a, 0x0f, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69,
|
||||||
0x6f, 0x78, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x65,
|
0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79,
|
||||||
0x78, 0x70, 0x69, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x65, 0x78, 0x70,
|
0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54,
|
||||||
0x69, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05,
|
0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0e, 0x73, 0x65, 0x6e,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x3d, 0x0a,
|
0x64, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x47, 0x0a, 0x0e, 0x70,
|
||||||
0x0d, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x50, 0x01,
|
0x72, 0x6f, 0x78, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20,
|
||||||
0x5a, 0x1e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c,
|
0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f,
|
||||||
0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x63, 0x6f, 0x72, 0x65,
|
0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65,
|
||||||
0xaa, 0x02, 0x09, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72,
|
0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x53, 0x65, 0x74, 0x74,
|
||||||
0x6f, 0x74, 0x6f, 0x33,
|
0x69, 0x6e, 0x67, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x18, 0x04,
|
||||||
|
0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07,
|
||||||
|
0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63,
|
||||||
|
0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x3d, 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72,
|
||||||
|
0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x50, 0x01, 0x5a, 0x1e, 0x67, 0x69, 0x74, 0x68, 0x75,
|
||||||
|
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d,
|
||||||
|
0x63, 0x6f, 0x72, 0x65, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0xaa, 0x02, 0x09, 0x58, 0x72, 0x61, 0x79,
|
||||||
|
0x2e, 0x43, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -357,7 +356,7 @@ var file_core_config_proto_goTypes = []interface{}{
|
|||||||
(*InboundHandlerConfig)(nil), // 1: xray.core.InboundHandlerConfig
|
(*InboundHandlerConfig)(nil), // 1: xray.core.InboundHandlerConfig
|
||||||
(*OutboundHandlerConfig)(nil), // 2: xray.core.OutboundHandlerConfig
|
(*OutboundHandlerConfig)(nil), // 2: xray.core.OutboundHandlerConfig
|
||||||
(*serial.TypedMessage)(nil), // 3: xray.common.serial.TypedMessage
|
(*serial.TypedMessage)(nil), // 3: xray.common.serial.TypedMessage
|
||||||
(*global.Config)(nil), // 4: xray.transport.Config
|
(*transport.Config)(nil), // 4: xray.transport.Config
|
||||||
}
|
}
|
||||||
var file_core_config_proto_depIdxs = []int32{
|
var file_core_config_proto_depIdxs = []int32{
|
||||||
1, // 0: xray.core.Config.inbound:type_name -> xray.core.InboundHandlerConfig
|
1, // 0: xray.core.Config.inbound:type_name -> xray.core.InboundHandlerConfig
|
||||||
|
@@ -7,7 +7,7 @@ option java_package = "com.xray.core";
|
|||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
import "common/serial/typed_message.proto";
|
import "common/serial/typed_message.proto";
|
||||||
import "transport/global/config.proto";
|
import "transport/config.proto";
|
||||||
|
|
||||||
// Config is the master config of Xray. Xray takes this config as input and
|
// Config is the master config of Xray. Xray takes this config as input and
|
||||||
// functions accordingly.
|
// functions accordingly.
|
||||||
|
@@ -18,7 +18,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
version = "1.4.2"
|
version = "1.3.1"
|
||||||
build = "Custom"
|
build = "Custom"
|
||||||
codename = "Xray, Penetrates Everything."
|
codename = "Xray, Penetrates Everything."
|
||||||
intro = "A unified platform for anti-censorship."
|
intro = "A unified platform for anti-censorship."
|
||||||
|
@@ -16,7 +16,6 @@ import (
|
|||||||
"github.com/xtls/xray-core/features/policy"
|
"github.com/xtls/xray-core/features/policy"
|
||||||
"github.com/xtls/xray-core/features/routing"
|
"github.com/xtls/xray-core/features/routing"
|
||||||
"github.com/xtls/xray-core/features/stats"
|
"github.com/xtls/xray-core/features/stats"
|
||||||
"github.com/xtls/xray-core/transport/internet"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server is an instance of Xray. At any time, there must be at most one Server instance running.
|
// Server is an instance of Xray. At any time, there must be at most one Server instance running.
|
||||||
@@ -224,14 +223,6 @@ func initInstanceWithConfig(config *Config, server *Instance) (bool, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internet.InitSystemDialer(
|
|
||||||
server.GetFeature(dns.ClientType()).(dns.Client),
|
|
||||||
func() outbound.Manager {
|
|
||||||
obm, _ := server.GetFeature(outbound.ManagerType()).(outbound.Manager)
|
|
||||||
return obm
|
|
||||||
}(),
|
|
||||||
)
|
|
||||||
|
|
||||||
if server.featureResolutions != nil {
|
if server.featureResolutions != nil {
|
||||||
return true, newError("not all dependency are resolved.")
|
return true, newError("not all dependency are resolved.")
|
||||||
}
|
}
|
||||||
|
@@ -7,13 +7,6 @@ import (
|
|||||||
"github.com/xtls/xray-core/features"
|
"github.com/xtls/xray-core/features"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IPOption is an object for IP query options.
|
|
||||||
type IPOption struct {
|
|
||||||
IPv4Enable bool
|
|
||||||
IPv6Enable bool
|
|
||||||
FakeEnable bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// Client is a Xray feature for querying DNS information.
|
// Client is a Xray feature for querying DNS information.
|
||||||
//
|
//
|
||||||
// xray:api:stable
|
// xray:api:stable
|
||||||
@@ -21,7 +14,21 @@ type Client interface {
|
|||||||
features.Feature
|
features.Feature
|
||||||
|
|
||||||
// LookupIP returns IP address for the given domain. IPs may contain IPv4 and/or IPv6 addresses.
|
// LookupIP returns IP address for the given domain. IPs may contain IPv4 and/or IPv6 addresses.
|
||||||
LookupIP(domain string, option IPOption) ([]net.IP, error)
|
LookupIP(domain string) ([]net.IP, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPv4Lookup is an optional feature for querying IPv4 addresses only.
|
||||||
|
//
|
||||||
|
// xray:api:beta
|
||||||
|
type IPv4Lookup interface {
|
||||||
|
LookupIPv4(domain string) ([]net.IP, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPv6Lookup is an optional feature for querying IPv6 addresses only.
|
||||||
|
//
|
||||||
|
// xray:api:beta
|
||||||
|
type IPv6Lookup interface {
|
||||||
|
LookupIPv6(domain string) ([]net.IP, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClientType returns the type of Client interface. Can be used for implementing common.HasType.
|
// ClientType returns the type of Client interface. Can be used for implementing common.HasType.
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
package dns
|
|
||||||
|
|
||||||
import (
|
|
||||||
gonet "net"
|
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common/net"
|
|
||||||
"github.com/xtls/xray-core/features"
|
|
||||||
)
|
|
||||||
|
|
||||||
type FakeDNSEngine interface {
|
|
||||||
features.Feature
|
|
||||||
GetFakeIPForDomain(domain string) []net.Address
|
|
||||||
GetDomainFromFakeDNS(ip net.Address) string
|
|
||||||
GetFakeIPRange() *gonet.IPNet
|
|
||||||
}
|
|
||||||
|
|
||||||
var FakeIPPool = "198.18.0.0/16"
|
|
@@ -20,41 +20,58 @@ func (*Client) Start() error { return nil }
|
|||||||
func (*Client) Close() error { return nil }
|
func (*Client) Close() error { return nil }
|
||||||
|
|
||||||
// LookupIP implements Client.
|
// LookupIP implements Client.
|
||||||
func (*Client) LookupIP(host string, option dns.IPOption) ([]net.IP, error) {
|
func (*Client) LookupIP(host string) ([]net.IP, error) {
|
||||||
ips, err := net.LookupIP(host)
|
ips, err := net.LookupIP(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
parsedIPs := make([]net.IP, 0, len(ips))
|
parsedIPs := make([]net.IP, 0, len(ips))
|
||||||
ipv4 := make([]net.IP, 0, len(ips))
|
|
||||||
ipv6 := make([]net.IP, 0, len(ips))
|
|
||||||
for _, ip := range ips {
|
for _, ip := range ips {
|
||||||
parsed := net.IPAddress(ip)
|
parsed := net.IPAddress(ip)
|
||||||
if parsed != nil {
|
if parsed != nil {
|
||||||
parsedIPs = append(parsedIPs, parsed.IP())
|
parsedIPs = append(parsedIPs, parsed.IP())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if len(parsedIPs) == 0 {
|
||||||
|
return nil, dns.ErrEmptyResponse
|
||||||
|
}
|
||||||
|
return parsedIPs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LookupIPv4 implements IPv4Lookup.
|
||||||
|
func (c *Client) LookupIPv4(host string) ([]net.IP, error) {
|
||||||
|
ips, err := c.LookupIP(host)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ipv4 := make([]net.IP, 0, len(ips))
|
||||||
|
for _, ip := range ips {
|
||||||
if len(ip) == net.IPv4len {
|
if len(ip) == net.IPv4len {
|
||||||
ipv4 = append(ipv4, ip)
|
ipv4 = append(ipv4, ip)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if len(ipv4) == 0 {
|
||||||
|
return nil, dns.ErrEmptyResponse
|
||||||
|
}
|
||||||
|
return ipv4, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LookupIPv6 implements IPv6Lookup.
|
||||||
|
func (c *Client) LookupIPv6(host string) ([]net.IP, error) {
|
||||||
|
ips, err := c.LookupIP(host)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ipv6 := make([]net.IP, 0, len(ips))
|
||||||
|
for _, ip := range ips {
|
||||||
if len(ip) == net.IPv6len {
|
if len(ip) == net.IPv6len {
|
||||||
ipv6 = append(ipv6, ip)
|
ipv6 = append(ipv6, ip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch {
|
if len(ipv6) == 0 {
|
||||||
case option.IPv4Enable && option.IPv6Enable:
|
return nil, dns.ErrEmptyResponse
|
||||||
if len(parsedIPs) > 0 {
|
|
||||||
return parsedIPs, nil
|
|
||||||
}
|
|
||||||
case option.IPv4Enable:
|
|
||||||
if len(ipv4) > 0 {
|
|
||||||
return ipv4, nil
|
|
||||||
}
|
|
||||||
case option.IPv6Enable:
|
|
||||||
if len(ipv6) > 0 {
|
|
||||||
return ipv6, nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil, dns.ErrEmptyResponse
|
return ipv6, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// New create a new dns.Client that queries localhost for DNS.
|
// New create a new dns.Client that queries localhost for DNS.
|
||||||
|
@@ -1,9 +0,0 @@
|
|||||||
package localdns
|
|
||||||
|
|
||||||
import "github.com/xtls/xray-core/common/errors"
|
|
||||||
|
|
||||||
type errPathObjHolder struct{}
|
|
||||||
|
|
||||||
func newError(values ...interface{}) *errors.Error {
|
|
||||||
return errors.New(values...).WithPathObj(errPathObjHolder{})
|
|
||||||
}
|
|
@@ -26,11 +26,7 @@ func (ctx *ResolvableContext) GetTargetIPs() []net.IP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if domain := ctx.GetTargetDomain(); len(domain) != 0 {
|
if domain := ctx.GetTargetDomain(); len(domain) != 0 {
|
||||||
ips, err := ctx.dnsClient.LookupIP(domain, dns.IPOption{
|
ips, err := ctx.dnsClient.LookupIP(domain)
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
})
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
ctx.resolvedIPs = ips
|
ctx.resolvedIPs = ips
|
||||||
return ips
|
return ips
|
||||||
|
23
go.mod
23
go.mod
@@ -5,23 +5,22 @@ go 1.16
|
|||||||
require (
|
require (
|
||||||
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
|
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
|
||||||
github.com/golang/mock v1.5.0
|
github.com/golang/mock v1.5.0
|
||||||
github.com/golang/protobuf v1.5.2
|
github.com/golang/protobuf v1.4.3
|
||||||
github.com/google/go-cmp v0.5.5
|
github.com/google/go-cmp v0.5.4
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/lucas-clemente/quic-go v0.20.0
|
github.com/lucas-clemente/quic-go v0.19.3
|
||||||
github.com/miekg/dns v1.1.41
|
github.com/miekg/dns v1.1.40
|
||||||
github.com/pelletier/go-toml v1.8.1
|
github.com/pelletier/go-toml v1.8.1
|
||||||
github.com/pires/go-proxyproto v0.5.0
|
github.com/pires/go-proxyproto v0.4.2
|
||||||
github.com/refraction-networking/utls v0.0.0-20201210053706-2179f286686b
|
|
||||||
github.com/seiflotfy/cuckoofilter v0.0.0-20201222105146-bc6005554a0c
|
github.com/seiflotfy/cuckoofilter v0.0.0-20201222105146-bc6005554a0c
|
||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.7.0
|
||||||
github.com/xtls/go v0.0.0-20201118062508-3632bf3b7499
|
github.com/xtls/go v0.0.0-20201118062508-3632bf3b7499
|
||||||
go.starlark.net v0.0.0-20210312235212-74c10e2c17dc
|
go.starlark.net v0.0.0-20210223155950-e043a3d3c984
|
||||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
|
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
|
||||||
golang.org/x/net v0.0.0-20210330230544-e57232859fb2
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
||||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44
|
golang.org/x/sys v0.0.0-20210301091718-77cc2087c03b
|
||||||
google.golang.org/grpc v1.36.1
|
google.golang.org/grpc v1.36.0
|
||||||
google.golang.org/protobuf v1.26.0
|
google.golang.org/protobuf v1.25.0
|
||||||
h12.io/socks v1.0.2
|
h12.io/socks v1.0.2
|
||||||
)
|
)
|
||||||
|
73
go.sum
73
go.sum
@@ -43,9 +43,12 @@ github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aev
|
|||||||
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
|
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
|
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||||
github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g=
|
github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g=
|
||||||
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
|
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
|
||||||
@@ -59,9 +62,8 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W
|
|||||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
||||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
|
||||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
@@ -69,8 +71,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
|
|||||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
||||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||||
@@ -96,19 +98,19 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
|||||||
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/lucas-clemente/quic-go v0.20.0 h1:FSU3YN5VnLafHR27Ejs1r1CYMS7XMyIVDzRewkDLNBw=
|
github.com/lucas-clemente/quic-go v0.19.3 h1:eCDQqvGBB+kCTkA0XrAFtNe81FMa0/fn4QSoeAbmiF4=
|
||||||
github.com/lucas-clemente/quic-go v0.20.0/go.mod h1:fZq/HUDIM+mW6X6wtzORjC0E/WDBMKe5Hf9bgjISwLk=
|
github.com/lucas-clemente/quic-go v0.19.3/go.mod h1:ADXpNbTQjq1hIzCpB+y/k5iz4n4z4IwqoLb94Kh5Hu8=
|
||||||
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
|
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
|
||||||
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
github.com/marten-seemann/qpack v0.2.1/go.mod h1:F7Gl5L1jIgN1D11ucXefiuJS9UMVP2opoCp2jDKb7wc=
|
github.com/marten-seemann/qpack v0.2.1/go.mod h1:F7Gl5L1jIgN1D11ucXefiuJS9UMVP2opoCp2jDKb7wc=
|
||||||
github.com/marten-seemann/qtls-go1-15 v0.1.4 h1:RehYMOyRW8hPVEja1KBVsFVNSm35Jj9Mvs5yNoZZ28A=
|
github.com/marten-seemann/qtls v0.10.0 h1:ECsuYUKalRL240rRD4Ri33ISb7kAQ3qGDlrrl55b2pc=
|
||||||
github.com/marten-seemann/qtls-go1-15 v0.1.4/go.mod h1:GyFwywLKkRt+6mfU99csTEY1joMZz5vmB1WNZH3P81I=
|
github.com/marten-seemann/qtls v0.10.0/go.mod h1:UvMd1oaYDACI99/oZUYLzMCkBXQVT0aGm99sJhbT8hs=
|
||||||
github.com/marten-seemann/qtls-go1-16 v0.1.3 h1:XEZ1xGorVy9u+lJq+WXNE+hiqRYLNvJGYmwfwKQN2gU=
|
github.com/marten-seemann/qtls-go1-15 v0.1.1 h1:LIH6K34bPVttyXnUWixk0bzH6/N07VxbSabxn5A5gZQ=
|
||||||
github.com/marten-seemann/qtls-go1-16 v0.1.3/go.mod h1:gNpI2Ol+lRS3WwSOtIUUtRwZEQMXjYK+dQSBFbethAk=
|
github.com/marten-seemann/qtls-go1-15 v0.1.1/go.mod h1:GyFwywLKkRt+6mfU99csTEY1joMZz5vmB1WNZH3P81I=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
|
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
|
||||||
github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY=
|
github.com/miekg/dns v1.1.40 h1:pyyPFfGMnciYUk/mXpKkVmeMQjfXqt3FAJ2hy7tPiLA=
|
||||||
github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI=
|
github.com/miekg/dns v1.1.40/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
|
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
|
||||||
@@ -127,8 +129,8 @@ github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNC
|
|||||||
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
||||||
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc=
|
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc=
|
||||||
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE=
|
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE=
|
||||||
github.com/pires/go-proxyproto v0.5.0 h1:A4Jv4ZCaV3AFJeGh5mGwkz4iuWUYMlQ7IoO/GTuSuLo=
|
github.com/pires/go-proxyproto v0.4.2 h1:VRAvsUCTrmiahoU5fqQqkbY0GWcJ1Q0F7b7CkFaipSU=
|
||||||
github.com/pires/go-proxyproto v0.5.0/go.mod h1:Odh9VFOZJCf9G8cLW5o435Xf1J95Jw9Gw5rnCjcwzAY=
|
github.com/pires/go-proxyproto v0.4.2/go.mod h1:Odh9VFOZJCf9G8cLW5o435Xf1J95Jw9Gw5rnCjcwzAY=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
@@ -137,8 +139,6 @@ github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:
|
|||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||||
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||||
github.com/refraction-networking/utls v0.0.0-20201210053706-2179f286686b h1:lzo71oHzQEz0fKMSjR0BpVzuh2hOHvJTxnN3Rnikmtg=
|
|
||||||
github.com/refraction-networking/utls v0.0.0-20201210053706-2179f286686b/go.mod h1:tz9gX959MEFfFN5whTIocCLUG57WiILqtdVxI8c6Wj0=
|
|
||||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||||
github.com/seiflotfy/cuckoofilter v0.0.0-20201222105146-bc6005554a0c h1:pqy40B3MQWYrza7YZXOXgl0Nf0QGFqrOC0BKae1UNAA=
|
github.com/seiflotfy/cuckoofilter v0.0.0-20201222105146-bc6005554a0c h1:pqy40B3MQWYrza7YZXOXgl0Nf0QGFqrOC0BKae1UNAA=
|
||||||
github.com/seiflotfy/cuckoofilter v0.0.0-20201222105146-bc6005554a0c/go.mod h1:bR6DqgcAl1zTcOX8/pE2Qkj9XO00eCNqmKb7lXP8EAg=
|
github.com/seiflotfy/cuckoofilter v0.0.0-20201222105146-bc6005554a0c/go.mod h1:bR6DqgcAl1zTcOX8/pE2Qkj9XO00eCNqmKb7lXP8EAg=
|
||||||
@@ -169,6 +169,7 @@ github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:Udh
|
|||||||
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
|
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
@@ -179,8 +180,9 @@ github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMI
|
|||||||
github.com/xtls/go v0.0.0-20201118062508-3632bf3b7499 h1:QHESTXtfgc1ABV+ArlbPVqUx9Ht5I0dDkYhxYoXFxNo=
|
github.com/xtls/go v0.0.0-20201118062508-3632bf3b7499 h1:QHESTXtfgc1ABV+ArlbPVqUx9Ht5I0dDkYhxYoXFxNo=
|
||||||
github.com/xtls/go v0.0.0-20201118062508-3632bf3b7499/go.mod h1:5TB2+k58gx4A4g2Nf5miSHNDF6CuAzHKpWBooLAshTs=
|
github.com/xtls/go v0.0.0-20201118062508-3632bf3b7499/go.mod h1:5TB2+k58gx4A4g2Nf5miSHNDF6CuAzHKpWBooLAshTs=
|
||||||
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
|
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
|
||||||
go.starlark.net v0.0.0-20210312235212-74c10e2c17dc h1:pVkptfeOTFfx+zXZo7HEHN3d5LmhatBFvHdm/f2QnpY=
|
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||||
go.starlark.net v0.0.0-20210312235212-74c10e2c17dc/go.mod h1:t3mmBBPzAVvK0L0n1drDmrQsJ8FoIx4INCqVMTr/Zo0=
|
go.starlark.net v0.0.0-20210223155950-e043a3d3c984 h1:xwwDQW5We85NaTk2APgoN9202w/l0DVGp+GZMfsrh7s=
|
||||||
|
go.starlark.net v0.0.0-20210223155950-e043a3d3c984/go.mod h1:t3mmBBPzAVvK0L0n1drDmrQsJ8FoIx4INCqVMTr/Zo0=
|
||||||
go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
|
go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
|
||||||
golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw=
|
golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw=
|
||||||
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
@@ -189,13 +191,14 @@ golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACk
|
|||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w=
|
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 h1:/ZScEX8SfEmUGRHs0gxpqteO5nfNW6axyZbBdw9A12g=
|
||||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
@@ -208,11 +211,11 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
|
|||||||
golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20210330230544-e57232859fb2 h1:nGCZOty+lVDsc4H2qPFksI5Se296+V+GhMiL/TzmYNk=
|
|
||||||
golang.org/x/net v0.0.0-20210330230544-e57232859fb2/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
@@ -232,19 +235,22 @@ golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5h
|
|||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201231184435-2d18734c6014/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210301091718-77cc2087c03b h1:kHlr0tATeLRMEiZJu5CknOw/E8V6h69sXXQFGoPtjcc=
|
||||||
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210301091718-77cc2087c03b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44 h1:Bli41pIlzTzf3KEY06n+xnzK/BESIg2ze4Pgfh/aI8c=
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
@@ -261,6 +267,7 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3
|
|||||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
@@ -278,6 +285,7 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA
|
|||||||
google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg=
|
google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg=
|
||||||
google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
|
||||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||||
@@ -285,11 +293,12 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE
|
|||||||
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
|
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
|
||||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
|
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||||
google.golang.org/grpc v1.36.1 h1:cmUfbeGKnz9+2DD/UYsMQXeqbHZqZDs4eQwW0sFOpBY=
|
google.golang.org/grpc v1.36.0 h1:o1bcQ6imQMIOpdrO3SWf2z5RV72WbDwdXuK0MDlc8As=
|
||||||
google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
@@ -298,10 +307,8 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
|
|||||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
|
||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
|
||||||
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
@@ -324,5 +331,7 @@ honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWh
|
|||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||||
|
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||||
sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck=
|
sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck=
|
||||||
sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0=
|
sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0=
|
||||||
|
@@ -1,66 +0,0 @@
|
|||||||
package conf
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"github.com/xtls/xray-core/app/dns/fakedns"
|
|
||||||
"github.com/xtls/xray-core/features/dns"
|
|
||||||
)
|
|
||||||
|
|
||||||
type FakeDNSConfig struct {
|
|
||||||
IPPool string `json:"ipPool"`
|
|
||||||
LruSize int64 `json:"poolSize"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f FakeDNSConfig) Build() (proto.Message, error) {
|
|
||||||
return &fakedns.FakeDnsPool{
|
|
||||||
IpPool: f.IPPool,
|
|
||||||
LruSize: f.LruSize,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type FakeDNSPostProcessingStage struct{}
|
|
||||||
|
|
||||||
func (FakeDNSPostProcessingStage) Process(conf *Config) error {
|
|
||||||
var fakeDNSInUse bool
|
|
||||||
|
|
||||||
if conf.DNSConfig != nil {
|
|
||||||
for _, v := range conf.DNSConfig.Servers {
|
|
||||||
if v.Address.Family().IsDomain() {
|
|
||||||
if v.Address.Domain() == "fakedns" {
|
|
||||||
fakeDNSInUse = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if fakeDNSInUse {
|
|
||||||
if conf.FakeDNS == nil {
|
|
||||||
// Add a Fake DNS Config if there is none
|
|
||||||
conf.FakeDNS = &FakeDNSConfig{
|
|
||||||
IPPool: dns.FakeIPPool,
|
|
||||||
LruSize: 65535,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
found := false
|
|
||||||
// Check if there is a Outbound with necessary sniffer on
|
|
||||||
var inbounds []InboundDetourConfig
|
|
||||||
|
|
||||||
if len(conf.InboundConfigs) > 0 {
|
|
||||||
inbounds = append(inbounds, conf.InboundConfigs...)
|
|
||||||
}
|
|
||||||
for _, v := range inbounds {
|
|
||||||
if v.SniffingConfig != nil && v.SniffingConfig.Enabled && v.SniffingConfig.DestOverride != nil {
|
|
||||||
for _, dov := range *v.SniffingConfig.DestOverride {
|
|
||||||
if dov == "fakedns" {
|
|
||||||
found = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
newError("Defined Fake DNS but haven't enabled fake dns sniffing at any inbound.").AtWarning().WriteToLog()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
@@ -1,16 +0,0 @@
|
|||||||
package conf
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
|
|
||||||
"github.com/xtls/xray-core/transport/internet/grpc"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GRPCConfig struct {
|
|
||||||
ServiceName string `json:"serviceName"`
|
|
||||||
MultiMode bool `json:"multiMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g GRPCConfig) Build() (proto.Message, error) {
|
|
||||||
return &grpc.Config{ServiceName: g.ServiceName, MultiMode: g.MultiMode}, nil
|
|
||||||
}
|
|
@@ -1,5 +0,0 @@
|
|||||||
package conf
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
RegisterConfigureFilePostProcessingStage("FakeDNS", &FakeDNSPostProcessingStage{})
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
package conf
|
|
||||||
|
|
||||||
type ConfigureFilePostProcessingStage interface {
|
|
||||||
Process(conf *Config) error
|
|
||||||
}
|
|
||||||
|
|
||||||
var configureFilePostProcessingStages map[string]ConfigureFilePostProcessingStage
|
|
||||||
|
|
||||||
func RegisterConfigureFilePostProcessingStage(name string, stage ConfigureFilePostProcessingStage) {
|
|
||||||
if configureFilePostProcessingStages == nil {
|
|
||||||
configureFilePostProcessingStages = make(map[string]ConfigureFilePostProcessingStage)
|
|
||||||
}
|
|
||||||
configureFilePostProcessingStages[name] = stage
|
|
||||||
}
|
|
||||||
|
|
||||||
func PostProcessConfigureFile(conf *Config) error {
|
|
||||||
for k, v := range configureFilePostProcessingStages {
|
|
||||||
if err := v.Process(conf); err != nil {
|
|
||||||
return newError("Rejected by Postprocessing Stage ", k).AtError().Base(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
@@ -19,7 +19,6 @@ type LogConfig struct {
|
|||||||
AccessLog string `json:"access"`
|
AccessLog string `json:"access"`
|
||||||
ErrorLog string `json:"error"`
|
ErrorLog string `json:"error"`
|
||||||
LogLevel string `json:"loglevel"`
|
LogLevel string `json:"loglevel"`
|
||||||
DNSLog bool `json:"dnsLog"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *LogConfig) Build() *log.Config {
|
func (v *LogConfig) Build() *log.Config {
|
||||||
@@ -29,7 +28,6 @@ func (v *LogConfig) Build() *log.Config {
|
|||||||
config := &log.Config{
|
config := &log.Config{
|
||||||
ErrorLogType: log.LogType_Console,
|
ErrorLogType: log.LogType_Console,
|
||||||
AccessLogType: log.LogType_Console,
|
AccessLogType: log.LogType_Console,
|
||||||
EnableDnsLog: v.DNSLog,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.AccessLog == "none" {
|
if v.AccessLog == "none" {
|
||||||
|
@@ -98,8 +98,6 @@ type RouterRule struct {
|
|||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
OutboundTag string `json:"outboundTag"`
|
OutboundTag string `json:"outboundTag"`
|
||||||
BalancerTag string `json:"balancerTag"`
|
BalancerTag string `json:"balancerTag"`
|
||||||
|
|
||||||
DomainMatcher string `json:"domainMatcher"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseIP(s string) (*router.CIDR, error) {
|
func ParseIP(s string) (*router.CIDR, error) {
|
||||||
@@ -493,10 +491,6 @@ func parseFieldRule(msg json.RawMessage) (*router.RoutingRule, error) {
|
|||||||
return nil, newError("neither outboundTag nor balancerTag is specified in routing rule")
|
return nil, newError("neither outboundTag nor balancerTag is specified in routing rule")
|
||||||
}
|
}
|
||||||
|
|
||||||
if rawFieldRule.DomainMatcher != "" {
|
|
||||||
rule.DomainMatcher = rawFieldRule.DomainMatcher
|
|
||||||
}
|
|
||||||
|
|
||||||
if rawFieldRule.Domain != nil {
|
if rawFieldRule.Domain != nil {
|
||||||
for _, domain := range *rawFieldRule.Domain {
|
for _, domain := range *rawFieldRule.Domain {
|
||||||
rules, err := parseDomainRule(domain)
|
rules, err := parseDomainRule(domain)
|
||||||
|
@@ -2,7 +2,7 @@ package conf
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/xtls/xray-core/common/serial"
|
"github.com/xtls/xray-core/common/serial"
|
||||||
"github.com/xtls/xray-core/transport/global"
|
"github.com/xtls/xray-core/transport"
|
||||||
"github.com/xtls/xray-core/transport/internet"
|
"github.com/xtls/xray-core/transport/internet"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,13 +13,11 @@ type TransportConfig struct {
|
|||||||
HTTPConfig *HTTPConfig `json:"httpSettings"`
|
HTTPConfig *HTTPConfig `json:"httpSettings"`
|
||||||
DSConfig *DomainSocketConfig `json:"dsSettings"`
|
DSConfig *DomainSocketConfig `json:"dsSettings"`
|
||||||
QUICConfig *QUICConfig `json:"quicSettings"`
|
QUICConfig *QUICConfig `json:"quicSettings"`
|
||||||
GRPCConfig *GRPCConfig `json:"grpcSettings"`
|
|
||||||
GUNConfig *GRPCConfig `json:"gunSettings"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build implements Buildable.
|
// Build implements Buildable.
|
||||||
func (c *TransportConfig) Build() (*global.Config, error) {
|
func (c *TransportConfig) Build() (*transport.Config, error) {
|
||||||
config := new(global.Config)
|
config := new(transport.Config)
|
||||||
|
|
||||||
if c.TCPConfig != nil {
|
if c.TCPConfig != nil {
|
||||||
ts, err := c.TCPConfig.Build()
|
ts, err := c.TCPConfig.Build()
|
||||||
@@ -87,19 +85,5 @@ func (c *TransportConfig) Build() (*global.Config, error) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.GRPCConfig == nil {
|
|
||||||
c.GRPCConfig = c.GUNConfig
|
|
||||||
}
|
|
||||||
if c.GRPCConfig != nil {
|
|
||||||
gs, err := c.GRPCConfig.Build()
|
|
||||||
if err != nil {
|
|
||||||
return nil, newError("Failed to build gRPC config.").Base(err)
|
|
||||||
}
|
|
||||||
config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{
|
|
||||||
ProtocolName: "grpc",
|
|
||||||
Settings: serial.ToTypedMessage(gs),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
@@ -2,9 +2,6 @@ package conf
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"math"
|
|
||||||
"net/url"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
@@ -157,20 +154,9 @@ func (c *WebSocketConfig) Build() (proto.Message, error) {
|
|||||||
Value: value,
|
Value: value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
var ed uint32
|
|
||||||
if u, err := url.Parse(path); err == nil {
|
|
||||||
if q := u.Query(); q.Get("ed") != "" {
|
|
||||||
Ed, _ := strconv.Atoi(q.Get("ed"))
|
|
||||||
ed = uint32(Ed)
|
|
||||||
q.Del("ed")
|
|
||||||
u.RawQuery = q.Encode()
|
|
||||||
path = u.String()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
config := &websocket.Config{
|
config := &websocket.Config{
|
||||||
Path: path,
|
Path: path,
|
||||||
Header: header,
|
Header: header,
|
||||||
Ed: ed,
|
|
||||||
}
|
}
|
||||||
if c.AcceptProxyProtocol {
|
if c.AcceptProxyProtocol {
|
||||||
config.AcceptProxyProtocol = c.AcceptProxyProtocol
|
config.AcceptProxyProtocol = c.AcceptProxyProtocol
|
||||||
@@ -321,7 +307,6 @@ type TLSConfig struct {
|
|||||||
MaxVersion string `json:"maxVersion"`
|
MaxVersion string `json:"maxVersion"`
|
||||||
CipherSuites string `json:"cipherSuites"`
|
CipherSuites string `json:"cipherSuites"`
|
||||||
PreferServerCipherSuites bool `json:"preferServerCipherSuites"`
|
PreferServerCipherSuites bool `json:"preferServerCipherSuites"`
|
||||||
Fingerprint string `json:"fingerprint"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build implements Buildable.
|
// Build implements Buildable.
|
||||||
@@ -349,7 +334,6 @@ func (c *TLSConfig) Build() (proto.Message, error) {
|
|||||||
config.MaxVersion = c.MaxVersion
|
config.MaxVersion = c.MaxVersion
|
||||||
config.CipherSuites = c.CipherSuites
|
config.CipherSuites = c.CipherSuites
|
||||||
config.PreferServerCipherSuites = c.PreferServerCipherSuites
|
config.PreferServerCipherSuites = c.PreferServerCipherSuites
|
||||||
config.Fingerprint = strings.ToLower(c.Fingerprint)
|
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,37 +444,26 @@ func (p TransportProtocol) Build() (string, error) {
|
|||||||
return "domainsocket", nil
|
return "domainsocket", nil
|
||||||
case "quic":
|
case "quic":
|
||||||
return "quic", nil
|
return "quic", nil
|
||||||
case "grpc", "gun":
|
|
||||||
return "grpc", nil
|
|
||||||
default:
|
default:
|
||||||
return "", newError("Config: unknown transport protocol: ", p)
|
return "", newError("Config: unknown transport protocol: ", p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type SocketConfig struct {
|
type SocketConfig struct {
|
||||||
Mark int32 `json:"mark"`
|
Mark int32 `json:"mark"`
|
||||||
TFO interface{} `json:"tcpFastOpen"`
|
TFO *bool `json:"tcpFastOpen"`
|
||||||
TProxy string `json:"tproxy"`
|
TProxy string `json:"tproxy"`
|
||||||
AcceptProxyProtocol bool `json:"acceptProxyProtocol"`
|
AcceptProxyProtocol bool `json:"acceptProxyProtocol"`
|
||||||
DomainStrategy string `json:"domainStrategy"`
|
|
||||||
DialerProxy string `json:"dialerProxy"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build implements Buildable.
|
// Build implements Buildable.
|
||||||
func (c *SocketConfig) Build() (*internet.SocketConfig, error) {
|
func (c *SocketConfig) Build() (*internet.SocketConfig, error) {
|
||||||
tfo := int32(0) // don't invoke setsockopt() for TFO
|
var tfoSettings internet.SocketConfig_TCPFastOpenState
|
||||||
if c.TFO != nil {
|
if c.TFO != nil {
|
||||||
switch v := c.TFO.(type) {
|
if *c.TFO {
|
||||||
case bool:
|
tfoSettings = internet.SocketConfig_Enable
|
||||||
if v {
|
} else {
|
||||||
tfo = 256
|
tfoSettings = internet.SocketConfig_Disable
|
||||||
} else {
|
|
||||||
tfo = -1 // TFO need to be disabled
|
|
||||||
}
|
|
||||||
case float64:
|
|
||||||
tfo = int32(math.Min(v, math.MaxInt32))
|
|
||||||
default:
|
|
||||||
return nil, newError("tcpFastOpen: only boolean and integer value is acceptable")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var tproxy internet.SocketConfig_TProxyMode
|
var tproxy internet.SocketConfig_TProxyMode
|
||||||
@@ -503,23 +476,11 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) {
|
|||||||
tproxy = internet.SocketConfig_Off
|
tproxy = internet.SocketConfig_Off
|
||||||
}
|
}
|
||||||
|
|
||||||
var dStrategy = internet.DomainStrategy_AS_IS
|
|
||||||
switch strings.ToLower(c.DomainStrategy) {
|
|
||||||
case "useip", "use_ip":
|
|
||||||
dStrategy = internet.DomainStrategy_USE_IP
|
|
||||||
case "useip4", "useipv4", "use_ipv4", "use_ip_v4", "use_ip4":
|
|
||||||
dStrategy = internet.DomainStrategy_USE_IP4
|
|
||||||
case "useip6", "useipv6", "use_ipv6", "use_ip_v6", "use_ip6":
|
|
||||||
dStrategy = internet.DomainStrategy_USE_IP6
|
|
||||||
}
|
|
||||||
|
|
||||||
return &internet.SocketConfig{
|
return &internet.SocketConfig{
|
||||||
Mark: c.Mark,
|
Mark: c.Mark,
|
||||||
Tfo: tfo,
|
Tfo: tfoSettings,
|
||||||
Tproxy: tproxy,
|
Tproxy: tproxy,
|
||||||
DomainStrategy: dStrategy,
|
|
||||||
AcceptProxyProtocol: c.AcceptProxyProtocol,
|
AcceptProxyProtocol: c.AcceptProxyProtocol,
|
||||||
DialerProxy: c.DialerProxy,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,8 +496,6 @@ type StreamConfig struct {
|
|||||||
DSSettings *DomainSocketConfig `json:"dsSettings"`
|
DSSettings *DomainSocketConfig `json:"dsSettings"`
|
||||||
QUICSettings *QUICConfig `json:"quicSettings"`
|
QUICSettings *QUICConfig `json:"quicSettings"`
|
||||||
SocketSettings *SocketConfig `json:"sockopt"`
|
SocketSettings *SocketConfig `json:"sockopt"`
|
||||||
GRPCConfig *GRPCConfig `json:"grpcSettings"`
|
|
||||||
GUNConfig *GRPCConfig `json:"gunSettings"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build implements Buildable.
|
// Build implements Buildable.
|
||||||
@@ -646,19 +605,6 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) {
|
|||||||
Settings: serial.ToTypedMessage(qs),
|
Settings: serial.ToTypedMessage(qs),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if c.GRPCConfig == nil {
|
|
||||||
c.GRPCConfig = c.GUNConfig
|
|
||||||
}
|
|
||||||
if c.GRPCConfig != nil {
|
|
||||||
gs, err := c.GRPCConfig.Build()
|
|
||||||
if err != nil {
|
|
||||||
return nil, newError("Failed to build gRPC config.").Base(err)
|
|
||||||
}
|
|
||||||
config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{
|
|
||||||
ProtocolName: "grpc",
|
|
||||||
Settings: serial.ToTypedMessage(gs),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if c.SocketSettings != nil {
|
if c.SocketSettings != nil {
|
||||||
ss, err := c.SocketSettings.Build()
|
ss, err := c.SocketSettings.Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -671,9 +617,6 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) {
|
|||||||
|
|
||||||
type ProxyConfig struct {
|
type ProxyConfig struct {
|
||||||
Tag string `json:"tag"`
|
Tag string `json:"tag"`
|
||||||
|
|
||||||
// TransportLayerProxy: For compatibility.
|
|
||||||
TransportLayerProxy bool `json:"transportLayer"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build implements Buildable.
|
// Build implements Buildable.
|
||||||
@@ -682,7 +625,6 @@ func (v *ProxyConfig) Build() (*internet.ProxyConfig, error) {
|
|||||||
return nil, newError("Proxy tag is not set.")
|
return nil, newError("Proxy tag is not set.")
|
||||||
}
|
}
|
||||||
return &internet.ProxyConfig{
|
return &internet.ProxyConfig{
|
||||||
Tag: v.Tag,
|
Tag: v.Tag,
|
||||||
TransportLayerProxy: v.TransportLayerProxy,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@@ -8,9 +8,8 @@ import (
|
|||||||
"github.com/xtls/xray-core/common/protocol"
|
"github.com/xtls/xray-core/common/protocol"
|
||||||
"github.com/xtls/xray-core/common/serial"
|
"github.com/xtls/xray-core/common/serial"
|
||||||
. "github.com/xtls/xray-core/infra/conf"
|
. "github.com/xtls/xray-core/infra/conf"
|
||||||
"github.com/xtls/xray-core/transport/global"
|
"github.com/xtls/xray-core/transport"
|
||||||
"github.com/xtls/xray-core/transport/internet"
|
"github.com/xtls/xray-core/transport/internet"
|
||||||
"github.com/xtls/xray-core/transport/internet/grpc"
|
|
||||||
"github.com/xtls/xray-core/transport/internet/headers/http"
|
"github.com/xtls/xray-core/transport/internet/headers/http"
|
||||||
"github.com/xtls/xray-core/transport/internet/headers/noop"
|
"github.com/xtls/xray-core/transport/internet/headers/noop"
|
||||||
"github.com/xtls/xray-core/transport/internet/headers/tls"
|
"github.com/xtls/xray-core/transport/internet/headers/tls"
|
||||||
@@ -31,134 +30,19 @@ func TestSocketConfig(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// test "tcpFastOpen": true, queue length 256 is expected. other parameters are tested here too
|
|
||||||
expectedOutput := &internet.SocketConfig{
|
|
||||||
Mark: 1,
|
|
||||||
Tfo: 256,
|
|
||||||
DomainStrategy: internet.DomainStrategy_USE_IP,
|
|
||||||
DialerProxy: "tag",
|
|
||||||
}
|
|
||||||
runMultiTestCase(t, []TestCase{
|
runMultiTestCase(t, []TestCase{
|
||||||
{
|
{
|
||||||
Input: `{
|
Input: `{
|
||||||
"mark": 1,
|
"mark": 1,
|
||||||
"tcpFastOpen": true,
|
"tcpFastOpen": true
|
||||||
"domainStrategy": "UseIP",
|
|
||||||
"dialerProxy": "tag"
|
|
||||||
}`,
|
}`,
|
||||||
Parser: createParser(),
|
Parser: createParser(),
|
||||||
Output: expectedOutput,
|
Output: &internet.SocketConfig{
|
||||||
|
Mark: 1,
|
||||||
|
Tfo: internet.SocketConfig_Enable,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if expectedOutput.ParseTFOValue() != 256 {
|
|
||||||
t.Fatalf("unexpected parsed TFO value, which should be 256")
|
|
||||||
}
|
|
||||||
|
|
||||||
// test "tcpFastOpen": false, disabled TFO is expected
|
|
||||||
expectedOutput = &internet.SocketConfig{
|
|
||||||
Mark: 0,
|
|
||||||
Tfo: -1,
|
|
||||||
}
|
|
||||||
runMultiTestCase(t, []TestCase{
|
|
||||||
{
|
|
||||||
Input: `{
|
|
||||||
"tcpFastOpen": false
|
|
||||||
}`,
|
|
||||||
Parser: createParser(),
|
|
||||||
Output: expectedOutput,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if expectedOutput.ParseTFOValue() != 0 {
|
|
||||||
t.Fatalf("unexpected parsed TFO value, which should be 0")
|
|
||||||
}
|
|
||||||
|
|
||||||
// test "tcpFastOpen": 65535, queue length 65535 is expected
|
|
||||||
expectedOutput = &internet.SocketConfig{
|
|
||||||
Mark: 0,
|
|
||||||
Tfo: 65535,
|
|
||||||
}
|
|
||||||
runMultiTestCase(t, []TestCase{
|
|
||||||
{
|
|
||||||
Input: `{
|
|
||||||
"tcpFastOpen": 65535
|
|
||||||
}`,
|
|
||||||
Parser: createParser(),
|
|
||||||
Output: expectedOutput,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if expectedOutput.ParseTFOValue() != 65535 {
|
|
||||||
t.Fatalf("unexpected parsed TFO value, which should be 65535")
|
|
||||||
}
|
|
||||||
|
|
||||||
// test "tcpFastOpen": -65535, disable TFO is expected
|
|
||||||
expectedOutput = &internet.SocketConfig{
|
|
||||||
Mark: 0,
|
|
||||||
Tfo: -65535,
|
|
||||||
}
|
|
||||||
runMultiTestCase(t, []TestCase{
|
|
||||||
{
|
|
||||||
Input: `{
|
|
||||||
"tcpFastOpen": -65535
|
|
||||||
}`,
|
|
||||||
Parser: createParser(),
|
|
||||||
Output: expectedOutput,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if expectedOutput.ParseTFOValue() != 0 {
|
|
||||||
t.Fatalf("unexpected parsed TFO value, which should be 0")
|
|
||||||
}
|
|
||||||
|
|
||||||
// test "tcpFastOpen": 0, no operation is expected
|
|
||||||
expectedOutput = &internet.SocketConfig{
|
|
||||||
Mark: 0,
|
|
||||||
Tfo: 0,
|
|
||||||
}
|
|
||||||
runMultiTestCase(t, []TestCase{
|
|
||||||
{
|
|
||||||
Input: `{
|
|
||||||
"tcpFastOpen": 0
|
|
||||||
}`,
|
|
||||||
Parser: createParser(),
|
|
||||||
Output: expectedOutput,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if expectedOutput.ParseTFOValue() != -1 {
|
|
||||||
t.Fatalf("unexpected parsed TFO value, which should be -1")
|
|
||||||
}
|
|
||||||
|
|
||||||
// test omit "tcpFastOpen", no operation is expected
|
|
||||||
expectedOutput = &internet.SocketConfig{
|
|
||||||
Mark: 0,
|
|
||||||
Tfo: 0,
|
|
||||||
}
|
|
||||||
runMultiTestCase(t, []TestCase{
|
|
||||||
{
|
|
||||||
Input: `{}`,
|
|
||||||
Parser: createParser(),
|
|
||||||
Output: expectedOutput,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if expectedOutput.ParseTFOValue() != -1 {
|
|
||||||
t.Fatalf("unexpected parsed TFO value, which should be -1")
|
|
||||||
}
|
|
||||||
|
|
||||||
// test "tcpFastOpen": null, no operation is expected
|
|
||||||
expectedOutput = &internet.SocketConfig{
|
|
||||||
Mark: 0,
|
|
||||||
Tfo: 0,
|
|
||||||
}
|
|
||||||
runMultiTestCase(t, []TestCase{
|
|
||||||
{
|
|
||||||
Input: `{
|
|
||||||
"tcpFastOpen": null
|
|
||||||
}`,
|
|
||||||
Parser: createParser(),
|
|
||||||
Output: expectedOutput,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if expectedOutput.ParseTFOValue() != -1 {
|
|
||||||
t.Fatalf("unexpected parsed TFO value, which should be -1")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTransportConfig(t *testing.T) {
|
func TestTransportConfig(t *testing.T) {
|
||||||
@@ -208,14 +92,10 @@ func TestTransportConfig(t *testing.T) {
|
|||||||
"header": {
|
"header": {
|
||||||
"type": "dtls"
|
"type": "dtls"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"grpcSettings": {
|
|
||||||
"serviceName": "name",
|
|
||||||
"multiMode": true
|
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
Parser: createParser(),
|
Parser: createParser(),
|
||||||
Output: &global.Config{
|
Output: &transport.Config{
|
||||||
TransportSettings: []*internet.TransportConfig{
|
TransportSettings: []*internet.TransportConfig{
|
||||||
{
|
{
|
||||||
ProtocolName: "tcp",
|
ProtocolName: "tcp",
|
||||||
@@ -282,31 +162,6 @@ func TestTransportConfig(t *testing.T) {
|
|||||||
Header: serial.ToTypedMessage(&tls.PacketConfig{}),
|
Header: serial.ToTypedMessage(&tls.PacketConfig{}),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
ProtocolName: "grpc",
|
|
||||||
Settings: serial.ToTypedMessage(&grpc.Config{
|
|
||||||
ServiceName: "name",
|
|
||||||
MultiMode: true,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Input: `{
|
|
||||||
"gunSettings": {
|
|
||||||
"serviceName": "name"
|
|
||||||
}
|
|
||||||
}`,
|
|
||||||
Parser: createParser(),
|
|
||||||
Output: &global.Config{
|
|
||||||
TransportSettings: []*internet.TransportConfig{
|
|
||||||
{
|
|
||||||
ProtocolName: "grpc",
|
|
||||||
Settings: serial.ToTypedMessage(&grpc.Config{
|
|
||||||
ServiceName: "name",
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@@ -104,7 +104,7 @@ type TrojanUserConfig struct {
|
|||||||
// TrojanServerConfig is Inbound configuration
|
// TrojanServerConfig is Inbound configuration
|
||||||
type TrojanServerConfig struct {
|
type TrojanServerConfig struct {
|
||||||
Clients []*TrojanUserConfig `json:"clients"`
|
Clients []*TrojanUserConfig `json:"clients"`
|
||||||
Fallback *TrojanInboundFallback `json:"fallback"`
|
Fallback json.RawMessage `json:"fallback"`
|
||||||
Fallbacks []*TrojanInboundFallback `json:"fallbacks"`
|
Fallbacks []*TrojanInboundFallback `json:"fallbacks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ type VLessInboundFallback struct {
|
|||||||
type VLessInboundConfig struct {
|
type VLessInboundConfig struct {
|
||||||
Clients []json.RawMessage `json:"clients"`
|
Clients []json.RawMessage `json:"clients"`
|
||||||
Decryption string `json:"decryption"`
|
Decryption string `json:"decryption"`
|
||||||
Fallback *VLessInboundFallback `json:"fallback"`
|
Fallback json.RawMessage `json:"fallback"`
|
||||||
Fallbacks []*VLessInboundFallback `json:"fallbacks"`
|
Fallbacks []*VLessInboundFallback `json:"fallbacks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,7 +2,6 @@ package conf
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/xtls/xray-core/transport/internet"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -62,7 +61,6 @@ type SniffingConfig struct {
|
|||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
DestOverride *StringList `json:"destOverride"`
|
DestOverride *StringList `json:"destOverride"`
|
||||||
DomainsExcluded *StringList `json:"domainsExcluded"`
|
DomainsExcluded *StringList `json:"domainsExcluded"`
|
||||||
MetadataOnly bool `json:"metadataOnly"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build implements Buildable.
|
// Build implements Buildable.
|
||||||
@@ -75,8 +73,6 @@ func (c *SniffingConfig) Build() (*proxyman.SniffingConfig, error) {
|
|||||||
p = append(p, "http")
|
p = append(p, "http")
|
||||||
case "tls", "https", "ssl":
|
case "tls", "https", "ssl":
|
||||||
p = append(p, "tls")
|
p = append(p, "tls")
|
||||||
case "fakedns":
|
|
||||||
p = append(p, "fakedns")
|
|
||||||
default:
|
default:
|
||||||
return nil, newError("unknown protocol: ", protocol)
|
return nil, newError("unknown protocol: ", protocol)
|
||||||
}
|
}
|
||||||
@@ -94,7 +90,6 @@ func (c *SniffingConfig) Build() (*proxyman.SniffingConfig, error) {
|
|||||||
Enabled: c.Enabled,
|
Enabled: c.Enabled,
|
||||||
DestinationOverride: p,
|
DestinationOverride: p,
|
||||||
DomainsExcluded: d,
|
DomainsExcluded: d,
|
||||||
MetadataOnly: c.MetadataOnly,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,22 +267,9 @@ type OutboundDetourConfig struct {
|
|||||||
MuxSettings *MuxConfig `json:"mux"`
|
MuxSettings *MuxConfig `json:"mux"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *OutboundDetourConfig) checkChainProxyConfig() error {
|
|
||||||
if c.StreamSetting == nil || c.ProxySettings == nil || c.StreamSetting.SocketSettings == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if len(c.ProxySettings.Tag) > 0 && len(c.StreamSetting.SocketSettings.DialerProxy) > 0 {
|
|
||||||
return newError("proxySettings.tag is conflicted with sockopt.dialerProxy").AtWarning()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build implements Buildable.
|
// Build implements Buildable.
|
||||||
func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) {
|
func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) {
|
||||||
senderSettings := &proxyman.SenderConfig{}
|
senderSettings := &proxyman.SenderConfig{}
|
||||||
if err := c.checkChainProxyConfig(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.SendThrough != nil {
|
if c.SendThrough != nil {
|
||||||
address := c.SendThrough
|
address := c.SendThrough
|
||||||
@@ -313,18 +295,6 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("invalid outbound detour proxy settings.").Base(err)
|
return nil, newError("invalid outbound detour proxy settings.").Base(err)
|
||||||
}
|
}
|
||||||
if ps.TransportLayerProxy {
|
|
||||||
if senderSettings.StreamSettings != nil {
|
|
||||||
if senderSettings.StreamSettings.SocketSettings != nil {
|
|
||||||
senderSettings.StreamSettings.SocketSettings.DialerProxy = ps.Tag
|
|
||||||
} else {
|
|
||||||
senderSettings.StreamSettings.SocketSettings = &internet.SocketConfig{DialerProxy: ps.Tag}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
senderSettings.StreamSettings = &internet.StreamConfig{SocketSettings: &internet.SocketConfig{DialerProxy: ps.Tag}}
|
|
||||||
}
|
|
||||||
ps = nil
|
|
||||||
}
|
|
||||||
senderSettings.ProxySettings = ps
|
senderSettings.ProxySettings = ps
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,7 +369,6 @@ type Config struct {
|
|||||||
API *APIConfig `json:"api"`
|
API *APIConfig `json:"api"`
|
||||||
Stats *StatsConfig `json:"stats"`
|
Stats *StatsConfig `json:"stats"`
|
||||||
Reverse *ReverseConfig `json:"reverse"`
|
Reverse *ReverseConfig `json:"reverse"`
|
||||||
FakeDNS *FakeDNSConfig `json:"fakeDns"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) findInboundTag(tag string) int {
|
func (c *Config) findInboundTag(tag string) int {
|
||||||
@@ -453,10 +422,6 @@ func (c *Config) Override(o *Config, fn string) {
|
|||||||
c.Reverse = o.Reverse
|
c.Reverse = o.Reverse
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.FakeDNS != nil {
|
|
||||||
c.FakeDNS = o.FakeDNS
|
|
||||||
}
|
|
||||||
|
|
||||||
// deprecated attrs... keep them for now
|
// deprecated attrs... keep them for now
|
||||||
if o.InboundConfig != nil {
|
if o.InboundConfig != nil {
|
||||||
c.InboundConfig = o.InboundConfig
|
c.InboundConfig = o.InboundConfig
|
||||||
@@ -528,10 +493,6 @@ func applyTransportConfig(s *StreamConfig, t *TransportConfig) {
|
|||||||
|
|
||||||
// Build implements Buildable.
|
// Build implements Buildable.
|
||||||
func (c *Config) Build() (*core.Config, error) {
|
func (c *Config) Build() (*core.Config, error) {
|
||||||
if err := PostProcessConfigureFile(c); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
config := &core.Config{
|
config := &core.Config{
|
||||||
App: []*serial.TypedMessage{
|
App: []*serial.TypedMessage{
|
||||||
serial.ToTypedMessage(&dispatcher.Config{}),
|
serial.ToTypedMessage(&dispatcher.Config{}),
|
||||||
@@ -598,14 +559,6 @@ func (c *Config) Build() (*core.Config, error) {
|
|||||||
config.App = append(config.App, serial.ToTypedMessage(r))
|
config.App = append(config.App, serial.ToTypedMessage(r))
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.FakeDNS != nil {
|
|
||||||
r, err := c.FakeDNS.Build()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
config.App = append(config.App, serial.ToTypedMessage(r))
|
|
||||||
}
|
|
||||||
|
|
||||||
var inbounds []InboundDetourConfig
|
var inbounds []InboundDetourConfig
|
||||||
|
|
||||||
if c.InboundConfig != nil {
|
if c.InboundConfig != nil {
|
||||||
|
@@ -26,9 +26,6 @@ Arguments:
|
|||||||
-domain=domain_name
|
-domain=domain_name
|
||||||
The domain name for the certificate.
|
The domain name for the certificate.
|
||||||
|
|
||||||
-name=common_name
|
|
||||||
The common name for the certificate.
|
|
||||||
|
|
||||||
-org=organization
|
-org=organization
|
||||||
The organization name for the certificate.
|
The organization name for the certificate.
|
||||||
|
|
||||||
|
@@ -16,7 +16,6 @@ import (
|
|||||||
|
|
||||||
// Other optional features.
|
// Other optional features.
|
||||||
_ "github.com/xtls/xray-core/app/dns"
|
_ "github.com/xtls/xray-core/app/dns"
|
||||||
_ "github.com/xtls/xray-core/app/dns/fakedns"
|
|
||||||
_ "github.com/xtls/xray-core/app/log"
|
_ "github.com/xtls/xray-core/app/log"
|
||||||
_ "github.com/xtls/xray-core/app/policy"
|
_ "github.com/xtls/xray-core/app/policy"
|
||||||
_ "github.com/xtls/xray-core/app/reverse"
|
_ "github.com/xtls/xray-core/app/reverse"
|
||||||
@@ -40,7 +39,6 @@ import (
|
|||||||
|
|
||||||
// Transports
|
// Transports
|
||||||
_ "github.com/xtls/xray-core/transport/internet/domainsocket"
|
_ "github.com/xtls/xray-core/transport/internet/domainsocket"
|
||||||
_ "github.com/xtls/xray-core/transport/internet/grpc"
|
|
||||||
_ "github.com/xtls/xray-core/transport/internet/http"
|
_ "github.com/xtls/xray-core/transport/internet/http"
|
||||||
_ "github.com/xtls/xray-core/transport/internet/kcp"
|
_ "github.com/xtls/xray-core/transport/internet/kcp"
|
||||||
_ "github.com/xtls/xray-core/transport/internet/quic"
|
_ "github.com/xtls/xray-core/transport/internet/quic"
|
||||||
|
22
main/run.go
22
main/run.go
@@ -11,7 +11,6 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common/cmdarg"
|
"github.com/xtls/xray-core/common/cmdarg"
|
||||||
@@ -32,7 +31,7 @@ Xray. Multiple assign is accepted.
|
|||||||
The -confdir=dir flag sets a dir with multiple json config
|
The -confdir=dir flag sets a dir with multiple json config
|
||||||
|
|
||||||
The -format=json flag sets the format of config files.
|
The -format=json flag sets the format of config files.
|
||||||
Default "auto".
|
Default "json".
|
||||||
|
|
||||||
The -test flag tells Xray to test config files only,
|
The -test flag tells Xray to test config files only,
|
||||||
without launching the server
|
without launching the server
|
||||||
@@ -47,7 +46,7 @@ var (
|
|||||||
configFiles cmdarg.Arg // "Config file for Xray.", the option is customed type, parse in main
|
configFiles cmdarg.Arg // "Config file for Xray.", the option is customed type, parse in main
|
||||||
configDir string
|
configDir string
|
||||||
test = cmdRun.Flag.Bool("test", false, "Test config file only, without launching Xray server.")
|
test = cmdRun.Flag.Bool("test", false, "Test config file only, without launching Xray server.")
|
||||||
format = cmdRun.Flag.String("format", "auto", "Format of input file.")
|
format = cmdRun.Flag.String("format", "json", "Format of input file.")
|
||||||
|
|
||||||
/* We have to do this here because Golang's Test will also need to parse flag, before
|
/* We have to do this here because Golang's Test will also need to parse flag, before
|
||||||
* main func in this file is run.
|
* main func in this file is run.
|
||||||
@@ -112,26 +111,13 @@ func dirExists(file string) bool {
|
|||||||
return err == nil && info.IsDir()
|
return err == nil && info.IsDir()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRegepxByFormat() string {
|
|
||||||
switch strings.ToLower(*format) {
|
|
||||||
case "json":
|
|
||||||
return `^.+\.json$`
|
|
||||||
case "toml":
|
|
||||||
return `^.+\.toml$`
|
|
||||||
case "yaml", "yml":
|
|
||||||
return `^.+\.(yaml|yml)$`
|
|
||||||
default:
|
|
||||||
return `^.+\.(json|toml|yaml|yml)$`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func readConfDir(dirPath string) {
|
func readConfDir(dirPath string) {
|
||||||
confs, err := ioutil.ReadDir(dirPath)
|
confs, err := ioutil.ReadDir(dirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
for _, f := range confs {
|
for _, f := range confs {
|
||||||
matched, err := regexp.MatchString(getRegepxByFormat(), f.Name())
|
matched, err := regexp.MatchString(`^.+\.(json|toml|yaml|yml)$`, f.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
@@ -174,7 +160,7 @@ func getConfigFilePath() cmdarg.Arg {
|
|||||||
func getConfigFormat() string {
|
func getConfigFormat() string {
|
||||||
f := core.GetFormatByExtension(*format)
|
f := core.GetFormatByExtension(*format)
|
||||||
if f == "" {
|
if f == "" {
|
||||||
f = "auto"
|
f = "json"
|
||||||
}
|
}
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
@@ -36,13 +36,25 @@ type ownLinkVerifier interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
client dns.Client
|
ipv4Lookup dns.IPv4Lookup
|
||||||
|
ipv6Lookup dns.IPv6Lookup
|
||||||
ownLinkVerifier ownLinkVerifier
|
ownLinkVerifier ownLinkVerifier
|
||||||
server net.Destination
|
server net.Destination
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) Init(config *Config, dnsClient dns.Client) error {
|
func (h *Handler) Init(config *Config, dnsClient dns.Client) error {
|
||||||
h.client = dnsClient
|
ipv4lookup, ok := dnsClient.(dns.IPv4Lookup)
|
||||||
|
if !ok {
|
||||||
|
return newError("dns.Client doesn't implement IPv4Lookup")
|
||||||
|
}
|
||||||
|
h.ipv4Lookup = ipv4lookup
|
||||||
|
|
||||||
|
ipv6lookup, ok := dnsClient.(dns.IPv6Lookup)
|
||||||
|
if !ok {
|
||||||
|
return newError("dns.Client doesn't implement IPv6Lookup")
|
||||||
|
}
|
||||||
|
h.ipv6Lookup = ipv6lookup
|
||||||
|
|
||||||
if v, ok := dnsClient.(ownLinkVerifier); ok {
|
if v, ok := dnsClient.(ownLinkVerifier); ok {
|
||||||
h.ownLinkVerifier = v
|
h.ownLinkVerifier = v
|
||||||
}
|
}
|
||||||
@@ -197,21 +209,11 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string,
|
|||||||
var ips []net.IP
|
var ips []net.IP
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
var ttl uint32 = 600
|
|
||||||
|
|
||||||
switch qType {
|
switch qType {
|
||||||
case dnsmessage.TypeA:
|
case dnsmessage.TypeA:
|
||||||
ips, err = h.client.LookupIP(domain, dns.IPOption{
|
ips, err = h.ipv4Lookup.LookupIPv4(domain)
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: false,
|
|
||||||
FakeEnable: true,
|
|
||||||
})
|
|
||||||
case dnsmessage.TypeAAAA:
|
case dnsmessage.TypeAAAA:
|
||||||
ips, err = h.client.LookupIP(domain, dns.IPOption{
|
ips, err = h.ipv6Lookup.LookupIPv6(domain)
|
||||||
IPv4Enable: false,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: true,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rcode := dns.RCodeFromError(err)
|
rcode := dns.RCodeFromError(err)
|
||||||
@@ -239,7 +241,7 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string,
|
|||||||
}))
|
}))
|
||||||
common.Must(builder.StartAnswers())
|
common.Must(builder.StartAnswers())
|
||||||
|
|
||||||
rHeader := dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(domain), Class: dnsmessage.ClassINET, TTL: ttl}
|
rHeader := dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(domain), Class: dnsmessage.ClassINET, TTL: 600}
|
||||||
for _, ip := range ips {
|
for _, ip := range ips {
|
||||||
if len(ip) == net.IPv4len {
|
if len(ip) == net.IPv4len {
|
||||||
var r dnsmessage.AResource
|
var r dnsmessage.AResource
|
||||||
|
@@ -59,26 +59,19 @@ func (h *Handler) policy() policy.Session {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) resolveIP(ctx context.Context, domain string, localAddr net.Address) net.Address {
|
func (h *Handler) resolveIP(ctx context.Context, domain string, localAddr net.Address) net.Address {
|
||||||
var option dns.IPOption = dns.IPOption{
|
var lookupFunc func(string) ([]net.IP, error) = h.dns.LookupIP
|
||||||
IPv4Enable: true,
|
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
}
|
|
||||||
if h.config.DomainStrategy == Config_USE_IP4 || (localAddr != nil && localAddr.Family().IsIPv4()) {
|
if h.config.DomainStrategy == Config_USE_IP4 || (localAddr != nil && localAddr.Family().IsIPv4()) {
|
||||||
option = dns.IPOption{
|
if lookupIPv4, ok := h.dns.(dns.IPv4Lookup); ok {
|
||||||
IPv4Enable: true,
|
lookupFunc = lookupIPv4.LookupIPv4
|
||||||
IPv6Enable: false,
|
|
||||||
FakeEnable: false,
|
|
||||||
}
|
}
|
||||||
} else if h.config.DomainStrategy == Config_USE_IP6 || (localAddr != nil && localAddr.Family().IsIPv6()) {
|
} else if h.config.DomainStrategy == Config_USE_IP6 || (localAddr != nil && localAddr.Family().IsIPv6()) {
|
||||||
option = dns.IPOption{
|
if lookupIPv6, ok := h.dns.(dns.IPv6Lookup); ok {
|
||||||
IPv4Enable: false,
|
lookupFunc = lookupIPv6.LookupIPv6
|
||||||
IPv6Enable: true,
|
|
||||||
FakeEnable: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ips, err := h.dns.LookupIP(domain, option)
|
ips, err := lookupFunc(domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newError("failed to get IP address for domain ", domain).Base(err).WriteToLog(session.ExportIDToError(ctx))
|
newError("failed to get IP address for domain ", domain).Base(err).WriteToLog(session.ExportIDToError(ctx))
|
||||||
}
|
}
|
||||||
@@ -132,7 +125,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|||||||
Address: ip,
|
Address: ip,
|
||||||
Port: dialDest.Port,
|
Port: dialDest.Port,
|
||||||
}
|
}
|
||||||
newError("dialing to ", dialDest).WriteToLog(session.ExportIDToError(ctx))
|
newError("dialing to to ", dialDest).WriteToLog(session.ExportIDToError(ctx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -458,7 +458,7 @@ func (s *Server) fallback(ctx context.Context, sid errors.ExportOption, err erro
|
|||||||
if k == '\r' || k == '\n' { // avoid logging \r or \n
|
if k == '\r' || k == '\n' { // avoid logging \r or \n
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if k == '?' || k == ' ' {
|
if k == ' ' {
|
||||||
path = string(firstBytes[i:j])
|
path = string(firstBytes[i:j])
|
||||||
newError("realPath = " + path).AtInfo().WriteToLog(sid)
|
newError("realPath = " + path).AtInfo().WriteToLog(sid)
|
||||||
if pfb[path] == nil {
|
if pfb[path] == nil {
|
||||||
|
@@ -293,7 +293,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
|
|||||||
if k == '\r' || k == '\n' { // avoid logging \r or \n
|
if k == '\r' || k == '\n' { // avoid logging \r or \n
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if k == '?' || k == ' ' {
|
if k == ' ' {
|
||||||
path = string(firstBytes[i:j])
|
path = string(firstBytes[i:j])
|
||||||
newError("realPath = " + path).AtInfo().WriteToLog(sid)
|
newError("realPath = " + path).AtInfo().WriteToLog(sid)
|
||||||
if pfb[path] == nil {
|
if pfb[path] == nil {
|
||||||
|
@@ -178,7 +178,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|||||||
clientReader := link.Reader // .(*pipe.Reader)
|
clientReader := link.Reader // .(*pipe.Reader)
|
||||||
clientWriter := link.Writer // .(*pipe.Writer)
|
clientWriter := link.Writer // .(*pipe.Writer)
|
||||||
|
|
||||||
if request.Command == protocol.RequestCommandUDP && h.cone && request.Port != 53 && request.Port != 443 {
|
if request.Command == protocol.RequestCommandUDP && h.cone {
|
||||||
request.Command = protocol.RequestCommandMux
|
request.Command = protocol.RequestCommandMux
|
||||||
request.Address = net.DomainAddress("v1.mux.cool")
|
request.Address = net.DomainAddress("v1.mux.cool")
|
||||||
request.Port = net.Port(666)
|
request.Port = net.Port(666)
|
||||||
|
@@ -131,7 +131,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
timer := signal.CancelAfterInactivity(ctx, cancel, sessionPolicy.Timeouts.ConnectionIdle)
|
timer := signal.CancelAfterInactivity(ctx, cancel, sessionPolicy.Timeouts.ConnectionIdle)
|
||||||
|
|
||||||
if request.Command == protocol.RequestCommandUDP && h.cone && request.Port != 53 && request.Port != 443 {
|
if request.Command == protocol.RequestCommandUDP && h.cone {
|
||||||
request.Command = protocol.RequestCommandMux
|
request.Command = protocol.RequestCommandMux
|
||||||
request.Address = net.DomainAddress("v1.mux.cool")
|
request.Address = net.DomainAddress("v1.mux.cool")
|
||||||
request.Port = net.Port(666)
|
request.Port = net.Port(666)
|
||||||
|
@@ -6,7 +6,6 @@ package mocks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
gomock "github.com/golang/mock/gomock"
|
gomock "github.com/golang/mock/gomock"
|
||||||
dns "github.com/xtls/xray-core/features/dns"
|
|
||||||
net "net"
|
net "net"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
)
|
)
|
||||||
@@ -49,18 +48,18 @@ func (mr *DNSClientMockRecorder) Close() *gomock.Call {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LookupIP mocks base method
|
// LookupIP mocks base method
|
||||||
func (m *DNSClient) LookupIP(arg0 string, arg1 dns.IPOption) ([]net.IP, error) {
|
func (m *DNSClient) LookupIP(arg0 string) ([]net.IP, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "LookupIP", arg0, arg1)
|
ret := m.ctrl.Call(m, "LookupIP", arg0)
|
||||||
ret0, _ := ret[0].([]net.IP)
|
ret0, _ := ret[0].([]net.IP)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// LookupIP indicates an expected call of LookupIP
|
// LookupIP indicates an expected call of LookupIP
|
||||||
func (mr *DNSClientMockRecorder) LookupIP(arg0, arg1 interface{}) *gomock.Call {
|
func (mr *DNSClientMockRecorder) LookupIP(arg0 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LookupIP", reflect.TypeOf((*DNSClient)(nil).LookupIP), arg0, arg1)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LookupIP", reflect.TypeOf((*DNSClient)(nil).LookupIP), arg0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start mocks base method
|
// Start mocks base method
|
||||||
|
@@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/xtls/xray-core/testing/servers/tcp"
|
"github.com/xtls/xray-core/testing/servers/tcp"
|
||||||
"github.com/xtls/xray-core/testing/servers/udp"
|
"github.com/xtls/xray-core/testing/servers/udp"
|
||||||
"github.com/xtls/xray-core/transport/internet"
|
"github.com/xtls/xray-core/transport/internet"
|
||||||
"github.com/xtls/xray-core/transport/internet/grpc"
|
|
||||||
"github.com/xtls/xray-core/transport/internet/http"
|
"github.com/xtls/xray-core/transport/internet/http"
|
||||||
"github.com/xtls/xray-core/transport/internet/tls"
|
"github.com/xtls/xray-core/transport/internet/tls"
|
||||||
"github.com/xtls/xray-core/transport/internet/websocket"
|
"github.com/xtls/xray-core/transport/internet/websocket"
|
||||||
@@ -590,239 +589,3 @@ func TestHTTP2(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGRPC(t *testing.T) {
|
|
||||||
tcpServer := tcp.Server{
|
|
||||||
MsgProcessor: xor,
|
|
||||||
}
|
|
||||||
dest, err := tcpServer.Start()
|
|
||||||
common.Must(err)
|
|
||||||
defer tcpServer.Close()
|
|
||||||
|
|
||||||
userID := protocol.NewID(uuid.New())
|
|
||||||
serverPort := tcp.PickPort()
|
|
||||||
serverConfig := &core.Config{
|
|
||||||
Inbound: []*core.InboundHandlerConfig{
|
|
||||||
{
|
|
||||||
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
|
|
||||||
PortRange: net.SinglePortRange(serverPort),
|
|
||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
|
||||||
StreamSettings: &internet.StreamConfig{
|
|
||||||
ProtocolName: "grpc",
|
|
||||||
TransportSettings: []*internet.TransportConfig{
|
|
||||||
{
|
|
||||||
ProtocolName: "grpc",
|
|
||||||
Settings: serial.ToTypedMessage(&grpc.Config{ServiceName: "🍉"}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
SecurityType: serial.GetMessageType(&tls.Config{}),
|
|
||||||
SecuritySettings: []*serial.TypedMessage{
|
|
||||||
serial.ToTypedMessage(&tls.Config{
|
|
||||||
Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil))},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
ProxySettings: serial.ToTypedMessage(&inbound.Config{
|
|
||||||
User: []*protocol.User{
|
|
||||||
{
|
|
||||||
Account: serial.ToTypedMessage(&vmess.Account{
|
|
||||||
Id: userID.String(),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Outbound: []*core.OutboundHandlerConfig{
|
|
||||||
{
|
|
||||||
ProxySettings: serial.ToTypedMessage(&freedom.Config{}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
clientPort := tcp.PickPort()
|
|
||||||
clientConfig := &core.Config{
|
|
||||||
Inbound: []*core.InboundHandlerConfig{
|
|
||||||
{
|
|
||||||
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
|
|
||||||
PortRange: net.SinglePortRange(clientPort),
|
|
||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
|
||||||
}),
|
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
|
||||||
Port: uint32(dest.Port),
|
|
||||||
NetworkList: &net.NetworkList{
|
|
||||||
Network: []net.Network{net.Network_TCP},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Outbound: []*core.OutboundHandlerConfig{
|
|
||||||
{
|
|
||||||
ProxySettings: serial.ToTypedMessage(&outbound.Config{
|
|
||||||
Receiver: []*protocol.ServerEndpoint{
|
|
||||||
{
|
|
||||||
Address: net.NewIPOrDomain(net.LocalHostIP),
|
|
||||||
Port: uint32(serverPort),
|
|
||||||
User: []*protocol.User{
|
|
||||||
{
|
|
||||||
Account: serial.ToTypedMessage(&vmess.Account{
|
|
||||||
Id: userID.String(),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
|
||||||
StreamSettings: &internet.StreamConfig{
|
|
||||||
ProtocolName: "grpc",
|
|
||||||
TransportSettings: []*internet.TransportConfig{
|
|
||||||
{
|
|
||||||
ProtocolName: "grpc",
|
|
||||||
Settings: serial.ToTypedMessage(&grpc.Config{ServiceName: "🍉"}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
SecurityType: serial.GetMessageType(&tls.Config{}),
|
|
||||||
SecuritySettings: []*serial.TypedMessage{
|
|
||||||
serial.ToTypedMessage(&tls.Config{
|
|
||||||
AllowInsecure: true,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
|
||||||
common.Must(err)
|
|
||||||
defer CloseAllServers(servers)
|
|
||||||
|
|
||||||
var errg errgroup.Group
|
|
||||||
for i := 0; i < 10; i++ {
|
|
||||||
errg.Go(testTCPConn(clientPort, 1024*10240, time.Second*40))
|
|
||||||
}
|
|
||||||
if err := errg.Wait(); err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGRPCMultiMode(t *testing.T) {
|
|
||||||
tcpServer := tcp.Server{
|
|
||||||
MsgProcessor: xor,
|
|
||||||
}
|
|
||||||
dest, err := tcpServer.Start()
|
|
||||||
common.Must(err)
|
|
||||||
defer tcpServer.Close()
|
|
||||||
|
|
||||||
userID := protocol.NewID(uuid.New())
|
|
||||||
serverPort := tcp.PickPort()
|
|
||||||
serverConfig := &core.Config{
|
|
||||||
Inbound: []*core.InboundHandlerConfig{
|
|
||||||
{
|
|
||||||
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
|
|
||||||
PortRange: net.SinglePortRange(serverPort),
|
|
||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
|
||||||
StreamSettings: &internet.StreamConfig{
|
|
||||||
ProtocolName: "grpc",
|
|
||||||
TransportSettings: []*internet.TransportConfig{
|
|
||||||
{
|
|
||||||
ProtocolName: "grpc",
|
|
||||||
Settings: serial.ToTypedMessage(&grpc.Config{ServiceName: "🍉"}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
SecurityType: serial.GetMessageType(&tls.Config{}),
|
|
||||||
SecuritySettings: []*serial.TypedMessage{
|
|
||||||
serial.ToTypedMessage(&tls.Config{
|
|
||||||
Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil))},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
ProxySettings: serial.ToTypedMessage(&inbound.Config{
|
|
||||||
User: []*protocol.User{
|
|
||||||
{
|
|
||||||
Account: serial.ToTypedMessage(&vmess.Account{
|
|
||||||
Id: userID.String(),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Outbound: []*core.OutboundHandlerConfig{
|
|
||||||
{
|
|
||||||
ProxySettings: serial.ToTypedMessage(&freedom.Config{}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
clientPort := tcp.PickPort()
|
|
||||||
clientConfig := &core.Config{
|
|
||||||
Inbound: []*core.InboundHandlerConfig{
|
|
||||||
{
|
|
||||||
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
|
|
||||||
PortRange: net.SinglePortRange(clientPort),
|
|
||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
|
||||||
}),
|
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
|
||||||
Port: uint32(dest.Port),
|
|
||||||
NetworkList: &net.NetworkList{
|
|
||||||
Network: []net.Network{net.Network_TCP},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Outbound: []*core.OutboundHandlerConfig{
|
|
||||||
{
|
|
||||||
ProxySettings: serial.ToTypedMessage(&outbound.Config{
|
|
||||||
Receiver: []*protocol.ServerEndpoint{
|
|
||||||
{
|
|
||||||
Address: net.NewIPOrDomain(net.LocalHostIP),
|
|
||||||
Port: uint32(serverPort),
|
|
||||||
User: []*protocol.User{
|
|
||||||
{
|
|
||||||
Account: serial.ToTypedMessage(&vmess.Account{
|
|
||||||
Id: userID.String(),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
|
||||||
StreamSettings: &internet.StreamConfig{
|
|
||||||
ProtocolName: "grpc",
|
|
||||||
TransportSettings: []*internet.TransportConfig{
|
|
||||||
{
|
|
||||||
ProtocolName: "grpc",
|
|
||||||
Settings: serial.ToTypedMessage(&grpc.Config{ServiceName: "🍉", MultiMode: true}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
SecurityType: serial.GetMessageType(&tls.Config{}),
|
|
||||||
SecuritySettings: []*serial.TypedMessage{
|
|
||||||
serial.ToTypedMessage(&tls.Config{
|
|
||||||
AllowInsecure: true,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
|
||||||
common.Must(err)
|
|
||||||
defer CloseAllServers(servers)
|
|
||||||
|
|
||||||
var errg errgroup.Group
|
|
||||||
for i := 0; i < 10; i++ {
|
|
||||||
errg.Go(testTCPConn(clientPort, 1024*10240, time.Second*40))
|
|
||||||
}
|
|
||||||
if err := errg.Wait(); err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
package global
|
package transport
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/xtls/xray-core/transport/internet"
|
"github.com/xtls/xray-core/transport/internet"
|
165
transport/config.pb.go
Normal file
165
transport/config.pb.go
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// protoc-gen-go v1.25.0
|
||||||
|
// protoc v3.14.0
|
||||||
|
// source: transport/config.proto
|
||||||
|
|
||||||
|
package transport
|
||||||
|
|
||||||
|
import (
|
||||||
|
proto "github.com/golang/protobuf/proto"
|
||||||
|
internet "github.com/xtls/xray-core/transport/internet"
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
reflect "reflect"
|
||||||
|
sync "sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
// Global transport settings. This affects all type of connections that go
|
||||||
|
// through Xray. Deprecated. Use each settings in StreamConfig.
|
||||||
|
//
|
||||||
|
// Deprecated: Do not use.
|
||||||
|
type Config struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
TransportSettings []*internet.TransportConfig `protobuf:"bytes,1,rep,name=transport_settings,json=transportSettings,proto3" json:"transport_settings,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Config) Reset() {
|
||||||
|
*x = Config{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_transport_config_proto_msgTypes[0]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Config) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Config) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *Config) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_transport_config_proto_msgTypes[0]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
|
||||||
|
func (*Config) Descriptor() ([]byte, []int) {
|
||||||
|
return file_transport_config_proto_rawDescGZIP(), []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Config) GetTransportSettings() []*internet.TransportConfig {
|
||||||
|
if x != nil {
|
||||||
|
return x.TransportSettings
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var File_transport_config_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
|
var file_transport_config_proto_rawDesc = []byte{
|
||||||
|
0x0a, 0x16, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66,
|
||||||
|
0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74,
|
||||||
|
0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x1a, 0x1f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70,
|
||||||
|
0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x6e,
|
||||||
|
0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x65, 0x0a, 0x06, 0x43, 0x6f, 0x6e,
|
||||||
|
0x66, 0x69, 0x67, 0x12, 0x57, 0x0a, 0x12, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74,
|
||||||
|
0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
|
||||||
|
0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74,
|
||||||
|
0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70,
|
||||||
|
0x6f, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x11, 0x74, 0x72, 0x61, 0x6e, 0x73,
|
||||||
|
0x70, 0x6f, 0x72, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x3a, 0x02, 0x18, 0x01,
|
||||||
|
0x42, 0x4c, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61,
|
||||||
|
0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x01, 0x5a, 0x23, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
|
||||||
|
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63,
|
||||||
|
0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0xaa, 0x02, 0x0e,
|
||||||
|
0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x62, 0x06,
|
||||||
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
file_transport_config_proto_rawDescOnce sync.Once
|
||||||
|
file_transport_config_proto_rawDescData = file_transport_config_proto_rawDesc
|
||||||
|
)
|
||||||
|
|
||||||
|
func file_transport_config_proto_rawDescGZIP() []byte {
|
||||||
|
file_transport_config_proto_rawDescOnce.Do(func() {
|
||||||
|
file_transport_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_transport_config_proto_rawDescData)
|
||||||
|
})
|
||||||
|
return file_transport_config_proto_rawDescData
|
||||||
|
}
|
||||||
|
|
||||||
|
var file_transport_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||||
|
var file_transport_config_proto_goTypes = []interface{}{
|
||||||
|
(*Config)(nil), // 0: xray.transport.Config
|
||||||
|
(*internet.TransportConfig)(nil), // 1: xray.transport.internet.TransportConfig
|
||||||
|
}
|
||||||
|
var file_transport_config_proto_depIdxs = []int32{
|
||||||
|
1, // 0: xray.transport.Config.transport_settings:type_name -> xray.transport.internet.TransportConfig
|
||||||
|
1, // [1:1] is the sub-list for method output_type
|
||||||
|
1, // [1:1] is the sub-list for method input_type
|
||||||
|
1, // [1:1] is the sub-list for extension type_name
|
||||||
|
1, // [1:1] is the sub-list for extension extendee
|
||||||
|
0, // [0:1] is the sub-list for field type_name
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { file_transport_config_proto_init() }
|
||||||
|
func file_transport_config_proto_init() {
|
||||||
|
if File_transport_config_proto != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !protoimpl.UnsafeEnabled {
|
||||||
|
file_transport_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_transport_config_proto_rawDesc,
|
||||||
|
NumEnums: 0,
|
||||||
|
NumMessages: 1,
|
||||||
|
NumExtensions: 0,
|
||||||
|
NumServices: 0,
|
||||||
|
},
|
||||||
|
GoTypes: file_transport_config_proto_goTypes,
|
||||||
|
DependencyIndexes: file_transport_config_proto_depIdxs,
|
||||||
|
MessageInfos: file_transport_config_proto_msgTypes,
|
||||||
|
}.Build()
|
||||||
|
File_transport_config_proto = out.File
|
||||||
|
file_transport_config_proto_rawDesc = nil
|
||||||
|
file_transport_config_proto_goTypes = nil
|
||||||
|
file_transport_config_proto_depIdxs = nil
|
||||||
|
}
|
@@ -1,9 +1,9 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package xray.transport;
|
package xray.transport;
|
||||||
option csharp_namespace = "Xray.Transport.Global";
|
option csharp_namespace = "Xray.Transport";
|
||||||
option go_package = "github.com/xtls/xray-core/transport/global";
|
option go_package = "github.com/xtls/xray-core/transport";
|
||||||
option java_package = "com.xray.transport.global";
|
option java_package = "com.xray.transport";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
import "transport/internet/config.proto";
|
import "transport/internet/config.proto";
|
@@ -1,167 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// protoc-gen-go v1.25.0
|
|
||||||
// protoc v3.14.0
|
|
||||||
// source: transport/global/config.proto
|
|
||||||
|
|
||||||
package global
|
|
||||||
|
|
||||||
import (
|
|
||||||
proto "github.com/golang/protobuf/proto"
|
|
||||||
internet "github.com/xtls/xray-core/transport/internet"
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
// Global transport settings. This affects all type of connections that go
|
|
||||||
// through Xray. Deprecated. Use each settings in StreamConfig.
|
|
||||||
//
|
|
||||||
// Deprecated: Do not use.
|
|
||||||
type Config struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
TransportSettings []*internet.TransportConfig `protobuf:"bytes,1,rep,name=transport_settings,json=transportSettings,proto3" json:"transport_settings,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Config) Reset() {
|
|
||||||
*x = Config{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_transport_global_config_proto_msgTypes[0]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Config) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*Config) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *Config) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_transport_global_config_proto_msgTypes[0]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
|
|
||||||
func (*Config) Descriptor() ([]byte, []int) {
|
|
||||||
return file_transport_global_config_proto_rawDescGZIP(), []int{0}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Config) GetTransportSettings() []*internet.TransportConfig {
|
|
||||||
if x != nil {
|
|
||||||
return x.TransportSettings
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_transport_global_config_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
var file_transport_global_config_proto_rawDesc = []byte{
|
|
||||||
0x0a, 0x1d, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x67, 0x6c, 0x6f, 0x62,
|
|
||||||
0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
|
||||||
0x0e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x1a,
|
|
||||||
0x1f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72,
|
|
||||||
0x6e, 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
|
||||||
0x22, 0x65, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x57, 0x0a, 0x12, 0x74, 0x72,
|
|
||||||
0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73,
|
|
||||||
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72,
|
|
||||||
0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74,
|
|
||||||
0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
|
|
||||||
0x52, 0x11, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69,
|
|
||||||
0x6e, 0x67, 0x73, 0x3a, 0x02, 0x18, 0x01, 0x42, 0x61, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x78,
|
|
||||||
0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x67, 0x6c,
|
|
||||||
0x6f, 0x62, 0x61, 0x6c, 0x50, 0x01, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
|
|
||||||
0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72,
|
|
||||||
0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x67, 0x6c, 0x6f, 0x62,
|
|
||||||
0x61, 0x6c, 0xaa, 0x02, 0x15, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70,
|
|
||||||
0x6f, 0x72, 0x74, 0x2e, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
|
||||||
0x6f, 0x33,
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
file_transport_global_config_proto_rawDescOnce sync.Once
|
|
||||||
file_transport_global_config_proto_rawDescData = file_transport_global_config_proto_rawDesc
|
|
||||||
)
|
|
||||||
|
|
||||||
func file_transport_global_config_proto_rawDescGZIP() []byte {
|
|
||||||
file_transport_global_config_proto_rawDescOnce.Do(func() {
|
|
||||||
file_transport_global_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_transport_global_config_proto_rawDescData)
|
|
||||||
})
|
|
||||||
return file_transport_global_config_proto_rawDescData
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_transport_global_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
|
||||||
var file_transport_global_config_proto_goTypes = []interface{}{
|
|
||||||
(*Config)(nil), // 0: xray.transport.Config
|
|
||||||
(*internet.TransportConfig)(nil), // 1: xray.transport.internet.TransportConfig
|
|
||||||
}
|
|
||||||
var file_transport_global_config_proto_depIdxs = []int32{
|
|
||||||
1, // 0: xray.transport.Config.transport_settings:type_name -> xray.transport.internet.TransportConfig
|
|
||||||
1, // [1:1] is the sub-list for method output_type
|
|
||||||
1, // [1:1] is the sub-list for method input_type
|
|
||||||
1, // [1:1] is the sub-list for extension type_name
|
|
||||||
1, // [1:1] is the sub-list for extension extendee
|
|
||||||
0, // [0:1] is the sub-list for field type_name
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { file_transport_global_config_proto_init() }
|
|
||||||
func file_transport_global_config_proto_init() {
|
|
||||||
if File_transport_global_config_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !protoimpl.UnsafeEnabled {
|
|
||||||
file_transport_global_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_transport_global_config_proto_rawDesc,
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 1,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 0,
|
|
||||||
},
|
|
||||||
GoTypes: file_transport_global_config_proto_goTypes,
|
|
||||||
DependencyIndexes: file_transport_global_config_proto_depIdxs,
|
|
||||||
MessageInfos: file_transport_global_config_proto_msgTypes,
|
|
||||||
}.Build()
|
|
||||||
File_transport_global_config_proto = out.File
|
|
||||||
file_transport_global_config_proto_rawDesc = nil
|
|
||||||
file_transport_global_config_proto_goTypes = nil
|
|
||||||
file_transport_global_config_proto_depIdxs = nil
|
|
||||||
}
|
|
@@ -84,56 +84,56 @@ func (TransportProtocol) EnumDescriptor() ([]byte, []int) {
|
|||||||
return file_transport_internet_config_proto_rawDescGZIP(), []int{0}
|
return file_transport_internet_config_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DomainStrategy int32
|
type SocketConfig_TCPFastOpenState int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DomainStrategy_AS_IS DomainStrategy = 0
|
// AsIs is to leave the current TFO state as is, unmodified.
|
||||||
DomainStrategy_USE_IP DomainStrategy = 1
|
SocketConfig_AsIs SocketConfig_TCPFastOpenState = 0
|
||||||
DomainStrategy_USE_IP4 DomainStrategy = 2
|
// Enable is for enabling TFO explictly.
|
||||||
DomainStrategy_USE_IP6 DomainStrategy = 3
|
SocketConfig_Enable SocketConfig_TCPFastOpenState = 1
|
||||||
|
// Disable is for disabling TFO explictly.
|
||||||
|
SocketConfig_Disable SocketConfig_TCPFastOpenState = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum value maps for DomainStrategy.
|
// Enum value maps for SocketConfig_TCPFastOpenState.
|
||||||
var (
|
var (
|
||||||
DomainStrategy_name = map[int32]string{
|
SocketConfig_TCPFastOpenState_name = map[int32]string{
|
||||||
0: "AS_IS",
|
0: "AsIs",
|
||||||
1: "USE_IP",
|
1: "Enable",
|
||||||
2: "USE_IP4",
|
2: "Disable",
|
||||||
3: "USE_IP6",
|
|
||||||
}
|
}
|
||||||
DomainStrategy_value = map[string]int32{
|
SocketConfig_TCPFastOpenState_value = map[string]int32{
|
||||||
"AS_IS": 0,
|
"AsIs": 0,
|
||||||
"USE_IP": 1,
|
"Enable": 1,
|
||||||
"USE_IP4": 2,
|
"Disable": 2,
|
||||||
"USE_IP6": 3,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (x DomainStrategy) Enum() *DomainStrategy {
|
func (x SocketConfig_TCPFastOpenState) Enum() *SocketConfig_TCPFastOpenState {
|
||||||
p := new(DomainStrategy)
|
p := new(SocketConfig_TCPFastOpenState)
|
||||||
*p = x
|
*p = x
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x DomainStrategy) String() string {
|
func (x SocketConfig_TCPFastOpenState) String() string {
|
||||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (DomainStrategy) Descriptor() protoreflect.EnumDescriptor {
|
func (SocketConfig_TCPFastOpenState) Descriptor() protoreflect.EnumDescriptor {
|
||||||
return file_transport_internet_config_proto_enumTypes[1].Descriptor()
|
return file_transport_internet_config_proto_enumTypes[1].Descriptor()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (DomainStrategy) Type() protoreflect.EnumType {
|
func (SocketConfig_TCPFastOpenState) Type() protoreflect.EnumType {
|
||||||
return &file_transport_internet_config_proto_enumTypes[1]
|
return &file_transport_internet_config_proto_enumTypes[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x DomainStrategy) Number() protoreflect.EnumNumber {
|
func (x SocketConfig_TCPFastOpenState) Number() protoreflect.EnumNumber {
|
||||||
return protoreflect.EnumNumber(x)
|
return protoreflect.EnumNumber(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use DomainStrategy.Descriptor instead.
|
// Deprecated: Use SocketConfig_TCPFastOpenState.Descriptor instead.
|
||||||
func (DomainStrategy) EnumDescriptor() ([]byte, []int) {
|
func (SocketConfig_TCPFastOpenState) EnumDescriptor() ([]byte, []int) {
|
||||||
return file_transport_internet_config_proto_rawDescGZIP(), []int{1}
|
return file_transport_internet_config_proto_rawDescGZIP(), []int{3, 0}
|
||||||
}
|
}
|
||||||
|
|
||||||
type SocketConfig_TProxyMode int32
|
type SocketConfig_TProxyMode int32
|
||||||
@@ -185,7 +185,7 @@ func (x SocketConfig_TProxyMode) Number() protoreflect.EnumNumber {
|
|||||||
|
|
||||||
// Deprecated: Use SocketConfig_TProxyMode.Descriptor instead.
|
// Deprecated: Use SocketConfig_TProxyMode.Descriptor instead.
|
||||||
func (SocketConfig_TProxyMode) EnumDescriptor() ([]byte, []int) {
|
func (SocketConfig_TProxyMode) EnumDescriptor() ([]byte, []int) {
|
||||||
return file_transport_internet_config_proto_rawDescGZIP(), []int{3, 0}
|
return file_transport_internet_config_proto_rawDescGZIP(), []int{3, 1}
|
||||||
}
|
}
|
||||||
|
|
||||||
type TransportConfig struct {
|
type TransportConfig struct {
|
||||||
@@ -357,8 +357,7 @@ type ProxyConfig struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
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"`
|
||||||
TransportLayerProxy bool `protobuf:"varint,2,opt,name=transportLayerProxy,proto3" json:"transportLayerProxy,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ProxyConfig) Reset() {
|
func (x *ProxyConfig) Reset() {
|
||||||
@@ -400,13 +399,6 @@ func (x *ProxyConfig) GetTag() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ProxyConfig) GetTransportLayerProxy() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.TransportLayerProxy
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// SocketConfig is options to be applied on network sockets.
|
// SocketConfig is options to be applied on network sockets.
|
||||||
type SocketConfig struct {
|
type SocketConfig struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@@ -416,17 +408,15 @@ type SocketConfig struct {
|
|||||||
// Mark of the connection. If non-zero, the value will be set to SO_MARK.
|
// Mark of the connection. If non-zero, the value will be set to SO_MARK.
|
||||||
Mark int32 `protobuf:"varint,1,opt,name=mark,proto3" json:"mark,omitempty"`
|
Mark int32 `protobuf:"varint,1,opt,name=mark,proto3" json:"mark,omitempty"`
|
||||||
// TFO is the state of TFO settings.
|
// TFO is the state of TFO settings.
|
||||||
Tfo int32 `protobuf:"varint,2,opt,name=tfo,proto3" json:"tfo,omitempty"`
|
Tfo SocketConfig_TCPFastOpenState `protobuf:"varint,2,opt,name=tfo,proto3,enum=xray.transport.internet.SocketConfig_TCPFastOpenState" json:"tfo,omitempty"`
|
||||||
// TProxy is for enabling TProxy socket option.
|
// TProxy is for enabling TProxy socket option.
|
||||||
Tproxy SocketConfig_TProxyMode `protobuf:"varint,3,opt,name=tproxy,proto3,enum=xray.transport.internet.SocketConfig_TProxyMode" json:"tproxy,omitempty"`
|
Tproxy SocketConfig_TProxyMode `protobuf:"varint,3,opt,name=tproxy,proto3,enum=xray.transport.internet.SocketConfig_TProxyMode" json:"tproxy,omitempty"`
|
||||||
// ReceiveOriginalDestAddress is for enabling IP_RECVORIGDSTADDR socket
|
// ReceiveOriginalDestAddress is for enabling IP_RECVORIGDSTADDR socket
|
||||||
// option. This option is for UDP only.
|
// option. This option is for UDP only.
|
||||||
ReceiveOriginalDestAddress bool `protobuf:"varint,4,opt,name=receive_original_dest_address,json=receiveOriginalDestAddress,proto3" json:"receive_original_dest_address,omitempty"`
|
ReceiveOriginalDestAddress bool `protobuf:"varint,4,opt,name=receive_original_dest_address,json=receiveOriginalDestAddress,proto3" json:"receive_original_dest_address,omitempty"`
|
||||||
BindAddress []byte `protobuf:"bytes,5,opt,name=bind_address,json=bindAddress,proto3" json:"bind_address,omitempty"`
|
BindAddress []byte `protobuf:"bytes,5,opt,name=bind_address,json=bindAddress,proto3" json:"bind_address,omitempty"`
|
||||||
BindPort uint32 `protobuf:"varint,6,opt,name=bind_port,json=bindPort,proto3" json:"bind_port,omitempty"`
|
BindPort uint32 `protobuf:"varint,6,opt,name=bind_port,json=bindPort,proto3" json:"bind_port,omitempty"`
|
||||||
AcceptProxyProtocol bool `protobuf:"varint,7,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"`
|
AcceptProxyProtocol bool `protobuf:"varint,7,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"`
|
||||||
DomainStrategy DomainStrategy `protobuf:"varint,8,opt,name=domain_strategy,json=domainStrategy,proto3,enum=xray.transport.internet.DomainStrategy" json:"domain_strategy,omitempty"`
|
|
||||||
DialerProxy string `protobuf:"bytes,9,opt,name=dialer_proxy,json=dialerProxy,proto3" json:"dialer_proxy,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SocketConfig) Reset() {
|
func (x *SocketConfig) Reset() {
|
||||||
@@ -468,11 +458,11 @@ func (x *SocketConfig) GetMark() int32 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SocketConfig) GetTfo() int32 {
|
func (x *SocketConfig) GetTfo() SocketConfig_TCPFastOpenState {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Tfo
|
return x.Tfo
|
||||||
}
|
}
|
||||||
return 0
|
return SocketConfig_AsIs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SocketConfig) GetTproxy() SocketConfig_TProxyMode {
|
func (x *SocketConfig) GetTproxy() SocketConfig_TProxyMode {
|
||||||
@@ -510,20 +500,6 @@ func (x *SocketConfig) GetAcceptProxyProtocol() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SocketConfig) GetDomainStrategy() DomainStrategy {
|
|
||||||
if x != nil {
|
|
||||||
return x.DomainStrategy
|
|
||||||
}
|
|
||||||
return DomainStrategy_AS_IS
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *SocketConfig) GetDialerProxy() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.DialerProxy
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_transport_internet_config_proto protoreflect.FileDescriptor
|
var File_transport_internet_config_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_transport_internet_config_proto_rawDesc = []byte{
|
var file_transport_internet_config_proto_rawDesc = []byte{
|
||||||
@@ -571,58 +547,51 @@ var file_transport_internet_config_proto_rawDesc = []byte{
|
|||||||
0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
|
0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
|
||||||
0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52,
|
0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52,
|
||||||
0x0e, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22,
|
0x0e, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22,
|
||||||
0x51, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10,
|
0x1f, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10,
|
||||||
0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67,
|
0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67,
|
||||||
0x12, 0x30, 0x0a, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79,
|
0x22, 0xd5, 0x03, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69,
|
||||||
0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x74,
|
0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||||
0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f,
|
0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x48, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01,
|
||||||
0x78, 0x79, 0x22, 0xdb, 0x03, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e,
|
0x28, 0x0e, 0x32, 0x36, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70,
|
||||||
0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63,
|
||||||
0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02,
|
0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x54, 0x43, 0x50, 0x46, 0x61, 0x73,
|
||||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, 0x70, 0x72,
|
0x74, 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12,
|
||||||
0x6f, 0x78, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79,
|
0x48, 0x0a, 0x06, 0x74, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32,
|
||||||
|
0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74,
|
||||||
|
0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74,
|
||||||
|
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64,
|
||||||
|
0x65, 0x52, 0x06, 0x74, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x41, 0x0a, 0x1d, 0x72, 0x65, 0x63,
|
||||||
|
0x65, 0x69, 0x76, 0x65, 0x5f, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x65,
|
||||||
|
0x73, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08,
|
||||||
|
0x52, 0x1a, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61,
|
||||||
|
0x6c, 0x44, 0x65, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x21, 0x0a, 0x0c,
|
||||||
|
0x62, 0x69, 0x6e, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01,
|
||||||
|
0x28, 0x0c, 0x52, 0x0b, 0x62, 0x69, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12,
|
||||||
|
0x1b, 0x0a, 0x09, 0x62, 0x69, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01,
|
||||||
|
0x28, 0x0d, 0x52, 0x08, 0x62, 0x69, 0x6e, 0x64, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x32, 0x0a, 0x15,
|
||||||
|
0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f,
|
||||||
|
0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63,
|
||||||
|
0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c,
|
||||||
|
0x22, 0x35, 0x0a, 0x10, 0x54, 0x43, 0x50, 0x46, 0x61, 0x73, 0x74, 0x4f, 0x70, 0x65, 0x6e, 0x53,
|
||||||
|
0x74, 0x61, 0x74, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x73, 0x49, 0x73, 0x10, 0x00, 0x12, 0x0a,
|
||||||
|
0x0a, 0x06, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x69,
|
||||||
|
0x73, 0x61, 0x62, 0x6c, 0x65, 0x10, 0x02, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78,
|
||||||
|
0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a,
|
||||||
|
0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65,
|
||||||
|
0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x5a, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x6e,
|
||||||
|
0x73, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x07, 0x0a,
|
||||||
|
0x03, 0x54, 0x43, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x55, 0x44, 0x50, 0x10, 0x01, 0x12,
|
||||||
|
0x08, 0x0a, 0x04, 0x4d, 0x4b, 0x43, 0x50, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x65, 0x62,
|
||||||
|
0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50,
|
||||||
|
0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x6f, 0x63, 0x6b,
|
||||||
|
0x65, 0x74, 0x10, 0x05, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79,
|
||||||
0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72,
|
0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72,
|
||||||
0x6e, 0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
|
0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
||||||
0x2e, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x06, 0x74, 0x70, 0x72,
|
0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65,
|
||||||
0x6f, 0x78, 0x79, 0x12, 0x41, 0x0a, 0x1d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x5f, 0x6f,
|
0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72,
|
||||||
0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x64, 0x64,
|
0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73,
|
||||||
0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x72, 0x65, 0x63, 0x65,
|
0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70,
|
||||||
0x69, 0x76, 0x65, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x44, 0x65, 0x73, 0x74, 0x41,
|
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x69, 0x6e, 0x64, 0x5f, 0x61,
|
|
||||||
0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x69,
|
|
||||||
0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x69, 0x6e,
|
|
||||||
0x64, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x62, 0x69,
|
|
||||||
0x6e, 0x64, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74,
|
|
||||||
0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18,
|
|
||||||
0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f,
|
|
||||||
0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x50, 0x0a, 0x0f, 0x64, 0x6f,
|
|
||||||
0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x08, 0x20,
|
|
||||||
0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73,
|
|
||||||
0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x44, 0x6f,
|
|
||||||
0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f,
|
|
||||||
0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x21, 0x0a, 0x0c,
|
|
||||||
0x64, 0x69, 0x61, 0x6c, 0x65, 0x72, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x09, 0x20, 0x01,
|
|
||||||
0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x61, 0x6c, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x22,
|
|
||||||
0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a,
|
|
||||||
0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79,
|
|
||||||
0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02,
|
|
||||||
0x2a, 0x5a, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f,
|
|
||||||
0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x00, 0x12, 0x07,
|
|
||||||
0x0a, 0x03, 0x55, 0x44, 0x50, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x4d, 0x4b, 0x43, 0x50, 0x10,
|
|
||||||
0x02, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03,
|
|
||||||
0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x6f,
|
|
||||||
0x6d, 0x61, 0x69, 0x6e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x05, 0x2a, 0x41, 0x0a, 0x0e,
|
|
||||||
0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09,
|
|
||||||
0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45,
|
|
||||||
0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34,
|
|
||||||
0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x42,
|
|
||||||
0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e,
|
|
||||||
0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01,
|
|
||||||
0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c,
|
|
||||||
0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e,
|
|
||||||
0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02,
|
|
||||||
0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e,
|
|
||||||
0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -640,14 +609,14 @@ func file_transport_internet_config_proto_rawDescGZIP() []byte {
|
|||||||
var file_transport_internet_config_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
|
var file_transport_internet_config_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
|
||||||
var file_transport_internet_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
var file_transport_internet_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||||
var file_transport_internet_config_proto_goTypes = []interface{}{
|
var file_transport_internet_config_proto_goTypes = []interface{}{
|
||||||
(TransportProtocol)(0), // 0: xray.transport.internet.TransportProtocol
|
(TransportProtocol)(0), // 0: xray.transport.internet.TransportProtocol
|
||||||
(DomainStrategy)(0), // 1: xray.transport.internet.DomainStrategy
|
(SocketConfig_TCPFastOpenState)(0), // 1: xray.transport.internet.SocketConfig.TCPFastOpenState
|
||||||
(SocketConfig_TProxyMode)(0), // 2: xray.transport.internet.SocketConfig.TProxyMode
|
(SocketConfig_TProxyMode)(0), // 2: xray.transport.internet.SocketConfig.TProxyMode
|
||||||
(*TransportConfig)(nil), // 3: xray.transport.internet.TransportConfig
|
(*TransportConfig)(nil), // 3: xray.transport.internet.TransportConfig
|
||||||
(*StreamConfig)(nil), // 4: xray.transport.internet.StreamConfig
|
(*StreamConfig)(nil), // 4: xray.transport.internet.StreamConfig
|
||||||
(*ProxyConfig)(nil), // 5: xray.transport.internet.ProxyConfig
|
(*ProxyConfig)(nil), // 5: xray.transport.internet.ProxyConfig
|
||||||
(*SocketConfig)(nil), // 6: xray.transport.internet.SocketConfig
|
(*SocketConfig)(nil), // 6: xray.transport.internet.SocketConfig
|
||||||
(*serial.TypedMessage)(nil), // 7: xray.common.serial.TypedMessage
|
(*serial.TypedMessage)(nil), // 7: xray.common.serial.TypedMessage
|
||||||
}
|
}
|
||||||
var file_transport_internet_config_proto_depIdxs = []int32{
|
var file_transport_internet_config_proto_depIdxs = []int32{
|
||||||
0, // 0: xray.transport.internet.TransportConfig.protocol:type_name -> xray.transport.internet.TransportProtocol
|
0, // 0: xray.transport.internet.TransportConfig.protocol:type_name -> xray.transport.internet.TransportProtocol
|
||||||
@@ -656,8 +625,8 @@ var file_transport_internet_config_proto_depIdxs = []int32{
|
|||||||
3, // 3: xray.transport.internet.StreamConfig.transport_settings:type_name -> xray.transport.internet.TransportConfig
|
3, // 3: xray.transport.internet.StreamConfig.transport_settings:type_name -> xray.transport.internet.TransportConfig
|
||||||
7, // 4: xray.transport.internet.StreamConfig.security_settings:type_name -> xray.common.serial.TypedMessage
|
7, // 4: xray.transport.internet.StreamConfig.security_settings:type_name -> xray.common.serial.TypedMessage
|
||||||
6, // 5: xray.transport.internet.StreamConfig.socket_settings:type_name -> xray.transport.internet.SocketConfig
|
6, // 5: xray.transport.internet.StreamConfig.socket_settings:type_name -> xray.transport.internet.SocketConfig
|
||||||
2, // 6: xray.transport.internet.SocketConfig.tproxy:type_name -> xray.transport.internet.SocketConfig.TProxyMode
|
1, // 6: xray.transport.internet.SocketConfig.tfo:type_name -> xray.transport.internet.SocketConfig.TCPFastOpenState
|
||||||
1, // 7: xray.transport.internet.SocketConfig.domain_strategy:type_name -> xray.transport.internet.DomainStrategy
|
2, // 7: xray.transport.internet.SocketConfig.tproxy:type_name -> xray.transport.internet.SocketConfig.TProxyMode
|
||||||
8, // [8:8] is the sub-list for method output_type
|
8, // [8:8] is the sub-list for method output_type
|
||||||
8, // [8:8] is the sub-list for method input_type
|
8, // [8:8] is the sub-list for method input_type
|
||||||
8, // [8:8] is the sub-list for extension type_name
|
8, // [8:8] is the sub-list for extension type_name
|
||||||
|
@@ -17,13 +17,6 @@ enum TransportProtocol {
|
|||||||
DomainSocket = 5;
|
DomainSocket = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DomainStrategy {
|
|
||||||
AS_IS = 0;
|
|
||||||
USE_IP = 1;
|
|
||||||
USE_IP4 = 2;
|
|
||||||
USE_IP6 = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message TransportConfig {
|
message TransportConfig {
|
||||||
// Type of network that this settings supports.
|
// Type of network that this settings supports.
|
||||||
// Deprecated. Use the string form below.
|
// Deprecated. Use the string form below.
|
||||||
@@ -54,18 +47,24 @@ message StreamConfig {
|
|||||||
SocketConfig socket_settings = 6;
|
SocketConfig socket_settings = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ProxyConfig {
|
message ProxyConfig { string tag = 1; }
|
||||||
string tag = 1;
|
|
||||||
bool transportLayerProxy = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SocketConfig is options to be applied on network sockets.
|
// SocketConfig is options to be applied on network sockets.
|
||||||
message SocketConfig {
|
message SocketConfig {
|
||||||
// Mark of the connection. If non-zero, the value will be set to SO_MARK.
|
// Mark of the connection. If non-zero, the value will be set to SO_MARK.
|
||||||
int32 mark = 1;
|
int32 mark = 1;
|
||||||
|
|
||||||
|
enum TCPFastOpenState {
|
||||||
|
// AsIs is to leave the current TFO state as is, unmodified.
|
||||||
|
AsIs = 0;
|
||||||
|
// Enable is for enabling TFO explictly.
|
||||||
|
Enable = 1;
|
||||||
|
// Disable is for disabling TFO explictly.
|
||||||
|
Disable = 2;
|
||||||
|
}
|
||||||
|
|
||||||
// TFO is the state of TFO settings.
|
// TFO is the state of TFO settings.
|
||||||
int32 tfo = 2;
|
TCPFastOpenState tfo = 2;
|
||||||
|
|
||||||
enum TProxyMode {
|
enum TProxyMode {
|
||||||
// TProxy is off.
|
// TProxy is off.
|
||||||
@@ -88,7 +87,4 @@ message SocketConfig {
|
|||||||
uint32 bind_port = 6;
|
uint32 bind_port = 6;
|
||||||
|
|
||||||
bool accept_proxy_protocol = 7;
|
bool accept_proxy_protocol = 7;
|
||||||
|
|
||||||
DomainStrategy domain_strategy = 8;
|
|
||||||
string dialer_proxy = 9;
|
|
||||||
}
|
}
|
||||||
|
@@ -1,14 +0,0 @@
|
|||||||
package grpc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/xtls/xray-core/common"
|
|
||||||
"github.com/xtls/xray-core/transport/internet"
|
|
||||||
)
|
|
||||||
|
|
||||||
const protocolName = "grpc"
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
|
|
||||||
return new(Config)
|
|
||||||
}))
|
|
||||||
}
|
|
@@ -1,172 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// protoc-gen-go v1.25.0
|
|
||||||
// protoc v3.15.6
|
|
||||||
// source: transport/internet/grpc/config.proto
|
|
||||||
|
|
||||||
package grpc
|
|
||||||
|
|
||||||
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"
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
type Config struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"`
|
|
||||||
ServiceName string `protobuf:"bytes,2,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"`
|
|
||||||
MultiMode bool `protobuf:"varint,3,opt,name=multi_mode,json=multiMode,proto3" json:"multi_mode,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Config) Reset() {
|
|
||||||
*x = Config{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_transport_internet_grpc_config_proto_msgTypes[0]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Config) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*Config) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *Config) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_transport_internet_grpc_config_proto_msgTypes[0]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
|
|
||||||
func (*Config) Descriptor() ([]byte, []int) {
|
|
||||||
return file_transport_internet_grpc_config_proto_rawDescGZIP(), []int{0}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Config) GetHost() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Host
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Config) GetServiceName() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.ServiceName
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Config) GetMultiMode() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.MultiMode
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_transport_internet_grpc_config_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
var file_transport_internet_grpc_config_proto_rawDesc = []byte{
|
|
||||||
0x0a, 0x24, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65,
|
|
||||||
0x72, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
|
|
||||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x25, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61,
|
|
||||||
0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e,
|
|
||||||
0x67, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x22, 0x5e, 0x0a,
|
|
||||||
0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18,
|
|
||||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73,
|
|
||||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
|
||||||
0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1d,
|
|
||||||
0x0a, 0x0a, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01,
|
|
||||||
0x28, 0x08, 0x52, 0x09, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x4d, 0x6f, 0x64, 0x65, 0x42, 0x33, 0x5a,
|
|
||||||
0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73,
|
|
||||||
0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73,
|
|
||||||
0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x72,
|
|
||||||
0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
file_transport_internet_grpc_config_proto_rawDescOnce sync.Once
|
|
||||||
file_transport_internet_grpc_config_proto_rawDescData = file_transport_internet_grpc_config_proto_rawDesc
|
|
||||||
)
|
|
||||||
|
|
||||||
func file_transport_internet_grpc_config_proto_rawDescGZIP() []byte {
|
|
||||||
file_transport_internet_grpc_config_proto_rawDescOnce.Do(func() {
|
|
||||||
file_transport_internet_grpc_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_transport_internet_grpc_config_proto_rawDescData)
|
|
||||||
})
|
|
||||||
return file_transport_internet_grpc_config_proto_rawDescData
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_transport_internet_grpc_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
|
||||||
var file_transport_internet_grpc_config_proto_goTypes = []interface{}{
|
|
||||||
(*Config)(nil), // 0: xray.transport.internet.grpc.encoding.Config
|
|
||||||
}
|
|
||||||
var file_transport_internet_grpc_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_transport_internet_grpc_config_proto_init() }
|
|
||||||
func file_transport_internet_grpc_config_proto_init() {
|
|
||||||
if File_transport_internet_grpc_config_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !protoimpl.UnsafeEnabled {
|
|
||||||
file_transport_internet_grpc_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_transport_internet_grpc_config_proto_rawDesc,
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 1,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 0,
|
|
||||||
},
|
|
||||||
GoTypes: file_transport_internet_grpc_config_proto_goTypes,
|
|
||||||
DependencyIndexes: file_transport_internet_grpc_config_proto_depIdxs,
|
|
||||||
MessageInfos: file_transport_internet_grpc_config_proto_msgTypes,
|
|
||||||
}.Build()
|
|
||||||
File_transport_internet_grpc_config_proto = out.File
|
|
||||||
file_transport_internet_grpc_config_proto_rawDesc = nil
|
|
||||||
file_transport_internet_grpc_config_proto_goTypes = nil
|
|
||||||
file_transport_internet_grpc_config_proto_depIdxs = nil
|
|
||||||
}
|
|
@@ -1,10 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
package xray.transport.internet.grpc.encoding;
|
|
||||||
option go_package = "github.com/xtls/xray-core/transport/internet/grpc";
|
|
||||||
|
|
||||||
message Config {
|
|
||||||
string host = 1;
|
|
||||||
string service_name = 2;
|
|
||||||
bool multi_mode = 3;
|
|
||||||
}
|
|
@@ -1,139 +0,0 @@
|
|||||||
package grpc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
gonet "net"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/backoff"
|
|
||||||
"google.golang.org/grpc/connectivity"
|
|
||||||
"google.golang.org/grpc/credentials"
|
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
|
||||||
"github.com/xtls/xray-core/common/net"
|
|
||||||
"github.com/xtls/xray-core/common/session"
|
|
||||||
"github.com/xtls/xray-core/transport/internet"
|
|
||||||
"github.com/xtls/xray-core/transport/internet/grpc/encoding"
|
|
||||||
"github.com/xtls/xray-core/transport/internet/tls"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (internet.Connection, error) {
|
|
||||||
newError("creating connection to ", dest).WriteToLog(session.ExportIDToError(ctx))
|
|
||||||
|
|
||||||
conn, err := dialgRPC(ctx, dest, streamSettings)
|
|
||||||
if err != nil {
|
|
||||||
return nil, newError("failed to dial gRPC").Base(err)
|
|
||||||
}
|
|
||||||
return internet.Connection(conn), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
common.Must(internet.RegisterTransportDialer(protocolName, Dial))
|
|
||||||
}
|
|
||||||
|
|
||||||
type dialerConf struct {
|
|
||||||
net.Destination
|
|
||||||
*internet.SocketConfig
|
|
||||||
*tls.Config
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
globalDialerMap map[dialerConf]*grpc.ClientConn
|
|
||||||
globalDialerAccess sync.Mutex
|
|
||||||
)
|
|
||||||
|
|
||||||
func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (net.Conn, error) {
|
|
||||||
grpcSettings := streamSettings.ProtocolSettings.(*Config)
|
|
||||||
|
|
||||||
tlsConfig := tls.ConfigFromStreamSettings(streamSettings)
|
|
||||||
|
|
||||||
conn, err := getGrpcClient(ctx, dest, tlsConfig, streamSettings.SocketSettings)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, newError("failed to dial gRPC").Base(err)
|
|
||||||
}
|
|
||||||
client := encoding.NewGRPCServiceClient(conn)
|
|
||||||
if grpcSettings.MultiMode {
|
|
||||||
newError("using gRPC multi mode").AtDebug().WriteToLog()
|
|
||||||
grpcService, err := client.(encoding.GRPCServiceClientX).TunMultiCustomName(ctx, grpcSettings.ServiceName)
|
|
||||||
if err != nil {
|
|
||||||
return nil, newError("Cannot dial gRPC").Base(err)
|
|
||||||
}
|
|
||||||
return encoding.NewMultiHunkConn(grpcService, nil), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
grpcService, err := client.(encoding.GRPCServiceClientX).TunCustomName(ctx, grpcSettings.ServiceName)
|
|
||||||
if err != nil {
|
|
||||||
return nil, newError("Cannot dial gRPC").Base(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return encoding.NewHunkConn(grpcService, nil), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getGrpcClient(ctx context.Context, dest net.Destination, tlsConfig *tls.Config, sockopt *internet.SocketConfig) (*grpc.ClientConn, error) {
|
|
||||||
globalDialerAccess.Lock()
|
|
||||||
defer globalDialerAccess.Unlock()
|
|
||||||
|
|
||||||
if globalDialerMap == nil {
|
|
||||||
globalDialerMap = make(map[dialerConf]*grpc.ClientConn)
|
|
||||||
}
|
|
||||||
|
|
||||||
if client, found := globalDialerMap[dialerConf{dest, sockopt, tlsConfig}]; found && client.GetState() != connectivity.Shutdown {
|
|
||||||
return client, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
dialOption := grpc.WithInsecure()
|
|
||||||
|
|
||||||
if tlsConfig != nil {
|
|
||||||
dialOption = grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig.GetTLSConfig()))
|
|
||||||
}
|
|
||||||
|
|
||||||
var grpcDestHost string
|
|
||||||
if dest.Address.Family().IsDomain() {
|
|
||||||
grpcDestHost = dest.Address.Domain()
|
|
||||||
} else {
|
|
||||||
grpcDestHost = dest.Address.IP().String()
|
|
||||||
}
|
|
||||||
conn, err := grpc.Dial(
|
|
||||||
gonet.JoinHostPort(grpcDestHost, dest.Port.String()),
|
|
||||||
dialOption,
|
|
||||||
grpc.WithConnectParams(grpc.ConnectParams{
|
|
||||||
Backoff: backoff.Config{
|
|
||||||
BaseDelay: 500 * time.Millisecond,
|
|
||||||
Multiplier: 1.5,
|
|
||||||
Jitter: 0.2,
|
|
||||||
MaxDelay: 19 * time.Second,
|
|
||||||
},
|
|
||||||
MinConnectTimeout: 5 * time.Second,
|
|
||||||
}),
|
|
||||||
grpc.WithContextDialer(func(gctx context.Context, s string) (gonet.Conn, error) {
|
|
||||||
gctx = session.ContextWithID(gctx, session.IDFromContext(ctx))
|
|
||||||
gctx = session.ContextWithOutbound(gctx, session.OutboundFromContext(ctx))
|
|
||||||
|
|
||||||
rawHost, rawPort, err := net.SplitHostPort(s)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if len(rawPort) == 0 {
|
|
||||||
rawPort = "443"
|
|
||||||
}
|
|
||||||
port, err := net.PortFromString(rawPort)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
address := net.ParseAddress(rawHost)
|
|
||||||
conn, err := internet.DialSystem(gctx, net.TCPDestination(address, port), sockopt)
|
|
||||||
if err != nil {
|
|
||||||
newError("failed to dial connection for gRPC").Base(err).WriteToLog()
|
|
||||||
}
|
|
||||||
return conn, err
|
|
||||||
}),
|
|
||||||
grpc.WithBlock(),
|
|
||||||
grpc.WithReturnConnectionError(),
|
|
||||||
grpc.WithDisableRetry(),
|
|
||||||
)
|
|
||||||
globalDialerMap[dialerConf{dest, sockopt, tlsConfig}] = conn
|
|
||||||
return conn, err
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user