Search in sources :

Example 16 with RouterIdentity

use of net.i2p.data.router.RouterIdentity in project i2p.i2p by i2p.

the class RouterGenerator method createRouterInfo.

static RouterInfo createRouterInfo(int num) {
    RouterInfo info = new RouterInfo();
    try {
        info.setAddresses(createAddresses(num));
        // not necessary, in constructor
        // info.setOptions(new Properties());
        // info.setPeers(new HashSet());
        info.setPublished(Clock.getInstance().now());
        RouterIdentity ident = new RouterIdentity();
        BigInteger bv = new BigInteger("" + num);
        Certificate cert = new Certificate(Certificate.CERTIFICATE_TYPE_NULL, bv.toByteArray());
        ident.setCertificate(cert);
        ident.setPublicKey(pubkey);
        ident.setSigningPublicKey(signingPubKey);
        info.setIdentity(ident);
        info.sign(signingPrivKey);
    } catch (Exception e) {
        System.err.println("Error building router " + num + ": " + e.getMessage());
        e.printStackTrace();
    }
    return info;
}
Also used : RouterInfo(net.i2p.data.router.RouterInfo) RouterIdentity(net.i2p.data.router.RouterIdentity) BigInteger(java.math.BigInteger) Certificate(net.i2p.data.Certificate)

Example 17 with RouterIdentity

use of net.i2p.data.router.RouterIdentity in project i2p.i2p by i2p.

the class RouterITBase method routerClassSetup.

@BeforeClass
public static void routerClassSetup() {
    // order of these matters
    Router r = new Router();
    _context = new RouterContext(r);
    _context.initAll();
    r.runRouter();
    RouterIdentity rIdentity = new TestRouterIdentity();
    RouterInfo rInfo = new RouterInfo();
    rInfo.setIdentity(rIdentity);
    r.setRouterInfo(rInfo);
    _config = prepareConfig(8);
}
Also used : RouterIdentity(net.i2p.data.router.RouterIdentity) RouterInfo(net.i2p.data.router.RouterInfo) RouterContext(net.i2p.router.RouterContext) Router(net.i2p.router.Router) BeforeClass(org.junit.BeforeClass)

Aggregations

RouterIdentity (net.i2p.data.router.RouterIdentity)17 RouterInfo (net.i2p.data.router.RouterInfo)10 IOException (java.io.IOException)6 DataFormatException (net.i2p.data.DataFormatException)5 Hash (net.i2p.data.Hash)5 RouterAddress (net.i2p.data.router.RouterAddress)5 SigType (net.i2p.crypto.SigType)4 OutNetMessage (net.i2p.router.OutNetMessage)4 Certificate (net.i2p.data.Certificate)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InetAddress (java.net.InetAddress)2 ArrayList (java.util.ArrayList)2 KeyCertificate (net.i2p.data.KeyCertificate)2 PrivateKey (net.i2p.data.PrivateKey)2 PublicKey (net.i2p.data.PublicKey)2 SigningPrivateKey (net.i2p.data.SigningPrivateKey)2 SigningPublicKey (net.i2p.data.SigningPublicKey)2 DatabaseStoreMessage (net.i2p.data.i2np.DatabaseStoreMessage)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1