|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.data.DataStructureImpl
net.i2p.data.DatabaseEntry
net.i2p.data.router.RouterInfo
public class RouterInfo
Defines the data that a router either publishes to the global routing table or provides to trusted peers. For efficiency, the methods and structures here are now unsynchronized. Initialize the RI with readBytes(), or call the setters and then sign() in a single thread. Don't change it after that. To ensure integrity of the RouterInfo, methods that change an element of the RouterInfo will throw an IllegalStateException after the RouterInfo is signed.
Field Summary | |
---|---|
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 |
PROP_CAPABILITIES
|
static String |
PROP_NETWORK_ID
|
Fields inherited from class net.i2p.data.DatabaseEntry |
---|
_currentRoutingKey, _routingKeyGenMod, _signature, KEY_TYPE_LEASESET, KEY_TYPE_ROUTERINFO |
Constructor Summary | |
---|---|
RouterInfo()
|
|
RouterInfo(RouterInfo old)
Used only by Router and PublishLocalRouterInfoJob. |
Method Summary | |
---|---|
void |
addCapability(char cap)
Warning, must be called AFTER setOptions(). |
void |
delCapability(char cap)
Deprecated. unused |
boolean |
equals(Object object)
|
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 |
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)
|
Properties |
getOptions()
Deprecated. use getOptionsMap() |
Map<Object,Object> |
getOptionsMap()
Retrieve a set of options or statistics that the router can expose. |
Set<Hash> |
getPeers()
Deprecated. Implemented here but unused elsewhere |
long |
getPublished()
Retrieve the approximate date on which the info was published (essentially a version number for the routerInfo structure, except that it also contains freshness information - whether or not the router is currently publishing its information). |
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) |
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 |
setPeers(Set<Hash> peers)
Deprecated. Implemented here but unused elsewhere |
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 |
Methods inherited from class net.i2p.data.DatabaseEntry |
---|
getHash, getRoutingKey, getSignature, getSigningPublicKey, setRoutingKey, setSignature, sign, validateRoutingKey |
Methods inherited from class net.i2p.data.DataStructureImpl |
---|
calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArray |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String PROP_NETWORK_ID
public static final String PROP_CAPABILITIES
public static final char CAPABILITY_HIDDEN
public static final String BW_CAPABILITY_CHARS
Constructor Detail |
---|
public RouterInfo()
public RouterInfo(RouterInfo old)
Method Detail |
---|
public long getDate()
DatabaseEntry
getDate
in class DatabaseEntry
public KeysAndCert getKeysAndCert()
DatabaseEntry
getKeysAndCert
in class DatabaseEntry
public int getType()
DatabaseEntry
getType
in class DatabaseEntry
public RouterIdentity getIdentity()
public void setIdentity(RouterIdentity ident)
IllegalStateException
- if RouterInfo is already signedpublic long getPublished()
public void setPublished(long published)
IllegalStateException
- if RouterInfo is already signedpublic Collection<RouterAddress> getAddresses()
public void setAddresses(Collection<RouterAddress> addresses)
addresses
- may be null
IllegalStateException
- if RouterInfo is already signed or addresses previously setpublic Set<Hash> getPeers()
public void setPeers(Set<Hash> peers)
IllegalStateException
- if RouterInfo is already signedpublic Properties getOptions()
public Map<Object,Object> getOptionsMap()
public String getOption(String opt)
public String getVersion()
public void setOptions(Properties options)
options
- if null, clears current options
IllegalStateException
- if RouterInfo is already signedprotected byte[] getBytes() throws DataFormatException
getBytes
in class DatabaseEntry
DataFormatException
- if the data is somehow b0rked (missing props, etc)public boolean isValid()
public boolean verifySignature()
verifySignature
in class DatabaseEntry
public int getNetworkId()
public String getCapabilities()
public boolean isHidden()
public String getBandwidthTier()
public void addCapability(char cap)
IllegalStateException
- if RouterInfo is already signedpublic void delCapability(char cap)
IllegalStateException
- if RouterInfo is already signedpublic boolean isCurrent(long maxAgeMs)
maxAgeMs
- milliseconds between the current time and publish date to check
public RouterAddress getTargetAddress(String transportStyle)
public List<RouterAddress> getTargetAddresses(String transportStyle)
public void readBytes(InputStream in) throws DataFormatException, IOException
in
- stream to read from
IllegalStateException
- if RouterInfo was already read in
DataFormatException
- if the data is improperly formatted
IOException
- if there was a problem reading the streampublic void readBytes(InputStream in, boolean verifySig) throws DataFormatException, IOException
IllegalStateException
- if RouterInfo was already read in
DataFormatException
IOException
public void writeBytes(OutputStream out) throws DataFormatException, IOException
out
- stream to write to
DataFormatException
- if the data was incomplete or not yet ready to be written
IOException
- if there was a problem writing to the streampublic boolean equals(Object object)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |