|
|
@ -17,8 +17,7 @@ package proxy
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"reflect"
|
|
|
|
"reflect"
|
|
|
|
|
|
|
|
"sync"
|
|
|
|
"github.com/fatedier/golib/errors"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
v1 "github.com/fatedier/frp/pkg/config/v1"
|
|
|
|
v1 "github.com/fatedier/frp/pkg/config/v1"
|
|
|
|
"github.com/fatedier/frp/pkg/msg"
|
|
|
|
"github.com/fatedier/frp/pkg/msg"
|
|
|
@ -32,7 +31,8 @@ type XTCPProxy struct {
|
|
|
|
*BaseProxy
|
|
|
|
*BaseProxy
|
|
|
|
cfg *v1.XTCPProxyConfig
|
|
|
|
cfg *v1.XTCPProxyConfig
|
|
|
|
|
|
|
|
|
|
|
|
closeCh chan struct{}
|
|
|
|
closeCh chan struct{}
|
|
|
|
|
|
|
|
closeOnce sync.Once
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewXTCPProxy(baseProxy *BaseProxy) Proxy {
|
|
|
|
func NewXTCPProxy(baseProxy *BaseProxy) Proxy {
|
|
|
@ -43,6 +43,7 @@ func NewXTCPProxy(baseProxy *BaseProxy) Proxy {
|
|
|
|
return &XTCPProxy{
|
|
|
|
return &XTCPProxy{
|
|
|
|
BaseProxy: baseProxy,
|
|
|
|
BaseProxy: baseProxy,
|
|
|
|
cfg: unwrapped,
|
|
|
|
cfg: unwrapped,
|
|
|
|
|
|
|
|
closeCh: make(chan struct{}),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -87,9 +88,9 @@ func (pxy *XTCPProxy) Run() (remoteAddr string, err error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (pxy *XTCPProxy) Close() {
|
|
|
|
func (pxy *XTCPProxy) Close() {
|
|
|
|
pxy.BaseProxy.Close()
|
|
|
|
pxy.closeOnce.Do(func() {
|
|
|
|
pxy.rc.NatHoleController.CloseClient(pxy.GetName())
|
|
|
|
pxy.BaseProxy.Close()
|
|
|
|
_ = errors.PanicToError(func() {
|
|
|
|
pxy.rc.NatHoleController.CloseClient(pxy.GetName())
|
|
|
|
close(pxy.closeCh)
|
|
|
|
close(pxy.closeCh)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|