Skip to content
This repository has been archived by the owner on May 2, 2019. It is now read-only.

Commit

Permalink
CENO.jar properly parses the stored signalSSK and is using it for mak…
Browse files Browse the repository at this point in the history
…ing new requests to the bridge
  • Loading branch information
misaakidis committed Jan 18, 2016
1 parent 1b9788e commit eab8703
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions ceno-freenet/src/plugins/CENO/Client/Signaling/ChannelMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class ChannelMaker implements Runnable {
private static final int MAX_KSK_POLLS = 20;

private FreenetURI signalSSK;
private FreenetURI signalSSKpub;
private boolean channelEstablished = false;
Expand All @@ -45,17 +45,23 @@ public ChannelMaker(String signalSSKString, long lastSynced) {
if (signalSSKString != null) {
this.signalSSK = new FreenetURI(signalSSKString);
this.signalSSKpub = this.signalSSK.deriveRequestURIFromInsertURI();
this.lastSynced = lastSynced;
channelStatus = ChannelStatus.publishedKSK;
Logger.warning(this, "Retrieved previously established channel from client.properties");
if (System.currentTimeMillis() - lastSynced < TimeUnit.DAYS.toMillis(15)) {
channelStatus = ChannelStatus.waitingForSyn;
Logger.warning(this, "The established channel was synced less than 15 days ago and will start using without re-establishment");
}
return;
}
} catch (MalformedURLException e) {
Logger.error(this, "signalSSK read from configuration is not a valid Freenet key");
} finally {
FreenetURI newKeyPair[] = CENOClient.nodeInterface.generateKeyPair();
this.signalSSK = newKeyPair[0];
this.signalSSKpub = newKeyPair[1];
this.channelStatus = ChannelStatus.starting;
}
FreenetURI newKeyPair[] = CENOClient.nodeInterface.generateKeyPair();
this.signalSSK = newKeyPair[0];
this.signalSSKpub = newKeyPair[1];
this.channelStatus = ChannelStatus.starting;
Logger.warning(this, "Generated keys for establishing a secure channel");
}

@Override
Expand Down Expand Up @@ -97,7 +103,7 @@ private boolean checkChannelEstablished() {

return channelEstablished;
}

private boolean waitForSyn() {
FreenetURI synURI = new FreenetURI("USK", "syn", signalSSKpub.getRoutingKey(), signalSSKpub.getCryptoKey(), signalSSKpub.getExtra());
FetchResult fetchResult = null;
Expand Down Expand Up @@ -196,11 +202,11 @@ private void establishChannel() {
return;
}
}

insertSubKSK(question, encReply, new int[0]);
waitForSyn();
}

private void insertSubKSK(String question, byte[] encReply, int[] prevSubKSK) {
FreenetURI insertedKSK = null;
int randSubKSK = (int) (Math.random() * MAX_KSK_POLLS);
Expand All @@ -227,12 +233,12 @@ private void insertSubKSK(String question, byte[] encReply, int[] prevSubKSK) {
Logger.normal(this, "Started publishing to KSK solution to the bridge slot " + randSubKSK);
return;
}

private class KSKSolutionPutCallback implements ClientPutCallback {
int[] prevSubKSK;
byte[] encReply;
String question;

public KSKSolutionPutCallback(String question, byte[] encReply, int[] prevSubKSK) {
this.question = question;
this.encReply = encReply;
Expand Down Expand Up @@ -284,7 +290,7 @@ public void onFailure(InsertException e, BaseClientPutter state) {
Logger.error(this, "Failed to publish KSK@solution: " + e.getMessage());
}
}

}

}

0 comments on commit eab8703

Please sign in to comment.