feat: add linsters

This commit is contained in:
Skyxim
2022-12-04 13:37:14 +08:00
parent ba884c29bd
commit 4f75201a98
49 changed files with 1018 additions and 306 deletions

View File

@ -2,29 +2,47 @@ package tuic
import (
"crypto/tls"
"encoding/json"
"net"
"strings"
"time"
"github.com/metacubex/quic-go"
"github.com/Dreamacro/clash/adapter/inbound"
"github.com/Dreamacro/clash/common/sockopt"
"github.com/Dreamacro/clash/config"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/adapter/inbound"
"github.com/Dreamacro/clash/log"
"github.com/Dreamacro/clash/transport/socks5"
"github.com/Dreamacro/clash/transport/tuic"
)
type TuicServer struct {
Enable bool
Listen string
Token []string
Certificate string
PrivateKey string
CongestionController string
MaxIdleTime int
AuthenticationTimeout int
ALPN []string
MaxUdpRelayPacketSize int
}
func (t TuicServer) String() string {
b, _ := json.Marshal(t)
return string(b)
}
type Listener struct {
closed bool
config config.TuicServer
config TuicServer
udpListeners []net.PacketConn
servers []*tuic.Server
}
func New(config config.TuicServer, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (*Listener, error) {
func New(config TuicServer, tcpIn chan<- C.ConnContext, udpIn chan<- *C.PacketAdapter) (*Listener, error) {
cert, err := tls.LoadX509KeyPair(config.Certificate, config.PrivateKey)
if err != nil {
return nil, err
@ -122,6 +140,6 @@ func (l *Listener) Close() {
}
}
func (l *Listener) Config() config.TuicServer {
func (l *Listener) Config() TuicServer {
return l.config
}