Skip to content

Commit 19c917f

Browse files
author
David Cooke
committed
fix port allocation on tcp+udp challenges
1 parent 2443508 commit 19c917f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ allprojects {
44
apply plugin: 'jacoco'
55

66
group = 'uk.co.ractf'
7-
version = '0.0.74'
7+
version = '0.0.75'
88

99
repositories {
1010
maven { url "https://repo1.maven.org/maven2/" }

polaris-application/src/main/java/uk/co/ractf/polaris/controller/PortAllocator.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public Map<PortMapping, PortBinding> allocate(final List<PortMapping> portMappin
3838
var lastUdpPort = portAllocations.getUdp().contains(lastTcpPort) ? generatePort(min, max, portAllocations.getUdp()) : lastTcpPort;
3939

4040
for (final var portMapping : portMappings) {
41+
System.out.println(portMapping);
4142
switch (portMapping.getProtocol()) {
4243
case "tcp": {
4344
portBindings.put(portMapping, new PortBinding(new Ports.Binding("0.0.0.0", lastTcpPort + "/tcp"),
@@ -53,9 +54,11 @@ public Map<PortMapping, PortBinding> allocate(final List<PortMapping> portMappin
5354
while (portAllocations.getTcp().contains(lastUdpPort)) {
5455
lastUdpPort = generatePort(min, max, portAllocations.getUdp());
5556
}
56-
portBindings.put(portMapping, new PortBinding(new Ports.Binding("0.0.0.0", lastUdpPort + "/udp"),
57+
portBindings.put(new PortMapping(portMapping.getPort(), "tcp", portMapping.isAdvertise()),
58+
new PortBinding(new Ports.Binding("0.0.0.0", lastUdpPort + "/udp"),
5759
new ExposedPort(portMapping.getPort(), InternetProtocol.UDP)));
58-
portBindings.put(portMapping, new PortBinding(new Ports.Binding("0.0.0.0", lastUdpPort + "/tcp"),
60+
portBindings.put(new PortMapping(portMapping.getPort(), "udp", portMapping.isAdvertise()),
61+
new PortBinding(new Ports.Binding("0.0.0.0", lastUdpPort + "/tcp"),
5962
new ExposedPort(portMapping.getPort(), InternetProtocol.TCP)));
6063
break;
6164
}

0 commit comments

Comments
 (0)