Skip to content

Commit

Permalink
Merge branch 'main' into dev-tun0
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhan6665 committed Mar 28, 2023
2 parents 8f7b552 + ff6bad9 commit e94e801
Show file tree
Hide file tree
Showing 12 changed files with 255 additions and 55 deletions.
84 changes: 58 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Project X

[Project X](https://github.com/XTLS) originates from XTLS protocol, provides a set of network tools such as [Xray-core](https://github.com/XTLS/Xray-core).
[Project X](https://github.com/XTLS) originates from XTLS protocol, providing a set of network tools such as [Xray-core](https://github.com/XTLS/Xray-core) and [REALITY](https://github.com/XTLS/REALITY).

[README](https://github.com/XTLS/Xray-core#readme) is open, so feel free to submit your project [here](https://github.com/XTLS/Xray-core/pulls).

## License

[Mozilla Public License Version 2.0](https://github.com/XTLS/Xray-core/blob/main/LICENSE)

## Document
## Documentation

[Project X](https://xtls.github.io/Xray-docs-next/config/)
[Project X Official Website](https://xtls.github.io)

## Telegram

Expand All @@ -19,22 +21,17 @@
## Installation

- Linux Script
- [Xray-install](https://github.com/XTLS/Xray-install) (Official)
- [XTLS/Xray-install](https://github.com/XTLS/Xray-install)
- Docker
- [teddysun/xray](https://hub.docker.com/r/teddysun/xray)
- One Click
- [Xray_bash_onekey](https://github.com/hello-yunshu/Xray_bash_onekey)
- [Xray-script](https://github.com/kirin10000/Xray-script)
- [v2ray-agent](https://github.com/mack-a/v2ray-agent)
- [Xray_onekey](https://github.com/wulabing/Xray_onekey)
- [Xray-yes](https://github.com/jiuqi9997/Xray-yes)
- [ProxySU](https://github.com/proxysu/ProxySU)
- Web Panel
- [X-UI](https://github.com/FranzKafkaYu/x-ui)
- [X-UI](https://github.com/FranzKafkaYu/x-ui), [X-UI-English](https://github.com/NidukaAkalanka/x-ui-english), [3X-UI](https://github.com/MHSanaei/3x-ui), [X-UI](https://github.com/alireza0/x-ui), [X-UI](https://github.com/diditra/x-ui)
- [Hiddify](https://github.com/hiddify/hiddify-config)
- Tutorial
- [Xray Vision tutorial](https://github.com/chika0801/Xray-install)
- [Xray REALITY tutorial](https://cscot.pages.dev/2023/03/02/Xray-REALITY-tutorial/)
- [Marzban](https://github.com/Gozargah/Marzban)
- One Click
- [Xray-script](https://github.com/kirin10000/Xray-script), [Xray-script](https://github.com/zxcvos/Xray-script), [xray_script](https://github.com/tdjnodj/xray_script)
- [XTool](https://github.com/LordPenguin666/XTool), [Xray_bash_onekey](https://github.com/hello-yunshu/Xray_bash_onekey), [xray-reality](https://github.com/sajjaddg/xray-reality)
- [v2ray-agent](https://github.com/mack-a/v2ray-agent), [Xray_onekey](https://github.com/wulabing/Xray_onekey), [ProxySU](https://github.com/proxysu/ProxySU)
- Magisk
- [Xray4Magisk](https://github.com/CerteKim/Xray4Magisk)
- [Xray_For_Magisk](https://github.com/E7KMbb/Xray_For_Magisk)
Expand All @@ -44,11 +41,17 @@

## Usage

[Xray-examples](https://github.com/XTLS/Xray-examples) / [All-in-One-fallbacks-Nginx](https://github.com/XTLS/Xray-examples/tree/main/All-in-One-fallbacks-Nginx) / [VLESS-TCP-XTLS-Vision](https://github.com/XTLS/Xray-examples/tree/main/VLESS-TCP-XTLS-Vision)

[chika0801's examples](https://github.com/chika0801/Xray-examples)

[lxhao61's examples](https://github.com/lxhao61/integrated-examples)
- Example
- [VLESS-XTLS-uTLS-REALITY](https://github.com/XTLS/REALITY#readme)
- [VLESS-TCP-XTLS-Vision](https://github.com/XTLS/Xray-examples/tree/main/VLESS-TCP-XTLS-Vision)
- [All-in-One-fallbacks-Nginx](https://github.com/XTLS/Xray-examples/tree/main/All-in-One-fallbacks-Nginx)
- Xray-examples
- [XTLS/Xray-examples](https://github.com/XTLS/Xray-examples)
- [chika0801/Xray-examples](https://github.com/chika0801/Xray-examples)
- [lxhao61/integrated-examples](https://github.com/lxhao61/integrated-examples)
- Tutorial
- [XTLS Vision](https://github.com/chika0801/Xray-install)
- [REALITY (English)](https://cscot.pages.dev/2023/03/02/Xray-REALITY-tutorial/)

## GUI Clients

Expand Down Expand Up @@ -77,16 +80,45 @@
- iOS
- [SFI](https://sing-box.sagernet.org/zh/installation/clients/sfi/)
- OpenWrt
- [PassWall](https://github.com/xiaorouji/openwrt-passwall), [PassWall 2](https://github.com/xiaorouji/openwrt-passwall2)
- [ShadowSocksR Plus+](https://github.com/fw876/helloworld)
- [PassWall](https://github.com/xiaorouji/openwrt-passwall)
- [PassWall 2](https://github.com/xiaorouji/openwrt-passwall2)
- [luci-app-xray](https://github.com/yichya/luci-app-xray)
- iOS & macOS
- [luci-app-xray](https://github.com/yichya/luci-app-xray) ([openwrt-xray](https://github.com/yichya/openwrt-xray))
- Windows
- [v2rayN](https://github.com/2dust/v2rayN)
- [Invisible Man - Xray](https://github.com/InvisibleManVPN/InvisibleMan-XRayClient)
- Android
- [v2rayNG](https://github.com/2dust/v2rayNG)
- [X-flutter](https://github.com/XTLS/X-flutter)
- iOS & macOS arm64
- [Mango](https://github.com/daemooon/Mango)
- [Wings X](https://apps.apple.com/app/wings-x/id6446119727)
- macOS arm64 & x64
- [V2RayXS](https://github.com/tzmax/V2RayXS)
- [Wings X](https://apps.apple.com/app/wings-x/id6446119727)

## Others that support VLESS, XTLS, REALITY, PLUX...

- iOS & macOS arm64
- [Shadowrocket](https://apps.apple.com/app/shadowrocket/id932747118)
- [Wings X](https://apps.apple.com/app/wings-x-client/id6446119727)
- [Stash](https://apps.apple.com/app/stash/id1596063349)
- macOS
- [V2RayXS](https://github.com/tzmax/V2RayXS)
- API Wrapper
- [xtlsapi](https://github.com/hiddify/xtlsapi)
- [XrayR](https://github.com/XrayR-project/XrayR)
- [XrayR-release](https://github.com/XrayR-project/XrayR-release)
- [XrayR-V2Board](https://github.com/missuo/XrayR-V2Board)
- [Clash.Meta](https://github.com/MetaCubeX/Clash.Meta)
- [Clash Verge](https://github.com/zzzgydi/clash-verge)
- [clashN](https://github.com/2dust/clashN)
- [Clash Meta for Android](https://github.com/MetaCubeX/ClashMetaForAndroid)
- [meta_for_ios](https://t.me/meta_for_ios)
- [sing-box](https://github.com/SagerNet/sing-box)
- [installReality](https://github.com/BoxXt/installReality)
- [sing-box-for-ios](https://github.com/SagerNet/sing-box-for-ios)

## Contributing

[Code of Conduct](https://github.com/XTLS/Xray-core/blob/main/CODE_OF_CONDUCT.md)

## Credits

Expand Down
6 changes: 4 additions & 2 deletions infra/conf/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func (v *Address) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &rawStr); err != nil {
return newError("invalid address: ", string(data)).Base(err)
}
if strings.HasPrefix(rawStr, "env:") {
rawStr = os.Getenv(rawStr[4:])
}
v.Address = net.ParseAddress(rawStr)

return nil
Expand Down Expand Up @@ -115,8 +118,7 @@ func parseIntPort(data []byte) (net.Port, error) {

func parseStringPort(s string) (net.Port, net.Port, error) {
if strings.HasPrefix(s, "env:") {
s = s[4:]
s = os.Getenv(s)
s = os.Getenv(s[4:])
}

pair := strings.SplitN(s, "-", 2)
Expand Down
2 changes: 2 additions & 0 deletions infra/conf/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type GRPCConfig struct {
HealthCheckTimeout int32 `json:"health_check_timeout"`
PermitWithoutStream bool `json:"permit_without_stream"`
InitialWindowsSize int32 `json:"initial_windows_size"`
UserAgent string `json:"user_agent"`
}

func (g *GRPCConfig) Build() (proto.Message, error) {
Expand All @@ -33,5 +34,6 @@ func (g *GRPCConfig) Build() (proto.Message, error) {
HealthCheckTimeout: g.HealthCheckTimeout,
PermitWithoutStream: g.PermitWithoutStream,
InitialWindowsSize: g.InitialWindowsSize,
UserAgent: g.UserAgent,
}, nil
}
40 changes: 38 additions & 2 deletions transport/internet/grpc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package grpc

import (
"net/url"
"strings"

"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/transport/internet"
Expand All @@ -15,6 +16,41 @@ func init() {
}))
}

func (c *Config) getNormalizedName() string {
return url.PathEscape(c.ServiceName)
func (c *Config) getServiceName() string {
// Normal old school config
if !strings.HasPrefix(c.ServiceName, "/") {
return url.PathEscape(c.ServiceName)
}
// Otherwise new custom paths
rawServiceName := c.ServiceName[1:strings.LastIndex(c.ServiceName, "/")] // trim from first to last '/'
serviceNameParts := strings.Split(rawServiceName, "/")
for i := range serviceNameParts {
serviceNameParts[i] = url.PathEscape(serviceNameParts[i])
}
return strings.Join(serviceNameParts, "/")
}

func (c *Config) getTunStreamName() string {
// Normal old school config
if !strings.HasPrefix(c.ServiceName, "/") {
return "Tun"
}
// Otherwise new custom paths
endingPath := c.ServiceName[strings.LastIndex(c.ServiceName, "/")+1:] // from the last '/' to end of string
return url.PathEscape(strings.Split(endingPath, "|")[0])
}

func (c *Config) getTunMultiStreamName() string {
// Normal old school config
if !strings.HasPrefix(c.ServiceName, "/") {
return "TunMulti"
}
// Otherwise new custom paths
endingPath := c.ServiceName[strings.LastIndex(c.ServiceName, "/")+1:] // from the last '/' to end of string
streamNames := strings.Split(endingPath, "|")
if len(streamNames) == 1 { // client side. Service name is the full path to multi tun
return url.PathEscape(streamNames[0])
} else { // server side. The second part is the path to multi tun
return url.PathEscape(streamNames[1])
}
}
22 changes: 16 additions & 6 deletions transport/internet/grpc/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions transport/internet/grpc/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ message Config {
int32 health_check_timeout = 5;
bool permit_without_stream = 6;
int32 initial_windows_size = 7;
string user_agent = 8;
}
111 changes: 111 additions & 0 deletions transport/internet/grpc/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package grpc

import (
"github.com/stretchr/testify/assert"
"testing"
)

func TestConfig_GetServiceName(t *testing.T) {
tests := []struct {
TestName string
ServiceName string
Expected string
}{
{
TestName: "simple no absolute path",
ServiceName: "hello",
Expected: "hello",
},
{
TestName: "escape no absolute path",
ServiceName: "hello/world!",
Expected: "hello%2Fworld%21",
},
{
TestName: "absolute path",
ServiceName: "/my/sample/path/a|b",
Expected: "my/sample/path",
},
{
TestName: "escape absolute path",
ServiceName: "/hello /world!/a|b",
Expected: "hello%20/world%21",
},
}
for _, test := range tests {
t.Run(test.TestName, func(t *testing.T) {
config := Config{ServiceName: test.ServiceName}
assert.Equal(t, test.Expected, config.getServiceName())
})
}
}

func TestConfig_GetTunStreamName(t *testing.T) {
tests := []struct {
TestName string
ServiceName string
Expected string
}{
{
TestName: "no absolute path",
ServiceName: "hello",
Expected: "Tun",
},
{
TestName: "absolute path server",
ServiceName: "/my/sample/path/tun_service|multi_service",
Expected: "tun_service",
},
{
TestName: "absolute path client",
ServiceName: "/my/sample/path/tun_service",
Expected: "tun_service",
},
{
TestName: "escape absolute path client",
ServiceName: "/m y/sa !mple/pa\\th/tun\\_serv!ice",
Expected: "tun%5C_serv%21ice",
},
}
for _, test := range tests {
t.Run(test.TestName, func(t *testing.T) {
config := Config{ServiceName: test.ServiceName}
assert.Equal(t, test.Expected, config.getTunStreamName())
})
}
}

func TestConfig_GetTunMultiStreamName(t *testing.T) {
tests := []struct {
TestName string
ServiceName string
Expected string
}{
{
TestName: "no absolute path",
ServiceName: "hello",
Expected: "TunMulti",
},
{
TestName: "absolute path server",
ServiceName: "/my/sample/path/tun_service|multi_service",
Expected: "multi_service",
},
{
TestName: "absolute path client",
ServiceName: "/my/sample/path/multi_service",
Expected: "multi_service",
},
{
TestName: "escape absolute path client",
ServiceName: "/m y/sa !mple/pa\\th/mu%lti\\_serv!ice",
Expected: "mu%25lti%5C_serv%21ice",
},
}
for _, test := range tests {
t.Run(test.TestName, func(t *testing.T) {
config := Config{ServiceName: test.ServiceName}
assert.Equal(t, test.Expected, config.getTunMultiStreamName())
})
}
}
Loading

0 comments on commit e94e801

Please sign in to comment.