格式化
This commit is contained in:
@@ -21,7 +21,7 @@ import (
|
||||
vmessin "github.com/xtls/xray-core/proxy/vmess/inbound"
|
||||
)
|
||||
|
||||
// AddVMessInbound demonstrates HandlerServiceClient.AddInbound for VMess inbound.
|
||||
// 添加 VMess 入站示例。
|
||||
func AddVMessInbound(ctx context.Context, client command.HandlerServiceClient, tag string, port uint32) error {
|
||||
inbound := inboundConfig(
|
||||
tag,
|
||||
@@ -46,7 +46,7 @@ func AddVMessInbound(ctx context.Context, client command.HandlerServiceClient, t
|
||||
return err
|
||||
}
|
||||
|
||||
// AddVLESSInbound adds a VLESS inbound with Vision style fallbacks.
|
||||
// 添加带 Vision 回落配置的 VLESS 入站。
|
||||
func AddVLESSInbound(ctx context.Context, client command.HandlerServiceClient, tag string, port uint32) error {
|
||||
inbound := inboundConfig(
|
||||
tag,
|
||||
@@ -80,7 +80,7 @@ func AddVLESSInbound(ctx context.Context, client command.HandlerServiceClient, t
|
||||
return err
|
||||
}
|
||||
|
||||
// AddTrojanInbound registers a Trojan inbound with two users and ALPN fallback.
|
||||
// 添加带双用户和 ALPN 回落的 Trojan 入站。
|
||||
func AddTrojanInbound(ctx context.Context, client command.HandlerServiceClient, tag string, port uint32) error {
|
||||
inbound := inboundConfig(
|
||||
tag,
|
||||
@@ -115,7 +115,7 @@ func AddTrojanInbound(ctx context.Context, client command.HandlerServiceClient,
|
||||
return err
|
||||
}
|
||||
|
||||
// AddShadowsocksInbound adds an AEAD Shadowsocks inbound supporting both TCP and UDP.
|
||||
// 添加支持 TCP/UDP 的 AEAD Shadowsocks 入站。
|
||||
func AddShadowsocksInbound(ctx context.Context, client command.HandlerServiceClient, tag string, port uint32) error {
|
||||
inbound := inboundConfig(
|
||||
tag,
|
||||
@@ -137,7 +137,7 @@ func AddShadowsocksInbound(ctx context.Context, client command.HandlerServiceCli
|
||||
return err
|
||||
}
|
||||
|
||||
// AddShadowsocks2022Inbound covers both single user and multi-user deployment.
|
||||
// 添加 Shadowsocks 2022 入站,兼容单用户和多用户场景。
|
||||
func AddShadowsocks2022Inbound(ctx context.Context, client command.HandlerServiceClient, tag string, port uint32) error {
|
||||
server := &ss2022.MultiUserServerConfig{
|
||||
Method: "2022-blake3-aes-128-gcm",
|
||||
@@ -168,7 +168,7 @@ func AddShadowsocks2022Inbound(ctx context.Context, client command.HandlerServic
|
||||
return err
|
||||
}
|
||||
|
||||
// AddSocksInbound exposes a SOCKS5 server with username/password authentication.
|
||||
// 添加带账号密码认证的 SOCKS5 入站。
|
||||
func AddSocksInbound(ctx context.Context, client command.HandlerServiceClient, tag string, port uint32) error {
|
||||
inbound := inboundConfig(
|
||||
tag,
|
||||
@@ -184,7 +184,7 @@ func AddSocksInbound(ctx context.Context, client command.HandlerServiceClient, t
|
||||
return err
|
||||
}
|
||||
|
||||
// AddHTTPInbound adds an HTTP proxy inbound with basic auth.
|
||||
// 添加带基础认证的 HTTP 入站。
|
||||
func AddHTTPInbound(ctx context.Context, client command.HandlerServiceClient, tag string, port uint32) error {
|
||||
inbound := inboundConfig(
|
||||
tag,
|
||||
@@ -199,7 +199,7 @@ func AddHTTPInbound(ctx context.Context, client command.HandlerServiceClient, ta
|
||||
return err
|
||||
}
|
||||
|
||||
// AddDokodemoInbound configures a dokodemo-door mirror port.
|
||||
// 添加 dokodemo-door 入站并转发到目标端口。
|
||||
func AddDokodemoInbound(ctx context.Context, client command.HandlerServiceClient, tag string, port uint32, targetPort uint32) error {
|
||||
inbound := inboundConfig(
|
||||
tag,
|
||||
@@ -216,7 +216,7 @@ func AddDokodemoInbound(ctx context.Context, client command.HandlerServiceClient
|
||||
return err
|
||||
}
|
||||
|
||||
// AddDNSInbound exposes the built-in DNS server on an API port.
|
||||
// 添加内置 DNS 入站。
|
||||
func AddDNSInbound(ctx context.Context, client command.HandlerServiceClient, tag string, port uint32) error {
|
||||
inbound := inboundConfig(
|
||||
tag,
|
||||
@@ -235,7 +235,7 @@ func AddDNSInbound(ctx context.Context, client command.HandlerServiceClient, tag
|
||||
return err
|
||||
}
|
||||
|
||||
// AddLoopbackInbound ties an inbound to an existing outbound chain.
|
||||
// 添加 loopback 入站并绑定已有出站链路。
|
||||
func AddLoopbackInbound(ctx context.Context, client command.HandlerServiceClient, tag string, port uint32, targetInbound string) error {
|
||||
inbound := inboundConfig(
|
||||
tag,
|
||||
@@ -245,4 +245,3 @@ func AddLoopbackInbound(ctx context.Context, client command.HandlerServiceClient
|
||||
_, err := client.AddInbound(ctx, &command.AddInboundRequest{Inbound: inbound})
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -195,4 +195,3 @@ func AddVMessOutbound(ctx context.Context, client command.HandlerServiceClient,
|
||||
_, err := client.AddOutbound(ctx, &command.AddOutboundRequest{Outbound: cfg})
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/xtls/xray-core/proxy/vmess"
|
||||
)
|
||||
|
||||
// AddVMessUser demonstrates AlterInbound(AddUserOperation) for VMess.
|
||||
// 通过 AlterInbound(AddUserOperation) 为 VMess 入站加用户。
|
||||
func AddVMessUser(ctx context.Context, client command.HandlerServiceClient, inboundTag, email string) error {
|
||||
req := &command.AlterInboundRequest{
|
||||
Tag: inboundTag,
|
||||
@@ -34,7 +34,7 @@ func AddVMessUser(ctx context.Context, client command.HandlerServiceClient, inbo
|
||||
return err
|
||||
}
|
||||
|
||||
// AddVLESSUser shows how to add VLESS users dynamically.
|
||||
// 为 VLESS 入站动态加用户。
|
||||
func AddVLESSUser(ctx context.Context, client command.HandlerServiceClient, inboundTag, email string) error {
|
||||
req := &command.AlterInboundRequest{
|
||||
Tag: inboundTag,
|
||||
@@ -53,7 +53,7 @@ func AddVLESSUser(ctx context.Context, client command.HandlerServiceClient, inbo
|
||||
return err
|
||||
}
|
||||
|
||||
// AddTrojanUser adds a Trojan password to an inbound handler.
|
||||
// 为 Trojan 入站加密码用户。
|
||||
func AddTrojanUser(ctx context.Context, client command.HandlerServiceClient, inboundTag, email, password string) error {
|
||||
req := &command.AlterInboundRequest{
|
||||
Tag: inboundTag,
|
||||
@@ -71,7 +71,7 @@ func AddTrojanUser(ctx context.Context, client command.HandlerServiceClient, inb
|
||||
return err
|
||||
}
|
||||
|
||||
// AddShadowsocksUser sets up a Shadowsocks AEAD credential.
|
||||
// 为 Shadowsocks 入站加 AEAD 凭据。
|
||||
func AddShadowsocksUser(ctx context.Context, client command.HandlerServiceClient, inboundTag, email, password string) error {
|
||||
req := &command.AlterInboundRequest{
|
||||
Tag: inboundTag,
|
||||
@@ -90,7 +90,7 @@ func AddShadowsocksUser(ctx context.Context, client command.HandlerServiceClient
|
||||
return err
|
||||
}
|
||||
|
||||
// AddShadowsocks2022User covers key rotation for SS2022.
|
||||
// 为 SS2022 入站新增用户密钥。
|
||||
func AddShadowsocks2022User(ctx context.Context, client command.HandlerServiceClient, inboundTag, email string) error {
|
||||
req := &command.AlterInboundRequest{
|
||||
Tag: inboundTag,
|
||||
@@ -107,7 +107,7 @@ func AddShadowsocks2022User(ctx context.Context, client command.HandlerServiceCl
|
||||
return err
|
||||
}
|
||||
|
||||
// RemoveUser removes any user (identified by email) from an inbound.
|
||||
// 按邮箱从入站移除用户。
|
||||
func RemoveUser(ctx context.Context, client command.HandlerServiceClient, inboundTag, email string) error {
|
||||
req := &command.AlterInboundRequest{
|
||||
Tag: inboundTag,
|
||||
|
||||
Reference in New Issue
Block a user