ss and vmess inbound add tfo
This commit is contained in:
parent
9c8e39827f
commit
0eecd11fdc
4 changed files with 22 additions and 9 deletions
|
@ -280,7 +280,7 @@ func ReCreateShadowSocks(shadowSocksConfig string, tcpIn chan<- C.ConnContext, u
|
|||
return
|
||||
}
|
||||
|
||||
listener, err := sing_shadowsocks.New(shadowSocksConfig, tcpIn, udpIn)
|
||||
listener, err := sing_shadowsocks.New(shadowSocksConfig, inboundTfo, tcpIn, udpIn)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ func ReCreateVmess(vmessConfig string, tcpIn chan<- C.ConnContext, udpIn chan<-
|
|||
return
|
||||
}
|
||||
|
||||
listener, err := sing_vmess.New(vmessConfig, tcpIn, udpIn)
|
||||
listener, err := sing_vmess.New(vmessConfig, inboundTfo, tcpIn, udpIn)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package shadowsocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/database64128/tfo-go/v2"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
|
@ -21,7 +23,7 @@ type Listener struct {
|
|||
|
||||
var _listener *Listener
|
||||
|
||||
func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (*Listener, error) {
|
||||
func New(config string, inboundTfo bool, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (*Listener, error) {
|
||||
addr, cipher, password, err := ParseSSURL(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -46,7 +48,10 @@ func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.Packet
|
|||
sl.udpListeners = append(sl.udpListeners, ul)
|
||||
|
||||
//TCP
|
||||
l, err := net.Listen("tcp", addr)
|
||||
lc := tfo.ListenConfig{
|
||||
DisableTFO: !inboundTfo,
|
||||
}
|
||||
l, err := lc.Listen(context.Background(), "tcp", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package sing_shadowsocks
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/database64128/tfo-go/v2"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
|
@ -32,7 +33,7 @@ type Listener struct {
|
|||
|
||||
var _listener *Listener
|
||||
|
||||
func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (C.AdvanceListener, error) {
|
||||
func New(config string, inboundTfo bool, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (C.AdvanceListener, error) {
|
||||
addr, cipher, password, err := embedSS.ParseSSURL(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -56,7 +57,7 @@ func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.Packet
|
|||
sl.service, err = shadowaead_2022.NewServiceWithPassword(cipher, password, udpTimeout, h)
|
||||
default:
|
||||
err = fmt.Errorf("shadowsocks: unsupported method: %s", cipher)
|
||||
return embedSS.New(config, tcpIn, udpIn)
|
||||
return embedSS.New(config, inboundTfo, tcpIn, udpIn)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -100,7 +101,10 @@ func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.Packet
|
|||
}()
|
||||
|
||||
//TCP
|
||||
l, err := net.Listen("tcp", addr)
|
||||
lc := tfo.ListenConfig{
|
||||
DisableTFO: !inboundTfo,
|
||||
}
|
||||
l, err := lc.Listen(context.Background(), "tcp", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package sing_vmess
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/database64128/tfo-go/v2"
|
||||
"net"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
@ -24,7 +25,7 @@ type Listener struct {
|
|||
|
||||
var _listener *Listener
|
||||
|
||||
func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (*Listener, error) {
|
||||
func New(config string, inboundTfo bool, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (*Listener, error) {
|
||||
addr, username, password, err := parseVmessURL(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -54,7 +55,10 @@ func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.Packet
|
|||
addr := addr
|
||||
|
||||
//TCP
|
||||
l, err := net.Listen("tcp", addr)
|
||||
lc := tfo.ListenConfig{
|
||||
DisableTFO: !inboundTfo,
|
||||
}
|
||||
l, err := lc.Listen(context.Background(), "tcp", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue