Skip to content

Commit c820bcd

Browse files
committed
Trying to get SNI to work.
1 parent be5ea4a commit c820bcd

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ Utils/.settings/org.eclipse.core.resources.prefs
4242
Utils/.settings/org.eclipse.jdt.core.prefs
4343
.project
4444
test.sh
45+
.settings/
46+
.classpath

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/config/delegate/ClientDelegate.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public void applyDelegate(Config config) {
7777
con.setPort(uri.getPort());
7878
}
7979
if (IPAddress.isValid(uri.getHost())) {
80+
System.out.println("Setting IP: " + uri.getHost());
8081
con.setIp(uri.getHost());
8182
if (sniHostname != null) {
8283
con.setHostname(sniHostname);

Transport/src/main/java/de/rub/nds/tlsattacker/transport/Connection.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public String getIp() {
5757
}
5858

5959
public void setIp(String ip) {
60+
System.out.println("Setting IP: " + ip);
61+
new Exception().printStackTrace(System.out);
6062
this.ip = ip;
6163
}
6264

Transport/src/main/java/de/rub/nds/tlsattacker/transport/TransportHandlerFactory.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ public static TransportHandler createTransportHandler(Connection con) {
2828
switch (con.getTransportHandlerType()) {
2929
case TCP:
3030
if (localConEndType == ConnectionEndType.CLIENT) {
31-
return new ClientTcpTransportHandler(timeout, con.getHostname(), con.getPort());
31+
return new ClientTcpTransportHandler(timeout, con.getIp(), con.getPort());
3232
} else {
3333
return new ServerTcpTransportHandler(timeout, con.getPort());
3434
}
3535
case EAP_TLS:
3636
throw new UnsupportedOperationException("EAP_TLS is currently not supported");
3737
case UDP:
3838
if (localConEndType == ConnectionEndType.CLIENT) {
39-
return new ClientUdpTransportHandler(timeout, con.getHostname(), con.getPort());
39+
return new ClientUdpTransportHandler(timeout, con.getIp(), con.getPort());
4040
} else {
4141
return new ServerUdpTransportHandler(timeout, con.getPort());
4242
}
@@ -50,26 +50,26 @@ public static TransportHandler createTransportHandler(Connection con) {
5050
throw new UnsupportedOperationException("STREAM TransportHandler can only be created manually");
5151
case TCP_TIMING:
5252
if (localConEndType == ConnectionEndType.CLIENT) {
53-
return new TimingClientTcpTransportHandler(timeout, con.getHostname(), con.getPort());
53+
return new TimingClientTcpTransportHandler(timeout, con.getIp(), con.getPort());
5454
} else {
5555
return new TimingServerTcpTransportHandler(timeout, con.getPort());
5656
}
5757
case UDP_TIMING:
5858
if (localConEndType == ConnectionEndType.CLIENT) {
59-
return new TimingClientUdpTransportHandler(timeout, con.getHostname(), con.getPort());
59+
return new TimingClientUdpTransportHandler(timeout, con.getIp(), con.getPort());
6060
} else {
6161
return new TimingServerUdpTransportHandler(timeout, con.getPort());
6262
}
6363
case TCP_PROXY_TIMING:
6464
if (localConEndType == ConnectionEndType.CLIENT) {
65-
return new TimingProxyClientTcpTransportHandler(timeout, con.getHostname(), con.getPort());
65+
return new TimingProxyClientTcpTransportHandler(timeout, con.getIp(), con.getPort());
6666
} else {
6767
throw new UnsupportedOperationException(
6868
"TCP_PROXY_TIMING for server sockets is currently not supported");
6969
}
7070
case TCP_NO_DELAY:
7171
if (localConEndType == ConnectionEndType.CLIENT) {
72-
return new ClientTcpNoDelayTransportHandler(timeout, con.getHostname(), con.getPort());
72+
return new ClientTcpNoDelayTransportHandler(timeout, con.getIp(), con.getPort());
7373
} else {
7474
throw new UnsupportedOperationException(
7575
"This transport handler type is only supported in client mode");

Transport/src/main/java/de/rub/nds/tlsattacker/transport/tcp/ClientTcpTransportHandler.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,30 @@ public class ClientTcpTransportHandler extends TransportHandler {
2929

3030
public ClientTcpTransportHandler(Connection connection) {
3131
super(connection.getTimeout(), ConnectionEndType.CLIENT);
32-
this.hostname = connection.getHostname();
32+
this.hostname = connection.getIp();
33+
System.out.println("Ctor 1: Got hostname: " + this.hostname);
3334
this.port = connection.getPort();
3435
this.connectionTimeout = 60000;
3536
}
3637

38+
public ClientTcpTransportHandler(Connection connection, long timeout) {
39+
this(connection);
40+
this.connectionTimeout = timeout;
41+
}
42+
3743
public ClientTcpTransportHandler(long timeout, String hostname, int port) {
3844
super(timeout, ConnectionEndType.CLIENT);
3945
this.hostname = hostname;
46+
System.out.println("Ctor 2: Got hostname: " + this.hostname);
47+
new Exception().printStackTrace(System.out);
4048
this.port = port;
4149
this.connectionTimeout = timeout;
4250
}
4351

4452
public ClientTcpTransportHandler(long connectionTimeout, long timeout, String hostname, int port) {
4553
super(timeout, ConnectionEndType.CLIENT);
4654
this.hostname = hostname;
55+
System.out.println("Ctor 3: Got hostname: " + this.hostname);
4756
this.port = port;
4857
this.connectionTimeout = connectionTimeout;
4958
}
@@ -59,6 +68,7 @@ public void closeConnection() throws IOException {
5968
@Override
6069
public void initialize() throws IOException {
6170
socket = new Socket();
71+
System.out.println("Connecting to " + hostname);
6272
socket.connect(new InetSocketAddress(hostname, port), (int) connectionTimeout);
6373
if (!socket.isConnected()) {
6474
throw new IOException("Could not connect to " + hostname + ":" + "port");

0 commit comments

Comments
 (0)