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 {
|
||||
return nil, err
|
||||
}
|
||||
receiverSettings, ok := rawReceiverSettings.(*proxyman.ReceiverConfig)
|
||||
if !ok {
|
||||
return nil, newError("not a ReceiverConfig").AtError()
|
||||
}
|
||||
proxySettings, err := config.ProxySettings.GetInstance()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
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
|
||||
if allocStrategy == nil || allocStrategy.Type == proxyman.AllocationStrategy_Always {
|
||||
return NewAlwaysOnInboundHandler(ctx, tag, receiverSettings, proxySettings)
|
||||
|
|
|
@ -21,23 +21,23 @@ type UnixInboundHandler struct {
|
|||
additional *proxyman.UnixReceiverConfig
|
||||
}
|
||||
|
||||
func (uih *UnixInboundHandler) Start() {
|
||||
func (uih *UnixInboundHandler) Start() error {
|
||||
var err error
|
||||
uih.listenerHolder, err = domainsocket.ListenDS(uih.ctx, uih.path)
|
||||
if err != nil {
|
||||
newError(err).AtError().WriteToLog()
|
||||
return newError(err).AtError()
|
||||
}
|
||||
err = uih.listenerHolder.LowerUP()
|
||||
if err != nil {
|
||||
newError(err).AtError().WriteToLog()
|
||||
return newError(err).AtError()
|
||||
}
|
||||
nchan := make(chan net.Conn, 2)
|
||||
err = uih.listenerHolder.UP(nchan, false)
|
||||
if err != nil {
|
||||
newError(err).AtError().WriteToLog()
|
||||
return newError(err).AtError()
|
||||
}
|
||||
go uih.progressTraffic(nchan)
|
||||
return
|
||||
return nil
|
||||
}
|
||||
func (uih *UnixInboundHandler) progressTraffic(rece <-chan net.Conn) {
|
||||
|
||||
|
@ -59,12 +59,12 @@ func (uih *UnixInboundHandler) progressTraffic(rece <-chan net.Conn) {
|
|||
}(conn)
|
||||
}
|
||||
}
|
||||
func (uih *UnixInboundHandler) Close() {
|
||||
func (uih *UnixInboundHandler) Close() error {
|
||||
if uih.listenerHolder != nil {
|
||||
uih.listenerHolder.Down()
|
||||
} else {
|
||||
newError("Called UnixInboundHandler.Close while listenerHolder is nil").AtDebug().WriteToLog()
|
||||
return nil
|
||||
}
|
||||
return newError("Called UnixInboundHandler.Close while listenerHolder is nil")
|
||||
|
||||
}
|
||||
func (uih *UnixInboundHandler) Tag() string {
|
||||
|
|
Loading…
Reference in New Issue