SSU intro key checks

This commit is contained in:
zzz
2014-08-23 13:48:13 +00:00
parent 68b15aadca
commit c79e33896e
2 changed files with 13 additions and 2 deletions

View File

@ -218,9 +218,12 @@ class IntroductionManager {
_log.info("Picking introducer: " + cur);
cur.setIntroducerTime();
UDPAddress ura = new UDPAddress(ra);
byte[] ikey = ura.getIntroKey();
if (ikey == null)
continue;
ssuOptions.setProperty(UDPAddress.PROP_INTRO_HOST_PREFIX + found, Addresses.toString(ip));
ssuOptions.setProperty(UDPAddress.PROP_INTRO_PORT_PREFIX + found, String.valueOf(port));
ssuOptions.setProperty(UDPAddress.PROP_INTRO_KEY_PREFIX + found, Base64.encode(ura.getIntroKey()));
ssuOptions.setProperty(UDPAddress.PROP_INTRO_KEY_PREFIX + found, Base64.encode(ikey));
ssuOptions.setProperty(UDPAddress.PROP_INTRO_TAG_PREFIX + found, String.valueOf(cur.getTheyRelayToUsAs()));
found++;
}

View File

@ -17,7 +17,7 @@ class UDPAddress {
private final String _host;
private InetAddress _hostAddress;
private final int _port;
private byte[] _introKey;
private final byte[] _introKey;
private String _introHosts[];
private InetAddress _introAddresses[];
private int _introPorts[];
@ -62,6 +62,7 @@ class UDPAddress {
if (addr == null) {
_host = null;
_port = 0;
_introKey = null;
return;
}
_host = addr.getOption(PROP_HOST);
@ -78,6 +79,10 @@ class UDPAddress {
byte[] ik = Base64.decode(key.trim());
if (ik != null && ik.length == SessionKey.KEYSIZE_BYTES)
_introKey = ik;
else
_introKey = null;
} else {
_introKey = null;
}
for (int i = MAX_INTRODUCERS - 1; i >= 0; i--) {
@ -167,6 +172,9 @@ class UDPAddress {
*/
public int getPort() { return _port; }
/**
* @return shouldn't be null but will be if invalid
*/
byte[] getIntroKey() { return _introKey; }
int getIntroducerCount() { return (_introAddresses == null ? 0 : _introAddresses.length); }