mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
secret owner listens, and custodian connects
This commit is contained in:
@@ -6,8 +6,10 @@ import org.briarproject.bramble.api.crypto.AgreementPublicKey;
|
||||
import org.briarproject.bramble.api.data.BdfList;
|
||||
import org.briarproject.briar.api.socialbackup.recovery.CustodianTask;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.security.PublicKey;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -47,6 +49,15 @@ public class CustodianTaskImpl implements CustodianTask {
|
||||
observer.onStateChanged(new CustodianTask.State.SendingShard());
|
||||
} catch (Exception e) {
|
||||
observer.onStateChanged(new CustodianTask.State.Failure(State.Failure.Reason.QR_CODE_INVALID));
|
||||
return;
|
||||
}
|
||||
|
||||
Socket s = new Socket();
|
||||
try {
|
||||
s.connect(remoteSocketAddress);
|
||||
} catch (IOException e) {
|
||||
observer.onStateChanged(new CustodianTask.State.Failure(State.Failure.Reason.QR_CODE_INVALID));
|
||||
}
|
||||
System.out.println("Connected *****");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,10 @@ import org.briarproject.bramble.api.data.BdfList;
|
||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.briar.api.socialbackup.recovery.SecretOwnerTask;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -37,7 +39,18 @@ public class SecretOwnerTaskImpl implements SecretOwnerTask {
|
||||
if (inetAddress == null) observer.onStateChanged(new State.Failure());
|
||||
System.out.println("InetAddress is " + inetAddress);
|
||||
socketAddress = new InetSocketAddress(inetAddress, 3002);
|
||||
// TODO start listening on socketAddress
|
||||
|
||||
// start listening on socketAddress
|
||||
ServerSocket ss = null;
|
||||
try {
|
||||
ss = new ServerSocket();
|
||||
ss.bind(socketAddress);
|
||||
} catch (IOException e) {
|
||||
observer.onStateChanged(new State.Failure());
|
||||
// TODO could try incrementing the port number
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// TODO add version number
|
||||
BdfList payloadList = new BdfList();
|
||||
|
||||
Reference in New Issue
Block a user