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:
@@ -15,16 +15,31 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"golang.org/x/time/rate"
|
||||
"reflect"
|
||||
|
||||
"github.com/fatedier/frp/pkg/config"
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterProxyFactory(reflect.TypeOf(&config.STCPProxyConf{}), NewSTCPProxy)
|
||||
}
|
||||
|
||||
type STCPProxy struct {
|
||||
*BaseProxy
|
||||
cfg *config.STCPProxyConf
|
||||
}
|
||||
|
||||
func NewSTCPProxy(baseProxy *BaseProxy, cfg config.ProxyConf) Proxy {
|
||||
unwrapped, ok := cfg.(*config.STCPProxyConf)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return &STCPProxy{
|
||||
BaseProxy: baseProxy,
|
||||
cfg: unwrapped,
|
||||
}
|
||||
}
|
||||
|
||||
func (pxy *STCPProxy) Run() (remoteAddr string, err error) {
|
||||
xl := pxy.xl
|
||||
allowUsers := pxy.cfg.AllowUsers
|
||||
@@ -40,7 +55,7 @@ func (pxy *STCPProxy) Run() (remoteAddr string, err error) {
|
||||
pxy.listeners = append(pxy.listeners, listener)
|
||||
xl.Info("stcp proxy custom listen success")
|
||||
|
||||
pxy.startListenHandler(pxy, HandleUserTCPConnection)
|
||||
pxy.startCommonTCPListenersHandler()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -48,10 +63,6 @@ func (pxy *STCPProxy) GetConf() config.ProxyConf {
|
||||
return pxy.cfg
|
||||
}
|
||||
|
||||
func (pxy *STCPProxy) GetLimiter() *rate.Limiter {
|
||||
return pxy.limiter
|
||||
}
|
||||
|
||||
func (pxy *STCPProxy) Close() {
|
||||
pxy.BaseProxy.Close()
|
||||
pxy.rc.VisitorManager.CloseListener(pxy.GetName())
|
||||
|
||||
Reference in New Issue
Block a user