use of net.i2p.data.i2cp.ReconfigureSessionMessage in project i2p.i2p by i2p.
the class I2CPMessageProducer method updateTunnels.
/**
* Update number of tunnels
*
* @param tunnels 0 for original configured number
*/
public void updateTunnels(I2PSessionImpl session, int tunnels) throws I2PSessionException {
ReconfigureSessionMessage msg = new ReconfigureSessionMessage();
SessionConfig cfg = new SessionConfig(session.getMyDestination());
Properties props = session.getOptions();
if (tunnels > 0) {
Properties newprops = new Properties();
newprops.putAll(props);
props = newprops;
props.setProperty("inbound.quantity", "" + tunnels);
props.setProperty("outbound.quantity", "" + tunnels);
props.setProperty("inbound.backupQuantity", "0");
props.setProperty("outbound.backupQuantity", "0");
}
cfg.setOptions(props);
try {
cfg.signSessionConfig(session.getPrivateKey());
} catch (DataFormatException dfe) {
throw new I2PSessionException("Unable to sign the session config", dfe);
}
msg.setSessionConfig(cfg);
SessionId sid = session.getSessionId();
if (sid == null) {
_log.error(session.toString() + " update config w/o session", new Exception());
return;
}
msg.setSessionId(sid);
session.sendMessage(msg);
}
Aggregations