Skip to content

gRPC Custom Path#1815

Merged
RPRX merged 4 commits intoXTLS:mainfrom
HirbodBehnam:grpc-custompath
Mar 26, 2023
Merged

gRPC Custom Path#1815
RPRX merged 4 commits intoXTLS:mainfrom
HirbodBehnam:grpc-custompath

Conversation

@HirbodBehnam
Copy link
Contributor

@HirbodBehnam HirbodBehnam commented Mar 18, 2023

In this PR, I added the ability to define custom full paths for gRPC as discussed in #1793. I added some tests as well just for the sake of it.
Here are two example configs:
Server:

{
    "log": {
        "loglevel": "debug"
    },
    "inbounds": [{
            "listen": "127.0.0.1",
            "port": 12345,
            "protocol": "trojan",
            "settings": {
                "clients": [{
                        "password": "123456"
                    }
                ]
            },
            "streamSettings": {
                "network": "gun",
                "security": "none",
                "grpcSettings": {
                    "serviceName": "/my/sample/path/customTun|customTunMulti"
                }
            }
        }
    ],
    "outbounds": [{
            "protocol": "freedom"
        }
    ]
}

Client Tun:

{
    "log": {
        "loglevel": "debug"
    },
    "inbounds": [{
            "listen": "127.0.0.1",
            "port": "10818",
            "protocol": "socks"
        }
    ],
    "outbounds": [{
            "protocol": "trojan",
            "settings": {
                "servers": [{
                        "address": "127.0.0.1",
                        "port": 12345,
                        "password": "123456"
                    }
                ]
            },
            "streamSettings": {
                "network": "gun",
                "security": "none",
                "grpcSettings": {
                    "serviceName": "/my/sample/path/customTun",
                    "multiMode": false
                }
            }
        }
    ]
}

Client Multi Tun:

{
    "log": {
        "loglevel": "debug"
    },
    "inbounds": [{
            "listen": "127.0.0.1",
            "port": "10818",
            "protocol": "socks"
        }
    ],
    "outbounds": [{
            "protocol": "trojan",
            "settings": {
                "servers": [{
                        "address": "127.0.0.1",
                        "port": 12345,
                        "password": "123456"
                    }
                ]
            },
            "streamSettings": {
                "network": "gun",
                "security": "none",
                "grpcSettings": {
                    "serviceName": "/my/sample/path/customTunMulti",
                    "multiMode": true
                }
            }
        }
    ]
}

As you can see, we have the limitation that both Tun and Tun Multi endpoints must have the same sub-route. There is a very small problem with this implementation: Service names like / will crash the app. We need to make sure that if the service name starts with /, it has at least two / in it. We should probably somehow validate the config file.
This PR will close #1793

@RPRX
Copy link
Member

RPRX commented Mar 18, 2023

感谢 PR,麻烦把 MultiTun 字样改成 TunMulti

@RPRX RPRX merged commit 1cf5bef into XTLS:main Mar 26, 2023
@RPRX
Copy link
Member

RPRX commented Mar 26, 2023

再次感谢!

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.

[Enhancement] Allow custom path and stream name for gRPC

2 participants