Merge pull request #680 from xepher/master

Add gRPC support
This commit is contained in:
ChsBuffer
2021-06-30 13:29:43 +08:00
committed by GitHub
6 changed files with 44 additions and 4 deletions

View File

@@ -48,9 +48,11 @@
"Transfer Protocol": "传输协议",
"Fake Type": "伪装类型",
"Host": "主机",
"Path": "路径",
"Path": "路径/服务名称",
"QUIC Security": "QUIC 加密方式",
"QUIC Secret": "QUIC 加密密钥",
"GRPC Mode": "QUIC 模式",
"GRPC ServiceName": "QUIC 服务名称",
"TLS Secure": "TLS 底层传输安全",
"Use Mux": "Mux 多路复用",
"Encrypt Method": "加密方式",

View File

@@ -183,6 +183,8 @@ namespace Netch.Servers.Models
public QuicSettings quicSettings { get; set; }
public TlsSettings xtlsSettings { get; set; }
public GrpcSettings grpcSettings { get; set; }
}
public class TlsSettings
@@ -278,4 +280,11 @@ namespace Netch.Servers.Models
public Header header { get; set; }
}
public class GrpcSettings
{
public string serviceName { get; set; }
public bool multiMode { get; set; }
}
}

View File

@@ -31,7 +31,7 @@
public string net { get; set; } = string.Empty;
/// <summary>
/// 伪装路径
/// 伪装路径/服务名称
/// </summary>
public string? path { get; set; } = string.Empty;

View File

@@ -310,6 +310,20 @@ namespace Netch.Servers.Utils
streamSettings.quicSettings = quicSettings;
break;
case "grpc":
var grpcSettings = new GrpcSettings
{
serviceName = server.Path,
multiMode = false
};
if (server.FakeType == "multi")
{
grpcSettings.multiMode = true;
}
streamSettings.grpcSettings = grpcSettings;
break;
default:
if (server.FakeType == "http")
{

View File

@@ -47,6 +47,10 @@ namespace Netch.Servers
server.QUICSecret = parameter.Get("key") ?? "";
server.FakeType = parameter.Get("headerType") ?? "none";
break;
case "grpc":
server.FakeType = parameter.Get("mode") ?? "gun";
server.Path = parameter.Get("serviceName") ?? "";
break;
}
server.TLSSecureType = parameter.Get("security") ?? "none";
@@ -115,6 +119,14 @@ namespace Netch.Servers
if (server.FakeType != "none")
parameter.Add("headerType", server.FakeType);
break;
case "grpc":
if (!string.IsNullOrEmpty(server.Path))
parameter.Add("serviceName", server.Path);
if (server.FakeType == "gun" || server.FakeType == "multi")
parameter.Add("mode", server.FakeType);
break;
}

View File

@@ -101,7 +101,8 @@ namespace Netch.Servers.VMess
"kcp",
"ws",
"h2",
"quic"
"quic",
"grpc"
};
/// <summary>
@@ -115,7 +116,9 @@ namespace Netch.Servers.VMess
"utp",
"wechat-video",
"dtls",
"wireguard"
"wireguard",
"gun",
"multi"
};
/// <summary>