public class RouterInfo extends DatabaseEntry
| Modifier and Type | Field and Description |
|---|---|
static String |
BW_CAPABILITY_CHARS
Public string of chars which serve as bandwidth capacity markers
NOTE: individual chars defined in Router.java
|
static char |
CAPABILITY_HIDDEN |
static String |
CONGESTION_CAPABILITY_CHARS
Public string of chars which serve as bandwidth congestion markers
NOTE: individual chars defined in Router.java
|
static int |
MAX_UNCOMPRESSED_SIZE
All legit RIs are currently under 2KB.
|
static String |
PROP_CAPABILITIES |
static String |
PROP_NETWORK_ID |
_signature, KEY_TYPE_ENCRYPTED_LS2, KEY_TYPE_LEASESET, KEY_TYPE_LS2, KEY_TYPE_META_LS2, KEY_TYPE_ROUTERINFO, KEY_TYPE_SERVICE_LIST, KEY_TYPE_SERVICE_RECORD| Constructor and Description |
|---|
RouterInfo() |
RouterInfo(RouterInfo old)
Used only by Router and PublishLocalRouterInfoJob.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object object) |
int |
getAddressCount()
Return the number of router addresses.
|
Collection<RouterAddress> |
getAddresses()
Retrieve the set of RouterAddress structures at which this
router can be contacted.
|
String |
getBandwidthTier()
Return a string representation of this node's bandwidth tier,
or "Unknown"
|
protected byte[] |
getBytes()
Write out the raw payload of the routerInfo, excluding the signature.
|
String |
getCapabilities()
what special capabilities this router offers
|
String |
getCongestionCap()
Return a string representation of this node's congestion cap,
or "Unknown"
|
long |
getDate()
A common interface to the timestamp of the two subclasses.
|
RouterIdentity |
getIdentity()
Retrieve the identity of the router represented
|
KeysAndCert |
getKeysAndCert()
Get the keys and the cert
Identical to getDestination() in LeaseSet,
and getIdentity() in RouterInfo.
|
int |
getNetworkId()
which network is this routerInfo a part of.
|
String |
getOption(String opt) |
Map<Object,Object> |
getOptionsMap()
Retrieve a set of options or statistics that the router can expose.
|
long |
getPublished()
Retrieve the timestamp on which the info was published,
essentially a version number for the RouterInfo.
|
RouterAddress |
getTargetAddress(String transportStyle)
Pull the first workable target address for the given transport.
|
List<RouterAddress> |
getTargetAddresses(String transportStyle)
For multiple addresses per-transport (IPv4 or IPv6)
|
List<RouterAddress> |
getTargetAddresses(String transportStyle1,
String transportStyle2)
For multiple addresses per-transport (IPv4 or IPv6)
Return addresses matching either of two styles
|
int |
getType()
Get the type of the data structure.
|
String |
getVersion()
For convenience, the same as getOption("router.version"),
but returns "0" if unset.
|
int |
hashCode() |
boolean |
isCurrent(long maxAgeMs)
Determine whether the router was published recently (within the given age milliseconds).
|
boolean |
isHidden()
Is this a hidden node?
|
boolean |
isValid()
Determine whether this router info is authorized with a valid signature
|
static void |
main(String[] args)
Print out routerinfos from files specified on the command line.
|
void |
readBytes(InputStream in)
This does NOT validate the signature
|
void |
readBytes(InputStream in,
boolean verifySig)
If verifySig is true,
this validates the signature while reading in,
and throws a DataFormatException if the sig is invalid.
|
void |
setAddresses(Collection<RouterAddress> addresses)
Specify a set of RouterAddress structures at which this router
can be contacted.
|
void |
setIdentity(RouterIdentity ident)
Configure the identity of the router represented
|
void |
setOptions(Properties options)
Configure a set of options or statistics that the router can expose.
|
void |
setPublished(long published)
Date on which it was published, in milliseconds since Midnight GMT on Jan 01, 1970
|
String |
toString() |
boolean |
verifySignature()
Same as isValid()
|
void |
writeBytes(OutputStream out)
This does NOT validate the signature
|
getHash, getReceivedAsPublished, getReceivedAsReply, getReceivedBy, getRoutingKey, getSignature, getSigningPublicKey, isLeaseSet, isLeaseSet, isRouterInfo, setReceivedAsPublished, setReceivedAsReply, setReceivedBy, setSignature, sign, validateRoutingKeycalculateHash, fromBase64, fromByteArray, read, toBase64, toByteArraypublic static final String BW_CAPABILITY_CHARS
public static final char CAPABILITY_HIDDEN
public static final String CONGESTION_CAPABILITY_CHARS
public static final int MAX_UNCOMPRESSED_SIZE
public static final String PROP_CAPABILITIES
public static final String PROP_NETWORK_ID
public RouterInfo()
public RouterInfo(RouterInfo old)
public int getAddressCount()
public Collection<RouterAddress> getAddresses()
public String getBandwidthTier()
protected byte[] getBytes()
throws DataFormatException
getBytes in class DatabaseEntryDataFormatException - if the data is somehow b0rked (missing props, etc)public String getCapabilities()
public String getCongestionCap()
public long getDate()
DatabaseEntrygetDate in class DatabaseEntrypublic RouterIdentity getIdentity()
public KeysAndCert getKeysAndCert()
DatabaseEntrygetKeysAndCert in class DatabaseEntrypublic int getNetworkId()
public Map<Object,Object> getOptionsMap()
public long getPublished()
public RouterAddress getTargetAddress(String transportStyle)
public List<RouterAddress> getTargetAddresses(String transportStyle)
public List<RouterAddress> getTargetAddresses(String transportStyle1, String transportStyle2)
public int getType()
DatabaseEntrygetType in class DatabaseEntrypublic String getVersion()
public boolean isCurrent(long maxAgeMs)
maxAgeMs - milliseconds between the current time and publish date to checkpublic boolean isHidden()
public boolean isValid()
public static void main(String[] args)
public void readBytes(InputStream in) throws DataFormatException, IOException
in - stream to read fromIllegalStateException - if RouterInfo was already read inDataFormatException - if the data is improperly formattedIOException - if there was a problem reading the streampublic void readBytes(InputStream in, boolean verifySig) throws DataFormatException, IOException
IllegalStateException - if RouterInfo was already read inDataFormatExceptionIOExceptionpublic void setAddresses(Collection<RouterAddress> addresses)
addresses - may be nullIllegalStateException - if RouterInfo is already signed or addresses previously setIllegalArgumentException - if too many addressespublic void setIdentity(RouterIdentity ident)
IllegalStateException - if RouterInfo is already signedpublic void setOptions(Properties options)
options - if null, clears current optionsIllegalStateException - if RouterInfo is already signedpublic void setPublished(long published)
IllegalStateException - if RouterInfo is already signedpublic boolean verifySignature()
verifySignature in class DatabaseEntrypublic void writeBytes(OutputStream out) throws DataFormatException, IOException
out - stream to write toDataFormatException - if the data was incomplete or not yet ready to be writtenIOException - if there was a problem writing to the stream