chore: restful api display fast-open for tuic and hysteria

This commit is contained in:
gVisor bot 2022-11-28 19:52:55 +08:00
parent 5c8ffc98c9
commit 4f1c2dfbaa
5 changed files with 13 additions and 3 deletions

View file

@ -92,6 +92,7 @@ func (p *Proxy) MarshalJSON() ([]byte, error) {
mapping["history"] = p.DelayHistory() mapping["history"] = p.DelayHistory()
mapping["name"] = p.Name() mapping["name"] = p.Name()
mapping["udp"] = p.SupportUDP() mapping["udp"] = p.SupportUDP()
mapping["tfo"] = p.SupportTFO()
return json.Marshal(mapping) return json.Marshal(mapping)
} }

View file

@ -18,6 +18,7 @@ type Base struct {
iface string iface string
tp C.AdapterType tp C.AdapterType
udp bool udp bool
tfo bool
rmark int rmark int
id string id string
prefer C.DNSPrefer prefer C.DNSPrefer
@ -76,6 +77,11 @@ func (b *Base) SupportUDP() bool {
return b.udp return b.udp
} }
// SupportTFO implements C.ProxyAdapter
func (b *Base) SupportTFO() bool {
return b.tfo
}
// MarshalJSON implements C.ProxyAdapter // MarshalJSON implements C.ProxyAdapter
func (b *Base) MarshalJSON() ([]byte, error) { func (b *Base) MarshalJSON() ([]byte, error) {
return json.Marshal(map[string]string{ return json.Marshal(map[string]string{
@ -130,6 +136,7 @@ type BaseOption struct {
Addr string Addr string
Type C.AdapterType Type C.AdapterType
UDP bool UDP bool
TFO bool
Interface string Interface string
RoutingMark int RoutingMark int
Prefer C.DNSPrefer Prefer C.DNSPrefer
@ -141,6 +148,7 @@ func NewBase(opt BaseOption) *Base {
addr: opt.Addr, addr: opt.Addr,
tp: opt.Type, tp: opt.Type,
udp: opt.UDP, udp: opt.UDP,
tfo: opt.TFO,
iface: opt.Interface, iface: opt.Interface,
rmark: opt.RoutingMark, rmark: opt.RoutingMark,
prefer: opt.Prefer, prefer: opt.Prefer,

View file

@ -30,12 +30,10 @@ import (
) )
const ( const (
mbpsToBps = 125000 mbpsToBps = 125000
minSpeedBPS = 16384
DefaultStreamReceiveWindow = 15728640 // 15 MB/s DefaultStreamReceiveWindow = 15728640 // 15 MB/s
DefaultConnectionReceiveWindow = 67108864 // 64 MB/s DefaultConnectionReceiveWindow = 67108864 // 64 MB/s
DefaultMaxIncomingStreams = 1024
DefaultALPN = "hysteria" DefaultALPN = "hysteria"
DefaultProtocol = "udp" DefaultProtocol = "udp"
@ -258,6 +256,7 @@ func NewHysteria(option HysteriaOption) (*Hysteria, error) {
addr: addr, addr: addr,
tp: C.Hysteria, tp: C.Hysteria,
udp: true, udp: true,
tfo: option.FastOpen,
iface: option.Interface, iface: option.Interface,
rmark: option.RoutingMark, rmark: option.RoutingMark,
prefer: C.NewDNSPrefer(option.IPVersion), prefer: C.NewDNSPrefer(option.IPVersion),

View file

@ -193,6 +193,7 @@ func NewTuic(option TuicOption) (*Tuic, error) {
addr: addr, addr: addr,
tp: C.Tuic, tp: C.Tuic,
udp: true, udp: true,
tfo: option.FastOpen,
iface: option.Interface, iface: option.Interface,
prefer: C.NewDNSPrefer(option.IPVersion), prefer: C.NewDNSPrefer(option.IPVersion),
}, },

View file

@ -86,6 +86,7 @@ type ProxyAdapter interface {
Type() AdapterType Type() AdapterType
Addr() string Addr() string
SupportUDP() bool SupportUDP() bool
SupportTFO() bool
MarshalJSON() ([]byte, error) MarshalJSON() ([]byte, error)
// StreamConn wraps a protocol around net.Conn with Metadata. // StreamConn wraps a protocol around net.Conn with Metadata.