Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the routing management gRPC API #412

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

Add the routing management gRPC API #412

wants to merge 11 commits into from

Conversation

tat5522
Copy link

@tat5522 tat5522 commented Mar 20, 2021

参照handlerService写了一份控制路由的grpc api。
支持使用gRPC 增加 删除 改变 RuleObjectBalancerObject。风格基本与handlerservice一致。
原本的RuleObject没有tag属性,此次修改增加了tag属性。用于控制从配置文件加入的RuleObject,不填tag属性时会采用uuid作为RuleObject的tag。原本RuleObject的tag标签改为TargetTag。

Test Case只完成了RuleObject相关的。BalancerObject由于不会添加Outbound所以未能完成。

@AkinoKaede AkinoKaede requested review from RPRX, a user and AkinoKaede March 20, 2021 13:48
@tat5522
Copy link
Author

tat5522 commented Mar 20, 2021

为啥三个test check过不了。
测试了commit 4e63c22197683deebb6adc91ebef6b7796131b64 也是一样无法通过

@AkinoKaede
Copy link
Contributor

4e63c22197683deebb6adc91ebef6b7796131b64

FAIL	github.com/xtls/xray-core/app/router [build failed]

@tat5522
Copy link
Author

tat5522 commented Mar 20, 2021

4e63c22197683deebb6adc91ebef6b7796131b64

FAIL	github.com/xtls/xray-core/app/router [build failed]

缺少geoip.dat文件导致的test测试不过。

panic: open D:\Xray-core\resources\geoip.dat: The system cannot find the path specified.

goroutine 1 [running]:
github.com/xtls/xray-core/common.Must(...)
        D:/Xray-core/common/common.go:26
github.com/xtls/xray-core/app/router_test.init.0()
        D:/Xray-core/app/router/condition_geoip_test.go:21 +0x42c
FAIL    github.com/xtls/xray-core/app/router    0.272s

@AkinoKaede
Copy link
Contributor

AkinoKaede commented Mar 20, 2021

4e63c22197683deebb6adc91ebef6b7796131b64

FAIL	github.com/xtls/xray-core/app/router [build failed]

缺少geoip.dat文件导致的test测试不过。

panic: open D:\Xray-core\resources\geoip.dat: The system cannot find the path specified.

goroutine 1 [running]:
github.com/xtls/xray-core/common.Must(...)
        D:/Xray-core/common/common.go:26
github.com/xtls/xray-core/app/router_test.init.0()
        D:/Xray-core/app/router/condition_geoip_test.go:21 +0x42c
FAIL    github.com/xtls/xray-core/app/router    0.272s

测试前应该先将 geoip.datgeosite.dat 放入 resources 目录下,GitHub Actions 中的测试完成了此项工作

@tat5522
Copy link
Author

tat5522 commented Mar 20, 2021

4e63c22197683deebb6adc91ebef6b7796131b64

FAIL	github.com/xtls/xray-core/app/router [build failed]

缺少geoip.dat文件导致的test测试不过。

panic: open D:\Xray-core\resources\geoip.dat: The system cannot find the path specified.

goroutine 1 [running]:
github.com/xtls/xray-core/common.Must(...)
        D:/Xray-core/common/common.go:26
github.com/xtls/xray-core/app/router_test.init.0()
        D:/Xray-core/app/router/condition_geoip_test.go:21 +0x42c
FAIL    github.com/xtls/xray-core/app/router    0.272s

测试前应该先将 geoip.datgeosite.dat 放入 resources 目录下,GitHub Actions 中的测试完成了此项工作

Windows 环境测试通过,Macos和ubuntu无法测试通过。

domainStrategy Config_DomainStrategy
rules []*Rule
rules map[string]*Rule
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Golang Map 是无序的,但是 rules 要求有序

@ghost ghost marked this pull request as draft March 20, 2021 15:37
@ghost
Copy link

ghost commented Mar 20, 2021

@tat5522

感谢您的贡献,有几个需要注意的地方需要说明:

  • Map
  • 一些代码需要格式化(import)。
  • 我个人认为不应修改单个路由规则,而是直接修改整体。

因此,我暂时将此 PR 修改为 work in progress。

@tat5522
Copy link
Author

tat5522 commented Mar 20, 2021

@tat5522

感谢您的贡献,有几个需要注意的地方需要说明:

  • Map
  • 一些代码需要格式化(import)。
  • 我个人认为不应修改单个路由规则,而是直接修改整体。

因此,我暂时将此 PR 修改为 work in progress。

Map已修改为Slice,取出时采用遍历方式取出需要的RuleObject
Import的格式化,需要什么格式的?Windows下开发使用go fmt ./...命令格式化似乎会遇到换行符CRLF问题。
修改整体采用API似乎不太容易做到控制单一路由。

@tat5522 tat5522 requested a review from a user March 20, 2021 16:56
@ghost ghost mentioned this pull request Mar 21, 2021
@ghost
Copy link

ghost commented Mar 21, 2021

@tat5522

感谢贡献。请在 #414 中充分讨论后再继续完成此 API。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Routing API 请问有无计划增加动态添加路由规则的grpcAPI?
2 participants