public class Router extends Object implements RouterClock.ClockShiftListener
| Modifier and Type | Field and Description |
|---|---|
Object |
_familyKeyLock |
static char |
CAPABILITY_BW_UNLIMITED |
static char |
CAPABILITY_BW12 |
static char |
CAPABILITY_BW128 |
static char |
CAPABILITY_BW256 |
static char |
CAPABILITY_BW32 |
static char |
CAPABILITY_BW512 |
static char |
CAPABILITY_BW64 |
static char |
CAPABILITY_CONGESTION_MODERATE |
static char |
CAPABILITY_CONGESTION_SEVERE |
static char |
CAPABILITY_NO_TUNNELS |
static char |
CAPABILITY_REACHABLE |
static char |
CAPABILITY_UNREACHABLE |
static long |
CLOCK_FUDGE_FACTOR
let clocks be off by 1 minute
|
static int |
COALESCE_TIME
coalesce stats this often - should be a little less than one minute, so the graphs get updated
|
static int |
DEFAULT_SHARE_PERCENTAGE |
static int |
EXIT_GRACEFUL
shut down after all tunnels are gone
|
static int |
EXIT_GRACEFUL_RESTART
shut down after all tunnels are gone, and tell the wrapper to restart
|
static int |
EXIT_HARD
shut down immediately
|
static int |
EXIT_HARD_RESTART
shut down immediately, and tell the wrapper to restart
|
static int |
EXIT_OOM
shut down immediately
|
static int |
MIN_BW_K
In binary (1024) Kbytes
|
static int |
MIN_BW_L
In binary (1024) Kbytes
|
static int |
MIN_BW_M
In binary (1024) Kbytes
|
static int |
MIN_BW_N
In binary (1024) Kbytes
|
static int |
MIN_BW_O
In binary (1024) Kbytes
|
static int |
MIN_BW_P
In binary (1024) Kbytes
|
static int |
MIN_BW_X
In binary (1024) Kbytes
|
static String |
PROP_BANDWIDTH_SHARE_PERCENTAGE |
static String |
PROP_CONFIG_FILE |
static String |
PROP_DYNAMIC_KEYS
New router keys at every restart.
|
static String |
PROP_FORCE_BWCLASS
for testing
|
static String |
PROP_FORCE_UNREACHABLE
for testing
|
static String |
PROP_HIDDEN
this puts an 'H' in your routerInfo
|
static String |
PROP_HIDDEN_HIDDEN
this does not put an 'H' in your routerInfo
|
static String |
PROP_IB_RANDOM_KEY |
static String |
PROP_OB_RANDOM_KEY |
static String |
PROP_REBUILD_KEYS
New router keys once only.
|
Object |
routerInfoFileLock
not for external use
|
static String |
UPDATE_FILE |
| Constructor and Description |
|---|
Router()
Instantiation only.
|
Router(Properties envProps)
Instantiation only.
|
Router(String configFilename)
Instantiation only.
|
Router(String configFilename,
Properties envProps)
Instantiation only.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancelGracefulShutdown()
Cancel any prior request to shut the router down gracefully.
|
static void |
clearCaches()
Not for external use.
|
void |
clockShift(long delta)
The clock shift listener.
|
EventLog |
eventLog() |
int |
get15sRate()
Max of inbound and outbound rate in bytes per second
|
int |
get15sRate(boolean outboundOnly)
When outboundOnly is false, outbound rate in bytes per second.
|
int |
get15sRateIn()
Inbound rate in bytes per second
|
int |
get1mRate()
Max of inbound and outbound rate in bytes per second
|
int |
get1mRate(boolean outboundOnly)
When outboundOnly is false, outbound rate in bytes per second.
|
int |
get1mRateIn()
Inbound rate in bytes per second
|
int |
get1sRate()
Max of inbound and outbound rate in bytes per second
|
int |
get1sRate(boolean outboundOnly)
When outboundOnly is false, outbound rate in bytes per second.
|
int |
get1sRateIn()
Inbound rate in bytes per second
|
int |
get5mRate()
Max of inbound and outbound rate in bytes per second
|
int |
get5mRate(boolean outboundOnly)
When outboundOnly is false, outbound rate in bytes per second.
|
char |
getBandwidthClass()
The current bandwidth class.
|
String |
getCapabilities()
For building our RI.
|
String |
getConfigFilename()
Get the absolute path to the router configuration file.
|
Map<String,String> |
getConfigMap()
Get an unmodifiable map of all configuration settings.
|
String |
getConfigSetting(String name)
Retrieve a configuration setting by name.
|
Set<String> |
getConfigSettings()
Get an unmodifiable set of all configuration property names.
|
RouterContext |
getContext()
Non-null, but take care when accessing context items before runRouter() is called
as the context will not be initialized.
|
long |
getEstimatedDowntime()
How long this router was down before it started, or 0 if unknown.
|
FamilyKeyCrypto |
getFamilyKeyCrypto()
Family Key Crypto Signer / Verifier.
|
boolean |
getKillVMOnEnd()
Check whether the router is configured to kill the JVM on shutdown.
|
int |
getNetworkID()
The network ID.
|
Hash |
getRouterHash()
Our current router hash.
|
RouterIdentity |
getRouterIdentity()
Our current router identity.
|
RouterInfo |
getRouterInfo()
Our current router info.
|
double |
getSharePercentage()
What fraction of the bandwidth specified in our bandwidth limits should
we allow to be consumed by participating tunnels?
|
long |
getShutdownTimeRemaining()
How long until the graceful shutdown will kill us?
|
UPnPScannerCallback |
getUPnPScannerCallback()
For Android only.
|
long |
getUptime()
Wall clock uptime.
|
long |
getWhenStarted()
Used only by routerconsole..
|
boolean |
gracefulShutdownInProgress()
Is a graceful shutdown in progress? This may be cancelled.
|
boolean |
isAdvanced() |
boolean |
isAlive()
Check if the router is alive (in startup or running state).
|
boolean |
isFinalShutdownInProgress()
Is a final shutdown in progress? This may not be cancelled.
|
boolean |
isHidden() |
boolean |
isRestarting() |
boolean |
isRunning() |
void |
killKeys()
Not for external use.
|
static void |
main(String[] args)
Usage: Router [rebuild]
No other options allowed, for now
Instantiates Router(), and either installs updates and exits,
or calls runRouter().
|
void |
readConfig()
This updates the config with all settings found in the file.
|
void |
rebuildNewIdentity()
Rebuild a new identity the hard way - delete all of our old identity
files, then reboot the router.
|
void |
rebuildRouterInfo()
Rebuild and republish our routerInfo since something significant
has changed.
|
void |
rebuildRouterInfo(boolean blockingRebuild)
Rebuild and republish our routerInfo since something significant
has changed.
|
void |
restart()
A "soft" restart, primarily of the comm system, after a port change or large step-change in system time.
|
void |
runRouter()
This must be called after instantiation.
|
boolean |
saveConfig()
Save the current config options (returning true if save was
successful, false otherwise)
Synchronized with file read in getConfig()
|
boolean |
saveConfig(Map toAdd,
Collection<String> toRemove)
Updates the current config and then saves it.
|
boolean |
saveConfig(String name,
String value)
Updates the current config with the given key/value and then saves it.
|
int |
scheduledGracefulExitCode()
What exit code do we plan on using when we shut down (or -1, if there isn't a graceful shutdown planned)
|
void |
setEstimatedDowntime(long downtime)
Only for soft restart.
|
void |
setExplTunnelsReady()
Only for Tunnel Building, after we have non-zero-hop expl.
|
void |
setIsAlive()
Only for Restarter, after soft restart is complete.
|
void |
setKillVMOnEnd(boolean shouldDie)
Configure the router to kill the JVM when the router shuts down, as well
as whether to explicitly halt the JVM during the hard fail process.
|
void |
setNetDbReady()
Only for NetDB, after RIs are loaded.
|
void |
setRouterInfo(RouterInfo info)
Caller must ensure info is valid - no validation done here.
|
void |
setUPnPScannerCallback(UPnPScannerCallback callback)
For Android only.
|
void |
shutdown(int exitCode)
Shutdown with no chance of cancellation.
|
void |
shutdown2(int exitCode)
Cancel the JVM runtime hook before calling this.
|
void |
shutdownGracefully()
Non-blocking shutdown.
|
void |
shutdownGracefully(int exitCode)
Non-blocking shutdown.
|
public final Object _familyKeyLock
public static final char CAPABILITY_BW_UNLIMITED
public static final char CAPABILITY_BW12
public static final char CAPABILITY_BW128
public static final char CAPABILITY_BW256
public static final char CAPABILITY_BW32
public static final char CAPABILITY_BW512
public static final char CAPABILITY_BW64
public static final char CAPABILITY_CONGESTION_MODERATE
public static final char CAPABILITY_CONGESTION_SEVERE
public static final char CAPABILITY_NO_TUNNELS
public static final char CAPABILITY_REACHABLE
public static final char CAPABILITY_UNREACHABLE
public static final long CLOCK_FUDGE_FACTOR
public static final int COALESCE_TIME
public static final int DEFAULT_SHARE_PERCENTAGE
public static final int EXIT_GRACEFUL
public static final int EXIT_GRACEFUL_RESTART
public static final int EXIT_HARD
public static final int EXIT_HARD_RESTART
public static final int EXIT_OOM
public static final int MIN_BW_K
public static final int MIN_BW_L
public static final int MIN_BW_M
public static final int MIN_BW_N
public static final int MIN_BW_O
public static final int MIN_BW_P
public static final int MIN_BW_X
public static final String PROP_BANDWIDTH_SHARE_PERCENTAGE
public static final String PROP_CONFIG_FILE
public static final String PROP_DYNAMIC_KEYS
public static final String PROP_FORCE_BWCLASS
public static final String PROP_FORCE_UNREACHABLE
public static final String PROP_HIDDEN
public static final String PROP_HIDDEN_HIDDEN
public static final String PROP_IB_RANDOM_KEY
public static final String PROP_OB_RANDOM_KEY
public static final String PROP_REBUILD_KEYS
public final Object routerInfoFileLock
public static final String UPDATE_FILE
public Router()
IllegalStateException - since 0.9.19 if another router with this config is runningpublic Router(Properties envProps)
envProps - may be nullIllegalStateException - since 0.9.19 if another router with this config is runningpublic Router(String configFilename)
configFilename - may be nullIllegalStateException - since 0.9.19 if another router with this config is runningpublic Router(String configFilename, Properties envProps)
configFilename - may be nullenvProps - may be nullIllegalStateException - since 0.9.19 if another router with this config is runningpublic void cancelGracefulShutdown()
public static final void clearCaches()
public void clockShift(long delta)
clockShift in interface RouterClock.ClockShiftListenerdelta - The system clock and adjusted clock just changed by this much,
in milliseconds (approximately)public EventLog eventLog()
public int get15sRate()
public int get15sRate(boolean outboundOnly)
public int get15sRateIn()
public int get1mRate()
public int get1mRate(boolean outboundOnly)
public int get1mRateIn()
public int get1sRate()
public int get1sRate(boolean outboundOnly)
public int get1sRateIn()
public int get5mRate()
public int get5mRate(boolean outboundOnly)
public char getBandwidthClass()
public String getCapabilities()
public String getConfigFilename()
public Map<String,String> getConfigMap()
public String getConfigSetting(String name)
name - the configuration property namepublic Set<String> getConfigSettings()
public RouterContext getContext()
public long getEstimatedDowntime()
public FamilyKeyCrypto getFamilyKeyCrypto()
public boolean getKillVMOnEnd()
public int getNetworkID()
public Hash getRouterHash()
public RouterIdentity getRouterIdentity()
public RouterInfo getRouterInfo()
public double getSharePercentage()
public long getShutdownTimeRemaining()
public UPnPScannerCallback getUPnPScannerCallback()
public long getUptime()
public long getWhenStarted()
public boolean gracefulShutdownInProgress()
public boolean isAdvanced()
public boolean isAlive()
public boolean isFinalShutdownInProgress()
public boolean isHidden()
public boolean isRestarting()
public boolean isRunning()
public void killKeys()
public static void main(String[] args)
args - null okIllegalArgumentExceptionpublic void readConfig()
public void rebuildNewIdentity()
public void rebuildRouterInfo()
public void rebuildRouterInfo(boolean blockingRebuild)
blockingRebuild - ignored, always nonblockingpublic void restart()
public void runRouter()
IllegalStateException - if called more than oncepublic boolean saveConfig()
public boolean saveConfig(Map toAdd, Collection<String> toRemove)
toAdd - settings to add/change before saving, may be null or emptytoRemove - settings to remove before saving, may be null or emptypublic boolean saveConfig(String name, String value)
name - setting to add/change/remove before savingvalue - if non-null, updated value; if null, setting will be removedpublic int scheduledGracefulExitCode()
public void setEstimatedDowntime(long downtime)
public void setExplTunnelsReady()
public void setIsAlive()
public void setKillVMOnEnd(boolean shouldDie)
shouldDie - true to kill VM on shutdown, false for embedded usepublic void setNetDbReady()
public void setRouterInfo(RouterInfo info)
public void setUPnPScannerCallback(UPnPScannerCallback callback)
callback - the callback or null to clear itpublic void shutdown(int exitCode)
exitCode - one of the EXIT_* values, non-negativeIllegalArgumentException - if exitCode negativepublic void shutdown2(int exitCode)
exitCode - one of the EXIT_* values, non-negativeIllegalArgumentException - if exitCode negativepublic void shutdownGracefully()
shutdown(int). If you want to cancel
the graceful shutdown (prior to actual shutdown ;), call
cancelGracefulShutdown().
Exit code will be EXIT_GRACEFUL.
Shutdown delay will be from zero to 11 minutes.public void shutdownGracefully(int exitCode)
exitCode - one of the EXIT_* values, non-negativeIllegalArgumentException - if exitCode negative