Removed connection timing. added protocol count connection info during
handshake
This commit is contained in:
parent
ccbe893efa
commit
fdf4ecf39b
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package dorkbox.network.connection.registration;
|
package dorkbox.network.connection.registration;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
|
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
|
||||||
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
|
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
|
||||||
|
@ -26,51 +26,35 @@ import io.netty.channel.ChannelHandler;
|
||||||
public
|
public
|
||||||
class MetaChannel {
|
class MetaChannel {
|
||||||
|
|
||||||
// how long between receiving data over TCP. This is used to determine how long to wait before notifying the APP,
|
|
||||||
// so the registration message has time to arrive to the other endpoint.
|
|
||||||
private AtomicLong nanoSecRoundTrip = new AtomicLong();
|
|
||||||
|
|
||||||
// used to keep track and associate TCP/UDP/etc sessions. This is always defined by the server
|
// used to keep track and associate TCP/UDP/etc sessions. This is always defined by the server
|
||||||
// a sessionId if '0', means we are still figuring it out.
|
// a sessionId if '0', means we are still figuring it out.
|
||||||
public int sessionId;
|
public volatile int sessionId;
|
||||||
|
|
||||||
public Channel localChannel = null; // only available for local "in jvm" channels. XOR with tcp/udp channels with CLIENT.
|
public volatile Channel localChannel = null; // only available for local "in jvm" channels. XOR with tcp/udp channels with CLIENT, server can have all types at once
|
||||||
public Channel tcpChannel = null;
|
public volatile Channel tcpChannel = null;
|
||||||
public Channel udpChannel = null;
|
public volatile Channel udpChannel = null;
|
||||||
|
|
||||||
public ChannelHandler connection; // only needed until the connection has been notified.
|
// keep track of how many protocols to register, so that way when we are ready to connect the SERVER sends a message to the client over
|
||||||
|
// all registered protocols and the last protocol to receive the message does the registration
|
||||||
|
// we ALWAYS start off with at least 1 protocol
|
||||||
|
public AtomicInteger totalProtocols = new AtomicInteger(1);
|
||||||
|
|
||||||
public ECPublicKeyParameters publicKey; // used for ECC crypto + handshake on NETWORK (remote) connections. This is the remote public key.
|
public volatile ChannelHandler connection; // only needed until the connection has been notified.
|
||||||
public AsymmetricCipherKeyPair ecdhKey; // used for ECC Diffie-Hellman-Merkle key exchanges: see http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange
|
|
||||||
|
public volatile ECPublicKeyParameters publicKey; // used for ECC crypto + handshake on NETWORK (remote) connections. This is the remote public key.
|
||||||
|
public volatile AsymmetricCipherKeyPair ecdhKey; // used for ECC Diffie-Hellman-Merkle key exchanges: see http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange
|
||||||
|
|
||||||
// since we are using AES-GCM, the aesIV here **MUST** be exactly 12 bytes
|
// since we are using AES-GCM, the aesIV here **MUST** be exactly 12 bytes
|
||||||
public byte[] aesKey;
|
public volatile byte[] aesKey;
|
||||||
public byte[] aesIV;
|
public volatile byte[] aesIV;
|
||||||
|
|
||||||
|
|
||||||
// indicates if the remote ECC key has changed for an IP address. If the client detects this, it will not connect.
|
// indicates if the remote ECC key has changed for an IP address. If the client detects this, it will not connect.
|
||||||
// If the server detects this, it has the option for additional security (two-factor auth, perhaps?)
|
// If the server detects this, it has the option for additional security (two-factor auth, perhaps?)
|
||||||
public boolean changedRemoteKey = false;
|
public volatile boolean changedRemoteKey = false;
|
||||||
|
|
||||||
public
|
public
|
||||||
MetaChannel(final int sessionId) {
|
MetaChannel(final int sessionId) {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the network round trip time.
|
|
||||||
*/
|
|
||||||
public
|
|
||||||
void updateRoundTripOnWrite() {
|
|
||||||
this.nanoSecRoundTrip.set(System.nanoTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the difference in time from the last write
|
|
||||||
*/
|
|
||||||
public
|
|
||||||
long getRoundTripTime() {
|
|
||||||
return System.nanoTime() - this.nanoSecRoundTrip.get();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user