public class OpennetManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
OpennetManager.ConnectionType |
Modifier and Type | Field and Description |
---|---|
static int |
AVAILABLE_SHORT_DISTANCE_NODES
The estimated number of nodes which are a short distance away.
|
static long |
DONT_READD_TIME
Don't re-add a node until it's been up and disconnected for at least this long
|
static long |
DROP_CONNECTED_TIME
Every DROP_CONNECTED_TIME, we may drop a peer even though it is connected.
|
static long |
DROP_DISCONNECT_DELAY
Don't drop a node until this long after losing connection to it.
|
static long |
DROP_DISCONNECT_DELAY_COOLDOWN
But if it has disconnected more than once in this period, allow it to be dropped anyway
|
static long |
DROP_MIN_AGE
Don't drop a node until it's at least this old, if it's connected.
|
static long |
DROP_MIN_AGE_DISCONNECTED
Don't drop a node until it's at least this old, if it's not connected (if it has connected once then DROP_DISCONNECT_DELAY applies, but only once an hour as below).
|
static long |
DROP_STARTUP_DELAY
Don't drop a node until this long after startup
|
static boolean |
ENABLE_PEERS_PER_KB_OUTPUT
Enable scaling of peers with bandwidth?
|
static int |
LAST_NETWORK_SIZE_ESTIMATE
The estimated average number of nodes which are active at any given time.
|
static double |
MAX_DISTANCE
The maximum possible distance between two nodes in the wrapping [0,1) location space.
|
static int |
MAX_OPENNET_NODEREF_LENGTH
Allow for future expansion.
|
static int |
MAX_PEERS_FOR_SCALING
Maximum number of peers.
|
static long |
MAX_TIME_ON_OLD_OPENNET_PEERS
Stop trying to reconnect to an old-opennet-peer after a month.
|
static int |
MIN_PEERS_FOR_SCALING
Minimum number of peers.
|
static int |
MIN_SUCCESS_BETWEEN_DROP_CONNS
Only drop a connection after at least this many successful requests.
|
static long |
MIN_TIME_BETWEEN_OFFERS
Minimum time between offers, if we have maximum peers.
|
static int |
PADDED_NODEREF_SIZE
How big to pad opennet noderefs to? If they are bigger than this then we won't send them.
|
static int |
PANIC_MAX_PEERS
Maximum number of peers for purposes of FOAF attack/sanity check
|
static int |
RESET_PATH_FOLDING_PROB
Chance of resetting path folding (for plausible deniability) is 1 in this number.
|
static double |
SCALING_CONSTANT
Constant for scaling peers: we multiply bandwidth in kB/sec by this
and then take the square root.
|
static double |
SHORT_NODES_FRACTION
The fraction of nodes which are only a short distance away.
|
static double |
SHORT_PROPORTION
The proportion of the routing table which consists of "short links".
|
Constructor and Description |
---|
OpennetManager(Node node,
NodeCryptoConfig opennetConfig,
long startupTime,
boolean enableAnnouncement) |
Modifier and Type | Method and Description |
---|---|
OpennetPeerNode |
addNewOpennetNode(SimpleFieldSet fs,
OpennetManager.ConnectionType connectionType,
boolean allowExisting) |
boolean |
alreadyHaveOpennetNode(SimpleFieldSet fs) |
void |
announce(double target,
AnnouncementCallback cb)
Do an announcement !!
|
void |
drawOpennetStatsBox(HTMLNode box) |
void |
drawSeedStatsBox(HTMLNode content) |
void |
finishSentAnnouncementRequest(PeerNode peer,
byte[] noderef,
ByteCounter ctr,
long xferUID) |
int |
getAnnouncementThreshold() |
long |
getCreationTime() |
int |
getNetworkSizeEstimate(long timestamp) |
int |
getNumberOfConnectedPeersToAim() |
int |
getNumberOfConnectedPeersToAim(freenet.node.OpennetManager.LinkLengthClass distance)
Get the target number of opennet peers.
|
int |
getNumberOfConnectedPeersToAimIncludingDarknet() |
int |
getSize(freenet.node.OpennetManager.LinkLengthClass distance)
How many opennet peers do we have?
Connected but out of date nodes don't count towards the connection limit.
|
void |
onConnectedPeer(PeerNode pn)
Called when a connection completes.
|
void |
onDisconnect(PeerNode node2)
Notification that a peer was disconnected.
|
void |
onRemove(OpennetPeerNode pn) |
void |
onSuccess(OpennetPeerNode pn) |
void |
purgeOldOpennetPeer(OpennetPeerNode source) |
void |
reannounce() |
static void |
rejectRef(long uid,
PeerNode source,
int reason,
ByteCounter ctr) |
void |
sendAnnouncementReply(long uid,
PeerNode peer,
byte[] noderef,
ByteCounter ctr) |
void |
sendOpennetRef(boolean isReply,
long uid,
PeerNode peer,
byte[] noderef,
ByteCounter ctr) |
boolean |
sendOpennetRef(boolean isReply,
long uid,
PeerNode peer,
byte[] noderef,
ByteCounter ctr,
BulkTransmitter.AllSentCallback cb)
Send our opennet noderef to a node.
|
void |
start() |
long |
startSendAnnouncementRequest(long uid,
PeerNode peer,
byte[] noderef,
ByteCounter ctr,
double target,
short htl) |
void |
stop(boolean purge)
Called when opennet is disabled
|
static SimpleFieldSet |
validateNoderef(byte[] noderef,
int offset,
int length,
PeerNode from,
boolean forceOpennetEnabled) |
static byte[] |
waitForOpennetNoderef(boolean isReply,
PeerNode source,
long uid,
ByteCounter ctr,
Node node)
Wait for an opennet noderef.
|
static void |
waitForOpennetNoderef(boolean isReply,
PeerNode source,
long uid,
ByteCounter ctr,
freenet.node.OpennetManager.NoderefCallback callback,
Node node) |
boolean |
waitingForUpdater() |
boolean |
wantPeer(OpennetPeerNode nodeToAddNow,
boolean addAtLRU,
boolean justChecking,
boolean oldOpennetPeer,
OpennetManager.ConnectionType connectionType) |
boolean |
wantPeer(OpennetPeerNode nodeToAddNow,
boolean addAtLRU,
boolean justChecking,
boolean oldOpennetPeer,
OpennetManager.ConnectionType connectionType,
freenet.node.OpennetManager.LinkLengthClass distance)
Trim the peers list and possibly add a new node.
|
void |
writeFile() |
public static final double SHORT_PROPORTION
public static final int MIN_SUCCESS_BETWEEN_DROP_CONNS
public static final int RESET_PATH_FOLDING_PROB
public static final long DONT_READD_TIME
public static final long DROP_MIN_AGE
public static final long DROP_MIN_AGE_DISCONNECTED
public static final long DROP_STARTUP_DELAY
public static final long DROP_DISCONNECT_DELAY
public static final long DROP_DISCONNECT_DELAY_COOLDOWN
public static final long DROP_CONNECTED_TIME
public static final long MIN_TIME_BETWEEN_OFFERS
public static final int PADDED_NODEREF_SIZE
public static final int MAX_OPENNET_NODEREF_LENGTH
public static final boolean ENABLE_PEERS_PER_KB_OUTPUT
public static final double SCALING_CONSTANT
public static final int MIN_PEERS_FOR_SCALING
public static final double MAX_DISTANCE
public static final double SHORT_NODES_FRACTION
public static final int LAST_NETWORK_SIZE_ESTIMATE
public static final int AVAILABLE_SHORT_DISTANCE_NODES
public static final int MAX_PEERS_FOR_SCALING
OpennetManager.LinkLengthClass
,
Constant Field Valuespublic static final int PANIC_MAX_PEERS
public static final long MAX_TIME_ON_OLD_OPENNET_PEERS
public OpennetManager(Node node, NodeCryptoConfig opennetConfig, long startupTime, boolean enableAnnouncement) throws NodeInitException
NodeInitException
public void writeFile()
public void start()
public void stop(boolean purge)
public boolean alreadyHaveOpennetNode(SimpleFieldSet fs)
public OpennetPeerNode addNewOpennetNode(SimpleFieldSet fs, OpennetManager.ConnectionType connectionType, boolean allowExisting) throws FSParseException, PeerParseException, ReferenceSignatureVerificationException
public boolean wantPeer(OpennetPeerNode nodeToAddNow, boolean addAtLRU, boolean justChecking, boolean oldOpennetPeer, OpennetManager.ConnectionType connectionType)
public boolean wantPeer(OpennetPeerNode nodeToAddNow, boolean addAtLRU, boolean justChecking, boolean oldOpennetPeer, OpennetManager.ConnectionType connectionType, freenet.node.OpennetManager.LinkLengthClass distance)
nodeToAddNow
- Node to add. Can be null, which means the caller needs to know whether
we have space for another node, without actually adding one. This happens e.g. when we are
the data source and are trying to decide whether to send our noderef downstream for path
folding.addAtLRU
- If there is a node to add, add it at the bottom rather than the top. Normally
we set this on new path folded nodes so that they will be replaced if during the trial period,
plus the time it takes to get a new path folding offer, they don't have a successful request.justChecking
- If true, we want to know whether there is space for a node to be added
RIGHT NOW. If false, the normal behaviour applies: if nodeToAddNow is passed in, we decide
whether to add that node, if it's null, we decide whether to send an offer subject to the
inter-offer time.oldOpennetPeer
- If true, we are trying to add an old-opennet-peer which has reconnected.
There is a throttle, we accept no more than one old-opennet-peer every 30 seconds. On receiving
a packet, we call once to decide whether to try to parse it against the old-opennet-peers, and
then again to decide whether it is worth keeping; in the latter case if we decide not, the
old-opennet-peer will be told to disconnect and go away, but normally we don't reach that point
because of the first check.isLong
- True if the peer to add is distant. False otherwise.public int getSize(freenet.node.OpennetManager.LinkLengthClass distance)
public void onSuccess(OpennetPeerNode pn)
public void onRemove(OpennetPeerNode pn)
public void purgeOldOpennetPeer(OpennetPeerNode source)
public int getNumberOfConnectedPeersToAimIncludingDarknet()
public int getNumberOfConnectedPeersToAim(freenet.node.OpennetManager.LinkLengthClass distance)
public int getNumberOfConnectedPeersToAim()
public void sendOpennetRef(boolean isReply, long uid, PeerNode peer, byte[] noderef, ByteCounter ctr) throws NotConnectedException
NotConnectedException
public boolean sendOpennetRef(boolean isReply, long uid, PeerNode peer, byte[] noderef, ByteCounter ctr, BulkTransmitter.AllSentCallback cb) throws NotConnectedException
isReply
- If true, send an FNPOpennetConnectReply, else send an FNPOpennetConnectDestination.uid
- The unique ID of the request chain involved.peer
- The node to send the noderef to. Not necessarily an OpennetPeerNode, as path
folding and possibly announcement can pass through darknet.cs
- The full compressed noderef to send.NotConnectedException
- If the peer becomes disconnected while we are trying to send the noderef.public long startSendAnnouncementRequest(long uid, PeerNode peer, byte[] noderef, ByteCounter ctr, double target, short htl) throws NotConnectedException
NotConnectedException
public void finishSentAnnouncementRequest(PeerNode peer, byte[] noderef, ByteCounter ctr, long xferUID) throws NotConnectedException
NotConnectedException
public void sendAnnouncementReply(long uid, PeerNode peer, byte[] noderef, ByteCounter ctr) throws NotConnectedException
NotConnectedException
public static byte[] waitForOpennetNoderef(boolean isReply, PeerNode source, long uid, ByteCounter ctr, Node node) throws freenet.node.OpennetManager.WaitedTooLongForOpennetNoderefException
isReply
- If true, wait for an FNPOpennetConnectReply[New], if false wait for an FNPOpennetConnectDestination[New].uid
- The UID of the parent request.freenet.node.OpennetManager.WaitedTooLongForOpennetNoderefException
public static void waitForOpennetNoderef(boolean isReply, PeerNode source, long uid, ByteCounter ctr, freenet.node.OpennetManager.NoderefCallback callback, Node node)
public static void rejectRef(long uid, PeerNode source, int reason, ByteCounter ctr)
public static SimpleFieldSet validateNoderef(byte[] noderef, int offset, int length, PeerNode from, boolean forceOpennetEnabled)
public void announce(double target, AnnouncementCallback cb)
target
- The location to announce to. In 0.7 we don't try to prevent nodes from choosing their
announcement location, because it is easy for them to get the location they want later on anyway,
and we can do a much more effective announcement this way.public long getCreationTime()
public int getNetworkSizeEstimate(long timestamp)
public int getAnnouncementThreshold()
public void onDisconnect(PeerNode node2)
public void drawOpennetStatsBox(HTMLNode box)
public boolean waitingForUpdater()
public void reannounce()
public void drawSeedStatsBox(HTMLNode content)
public void onConnectedPeer(PeerNode pn)