mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Remove transport ID from connection context.
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
package net.sf.briar.transport;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.protocol.TransportId;
|
||||
import net.sf.briar.api.protocol.TransportIndex;
|
||||
import net.sf.briar.api.transport.ConnectionContext;
|
||||
|
||||
class ConnectionContextImpl implements ConnectionContext {
|
||||
|
||||
private final ContactId contactId;
|
||||
private final TransportId transportId;
|
||||
private final TransportIndex transportIndex;
|
||||
private final long connectionNumber;
|
||||
|
||||
ConnectionContextImpl(ContactId contactId, TransportId transportId,
|
||||
TransportIndex transportIndex, long connectionNumber) {
|
||||
ConnectionContextImpl(ContactId contactId, TransportIndex transportIndex,
|
||||
long connectionNumber) {
|
||||
this.contactId = contactId;
|
||||
this.transportId = transportId;
|
||||
this.transportIndex = transportIndex;
|
||||
this.connectionNumber = connectionNumber;
|
||||
}
|
||||
@@ -24,10 +21,6 @@ class ConnectionContextImpl implements ConnectionContext {
|
||||
return contactId;
|
||||
}
|
||||
|
||||
public TransportId getTransportId() {
|
||||
return transportId;
|
||||
}
|
||||
|
||||
public TransportIndex getTransportIndex() {
|
||||
return transportIndex;
|
||||
}
|
||||
|
||||
@@ -62,12 +62,6 @@ public class ConnectionDispatcherImpl implements ConnectionDispatcher {
|
||||
r.dispose(false);
|
||||
return;
|
||||
}
|
||||
if(!t.equals(ctx.getTransportId())) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning("Connection has unexpected transport ID");
|
||||
r.dispose(false);
|
||||
return;
|
||||
}
|
||||
batchConnFactory.createIncomingConnection(ctx.getTransportIndex(),
|
||||
ctx.getContactId(), r, encryptedIv);
|
||||
}
|
||||
@@ -112,12 +106,6 @@ public class ConnectionDispatcherImpl implements ConnectionDispatcher {
|
||||
s.dispose(false);
|
||||
return;
|
||||
}
|
||||
if(!t.equals(ctx.getTransportId())) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning("Connection has unexpected transport ID");
|
||||
s.dispose(false);
|
||||
return;
|
||||
}
|
||||
streamConnFactory.createIncomingConnection(ctx.getTransportIndex(),
|
||||
ctx.getContactId(), s, encryptedIv);
|
||||
}
|
||||
|
||||
@@ -82,17 +82,17 @@ DatabaseListener {
|
||||
TransportIndex i = db.getRemoteIndex(c, t);
|
||||
if(i != null) {
|
||||
ConnectionWindow w = db.getConnectionWindow(c, i);
|
||||
calculateIvs(c, t, i, ivKey, w);
|
||||
calculateIvs(c, i, ivKey, w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void calculateIvs(ContactId c, TransportId t,
|
||||
TransportIndex i, ErasableKey ivKey, ConnectionWindow w)
|
||||
private synchronized void calculateIvs(ContactId c, TransportIndex i,
|
||||
ErasableKey ivKey, ConnectionWindow w)
|
||||
throws DbException {
|
||||
for(Long unseen : w.getUnseen()) {
|
||||
Bytes iv = new Bytes(encryptIv(i, unseen, ivKey));
|
||||
expected.put(iv, new ConnectionContextImpl(c, t, i, unseen));
|
||||
expected.put(iv, new ConnectionContextImpl(c, i, unseen));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ DatabaseListener {
|
||||
byte[] secret = db.getSharedSecret(c, true);
|
||||
ErasableKey ivKey = crypto.deriveIvKey(secret, true);
|
||||
for(int j = 0; j < secret.length; j++) secret[j] = 0;
|
||||
calculateIvs(c, ctx.getTransportId(), i, ivKey, w);
|
||||
calculateIvs(c, i, ivKey, w);
|
||||
} catch(NoSuchContactException e) {
|
||||
// The contact was removed - clean up when we get the event
|
||||
}
|
||||
@@ -191,7 +191,7 @@ DatabaseListener {
|
||||
TransportIndex i = db.getRemoteIndex(c, t);
|
||||
if(i != null) {
|
||||
ConnectionWindow w = db.getConnectionWindow(c, i);
|
||||
calculateIvs(c, t, i, ivKey, w);
|
||||
calculateIvs(c, i, ivKey, w);
|
||||
}
|
||||
} catch(NoSuchContactException e) {
|
||||
// The contact was removed - clean up when we get the event
|
||||
|
||||
Reference in New Issue
Block a user