Xray-core icon indicating copy to clipboard operation
Xray-core copied to clipboard

Add the routing management gRPC API

Open tat5522 opened this issue 4 years ago • 8 comments

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

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

tat5522 avatar Mar 20 '21 13:03 tat5522

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

tat5522 avatar Mar 20 '21 14:03 tat5522

4e63c22197683deebb6adc91ebef6b7796131b64

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

AkinoKaede avatar Mar 20 '21 14:03 AkinoKaede

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

tat5522 avatar Mar 20 '21 14:03 tat5522

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 中的测试完成了此项工作

AkinoKaede avatar Mar 20 '21 14:03 AkinoKaede

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无法测试通过。

tat5522 avatar Mar 20 '21 15:03 tat5522

@tat5522

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

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

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

ghost avatar Mar 20 '21 15:03 ghost

@tat5522

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

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

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

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

tat5522 avatar Mar 20 '21 16:03 tat5522

@tat5522

感谢贡献。请在 https://github.com/XTLS/Xray-core/issues/414 中充分讨论后再继续完成此 API。

ghost avatar Mar 21 '21 04:03 ghost