Skip to content

Commit

Permalink
Merge pull request #1246 from tls-attacker/fix/udpResetConnection
Browse files Browse the repository at this point in the history
Re-open UDP socket in ResetConnectionAction
  • Loading branch information
NErinola authored Jan 28, 2025
2 parents 5e4f1b2 + e176830 commit 3f7ae18
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

import de.rub.nds.tlsattacker.core.constants.Tls13KeySetType;
import de.rub.nds.tlsattacker.core.exceptions.ActionExecutionException;
import de.rub.nds.tlsattacker.core.layer.context.TcpContext;
import de.rub.nds.tlsattacker.core.layer.context.TlsContext;
import de.rub.nds.tlsattacker.core.layer.impl.QuicFrameLayer;
import de.rub.nds.tlsattacker.core.layer.impl.QuicPacketLayer;
import de.rub.nds.tlsattacker.core.record.cipher.RecordCipherFactory;
import de.rub.nds.tlsattacker.core.state.Context;
import de.rub.nds.tlsattacker.core.state.State;
import de.rub.nds.tlsattacker.core.state.quic.QuicContext;
import de.rub.nds.tlsattacker.transport.TransportHandler;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.io.IOException;
import java.util.Objects;
Expand Down Expand Up @@ -57,15 +57,15 @@ public void execute(State state) throws ActionExecutionException {
}
Context context = state.getContext(getConnectionAlias());
TlsContext tlsContext = context.getTlsContext();
TcpContext tcpContext = context.getTcpContext();
TransportHandler transportHandler = context.getTransportHandler();

if (isExecuted()) {
throw new ActionExecutionException("Action already executed!");
}

LOGGER.info("Terminating Connection");
try {
tcpContext.getTransportHandler().closeClientConnection();
transportHandler.closeClientConnection();
} catch (IOException ex) {
LOGGER.debug("Could not close client connection", ex);
}
Expand Down Expand Up @@ -124,9 +124,9 @@ public void execute(State state) throws ActionExecutionException {
LOGGER.info("Reopening Connection");
try {
if (switchToIpv6) {
tcpContext.getTransportHandler().setUseIpv6(true);
transportHandler.setUseIpv6(true);
}
tcpContext.getTransportHandler().initialize();
transportHandler.initialize();
asPlanned = true;
} catch (IOException ex) {
LOGGER.debug("Could not initialize TransportHandler", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public void initialize() throws IOException {
// this could be made an option
if (socket == null) {
throw new IOException("TransportHandler not preInitalized");
} else if (socket.isClosed()) {
// allow re-initialization
preInitialize();
}
this.initialized = true;
}
Expand Down

0 comments on commit 3f7ae18

Please sign in to comment.