use of com.biglybt.core.networkmanager.ConnectionEndpoint in project BiglyBT by BiglySoftware.
the class UDPConnectionManager method accept.
protected void accept(final int local_port, final InetSocketAddress remote_address, final UDPConnection connection) {
final UDPTransportHelper helper = new UDPTransportHelper(this, remote_address, connection);
try {
connection.setTransport(helper);
TransportCryptoManager.getSingleton().manageCrypto(helper, null, true, null, new TransportCryptoManager.HandshakeListener() {
@Override
public void handshakeSuccess(ProtocolDecoder decoder, ByteBuffer remaining_initial_data) {
TransportHelperFilter filter = decoder.getFilter();
ConnectionEndpoint co_ep = new ConnectionEndpoint(remote_address);
ProtocolEndpointUDP pe_udp = (ProtocolEndpointUDP) ProtocolEndpointFactory.createEndpoint(ProtocolEndpoint.PROTOCOL_UDP, co_ep, remote_address);
UDPTransport transport = new UDPTransport(pe_udp, filter);
helper.setTransport(transport);
incoming_manager.addConnection(local_port, filter, transport);
}
@Override
public void handshakeFailure(Throwable failure_msg) {
if (Logger.isEnabled()) {
Logger.log(new LogEvent(LOGID, "incoming crypto handshake failure: " + Debug.getNestedExceptionMessage(failure_msg)));
}
connection.close("handshake failure: " + Debug.getNestedExceptionMessage(failure_msg));
}
@Override
public void gotSecret(byte[] session_secret) {
helper.getConnection().setSecret(session_secret);
}
@Override
public int getMaximumPlainHeaderLength() {
return (incoming_manager.getMaxMinMatchBufferSize());
}
@Override
public int matchPlainHeader(ByteBuffer buffer) {
Object[] match_data = incoming_manager.checkForMatch(helper, local_port, buffer, true);
if (match_data == null) {
return (TransportCryptoManager.HandshakeListener.MATCH_NONE);
} else {
return (TransportCryptoManager.HandshakeListener.MATCH_CRYPTO_NO_AUTO_FALLBACK);
}
}
});
} catch (Throwable e) {
Debug.printStackTrace(e);
helper.close(Debug.getNestedExceptionMessage(e));
}
}
use of com.biglybt.core.networkmanager.ConnectionEndpoint in project BiglyBT by BiglySoftware.
the class ConnectionManagerImpl method createConnection.
@Override
public Connection createConnection(InetSocketAddress remote_address, MessageStreamEncoder encoder, MessageStreamDecoder decoder) {
ConnectionEndpoint connection_endpoint = new ConnectionEndpoint(remote_address);
connection_endpoint.addProtocol(ProtocolEndpointFactory.createEndpoint(ProtocolEndpoint.PROTOCOL_TCP, remote_address));
com.biglybt.core.networkmanager.NetworkConnection core_conn = NetworkManager.getSingleton().createConnection(connection_endpoint, new MessageStreamEncoderAdapter(encoder), new MessageStreamDecoderAdapter(decoder), false, false, null);
return new ConnectionImpl(core_conn, false);
}
Aggregations