mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-10-20 08:14:24 +00:00
fix: Report fork component references to reference manager
This commit is contained in:
@@ -84,6 +84,17 @@ func (h *Inbound) Start(stage adapter.StartStage, scope *adapter.Scope) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Inbound) References() []string {
|
||||
var references []string
|
||||
for _, inbound := range h.inbounds {
|
||||
referrer, isReferrer := inbound.(adapter.Referrer)
|
||||
if isReferrer {
|
||||
references = append(references, referrer.References()...)
|
||||
}
|
||||
}
|
||||
return references
|
||||
}
|
||||
|
||||
func (h *Inbound) connHandler(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc) error {
|
||||
request, err := ReadRequest(conn)
|
||||
if err != nil {
|
||||
|
||||
@@ -89,6 +89,37 @@ func (h *Outbound) Start(stage adapter.StartStage, scope *adapter.Scope) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Outbound) References() []string {
|
||||
var references []string
|
||||
for _, outbound := range h.outbounds {
|
||||
referrer, isReferrer := outbound.(adapter.Referrer)
|
||||
if isReferrer {
|
||||
references = append(references, referrer.References()...)
|
||||
} else {
|
||||
references = append(references, outbound.Dependencies()...)
|
||||
}
|
||||
}
|
||||
return references
|
||||
}
|
||||
|
||||
func (h *Outbound) SetKeepIdleConnections(keep bool) {
|
||||
for _, outbound := range h.outbounds {
|
||||
keeper, isKeeper := outbound.(adapter.IdleConnectionKeeper)
|
||||
if isKeeper {
|
||||
keeper.SetKeepIdleConnections(keep)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Outbound) CloseIdleConnections() {
|
||||
for _, outbound := range h.outbounds {
|
||||
keeper, isKeeper := outbound.(adapter.IdleConnectionKeeper)
|
||||
if isKeeper {
|
||||
keeper.CloseIdleConnections()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Outbound) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||
if N.NetworkName(network) == N.NetworkUDP {
|
||||
return h.uotClient.DialContext(ctx, network, destination)
|
||||
|
||||
@@ -69,6 +69,17 @@ func (h *Inbound) Start(stage adapter.StartStage, scope *adapter.Scope) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Inbound) References() []string {
|
||||
var references []string
|
||||
for _, inbound := range h.inbounds {
|
||||
referrer, isReferrer := inbound.(adapter.Referrer)
|
||||
if isReferrer {
|
||||
references = append(references, referrer.References()...)
|
||||
}
|
||||
}
|
||||
return references
|
||||
}
|
||||
|
||||
func (h *Inbound) connHandler(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc) error {
|
||||
if metadata.Destination != Destination {
|
||||
h.router.RouteConnectionEx(ctx, conn, metadata, onClose)
|
||||
|
||||
@@ -79,6 +79,37 @@ func (f *Failover) Start(stage adapter.StartStage, scope *adapter.Scope) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *Failover) References() []string {
|
||||
var references []string
|
||||
for _, outbound := range f.outbounds {
|
||||
referrer, isReferrer := outbound.(adapter.Referrer)
|
||||
if isReferrer {
|
||||
references = append(references, referrer.References()...)
|
||||
} else {
|
||||
references = append(references, outbound.Dependencies()...)
|
||||
}
|
||||
}
|
||||
return references
|
||||
}
|
||||
|
||||
func (f *Failover) SetKeepIdleConnections(keep bool) {
|
||||
for _, outbound := range f.outbounds {
|
||||
keeper, isKeeper := outbound.(adapter.IdleConnectionKeeper)
|
||||
if isKeeper {
|
||||
keeper.SetKeepIdleConnections(keep)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Failover) CloseIdleConnections() {
|
||||
for _, outbound := range f.outbounds {
|
||||
keeper, isKeeper := outbound.(adapter.IdleConnectionKeeper)
|
||||
if isKeeper {
|
||||
keeper.CloseIdleConnections()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Failover) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||
if N.NetworkName(network) == N.NetworkUDP {
|
||||
return f.uotClient.DialContext(ctx, network, destination)
|
||||
|
||||
@@ -100,6 +100,10 @@ func (h *Outbound) Start(stage adapter.StartStage, scope *adapter.Scope) error {
|
||||
return h.router.Start(stage, scope)
|
||||
}
|
||||
|
||||
func (h *Outbound) References() []string {
|
||||
return h.router.References()
|
||||
}
|
||||
|
||||
func (h *Outbound) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||
conn, err := h.detour.DialContext(ctx, network, destination)
|
||||
if err != nil {
|
||||
|
||||
@@ -100,6 +100,10 @@ func (h *Outbound) Start(stage adapter.StartStage, scope *adapter.Scope) error {
|
||||
return h.router.Start(stage, scope)
|
||||
}
|
||||
|
||||
func (h *Outbound) References() []string {
|
||||
return h.router.References()
|
||||
}
|
||||
|
||||
func (h *Outbound) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||
onClose, lockCtx, err := h.strategy.request(ctx, adapter.ContextFrom(ctx))
|
||||
if err != nil {
|
||||
|
||||
@@ -96,6 +96,10 @@ func (h *Outbound) Start(stage adapter.StartStage, scope *adapter.Scope) error {
|
||||
return h.router.Start(stage, scope)
|
||||
}
|
||||
|
||||
func (h *Outbound) References() []string {
|
||||
return h.router.References()
|
||||
}
|
||||
|
||||
func (h *Outbound) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||
if err := h.strategy.request(ctx, adapter.ContextFrom(ctx)); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -76,6 +76,10 @@ func (h *Outbound) Start(stage adapter.StartStage, scope *adapter.Scope) error {
|
||||
return h.router.Start(stage, scope)
|
||||
}
|
||||
|
||||
func (h *Outbound) References() []string {
|
||||
return h.router.References()
|
||||
}
|
||||
|
||||
func (h *Outbound) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||
conn, err := h.detour.DialContext(ctx, network, destination)
|
||||
if err != nil {
|
||||
|
||||
@@ -106,6 +106,14 @@ func (c *ClientEndpoint) Start(stage adapter.StartStage, scope *adapter.Scope) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ClientEndpoint) References() []string {
|
||||
referrer, isReferrer := c.outbound.(adapter.Referrer)
|
||||
if isReferrer {
|
||||
return referrer.References()
|
||||
}
|
||||
return c.outbound.Dependencies()
|
||||
}
|
||||
|
||||
func (c *ClientEndpoint) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||
if N.NetworkName(network) == N.NetworkUDP {
|
||||
return c.uotClient.DialContext(ctx, network, destination)
|
||||
|
||||
@@ -107,6 +107,17 @@ func (s *ServerEndpoint) Start(stage adapter.StartStage, scope *adapter.Scope) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ServerEndpoint) References() []string {
|
||||
var references []string
|
||||
for _, inbound := range s.inbounds {
|
||||
referrer, isReferrer := inbound.(adapter.Referrer)
|
||||
if isReferrer {
|
||||
references = append(references, referrer.References()...)
|
||||
}
|
||||
}
|
||||
return references
|
||||
}
|
||||
|
||||
func (s *ServerEndpoint) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||
if N.NetworkName(network) == N.NetworkUDP {
|
||||
return s.uotClient.DialContext(ctx, network, destination)
|
||||
|
||||
Reference in New Issue
Block a user