mirror of
https://github.com/fatedier/frp.git
synced 2026-01-11 22:23:12 +00:00
server/proxy: simplify the code (#3488)
This commit is contained in:
@@ -17,21 +17,35 @@ package proxy
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/time/rate"
|
||||
|
||||
"github.com/fatedier/frp/pkg/config"
|
||||
"github.com/fatedier/frp/pkg/consts"
|
||||
"github.com/fatedier/frp/pkg/util/util"
|
||||
"github.com/fatedier/frp/pkg/util/vhost"
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterProxyFactory(reflect.TypeOf(&config.TCPMuxProxyConf{}), NewTCPMuxProxy)
|
||||
}
|
||||
|
||||
type TCPMuxProxy struct {
|
||||
*BaseProxy
|
||||
cfg *config.TCPMuxProxyConf
|
||||
}
|
||||
|
||||
func NewTCPMuxProxy(baseProxy *BaseProxy, cfg config.ProxyConf) Proxy {
|
||||
unwrapped, ok := cfg.(*config.TCPMuxProxyConf)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return &TCPMuxProxy{
|
||||
BaseProxy: baseProxy,
|
||||
cfg: unwrapped,
|
||||
}
|
||||
}
|
||||
|
||||
func (pxy *TCPMuxProxy) httpConnectListen(
|
||||
domain, routeByHTTPUser, httpUser, httpPwd string, addrs []string) ([]string, error,
|
||||
) {
|
||||
@@ -78,7 +92,7 @@ func (pxy *TCPMuxProxy) httpConnectRun() (remoteAddr string, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
pxy.startListenHandler(pxy, HandleUserTCPConnection)
|
||||
pxy.startCommonTCPListenersHandler()
|
||||
remoteAddr = strings.Join(addrs, ",")
|
||||
return remoteAddr, err
|
||||
}
|
||||
@@ -101,10 +115,6 @@ func (pxy *TCPMuxProxy) GetConf() config.ProxyConf {
|
||||
return pxy.cfg
|
||||
}
|
||||
|
||||
func (pxy *TCPMuxProxy) GetLimiter() *rate.Limiter {
|
||||
return pxy.limiter
|
||||
}
|
||||
|
||||
func (pxy *TCPMuxProxy) Close() {
|
||||
pxy.BaseProxy.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user