|
@@ -39,7 +39,7 @@ import (
|
|
|
plugin "github.com/fatedier/frp/pkg/plugin/server"
|
|
|
"github.com/fatedier/frp/pkg/transport"
|
|
|
"github.com/fatedier/frp/pkg/util/log"
|
|
|
- frpNet "github.com/fatedier/frp/pkg/util/net"
|
|
|
+ utilnet "github.com/fatedier/frp/pkg/util/net"
|
|
|
"github.com/fatedier/frp/pkg/util/tcpmux"
|
|
|
"github.com/fatedier/frp/pkg/util/util"
|
|
|
"github.com/fatedier/frp/pkg/util/version"
|
|
@@ -210,7 +210,7 @@ func NewService(cfg config.ServerCommonConf) (svr *Service, err error) {
|
|
|
// Listen for accepting connections from client using kcp protocol.
|
|
|
if cfg.KCPBindPort > 0 {
|
|
|
address := net.JoinHostPort(cfg.BindAddr, strconv.Itoa(cfg.KCPBindPort))
|
|
|
- svr.kcpListener, err = frpNet.ListenKcp(address)
|
|
|
+ svr.kcpListener, err = utilnet.ListenKcp(address)
|
|
|
if err != nil {
|
|
|
err = fmt.Errorf("listen on kcp udp address %s error: %v", address, err)
|
|
|
return
|
|
@@ -235,11 +235,11 @@ func NewService(cfg config.ServerCommonConf) (svr *Service, err error) {
|
|
|
}
|
|
|
|
|
|
// Listen for accepting connections from client using websocket protocol.
|
|
|
- websocketPrefix := []byte("GET " + frpNet.FrpWebsocketPath)
|
|
|
+ websocketPrefix := []byte("GET " + utilnet.FrpWebsocketPath)
|
|
|
websocketLn := svr.muxer.Listen(0, uint32(len(websocketPrefix)), func(data []byte) bool {
|
|
|
return bytes.Equal(data, websocketPrefix)
|
|
|
})
|
|
|
- svr.websocketListener = frpNet.NewWebsocketListener(websocketLn)
|
|
|
+ svr.websocketListener = utilnet.NewWebsocketListener(websocketLn)
|
|
|
|
|
|
// Create http vhost muxer.
|
|
|
if cfg.VhostHTTPPort > 0 {
|
|
@@ -294,7 +294,7 @@ func NewService(cfg config.ServerCommonConf) (svr *Service, err error) {
|
|
|
// frp tls listener
|
|
|
svr.tlsListener = svr.muxer.Listen(2, 1, func(data []byte) bool {
|
|
|
// tls first byte can be 0x16 only when vhost https port is not same with bind port
|
|
|
- return int(data[0]) == frpNet.FRPTLSHeadByte || int(data[0]) == 0x16
|
|
|
+ return int(data[0]) == utilnet.FRPTLSHeadByte || int(data[0]) == 0x16
|
|
|
})
|
|
|
|
|
|
// Create nat hole controller.
|
|
@@ -442,12 +442,12 @@ func (svr *Service) HandleListener(l net.Listener) {
|
|
|
xl := xlog.New()
|
|
|
ctx := context.Background()
|
|
|
|
|
|
- c = frpNet.NewContextConn(xlog.NewContext(ctx, xl), c)
|
|
|
+ c = utilnet.NewContextConn(xlog.NewContext(ctx, xl), c)
|
|
|
|
|
|
log.Trace("start check TLS connection...")
|
|
|
originConn := c
|
|
|
var isTLS, custom bool
|
|
|
- c, isTLS, custom, err = frpNet.CheckAndEnableTLSServerConnWithTimeout(c, svr.tlsConfig, svr.cfg.TLSOnly, connReadTimeout)
|
|
|
+ c, isTLS, custom, err = utilnet.CheckAndEnableTLSServerConnWithTimeout(c, svr.tlsConfig, svr.cfg.TLSOnly, connReadTimeout)
|
|
|
if err != nil {
|
|
|
log.Warn("CheckAndEnableTLSServerConnWithTimeout error: %v", err)
|
|
|
originConn.Close()
|
|
@@ -501,7 +501,7 @@ func (svr *Service) HandleQUICListener(l quic.Listener) {
|
|
|
_ = frpConn.CloseWithError(0, "")
|
|
|
return
|
|
|
}
|
|
|
- go svr.handleConnection(ctx, frpNet.QuicStreamToNetConn(stream, frpConn))
|
|
|
+ go svr.handleConnection(ctx, utilnet.QuicStreamToNetConn(stream, frpConn))
|
|
|
}
|
|
|
}(context.Background(), c)
|
|
|
}
|
|
@@ -517,7 +517,7 @@ func (svr *Service) RegisterControl(ctlConn net.Conn, loginMsg *msg.Login) (err
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- ctx := frpNet.NewContextFromConn(ctlConn)
|
|
|
+ ctx := utilnet.NewContextFromConn(ctlConn)
|
|
|
xl := xlog.FromContextSafe(ctx)
|
|
|
xl.AppendPrefix(loginMsg.RunID)
|
|
|
ctx = xlog.NewContext(ctx, xl)
|
|
@@ -555,7 +555,7 @@ func (svr *Service) RegisterControl(ctlConn net.Conn, loginMsg *msg.Login) (err
|
|
|
|
|
|
// RegisterWorkConn register a new work connection to control and proxies need it.
|
|
|
func (svr *Service) RegisterWorkConn(workConn net.Conn, newMsg *msg.NewWorkConn) error {
|
|
|
- xl := frpNet.NewLogFromConn(workConn)
|
|
|
+ xl := utilnet.NewLogFromConn(workConn)
|
|
|
ctl, exist := svr.ctlManager.GetByID(newMsg.RunID)
|
|
|
if !exist {
|
|
|
xl.Warn("No client control found for run id [%s]", newMsg.RunID)
|