class ClientPeerSelector extends TunnelPeerSelector
TunnelPeerSelector.Excluder_firstHopFails, _peerCooldowns, _provenResponders, ATTACK_THRESHOLD, DEGRADED_BUILD_THRESHOLD, FAILURE_MAP_MAX_SIZE, FIRST_HOP_FAIL_COOLDOWN_MS, PEER_SELECTION_COOLDOWN_MS, PROVEN_RESPONDER_WINDOW_MS, STARTUP_WARNING_SUPPRESS_MSANY_V4, ctx, log| Constructor and Description |
|---|
ClientPeerSelector(RouterContext context)Constructor. |
| Modifier and Type | Method and Description |
|---|---|
(package private) static boolean | adoptIfFilled(List<Hash> rv,
Set<Hash> fallback)Adopts the fallback peer set when it has candidates: clears the
running selection and replaces it with the fallback. |
(package private) static boolean | canUseStressFallback(double buildSuccess,
boolean useHighCapPrimary,
int rvSize)Whether the selection may use the progressive stress fallbacks and
the shortened-tunnel allowance: network stress (build success below
the attack threshold) or HighCap-primary mode, with at least one peer
already selected. |
(package private) static int | compareAcceptance(PeerProfile prof1,
PeerProfile prof2)Acceptance ratio tiers: good (> 0.3) ranks above low (< 0.3), which
ranks above dead (<= 0). |
(package private) static int | compareActivity(PeerProfile prof1,
PeerProfile prof2,
long now,
long thirtyMinutes)Peers active within the activity window sort first. |
(package private) static int | compareExcluded(Hash p1,
Hash p2,
Set<Hash> exclude)Excluded peers sort last; two excluded peers compare equal. |
(package private) static int | compareLatency(float lat1,
float lat2)Lower measured tunnel-test latency sorts first; measured beats unknown. |
(package private) static int | compareQuality(Hash p1,
Hash p2,
Set<Hash> exclude,
PeerProfile prof1,
PeerProfile prof2,
long now,
long thirtyMinutes)Full quality comparison cascade. |
(package private) static int | compareSlowLatency(float lat1,
float lat2)Peers with tunnel test latency over 15s sort last; when both are slow,
the less slow one sorts first. |
(package private) List<Hash> | filterByReliability(Set<Hash> candidates,
Set<Hash> exclude)Filter candidates through the reliability gate: a peer must have an
adequate acceptance ratio and at least one recent activity or
connection signal to remain. |
(package private) List<Hash> | filterGhostPeers(List<Hash> peers)Filter out ghost peers from the selected peer list. |
(package private) List<Hash> | finalizeSelection(TunnelPoolSettings settings,
List<Hash> rv,
boolean isInbound)Insert self, ghost-filter, strategy post-processing, duplicate re-check,
and cooldowns. |
(package private) static int | firstHopQualityTier(int attempts,
boolean inStartup,
int currentTier)First-hop quality tier for the current attempt: 0 = prefer
established peers, 1 = also accept connecting peers, 2 = accept any
peer that passed the tier filters. |
(package private) boolean | isReliable(PeerProfile profile,
long now,
long tenMinutes,
long thirtyMinutes)Reliability gate: the acceptance ratio must be at least 0.3, and the
peer must show a recent tunnel-test success, recent activity, or an
established connection. |
(package private) static boolean | isStartupGracePeriod(RouterContext ctx)Whether the router is still in the startup grace period (first
STARTUP_GRACE_MS ms of uptime), during which strict first-hop
quality gates and soft fallbacks are relaxed because few peers are
available and transient transport failures are common. |
(package private) Comparator<Hash> | peerQualityComparator(Set<Hash> exclude,
long now,
long thirtyMinutes)Build a comparator that orders peers by tunnel-building quality: excluded
peers last, then by acceptance ratio, activity recency, and tunnel-test latency. |
List<Hash> | selectPeers(TunnelPoolSettings settings)Returns ENDPOINT FIRST, GATEWAY LAST!!!!
In: us .. |
addFreshCooldownExclusions, allowAsIBGW, allowAsOBEP, allowFirewalledUnderAttack, checkTunnel, compareProven, countKnownCaps, filterSlow, formatExcludedPeers, getActivityWindow, getActivityWindow, getBuildSuccess, getClosestHopExclude, getExclude, getLength, getPeersInPool, getWindowMultiplier, hasConnectivitySignal, hasRecoveredFromFailure, hasTunnelLongerThanOne, hasValidTransportAddress, isDuplicateSequence, isFirstHopFailing, isInStartupGracePeriod, isInStartupGracePeriod, isIPv6Only, isLowAcceptanceRatio, isOutdatedVersion, isProvenResponder, isStalePeer, isStalePeer, isUsableRouterAddress, isZeroHopSettings, keepAlive, matchesExistingTunnel, orderPeers, preConnectTo, prunePeerMaps, recordFirstHopFail, recordPeerFailure, regeneratePeers, relaxedExcludeCaps, selectExplicit, setWindowMultiplier, shouldExclude, shouldExclude, shouldSelectExplicit, supportsNTCP2canConnect, canConnect, canConnect, getInboundMask, getOutboundMask, isNTCPDisabled, isSSUDisabledpublic ClientPeerSelector(RouterContext context)
context - the router contextstatic boolean adoptIfFilled(List<Hash> rv, Set<Hash> fallback)
rv.rv - the running selection, replaced when fallback is non-emptyfallback - the fallback candidates (self already removed)static boolean canUseStressFallback(double buildSuccess,
boolean useHighCapPrimary,
int rvSize)buildSuccess - current tunnel build success rateuseHighCapPrimary - whether the selection prefers high-capacity peersrvSize - current number of selected peersstatic int compareAcceptance(PeerProfile prof1, PeerProfile prof2)
prof1 - first peer's profile, or nullprof2 - second peer's profile, or nullstatic int compareActivity(PeerProfile prof1, PeerProfile prof2, long now, long thirtyMinutes)
prof1 - first peer's profile, or nullprof2 - second peer's profile, or nullnow - current time from the router clockthirtyMinutes - activity window in msstatic int compareExcluded(Hash p1, Hash p2, Set<Hash> exclude)
p1 - first peerp2 - second peerexclude - peers to deprioritize, or nullstatic int compareLatency(float lat1,
float lat2)lat1 - first peer's tunnel test time averagelat2 - second peer's tunnel test time averagestatic int compareQuality(Hash p1, Hash p2, Set<Hash> exclude, PeerProfile prof1, PeerProfile prof2, long now, long thirtyMinutes)
p1 - first peerp2 - second peerexclude - peers to deprioritize, or nullprof1 - first peer's profile, or nullprof2 - second peer's profile, or nullnow - current time from the router clockthirtyMinutes - activity window in msstatic int compareSlowLatency(float lat1,
float lat2)lat1 - first peer's tunnel test time averagelat2 - second peer's tunnel test time averageList<Hash> filterByReliability(Set<Hash> candidates, Set<Hash> exclude)
candidates - peers to filterexclude - peers to excludeList<Hash> filterGhostPeers(List<Hash> peers)
peers - the list of selected peers (excluding self)List<Hash> finalizeSelection(TunnelPoolSettings settings, List<Hash> rv, boolean isInbound)
static int firstHopQualityTier(int attempts,
boolean inStartup,
int currentTier)Pure decision — no side effects.
attempts - number of quality-check attempts already madeinStartup - whether the router is in the startup grace periodcurrentTier - the tier before this attemptboolean isReliable(PeerProfile profile, long now, long tenMinutes, long thirtyMinutes)
profile - the peer profile (may be null)now - current time from the router clocktenMinutes - tunnel-test recency window in msthirtyMinutes - activity recency window in msstatic boolean isStartupGracePeriod(RouterContext ctx)
STARTUP_GRACE_MS ms of uptime), during which strict first-hop
quality gates and soft fallbacks are relaxed because few peers are
available and transient transport failures are common.Pure decision — no side effects.
ctx - the router contextComparator<Hash> peerQualityComparator(Set<Hash> exclude, long now, long thirtyMinutes)
Stage order is significant — each stage short-circuits the ones below it.
exclude - peers to deprioritize, or nullnow - current time from the router clockthirtyMinutes - activity window in mspublic List<Hash> selectPeers(TunnelPoolSettings settings)
selectPeers in class TunnelPeerSelectorsettings - the tunnel pool settings