## net.i2p.data
Class RouterInfo

    java.lang.Object
      net.i2p.data.DataStructureImpl
          net.i2p.data.RouterInfo

All Implemented Interfaces:
  DataStructure

public class RouterInfo
extends DataStructureImpl

Defines the data that a router either publishes to the global routing table or provides to trusted peers.

Author:
  jrandom

Field Summary
`static char` `CAPABILITY_HIDDEN`
`static java.lang.String` `PROP_CAPABILITIES`
`static java.lang.String` `PROP_NETWORK_ID`

Constructor Summary
`RouterInfo()`
`RouterInfo(RouterInfo old)`

Method Summary
`void` `addCapability(char cap)`
`void` `delCapability(char cap)`
`boolean` `equals(java.lang.Object object)`
`java.util.Set` `getAddresses()` Retrieve the set of RouterAddress structures at which this router can be contacted.
`java.lang.String` `getCapabilities()` what special capabilities this router offers
`RouterIdentity` `getIdentity()` Retrieve the identity of the router represented
`int` `getNetworkId()` which network is this routerInfo a part of.
`java.util.Properties` `getOptions()` Retrieve a set of options or statistics that the router can expose
`java.util.Set` `getPeers()` Retrieve a set of SHA-256 hashes of RouterIdentities from rotuers this router can be reached through.
`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).
`Hash` `getRoutingKey()` Get the routing key for the structure using the current modifier in the RoutingKeyGenerator.
`Signature` `getSignature()` Retrieve the proof that the identity stands behind the info here
`RouterAddress` `getTargetAddress(java.lang.String transportStyle)` Pull the first workable target address for the given transport
`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
`void` `readBytes(java.io.InputStream in)` Load up the current object with data from the given stream.
`void` `setAddresses(java.util.Set 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(java.util.Properties options)` Configure a set of options or statistics that the router can expose
`void` `setPeers(java.util.Set peers)` Specify a set of SHA-256 hashes of RouterIdentities from rotuers this router can be reached through.
`void` `setPublished(long published)` Date on which it was published, in milliseconds since Midnight GMT on Jan 01, 1970
`void` `setRoutingKey(Hash key)`
`void` `setSignature(Signature signature)` Configure the proof that the entity stands behind the info here
`void` `sign(SigningPrivateKey key)` Sign the structure using the supplied signing key
`java.lang.String` `toString()`
`boolean` `validateRoutingKey()`
`void` `writeBytes(java.io.OutputStream out)` Write out the data structure to the stream, using the format defined in the I2P data structure specification.

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

### PROP_NETWORK_ID

    public static final java.lang.String PROP_NETWORK_ID

See Also:
  Constant Field Values

### PROP_CAPABILITIES

    public static final java.lang.String PROP_CAPABILITIES

See Also:
  Constant Field Values

### CAPABILITY_HIDDEN

    public static final char CAPABILITY_HIDDEN

See Also:
  Constant Field Values

Constructor Detail

### RouterInfo

    public RouterInfo()

### RouterInfo

    public RouterInfo(RouterInfo old)

Method Detail

### getIdentity

    public RouterIdentity getIdentity()

  Retrieve the identity of the router represented

### setIdentity

    public void setIdentity(RouterIdentity ident)

  Configure the identity of the router represented

### getPublished

    public 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). This should be used to help expire old routerInfo structures

### setPublished

    public void setPublished(long published)

  Date on which it was published, in milliseconds since Midnight GMT on Jan 01, 1970

### getAddresses

    public java.util.Set getAddresses()

  Retrieve the set of RouterAddress structures at which this router can be contacted.

### setAddresses

    public void setAddresses(java.util.Set addresses)

  Specify a set of RouterAddress structures at which this router can be contacted.

### getPeers

    public java.util.Set getPeers()

  Retrieve a set of SHA-256 hashes of RouterIdentities from rotuers this router can be reached through.

### setPeers

    public void setPeers(java.util.Set peers)

  Specify a set of SHA-256 hashes of RouterIdentities from rotuers this router can be reached through.

### getOptions

    public java.util.Properties getOptions()

  Retrieve a set of options or statistics that the router can expose

### setOptions

    public void setOptions(java.util.Properties options)

  Configure a set of options or statistics that the router can expose

### getSignature

    public Signature getSignature()

  Retrieve the proof that the identity stands behind the info here

### setSignature

    public void setSignature(Signature signature)

  Configure the proof that the entity stands behind the info here

### sign

    public void sign(SigningPrivateKey key)
              throws DataFormatException

  Sign the structure using the supplied signing key

  Throws:
    `DataFormatException`

### isValid

    public boolean isValid()

  Determine whether this router info is authorized with a valid signature

### getNetworkId

    public int getNetworkId()

  which network is this routerInfo a part of. configured through the property PROP_NETWORK_ID

### getCapabilities

    public java.lang.String getCapabilities()

  what special capabilities this router offers

### isHidden

    public boolean isHidden()

  Is this a hidden node?

### addCapability

    public void addCapability(char cap)

### delCapability

    public void delCapability(char cap)

### getRoutingKey

    public Hash getRoutingKey()

  Get the routing key for the structure using the current modifier in the RoutingKeyGenerator. This only calculates a new one when necessary though (if the generator's key modifier changes)

### setRoutingKey

    public void setRoutingKey(Hash key)

### validateRoutingKey

    public boolean validateRoutingKey()

### isCurrent

    public boolean isCurrent(long maxAgeMs)

  Determine whether the router was published recently (within the given age milliseconds). The age should be large enough to take into consideration any clock fudge factor, so values such as 1 or 2 hours are probably reasonable.

  Parameters:
    `maxAgeMs` - milliseconds between the current time and publish date to check
  Returns:
    true if it was published recently, false otherwise

### getTargetAddress

    public RouterAddress getTargetAddress(java.lang.String transportStyle)

  Pull the first workable target address for the given transport

### readBytes

    public void readBytes(java.io.InputStream in)
                   throws DataFormatException,
                          java.io.IOException

  Description copied from interface: `DataStructure`
  Load up the current object with data from the given stream. Data loaded this way must match the I2P data structure specification.

  Parameters:
    `in` - stream to read from
  Throws:
    `DataFormatException` - if the data is improperly formatted
    `java.io.IOException` - if there was a problem reading the stream

### writeBytes

    public void writeBytes(java.io.OutputStream out)
                    throws DataFormatException,
                           java.io.IOException

  Description copied from interface: `DataStructure`
  Write out the data structure to the stream, using the format defined in the I2P data structure specification.

  Parameters:
    `out` - stream to write to
  Throws:
    `DataFormatException` - if the data was incomplete or not yet ready to be written
    `java.io.IOException` - if there was a problem writing to the stream

### equals

    public boolean equals(java.lang.Object object)

### hashCode

    public int hashCode()

### toString

    public java.lang.String toString()