mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-07 18:26:37 +08:00
fix(gost): use chain.NewNode() to properly initialize marker for failover
When creating temporary Node instances with struct literals like
&chain.Node{Addr: host}, the marker field was not initialized.
Only chain.NewNode() properly initializes marker = selector.NewFailMarker().
Without a valid marker:
- Failed nodes cannot be marked (marker.Mark() is no-op on nil)
- Subsequent selections cannot filter out failed nodes
- Failover mechanism completely fails
Fixed locations:
- sniffer.go dial(): &chain.Node{Addr: host} -> chain.NewNode("", host)
- sniffer.go dialTLS(): &chain.Node{Addr: host} -> chain.NewNode("", host)
- local/handler.go: target := &chain.Node{} -> var target *chain.Node
- remote/handler.go: &chain.Node{Addr: host} -> chain.NewNode("", host)
This commit is contained in:
@@ -195,7 +195,7 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand
|
|||||||
for attempt := 0; attempt < maxRetries; attempt++ {
|
for attempt := 0; attempt < maxRetries; attempt++ {
|
||||||
// Select a target node, excluding previously tried nodes
|
// Select a target node, excluding previously tried nodes
|
||||||
selectCtx := ctxvalue.ContextWithExcludeNodes(ctx, triedNodes)
|
selectCtx := ctxvalue.ContextWithExcludeNodes(ctx, triedNodes)
|
||||||
target := &chain.Node{}
|
var target *chain.Node
|
||||||
if h.hop != nil {
|
if h.hop != nil {
|
||||||
target = h.hop.Select(selectCtx,
|
target = h.hop.Select(selectCtx,
|
||||||
hop.ProtocolSelectOption(proto),
|
hop.ProtocolSelectOption(proto),
|
||||||
|
|||||||
@@ -225,9 +225,7 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand
|
|||||||
selectCtx := ctxvalue.ContextWithExcludeNodes(ctx, triedNodes)
|
selectCtx := ctxvalue.ContextWithExcludeNodes(ctx, triedNodes)
|
||||||
var target *chain.Node
|
var target *chain.Node
|
||||||
if host != "" {
|
if host != "" {
|
||||||
target = &chain.Node{
|
target = chain.NewNode("", host)
|
||||||
Addr: host,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if h.hop != nil {
|
if h.hop != nil {
|
||||||
target = h.hop.Select(selectCtx,
|
target = h.hop.Select(selectCtx,
|
||||||
|
|||||||
@@ -263,9 +263,7 @@ func (h *Sniffer) dial(ctx context.Context, conn net.Conn, req *http.Request, ho
|
|||||||
// Select a node, excluding previously tried nodes
|
// Select a node, excluding previously tried nodes
|
||||||
selectCtx := ctxvalue.ContextWithExcludeNodes(ctx, triedNodes)
|
selectCtx := ctxvalue.ContextWithExcludeNodes(ctx, triedNodes)
|
||||||
|
|
||||||
node = &chain.Node{
|
node = chain.NewNode("", host)
|
||||||
Addr: host,
|
|
||||||
}
|
|
||||||
if ho.Hop != nil {
|
if ho.Hop != nil {
|
||||||
node = ho.Hop.Select(selectCtx,
|
node = ho.Hop.Select(selectCtx,
|
||||||
hop.ClientIPSelectOption(net.ParseIP(ro.ClientIP)),
|
hop.ClientIPSelectOption(net.ParseIP(ro.ClientIP)),
|
||||||
@@ -903,9 +901,7 @@ func (h *Sniffer) dialTLS(ctx context.Context, host string, ho *HandleOptions) (
|
|||||||
|
|
||||||
node = nil
|
node = nil
|
||||||
if host != "" {
|
if host != "" {
|
||||||
node = &chain.Node{
|
node = chain.NewNode("", host)
|
||||||
Addr: host,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ho.Hop != nil {
|
if ho.Hop != nil {
|
||||||
node = ho.Hop.Select(selectCtx,
|
node = ho.Hop.Select(selectCtx,
|
||||||
|
|||||||
Reference in New Issue
Block a user