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

API - Add | Remove Routing Rules #3189

Merged
merged 7 commits into from
Mar 29, 2024
Merged

API - Add | Remove Routing Rules #3189

merged 7 commits into from
Mar 29, 2024

Conversation

hossinasaadi
Copy link
Contributor

add rules : ./xray api adrules --server=127.0.0.1:62789 c1.json c2.json
remove rules : ./xray api rmrules --server=127.0.0.1:62789 ruleTag1 ruleTag2

also add ruleTag to identify rules.

{
...
    "routing": {
...
      "rules": [
        {
          "ruleTag" : "mainRule",
          "outboundTag": "api",
          "type": "field",
          "inboundTag": [
            "api"
          ]
        },
...

@Fangliding
Copy link
Member

It seems the test has failed

@vrnobody
Copy link
Contributor

How about replace the entire routing object? That is easier to implement and use. More over we can hot-switch some balancing strategies too.

@hossinasaadi
Copy link
Contributor Author

It seems the test has failed

now should be ok

Copy link
Member

@yuhan6665 yuhan6665 left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! This is an important new feature. I've made some comments. Looking forward to it

app/router/router.go Outdated Show resolved Hide resolved
app/router/router.go Show resolved Hide resolved
main/commands/all/api/rules_add.go Show resolved Hide resolved
apply balancer config
@hossinasaadi
Copy link
Contributor Author

How about replace the entire routing object? That is easier to implement and use. More over we can hot-switch some balancing strategies too.

hot-switch balancer and replace|append new routing configs added.
@yuhan6665

@yuhan6665 yuhan6665 merged commit 53e5814 into XTLS:main Mar 29, 2024
34 checks passed
@yuhan6665
Copy link
Member

Thanks a lot! When I have time, I will integrate #412 as the next step. (Primarily to support GetRoutingRules API)

@hossinasaadi
Copy link
Contributor Author

hossinasaadi commented Mar 29, 2024

Thanks a lot! When I have time, I will integrate #412 as the next step. (Primarily to support GetRoutingRules API)

glad to hear that.also i will check and see how can i help with that.

@hossinasaadi hossinasaadi deleted the api branch March 29, 2024 17:42
arror added a commit to arror/Xray-core that referenced this pull request Apr 2, 2024
* main: (24 commits)
  Add "nosni" option to send empty SNI (XTLS#3214)
  API: add Source IP Block command (XTLS#3211)
  v1.8.10
  Fix TestXrayConfig in xray_test.go
  Add separate host config for websocket
  Update proto file for websocket and httpupgrade (breaking)
  API - Add | Remove Routing Rules  (XTLS#3189)
  Fix host in headers field does not work XTLS#3191
  fix: config `burstObservatory` override
  Bump github.com/sagernet/sing from 0.3.6 to 0.3.8
  Add support for HTTPupgrade custom headers
  improve balancer_info.go
  Fix(httpupgrade): `X-Forwarded-For` header not read. (XTLS#3172)
  Allow to send through random IPv6
  Update HTTPUpgrade spelling and proto
  Chore: Clean up legacy `field` usage
  Update README.md
  Bump github.com/quic-go/quic-go from 0.41.0 to 0.42.0
  Fix HTTPUpgrade transport register
  HTTPUpgrade 0-RTT (XTLS#3152)
  ...
@mzbqhbc
Copy link

mzbqhbc commented Apr 10, 2024

I run the command line and get this error
failed to perform AddRule: rpc error: code = Unimplemented desc = unknown service xray.app.router.command.RoutingService

@hossinasaadi
Copy link
Contributor Author

RoutingService

I run the command line and get this error failed to perform AddRule: rpc error: code = Unimplemented desc = unknown service xray.app.router.command.RoutingService

    "api": {
      "services": [
        "RoutingService"
      ]
    },

@mzbqhbc
Copy link

mzbqhbc commented Apr 11, 2024

RoutingService

I run the command line and get this error failed to perform AddRule: rpc error: code = Unimplemented desc = unknown service xray.app.router.command.RoutingService

    "api": {
      "services": [
        "RoutingService"
      ]
    },

Thanks

vrnobody pushed a commit to vrnobody/xraycore that referenced this pull request Apr 15, 2024
This reverts commit 53e5814.

Because this commit conflict with api getr/setr.
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.

5 participants