mirror of
https://github.com/fatedier/frp.git
synced 2025-07-27 07:35:07 +00:00
support protocol quic between frpc and frps (#3198)
This commit is contained in:
@@ -115,7 +115,7 @@ type ClientCommonConf struct {
|
||||
Start []string `ini:"start" json:"start"`
|
||||
// Start map[string]struct{} `json:"start"`
|
||||
// Protocol specifies the protocol to use when interacting with the server.
|
||||
// Valid values are "tcp", "kcp" and "websocket". By default, this value
|
||||
// Valid values are "tcp", "kcp", "quic" and "websocket". By default, this value
|
||||
// is "tcp".
|
||||
Protocol string `ini:"protocol" json:"protocol"`
|
||||
// TLSEnable specifies whether or not TLS should be used when communicating
|
||||
@@ -228,7 +228,7 @@ func (cfg *ClientCommonConf) Validate() error {
|
||||
}
|
||||
}
|
||||
|
||||
if cfg.Protocol != "tcp" && cfg.Protocol != "kcp" && cfg.Protocol != "websocket" {
|
||||
if cfg.Protocol != "tcp" && cfg.Protocol != "kcp" && cfg.Protocol != "websocket" && cfg.Protocol != "quic" {
|
||||
return fmt.Errorf("invalid protocol")
|
||||
}
|
||||
|
||||
|
@@ -46,6 +46,10 @@ type ServerCommonConf struct {
|
||||
// value is 0, the server will not listen for KCP connections. By default,
|
||||
// this value is 0.
|
||||
KCPBindPort int `ini:"kcp_bind_port" json:"kcp_bind_port" validate:"gte=0,lte=65535"`
|
||||
// QUICBindPort specifies the QUIC port that the server listens on.
|
||||
// Set this value to 0 will disable this feature.
|
||||
// By default, the value is 0.
|
||||
QUICBindPort int `ini:"quic_bind_port" json:"quic_bind_port" validate:"gte=0,lte=65535"`
|
||||
// ProxyBindAddr specifies the address that the proxy binds to. This value
|
||||
// may be the same as BindAddr.
|
||||
ProxyBindAddr string `ini:"proxy_bind_addr" json:"proxy_bind_addr"`
|
||||
|
@@ -22,6 +22,8 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
quic "github.com/lucas-clemente/quic-go"
|
||||
|
||||
"github.com/fatedier/frp/pkg/util/xlog"
|
||||
)
|
||||
|
||||
@@ -183,3 +185,29 @@ func (statsConn *StatsConn) Close() (err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type wrapQuicStream struct {
|
||||
quic.Stream
|
||||
c quic.Connection
|
||||
}
|
||||
|
||||
func QuicStreamToNetConn(s quic.Stream, c quic.Connection) net.Conn {
|
||||
return &wrapQuicStream{
|
||||
Stream: s,
|
||||
c: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (conn *wrapQuicStream) LocalAddr() net.Addr {
|
||||
if conn.c != nil {
|
||||
return conn.c.LocalAddr()
|
||||
}
|
||||
return (*net.TCPAddr)(nil)
|
||||
}
|
||||
|
||||
func (conn *wrapQuicStream) RemoteAddr() net.Addr {
|
||||
if conn.c != nil {
|
||||
return conn.c.RemoteAddr()
|
||||
}
|
||||
return (*net.TCPAddr)(nil)
|
||||
}
|
||||
|
Reference in New Issue
Block a user