From 4f1c2dfbaa529743260693f83f6c4226eae4b95f Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Mon, 28 Nov 2022 19:52:55 +0800 Subject: [PATCH] chore: restful api display fast-open for tuic and hysteria --- adapter/adapter.go | 1 + adapter/outbound/base.go | 8 ++++++++ adapter/outbound/hysteria.go | 5 ++--- adapter/outbound/tuic.go | 1 + constant/adapters.go | 1 + 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/adapter/adapter.go b/adapter/adapter.go index aa860ed4..feef72be 100644 --- a/adapter/adapter.go +++ b/adapter/adapter.go @@ -92,6 +92,7 @@ func (p *Proxy) MarshalJSON() ([]byte, error) { mapping["history"] = p.DelayHistory() mapping["name"] = p.Name() mapping["udp"] = p.SupportUDP() + mapping["tfo"] = p.SupportTFO() return json.Marshal(mapping) } diff --git a/adapter/outbound/base.go b/adapter/outbound/base.go index 145a3f97..a7e068dd 100644 --- a/adapter/outbound/base.go +++ b/adapter/outbound/base.go @@ -18,6 +18,7 @@ type Base struct { iface string tp C.AdapterType udp bool + tfo bool rmark int id string prefer C.DNSPrefer @@ -76,6 +77,11 @@ func (b *Base) SupportUDP() bool { return b.udp } +// SupportTFO implements C.ProxyAdapter +func (b *Base) SupportTFO() bool { + return b.tfo +} + // MarshalJSON implements C.ProxyAdapter func (b *Base) MarshalJSON() ([]byte, error) { return json.Marshal(map[string]string{ @@ -130,6 +136,7 @@ type BaseOption struct { Addr string Type C.AdapterType UDP bool + TFO bool Interface string RoutingMark int Prefer C.DNSPrefer @@ -141,6 +148,7 @@ func NewBase(opt BaseOption) *Base { addr: opt.Addr, tp: opt.Type, udp: opt.UDP, + tfo: opt.TFO, iface: opt.Interface, rmark: opt.RoutingMark, prefer: opt.Prefer, diff --git a/adapter/outbound/hysteria.go b/adapter/outbound/hysteria.go index 932e8feb..56462399 100644 --- a/adapter/outbound/hysteria.go +++ b/adapter/outbound/hysteria.go @@ -30,12 +30,10 @@ import ( ) const ( - mbpsToBps = 125000 - minSpeedBPS = 16384 + mbpsToBps = 125000 DefaultStreamReceiveWindow = 15728640 // 15 MB/s DefaultConnectionReceiveWindow = 67108864 // 64 MB/s - DefaultMaxIncomingStreams = 1024 DefaultALPN = "hysteria" DefaultProtocol = "udp" @@ -258,6 +256,7 @@ func NewHysteria(option HysteriaOption) (*Hysteria, error) { addr: addr, tp: C.Hysteria, udp: true, + tfo: option.FastOpen, iface: option.Interface, rmark: option.RoutingMark, prefer: C.NewDNSPrefer(option.IPVersion), diff --git a/adapter/outbound/tuic.go b/adapter/outbound/tuic.go index 264c991b..38c220de 100644 --- a/adapter/outbound/tuic.go +++ b/adapter/outbound/tuic.go @@ -193,6 +193,7 @@ func NewTuic(option TuicOption) (*Tuic, error) { addr: addr, tp: C.Tuic, udp: true, + tfo: option.FastOpen, iface: option.Interface, prefer: C.NewDNSPrefer(option.IPVersion), }, diff --git a/constant/adapters.go b/constant/adapters.go index 53d03fb0..d25023e2 100644 --- a/constant/adapters.go +++ b/constant/adapters.go @@ -86,6 +86,7 @@ type ProxyAdapter interface { Type() AdapterType Addr() string SupportUDP() bool + SupportTFO() bool MarshalJSON() ([]byte, error) // StreamConn wraps a protocol around net.Conn with Metadata.