Skip to content

Commit

Permalink
dialers/desync: skip desync on invalid cached ttls
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Aug 12, 2024
1 parent 9a33c57 commit 95463d5
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions intra/dialers/split_and_desync.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ const (

default_ttl = 64
// from: github.com/bol-van/zapret/blob/c369f11638/nfq/darkmagic.h#L214-L216
desync_max_ttl = 20
desync_noop_ttl = 3
desync_delta_ttl = 1
desync_max_ttl = 20
desync_noop_ttl = 3
desync_delta_ttl = 1
desync_invalid_ttl = -1
)

// ttlcache stores the TTL for a given IP address for a limited time.
Expand Down Expand Up @@ -256,8 +257,11 @@ func desyncWithTraceroute(d *protect.RDial, ipp netip.AddrPort) (*overwriteSplit
}
}

// skip desync if no measurement is done
oc.used.Store(!processed)
if !processed {
// skip desync if no measurement is done
oc.used.Store(false)
oc.ttl = desync_invalid_ttl
}

log.D("split-desync: done: %v, used? %t, ttl: %d", ipp, oc.used.Load(), oc.ttl)

Expand All @@ -272,12 +276,15 @@ func desyncWithFixedTtl(d *protect.RDial, ipp netip.AddrPort, initialTTL int) (*
if tcpConn == nil {
return nil, errNoConn
}
return &overwriteSplitter{
s := &overwriteSplitter{
conn: tcpConn,
ttl: initialTTL,
payload: []byte(http1_1str),
ip6: ipp.Addr().Is6(),
}, nil
}
// skip desync if no measurement is done
s.used.Store(initialTTL == desync_invalid_ttl)
return s, nil
}

// DialWithSplitAndDesync estimates the TTL with UDP traceroute,
Expand Down

1 comment on commit 95463d5

@ignoramous
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#81

Please sign in to comment.