diff --git a/docs/config.yaml b/docs/config.yaml index 9c55b69b4..f72576ec1 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -1891,8 +1891,8 @@ listeners: # after-bytes: 0 # 传输指定字节后开始限速 # bytes-per-sec: 0 # 基准速率(字节/秒) # burst-bytes-per-sec: 0 # 突发速率(字节/秒),大于 bytesPerSec 时生效 - # 如果填写tlsmirror则开启tlsmirror(注意不可与certificate和private-key同时填写) - # tlsmirror: + # 如果填写tlsmirror-config则开启tlsmirror(注意不可与certificate和private-key同时填写) + # tlsmirror-config: # dest: test.com:443 # primary-key: MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWY= # 必填,32 字节主密钥的 base64 编码 # proxy: "" diff --git a/listener/config/vmess.go b/listener/config/vmess.go index b218f03d3..e45a6499a 100644 --- a/listener/config/vmess.go +++ b/listener/config/vmess.go @@ -26,11 +26,11 @@ type VmessServer struct { ClientAuthCert string EchKey string RealityConfig reality.Config - TLSMirror TLSMirror - MuxOption sing.MuxOption `yaml:"mux-option" json:"mux-option,omitempty"` + TLSMirrorConfig TLSMirrorConfig `yaml:"tlsmirror-config" json:"tlsmirror-config,omitempty"` + MuxOption sing.MuxOption `yaml:"mux-option" json:"mux-option,omitempty"` } -type TLSMirror struct { +type TLSMirrorConfig struct { PrimaryKey string `yaml:"primary-key" json:"primary-key,omitempty"` Dest string `yaml:"dest" json:"dest,omitempty"` Proxy string `yaml:"proxy" json:"proxy,omitempty"` diff --git a/listener/inbound/tlsmirror.go b/listener/inbound/tlsmirror.go index fba53b7d8..9407132a3 100644 --- a/listener/inbound/tlsmirror.go +++ b/listener/inbound/tlsmirror.go @@ -4,7 +4,7 @@ import ( LC "github.com/metacubex/mihomo/listener/config" ) -type TLSMirror struct { +type TLSMirrorConfig struct { PrimaryKey string `inbound:"primary-key,omitempty"` Dest string `inbound:"dest,omitempty"` Proxy string `inbound:"proxy,omitempty"` @@ -52,8 +52,8 @@ func (p TLSMirrorTransportLayerPadding) Build() LC.TLSMirrorTransportLayerPaddin } } -func (c TLSMirror) Build() LC.TLSMirror { - return LC.TLSMirror{ +func (c TLSMirrorConfig) Build() LC.TLSMirrorConfig { + return LC.TLSMirrorConfig{ PrimaryKey: c.PrimaryKey, Dest: c.Dest, Proxy: c.Proxy, diff --git a/listener/inbound/vmess.go b/listener/inbound/vmess.go index 77732ad67..969140a17 100644 --- a/listener/inbound/vmess.go +++ b/listener/inbound/vmess.go @@ -11,17 +11,17 @@ import ( type VmessOption struct { BaseOption - Users []VmessUser `inbound:"users"` - WsPath string `inbound:"ws-path,omitempty"` - GrpcServiceName string `inbound:"grpc-service-name,omitempty"` - Certificate string `inbound:"certificate,omitempty"` - PrivateKey string `inbound:"private-key,omitempty"` - ClientAuthType string `inbound:"client-auth-type,omitempty"` - ClientAuthCert string `inbound:"client-auth-cert,omitempty"` - EchKey string `inbound:"ech-key,omitempty"` - RealityConfig RealityConfig `inbound:"reality-config,omitempty"` - TLSMirror TLSMirror `inbound:"tlsmirror,omitempty"` - MuxOption MuxOption `inbound:"mux-option,omitempty"` + Users []VmessUser `inbound:"users"` + WsPath string `inbound:"ws-path,omitempty"` + GrpcServiceName string `inbound:"grpc-service-name,omitempty"` + Certificate string `inbound:"certificate,omitempty"` + PrivateKey string `inbound:"private-key,omitempty"` + ClientAuthType string `inbound:"client-auth-type,omitempty"` + ClientAuthCert string `inbound:"client-auth-cert,omitempty"` + EchKey string `inbound:"ech-key,omitempty"` + RealityConfig RealityConfig `inbound:"reality-config,omitempty"` + TLSMirrorConfig TLSMirrorConfig `inbound:"tlsmirror-config,omitempty"` + MuxOption MuxOption `inbound:"mux-option,omitempty"` } type VmessUser struct { @@ -69,7 +69,7 @@ func NewVmess(options *VmessOption) (*Vmess, error) { ClientAuthCert: options.ClientAuthCert, EchKey: options.EchKey, RealityConfig: options.RealityConfig.Build(), - TLSMirror: options.TLSMirror.Build(), + TLSMirrorConfig: options.TLSMirrorConfig.Build(), MuxOption: options.MuxOption.Build(), }, }, nil diff --git a/listener/inbound/vmess_test.go b/listener/inbound/vmess_test.go index 53afe1067..e8f883da5 100644 --- a/listener/inbound/vmess_test.go +++ b/listener/inbound/vmess_test.go @@ -143,7 +143,7 @@ func TestInboundVMess_Ws(t *testing.T) { func TestInboundVMess_TLSMirror(t *testing.T) { inboundOptions := inbound.VmessOption{ - TLSMirror: inbound.TLSMirror{ + TLSMirrorConfig: inbound.TLSMirrorConfig{ PrimaryKey: tlsMirrorPrimaryKey, Dest: net.JoinHostPort(realityDest, "443"), }, @@ -164,7 +164,7 @@ func TestInboundVMess_TLSMirror(t *testing.T) { func TestInboundVMess_TLSMirror_Ws(t *testing.T) { inboundOptions := inbound.VmessOption{ WsPath: "/ws", - TLSMirror: inbound.TLSMirror{ + TLSMirrorConfig: inbound.TLSMirrorConfig{ PrimaryKey: tlsMirrorPrimaryKey, Dest: net.JoinHostPort(realityDest, "443"), }, @@ -189,7 +189,7 @@ func TestInboundVMess_TLSMirror_Ws(t *testing.T) { func TestInboundVMess_TLSMirror_Grpc(t *testing.T) { inboundOptions := inbound.VmessOption{ GrpcServiceName: "GunService", - TLSMirror: inbound.TLSMirror{ + TLSMirrorConfig: inbound.TLSMirrorConfig{ PrimaryKey: tlsMirrorPrimaryKey, Dest: net.JoinHostPort(realityDest, "443"), }, @@ -211,7 +211,7 @@ func TestInboundVMess_TLSMirror_Grpc(t *testing.T) { func TestInboundVMess_TLSMirror_AdvancedOptions(t *testing.T) { inboundOptions := inbound.VmessOption{ - TLSMirror: inbound.TLSMirror{ + TLSMirrorConfig: inbound.TLSMirrorConfig{ PrimaryKey: tlsMirrorPrimaryKey, Dest: net.JoinHostPort(realityDest, "443"), ExplicitNonceCipherSuites: tlsmirror.RecommendedExplicitNonceCipherSuites, @@ -243,7 +243,7 @@ func TestInboundVMess_TLSMirror_AdvancedOptions(t *testing.T) { func TestInboundVMess_TLSMirror_ConnectionEnrolment(t *testing.T) { inboundOptions := inbound.VmessOption{ - TLSMirror: inbound.TLSMirror{ + TLSMirrorConfig: inbound.TLSMirrorConfig{ PrimaryKey: tlsMirrorPrimaryKey, Dest: net.JoinHostPort(realityDest, "443"), ConnectionEnrolment: &inbound.TLSMirrorConnectionEnrolment{ @@ -269,7 +269,7 @@ func TestInboundVMess_TLSMirror_ConnectionEnrolment(t *testing.T) { func TestInboundVMess_TLSMirror_EmbeddedTrafficGenerator(t *testing.T) { inboundOptions := inbound.VmessOption{ - TLSMirror: inbound.TLSMirror{ + TLSMirrorConfig: inbound.TLSMirrorConfig{ PrimaryKey: tlsMirrorPrimaryKey, Dest: net.JoinHostPort(realityDest, "443"), }, diff --git a/listener/inbound/vmess_tlsmirror_interop_test.go b/listener/inbound/vmess_tlsmirror_interop_test.go index 583969281..ceb45d6fe 100644 --- a/listener/inbound/vmess_tlsmirror_interop_test.go +++ b/listener/inbound/vmess_tlsmirror_interop_test.go @@ -205,7 +205,7 @@ func tlsMirrorInteropTestCase(t *testing.T, v2rayBin, name string, advanced tlsM Users: []inbound.VmessUser{ {Username: "test", UUID: userUUID}, }, - TLSMirror: inbound.TLSMirror{ + TLSMirrorConfig: inbound.TLSMirrorConfig{ PrimaryKey: tlsMirrorInteropPrimaryKey, Dest: forward.addr, ExplicitNonceCipherSuites: advanced.config.ExplicitNonceCipherSuites, diff --git a/listener/sing_vmess/server.go b/listener/sing_vmess/server.go index c5db1a670..6b4130344 100644 --- a/listener/sing_vmess/server.go +++ b/listener/sing_vmess/server.go @@ -127,16 +127,16 @@ func New(config LC.VmessServer, lc C.InboundListenConfig, tunnel C.Tunnel, addit return nil, err } } - if config.TLSMirror.PrimaryKey != "" { + if config.TLSMirrorConfig.PrimaryKey != "" { tlsMirrorBuilder = tlsmirror.Config{ - PrimaryKey: config.TLSMirror.PrimaryKey, - Dest: config.TLSMirror.Dest, - Proxy: config.TLSMirror.Proxy, - ExplicitNonceCipherSuites: config.TLSMirror.ExplicitNonceCipherSuites, - DeferInstanceDerivedWriteTime: config.TLSMirror.DeferInstanceDerivedWriteTime.Build(), - TransportLayerPadding: config.TLSMirror.TransportLayerPadding.Build(), - ConnectionEnrolment: config.TLSMirror.ConnectionEnrolment.Build(), - SequenceWatermarkingEnabled: config.TLSMirror.SequenceWatermarkingEnabled, + PrimaryKey: config.TLSMirrorConfig.PrimaryKey, + Dest: config.TLSMirrorConfig.Dest, + Proxy: config.TLSMirrorConfig.Proxy, + ExplicitNonceCipherSuites: config.TLSMirrorConfig.ExplicitNonceCipherSuites, + DeferInstanceDerivedWriteTime: config.TLSMirrorConfig.DeferInstanceDerivedWriteTime.Build(), + TransportLayerPadding: config.TLSMirrorConfig.TransportLayerPadding.Build(), + ConnectionEnrolment: config.TLSMirrorConfig.ConnectionEnrolment.Build(), + SequenceWatermarkingEnabled: config.TLSMirrorConfig.SequenceWatermarkingEnabled, }.Build(tunnel) h.Tunnel = tlsMirrorBuilder.WrapTunnel(tunnel) }