From de19f927e86573a7a97159e3b9925049f06d4563 Mon Sep 17 00:00:00 2001 From: Chenx Dust Date: Tue, 12 Nov 2024 07:58:24 +0000 Subject: [PATCH] chore: restful api display smux and mptcp --- adapter/adapter.go | 2 ++ adapter/outbound/base.go | 10 ++++++++++ adapter/outbound/singmux.go | 4 ++++ adapter/outbound/wireguard.go | 14 ++++++++++++++ constant/adapters.go | 2 ++ 5 files changed, 32 insertions(+) diff --git a/adapter/adapter.go b/adapter/adapter.go index 6de7fb92..411069fb 100644 --- a/adapter/adapter.go +++ b/adapter/adapter.go @@ -165,6 +165,8 @@ func (p *Proxy) MarshalJSON() ([]byte, error) { mapping["udp"] = p.SupportUDP() mapping["xudp"] = p.SupportXUDP() mapping["tfo"] = p.SupportTFO() + mapping["mptcp"] = p.SupportMPTCP() + mapping["smux"] = p.SupportSMUX() return json.Marshal(mapping) } diff --git a/adapter/outbound/base.go b/adapter/outbound/base.go index ae8c4651..93e8d979 100644 --- a/adapter/outbound/base.go +++ b/adapter/outbound/base.go @@ -95,6 +95,16 @@ func (b *Base) SupportTFO() bool { return b.tfo } +// SupportMPTCP implements C.ProxyAdapter +func (b *Base) SupportMPTCP() bool { + return b.mpTcp +} + +// SupportSMUX implements C.ProxyAdapter +func (b *Base) SupportSMUX() bool { + return false +} + // IsL3Protocol implements C.ProxyAdapter func (b *Base) IsL3Protocol(metadata *C.Metadata) bool { return false diff --git a/adapter/outbound/singmux.go b/adapter/outbound/singmux.go index 67267744..5cc4e748 100644 --- a/adapter/outbound/singmux.go +++ b/adapter/outbound/singmux.go @@ -97,6 +97,10 @@ func (s *SingMux) SupportUOT() bool { return true } +func (s *SingMux) SupportSMUX() bool { + return true +} + func closeSingMux(s *SingMux) { _ = s.client.Close() } diff --git a/adapter/outbound/wireguard.go b/adapter/outbound/wireguard.go index 03145c37..ca732baa 100644 --- a/adapter/outbound/wireguard.go +++ b/adapter/outbound/wireguard.go @@ -625,6 +625,20 @@ func (r *refProxyAdapter) SupportTFO() bool { return false } +func (r *refProxyAdapter) SupportMPTCP() bool { + if r.proxyAdapter != nil { + return r.proxyAdapter.SupportMPTCP() + } + return false +} + +func (r *refProxyAdapter) SupportSMUX() bool { + if r.proxyAdapter != nil { + return r.proxyAdapter.SupportSMUX() + } + return false +} + func (r *refProxyAdapter) MarshalJSON() ([]byte, error) { if r.proxyAdapter != nil { return r.proxyAdapter.MarshalJSON() diff --git a/constant/adapters.go b/constant/adapters.go index c7b73a06..2bbcffba 100644 --- a/constant/adapters.go +++ b/constant/adapters.go @@ -106,6 +106,8 @@ type ProxyAdapter interface { SupportUDP() bool SupportXUDP() bool SupportTFO() bool + SupportMPTCP() bool + SupportSMUX() bool MarshalJSON() ([]byte, error) // Deprecated: use DialContextWithDialer and ListenPacketWithDialer instead.