Skip to content

Commit de999ba

Browse files
author
Alexei Moisseev
committed
replaced hardcoded localhost value with java.net.InetAddress
1 parent cc90cfa commit de999ba

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/org/browsermob/proxy/ProxyServer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
import org.browsermob.proxy.jetty.util.InetAddrPort;
1414
import org.openqa.selenium.Proxy;
1515

16+
import java.net.UnknownHostException;
1617
import java.util.Date;
1718
import java.util.Map;
1819

20+
import java.net.InetAddress;
21+
1922

2023
public class ProxyServer {
2124
private static final HarNameVersion CREATOR = new HarNameVersion("BrowserMob Proxy", "2.0");
@@ -58,10 +61,10 @@ public void start() throws Exception {
5861
server.start();
5962
}
6063

61-
public org.openqa.selenium.Proxy seleniumProxy() {
64+
public org.openqa.selenium.Proxy seleniumProxy() throws UnknownHostException {
6265
Proxy proxy = new Proxy();
6366
proxy.setProxyType(Proxy.ProxyType.MANUAL);
64-
String proxyStr = String.format("localhost:%d", getPort());
67+
String proxyStr = String.format("%s:%d", InetAddress.getLocalHost().getCanonicalHostName(), getPort());
6568
proxy.setHttpProxy(proxyStr);
6669
proxy.setSslProxy(proxyStr);
6770

0 commit comments

Comments
 (0)