Search in sources :

Example 11 with OrderedProperties

use of net.i2p.util.OrderedProperties in project i2p.i2p by i2p.

the class GetDateMessage method toString.

@Override
public String toString() {
    StringBuilder buf = new StringBuilder();
    buf.append("[GetDateMessage]");
    buf.append("\n\tVersion: ").append(_version);
    if (_options != null && !_options.isEmpty()) {
        buf.append("\n\tOptions: #: ").append(_options.size());
        Properties sorted = new OrderedProperties();
        sorted.putAll(_options);
        for (Map.Entry<Object, Object> e : sorted.entrySet()) {
            String key = (String) e.getKey();
            String val = (String) e.getValue();
            buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]");
        }
    }
    return buf.toString();
}
Also used : OrderedProperties(net.i2p.util.OrderedProperties) Properties(java.util.Properties) OrderedProperties(net.i2p.util.OrderedProperties) Map(java.util.Map)

Example 12 with OrderedProperties

use of net.i2p.util.OrderedProperties in project i2p.i2p by i2p.

the class RouterAddressTest method testSetOptionsAgain.

@SuppressWarnings("deprecation")
@Test
public void testSetOptionsAgain() {
    OrderedProperties options = new OrderedProperties();
    options.setProperty("hostname", "localhost");
    options.setProperty("portnum", "1234");
    RouterAddress addr = new RouterAddress("Blah", options, 42);
    options.setProperty("portnum", "2345");
    exception.expect(IllegalStateException.class);
    addr.setOptions(options);
}
Also used : OrderedProperties(net.i2p.util.OrderedProperties) StructureTest(net.i2p.data.StructureTest) Test(org.junit.Test)

Example 13 with OrderedProperties

use of net.i2p.util.OrderedProperties in project i2p.i2p by i2p.

the class RouterAddressTest method testToString.

@Test
public void testToString() {
    // addr.setExpiration(new Date(1000*60*60*24)); // jan 2 1970
    OrderedProperties options = new OrderedProperties();
    options.setProperty("hostname", "localhost");
    options.setProperty("portnum", "1234");
    RouterAddress addr = new RouterAddress("Blah", options, 42);
    String ret = addr.toString();
    // assertEquals("[RouterAddress: \n\tTransportStyle: Blah\n\tCost: 42\n\tExpiration: Fri Jan 02 00:00:00 UTC 1970\n\tOptions: #: 2\n\t\t[hostname] = [localhost]\n\t\t[portnum] = [1234]]", ret);
    assertEquals("[RouterAddress: \n\tType: Blah\n\tCost: 42\n\tOptions (2):\n\t\t[hostname] = [localhost]\n\t\t[portnum] = [1234]]", ret);
}
Also used : OrderedProperties(net.i2p.util.OrderedProperties) StructureTest(net.i2p.data.StructureTest) Test(org.junit.Test)

Example 14 with OrderedProperties

use of net.i2p.util.OrderedProperties in project i2p.i2p by i2p.

the class RouterAddressTest method createDataStructure.

public DataStructure createDataStructure() throws DataFormatException {
    // addr.setExpiration(new Date(1000*60*60*24)); // jan 2 1970
    OrderedProperties options = new OrderedProperties();
    options.setProperty("hostname", "localhost");
    options.setProperty("portnum", "1234");
    RouterAddress addr = new RouterAddress("Blah", options, 42);
    return addr;
}
Also used : OrderedProperties(net.i2p.util.OrderedProperties)

Example 15 with OrderedProperties

use of net.i2p.util.OrderedProperties in project i2p.i2p by i2p.

the class NTCPTransport method createNTCPAddress.

/**
 * This only creates an address if the hostname AND port are set in router.config,
 * which should be rare.
 * Otherwise, notifyReplaceAddress() below takes care of it.
 * Note this is only called from startListening() via configureLocalAddress()
 *
 * TODO return a list of one or more
 * TODO unlike in UDP rebuildExternalAddress(), this only runs once, at startup,
 * so we won't pick up IP changes.
 * TODO only returns non-null if port is configured
 *
 * @since IPv6 moved from CSFI
 */
private RouterAddress createNTCPAddress() {
    int p = _context.getProperty(PROP_I2NP_NTCP_PORT, -1);
    if (p <= 0 || p >= 64 * 1024)
        return null;
    String name = getConfiguredIP();
    if (name == null)
        return null;
    OrderedProperties props = new OrderedProperties();
    props.setProperty(RouterAddress.PROP_HOST, name);
    props.setProperty(RouterAddress.PROP_PORT, Integer.toString(p));
    int cost = getDefaultCost(false);
    RouterAddress addr = new RouterAddress(STYLE, props, cost);
    return addr;
}
Also used : OrderedProperties(net.i2p.util.OrderedProperties) RouterAddress(net.i2p.data.router.RouterAddress)

Aggregations

OrderedProperties (net.i2p.util.OrderedProperties)34 Properties (java.util.Properties)20 IOException (java.io.IOException)16 File (java.io.File)12 Map (java.util.Map)8 RouterAddress (net.i2p.data.router.RouterAddress)6 UnknownHostException (java.net.UnknownHostException)5 InputStream (java.io.InputStream)4 HashMap (java.util.HashMap)4 InetAddress (java.net.InetAddress)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 StructureTest (net.i2p.data.StructureTest)3 Test (org.junit.Test)3 BufferedInputStream (java.io.BufferedInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileInputStream (java.io.FileInputStream)2 OutputStream (java.io.OutputStream)2 Socket (java.net.Socket)2 GeneralSecurityException (java.security.GeneralSecurityException)2 I2PSessionException (net.i2p.client.I2PSessionException)2