net.i2p.sam
Class SAMBridge

java.lang.Object
  extended by net.i2p.sam.SAMBridge
All Implemented Interfaces:
java.lang.Runnable

public class SAMBridge
extends java.lang.Object
implements java.lang.Runnable

SAM bridge implementation.

Author:
human

Nested Class Summary
(package private) static class SAMBridge.HelpRequested
           
 
Field Summary
protected static java.lang.String DEFAULT_DATAGRAM_HOST
           
protected static java.lang.String DEFAULT_DATAGRAM_PORT
           
static java.lang.String DEFAULT_SAM_KEYFILE
           
protected static java.lang.String DEFAULT_TCP_HOST
           
protected static java.lang.String DEFAULT_TCP_PORT
           
static java.lang.String PROP_DATAGRAM_HOST
           
static java.lang.String PROP_DATAGRAM_PORT
           
static java.lang.String PROP_TCP_HOST
           
static java.lang.String PROP_TCP_PORT
           
 
Constructor Summary
SAMBridge(java.lang.String listenHost, int listenPort, java.util.Properties i2cpProps, java.lang.String persistFile)
          Build a new SAM bridge.
 
Method Summary
 void addKeystream(java.lang.String name, java.lang.String stream)
          Specify that the given keystream should be used for the given name
 Destination getDestination(java.lang.String name)
          Retrieve the destination associated with the given name
 java.lang.String getKeystream(java.lang.String name)
          Retrieve the I2P private keystream for the given name, formatted as a base64 string (Destination+PrivateKey+SessionPrivateKey, as I2CP stores it).
static void main(java.lang.String[] args)
          Usage: SAMBridge [ keyfile [listenHost ] listenPort [ name=val ]* ] or: SAMBridge [ name=val ]* name=val options are passed to the I2CP code to build a session, allowing the bridge to specify an alternate I2CP host and port, tunnel depth, etc.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SAM_KEYFILE

public static final java.lang.String DEFAULT_SAM_KEYFILE
See Also:
Constant Field Values

PROP_TCP_HOST

public static final java.lang.String PROP_TCP_HOST
See Also:
Constant Field Values

PROP_TCP_PORT

public static final java.lang.String PROP_TCP_PORT
See Also:
Constant Field Values

DEFAULT_TCP_HOST

protected static final java.lang.String DEFAULT_TCP_HOST
See Also:
Constant Field Values

DEFAULT_TCP_PORT

protected static final java.lang.String DEFAULT_TCP_PORT
See Also:
Constant Field Values

PROP_DATAGRAM_HOST

public static final java.lang.String PROP_DATAGRAM_HOST
See Also:
Constant Field Values

PROP_DATAGRAM_PORT

public static final java.lang.String PROP_DATAGRAM_PORT
See Also:
Constant Field Values

DEFAULT_DATAGRAM_HOST

protected static final java.lang.String DEFAULT_DATAGRAM_HOST
See Also:
Constant Field Values

DEFAULT_DATAGRAM_PORT

protected static final java.lang.String DEFAULT_DATAGRAM_PORT
See Also:
Constant Field Values
Constructor Detail

SAMBridge

public SAMBridge(java.lang.String listenHost,
                 int listenPort,
                 java.util.Properties i2cpProps,
                 java.lang.String persistFile)
Build a new SAM bridge.

Parameters:
listenHost - hostname to listen for SAM connections on ("0.0.0.0" for all)
listenPort - port number to listen for SAM connections on
i2cpProps - set of I2CP properties for finding and communicating with the router
persistFile - location to store/load named keys to/from
Method Detail

getDestination

public Destination getDestination(java.lang.String name)
Retrieve the destination associated with the given name

Parameters:
name - name of the destination
Returns:
null if the name does not exist, or if it is improperly formatted

getKeystream

public java.lang.String getKeystream(java.lang.String name)
Retrieve the I2P private keystream for the given name, formatted as a base64 string (Destination+PrivateKey+SessionPrivateKey, as I2CP stores it).

Parameters:
name - Name of the destination
Returns:
null if the name does not exist, else the stream

addKeystream

public void addKeystream(java.lang.String name,
                         java.lang.String stream)
Specify that the given keystream should be used for the given name

Parameters:
name - Name of the destination
stream - Name of the stream

main

public static void main(java.lang.String[] args)
Usage:
SAMBridge [ keyfile [listenHost ] listenPort [ name=val ]* ]
or:
SAMBridge [ name=val ]* 
name=val options are passed to the I2CP code to build a session, allowing the bridge to specify an alternate I2CP host and port, tunnel depth, etc.

Parameters:
args - [ keyfile [ listenHost ] listenPort [ name=val ]* ]

run

public void run()
Specified by:
run in interface java.lang.Runnable