more fixups from RouterAddress changes

This commit is contained in:
zzz
2012-01-08 14:04:19 +00:00
parent 5a4f2069f0
commit b34ae8f051

View File

@@ -266,24 +266,17 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
NTCPTransport t = (NTCPTransport) _manager.getTransport(NTCPTransport.STYLE); NTCPTransport t = (NTCPTransport) _manager.getTransport(NTCPTransport.STYLE);
if (t == null) if (t == null)
return; return;
Properties UDPProps = UDPAddr.getOptions();
if (UDPProps == null)
return;
Properties newProps;
RouterAddress oldAddr = t.getCurrentAddress(); RouterAddress oldAddr = t.getCurrentAddress();
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("Changing NTCP Address? was " + oldAddr); _log.info("Changing NTCP Address? was " + oldAddr);
RouterAddress newAddr = oldAddr; RouterAddress newAddr = new RouterAddress();
if (newAddr == null) {
newAddr = new RouterAddress();
newAddr.setCost(NTCPAddress.DEFAULT_COST);
newAddr.setExpiration(null);
newAddr.setTransportStyle(NTCPTransport.STYLE); newAddr.setTransportStyle(NTCPTransport.STYLE);
newProps = new Properties(); Properties newProps = new Properties();
if (oldAddr == null) {
newAddr.setCost(NTCPAddress.DEFAULT_COST);
} else { } else {
newProps = newAddr.getOptions(); newAddr.setCost(oldAddr.getCost());
if (newProps == null) newProps.putAll(oldAddr.getOptionsMap());
newProps = new Properties();
} }
boolean changed = false; boolean changed = false;
@@ -297,7 +290,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
if (cport != null && cport.length() > 0) { if (cport != null && cport.length() > 0) {
nport = cport; nport = cport;
} else if (_context.getBooleanPropertyDefaultTrue(PROP_I2NP_NTCP_AUTO_PORT)) { } else if (_context.getBooleanPropertyDefaultTrue(PROP_I2NP_NTCP_AUTO_PORT)) {
nport = UDPProps.getProperty(UDPAddress.PROP_PORT); nport = UDPAddr.getOption(UDPAddress.PROP_PORT);
} }
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("old: " + oport + " config: " + cport + " new: " + nport); _log.info("old: " + oport + " config: " + cport + " new: " + nport);
@@ -330,7 +323,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
_log.info("old: " + ohost + " config: " + name + " auto: " + enabled + " status: " + status); _log.info("old: " + ohost + " config: " + name + " auto: " + enabled + " status: " + status);
if (enabled.equals("always") || if (enabled.equals("always") ||
(Boolean.valueOf(enabled).booleanValue() && status == STATUS_OK)) { (Boolean.valueOf(enabled).booleanValue() && status == STATUS_OK)) {
String nhost = UDPProps.getProperty(UDPAddress.PROP_HOST); String nhost = UDPAddr.getOption(UDPAddress.PROP_HOST);
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("old: " + ohost + " config: " + name + " new: " + nhost); _log.info("old: " + ohost + " config: " + name + " new: " + nhost);
if (nhost == null || nhost.length() <= 0) if (nhost == null || nhost.length() <= 0)
@@ -483,10 +476,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
RouterAddress ra = ri.getTargetAddress("SSU"); RouterAddress ra = ri.getTargetAddress("SSU");
if (ra == null) if (ra == null)
return null; return null;
Properties props = ra.getOptions(); return ra.getOption("host");
if (props == null)
return null;
return props.getProperty("host");
} }
/** full name for a country code, or the code if we don't know the name */ /** full name for a country code, or the code if we don't know the name */