mirror of https://github.com/v2ray/v2ray-core
Added integration
parent
c51830bd75
commit
7e96581921
|
@ -123,15 +123,21 @@ func NewHandler(ctx context.Context, config *core.InboundHandlerConfig) (core.In
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
receiverSettings, ok := rawReceiverSettings.(*proxyman.ReceiverConfig)
|
|
||||||
if !ok {
|
|
||||||
return nil, newError("not a ReceiverConfig").AtError()
|
|
||||||
}
|
|
||||||
proxySettings, err := config.ProxySettings.GetInstance()
|
proxySettings, err := config.ProxySettings.GetInstance()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
tag := config.Tag
|
tag := config.Tag
|
||||||
|
|
||||||
|
receiverSettings, ok := rawReceiverSettings.(*proxyman.ReceiverConfig)
|
||||||
|
if !ok {
|
||||||
|
receiverSettings, ok := rawReceiverSettings.(*proxyman.UnixReceiverConfig)
|
||||||
|
if ok {
|
||||||
|
return NewUnixInboundHandler(ctx, tag, receiverSettings, proxySettings)
|
||||||
|
}
|
||||||
|
return nil, newError("not a ReceiverConfig").AtError()
|
||||||
|
}
|
||||||
|
|
||||||
allocStrategy := receiverSettings.AllocationStrategy
|
allocStrategy := receiverSettings.AllocationStrategy
|
||||||
if allocStrategy == nil || allocStrategy.Type == proxyman.AllocationStrategy_Always {
|
if allocStrategy == nil || allocStrategy.Type == proxyman.AllocationStrategy_Always {
|
||||||
return NewAlwaysOnInboundHandler(ctx, tag, receiverSettings, proxySettings)
|
return NewAlwaysOnInboundHandler(ctx, tag, receiverSettings, proxySettings)
|
||||||
|
|
|
@ -21,23 +21,23 @@ type UnixInboundHandler struct {
|
||||||
additional *proxyman.UnixReceiverConfig
|
additional *proxyman.UnixReceiverConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (uih *UnixInboundHandler) Start() {
|
func (uih *UnixInboundHandler) Start() error {
|
||||||
var err error
|
var err error
|
||||||
uih.listenerHolder, err = domainsocket.ListenDS(uih.ctx, uih.path)
|
uih.listenerHolder, err = domainsocket.ListenDS(uih.ctx, uih.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newError(err).AtError().WriteToLog()
|
return newError(err).AtError()
|
||||||
}
|
}
|
||||||
err = uih.listenerHolder.LowerUP()
|
err = uih.listenerHolder.LowerUP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newError(err).AtError().WriteToLog()
|
return newError(err).AtError()
|
||||||
}
|
}
|
||||||
nchan := make(chan net.Conn, 2)
|
nchan := make(chan net.Conn, 2)
|
||||||
err = uih.listenerHolder.UP(nchan, false)
|
err = uih.listenerHolder.UP(nchan, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newError(err).AtError().WriteToLog()
|
return newError(err).AtError()
|
||||||
}
|
}
|
||||||
go uih.progressTraffic(nchan)
|
go uih.progressTraffic(nchan)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
func (uih *UnixInboundHandler) progressTraffic(rece <-chan net.Conn) {
|
func (uih *UnixInboundHandler) progressTraffic(rece <-chan net.Conn) {
|
||||||
|
|
||||||
|
@ -59,12 +59,12 @@ func (uih *UnixInboundHandler) progressTraffic(rece <-chan net.Conn) {
|
||||||
}(conn)
|
}(conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (uih *UnixInboundHandler) Close() {
|
func (uih *UnixInboundHandler) Close() error {
|
||||||
if uih.listenerHolder != nil {
|
if uih.listenerHolder != nil {
|
||||||
uih.listenerHolder.Down()
|
uih.listenerHolder.Down()
|
||||||
} else {
|
return nil
|
||||||
newError("Called UnixInboundHandler.Close while listenerHolder is nil").AtDebug().WriteToLog()
|
|
||||||
}
|
}
|
||||||
|
return newError("Called UnixInboundHandler.Close while listenerHolder is nil")
|
||||||
|
|
||||||
}
|
}
|
||||||
func (uih *UnixInboundHandler) Tag() string {
|
func (uih *UnixInboundHandler) Tag() string {
|
||||||
|
|
Loading…
Reference in New Issue