mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-05 00:47:51 -05:00
commit
a8a68c2e70
@ -27,7 +27,7 @@ func (l *OutboundListener) add(conn net.Conn) {
|
|||||||
func (l *OutboundListener) Accept() (net.Conn, error) {
|
func (l *OutboundListener) Accept() (net.Conn, error) {
|
||||||
select {
|
select {
|
||||||
case <-l.done.C():
|
case <-l.done.C():
|
||||||
return nil, newError("listern closed")
|
return nil, newError("listen closed")
|
||||||
case c := <-l.buffer:
|
case c := <-l.buffer:
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin
|
|||||||
ctx = proxy.ContextWithTarget(ctx, destination)
|
ctx = proxy.ContextWithTarget(ctx, destination)
|
||||||
|
|
||||||
outbound := ray.NewRay(ctx)
|
outbound := ray.NewRay(ctx)
|
||||||
snifferList := proxyman.ProtocoSniffersFromContext(ctx)
|
snifferList := proxyman.ProtocolSniffersFromContext(ctx)
|
||||||
if destination.Address.Family().IsDomain() || len(snifferList) == 0 {
|
if destination.Address.Family().IsDomain() || len(snifferList) == 0 {
|
||||||
go d.routedDispatch(ctx, outbound, destination)
|
go d.routedDispatch(ctx, outbound, destination)
|
||||||
} else {
|
} else {
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
// InboundOperation is the interface for operations that applies to inbound handlers.
|
// InboundOperation is the interface for operations that applies to inbound handlers.
|
||||||
type InboundOperation interface {
|
type InboundOperation interface {
|
||||||
// ApplyInbound appliess this operation to the given inbound handler.
|
// ApplyInbound applies this operation to the given inbound handler.
|
||||||
ApplyInbound(context.Context, core.InboundHandler) error
|
ApplyInbound(context.Context, core.InboundHandler) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ func ContextWithProtocolSniffers(ctx context.Context, list []KnownProtocols) con
|
|||||||
return context.WithValue(ctx, protocolsKey, list)
|
return context.WithValue(ctx, protocolsKey, list)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProtocoSniffersFromContext(ctx context.Context) []KnownProtocols {
|
func ProtocolSniffersFromContext(ctx context.Context) []KnownProtocols {
|
||||||
if list, ok := ctx.Value(protocolsKey).([]KnownProtocols); ok {
|
if list, ok := ctx.Value(protocolsKey).([]KnownProtocols); ok {
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func (d *Done) Wait() {
|
|||||||
<-d.c
|
<-d.c
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close marks this Done 'done'. This method may be called mutliple times. All calls after first call will have no effect on its status.
|
// Close marks this Done 'done'. This method may be called multiple times. All calls after first call will have no effect on its status.
|
||||||
func (d *Done) Close() error {
|
func (d *Done) Close() error {
|
||||||
d.access.Lock()
|
d.access.Lock()
|
||||||
defer d.access.Unlock()
|
defer d.access.Unlock()
|
||||||
|
@ -12,7 +12,7 @@ func executeAndFulfill(f func() error, done chan<- error) {
|
|||||||
close(done)
|
close(done)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExecuteAsync executes a function asychrously and return its result.
|
// ExecuteAsync executes a function asynchronously and return its result.
|
||||||
func ExecuteAsync(f func() error) <-chan error {
|
func ExecuteAsync(f func() error) <-chan error {
|
||||||
done := make(chan error, 1)
|
done := make(chan error, 1)
|
||||||
go executeAndFulfill(f, done)
|
go executeAndFulfill(f, done)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package signal
|
package signal
|
||||||
|
|
||||||
// Notifier is an utility for notifying changes. The change producer may notify changes multiple time, and the consumer may get notified asychronously.
|
// Notifier is an utility for notifying changes. The change producer may notify changes multiple time, and the consumer may get notified asynchronously.
|
||||||
type Notifier struct {
|
type Notifier struct {
|
||||||
c chan struct{}
|
c chan struct{}
|
||||||
}
|
}
|
||||||
|
2
v2ray.go
2
v2ray.go
@ -130,7 +130,7 @@ func (s *Instance) Start() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RegisterFeature registers the given feature into V2Ray.
|
// RegisterFeature registers the given feature into V2Ray.
|
||||||
// If feature is one of the following types, the corressponding feature in this Instance
|
// If feature is one of the following types, the corresponding feature in this Instance
|
||||||
// will be replaced: DNSClient, PolicyManager, Router, Dispatcher, InboundHandlerManager, OutboundHandlerManager.
|
// will be replaced: DNSClient, PolicyManager, Router, Dispatcher, InboundHandlerManager, OutboundHandlerManager.
|
||||||
func (s *Instance) RegisterFeature(feature interface{}, instance Feature) error {
|
func (s *Instance) RegisterFeature(feature interface{}, instance Feature) error {
|
||||||
running := false
|
running := false
|
||||||
|
Loading…
Reference in New Issue
Block a user