Skip to content

feat(api): Add ListInbounds and ListOutbounds to the gRPC API #4723

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

gsergey418
Copy link

Fixes #2745. Add the ListInbounds and ListOutbounds methods to the gRPC HandlerService and write the respective CLI commands lsi and lso.

@gsergey418 gsergey418 marked this pull request as ready for review May 14, 2025 13:09
@gsergey418
Copy link
Author

gsergey418 commented May 14, 2025

Got it to work, added both methods, wrote a test and added the corresponding CLI commands. Expaneded two interfaces marked as xray:api:stable: features/inbound and features/outbound. May not be the best solution as I'm not very familiar with the codebase, so feel free to correct me. Currently it works like this:

$ ./xray api lsi -s localhost:1081
{
    "inbounds": [
        {
            "proxySettings": {
                "_TypedMessage_": "xray.proxy.http.ServerConfig",
                "accounts": {
                    "gsergey418": "REDACTED"
                }
            },
            "receiverSettings": {
                "_TypedMessage_": "xray.app.proxyman.ReceiverConfig",
                "listen": "127.0.0.1",
                "portList": 1080
            },
            "tag": "http"
        }
    ]
}

$ ./xray api lso -s localhost:1081
{
    "outbounds": [
        {
            "proxySettings": {
                "_TypedMessage_": "xray.proxy.freedom.Config"
            },
            "senderSettings": {
                "_TypedMessage_": "xray.app.proxyman.SenderConfig"
            },
            "tag": "direct"
        },
        {
            "proxySettings": {
                "_TypedMessage_": "xray.proxy.vless.outbound.Config",
                "vnext": [
                    {
                        "address": "REDACTED",
                        "port": 10086,
                        "user": [
                            {
                                "account": {
                                    "_TypedMessage_": "xray.proxy.vless.Account",
                                    "encryption": "none",
                                    "id": "REDACTED"
                                }
                            }
                        ]
                    }
                ]
            },
            "senderSettings": {
                "_TypedMessage_": "xray.app.proxyman.SenderConfig",
                "streamSettings": {
                    "protocolName": "tcp",
                    "socketSettings": {}
                }
            },
            "tag": "proxy"
        },
        {
            "proxySettings": {
                "_TypedMessage_": "xray.proxy.blackhole.Config"
            },
            "senderSettings": {
                "_TypedMessage_": "xray.app.proxyman.SenderConfig"
            },
            "tag": "block"
        }
    ]
}

@gsergey418
Copy link
Author

gsergey418 commented May 14, 2025

Opened a PR to the documentation. Similar changes needed in Chinese version and https://github.com/XTLS/Xray-API-documents.

@Fangliding
Copy link
Member

Could you set protoc and protoc-gen-go to the same version as in the core?

@gsergey418
Copy link
Author

@Fangliding Done

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.

gRPC APIs for list of inbounds and users
2 participants