Skip to content

Commit

Permalink
resolve ip address at point of allocation and not startup
Browse files Browse the repository at this point in the history
  • Loading branch information
deleolajide committed Mar 15, 2024
1 parent b61369b commit 91fdd41
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Binary file modified classes/linux-64/turn-server-log
Binary file not shown.
Binary file modified classes/win-64/turn-server-log.exe
Binary file not shown.
12 changes: 6 additions & 6 deletions src/java/org/ifsoft/turn/openfire/PionTurn.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ public void initializePlugin(final PluginManager manager, final File pluginDirec
{
executor = Executors.newCachedThreadPool();

String hostName = XMPPServer.getInstance().getServerInfo().getHostname();
String ipAddress = JiveGlobals.getProperty("pionturn.ipaddr", getIpAddress());
String ipAddress = JiveGlobals.getProperty("pionturn.ipaddr", getIpAddress(null));
String hostName = JiveGlobals.getProperty("pionturn.host", ipAddress);

try {
ipAddress = InetAddress.getByName(ipAddress).getHostAddress();
ipAddress = InetAddress.getByName(hostName).getHostAddress();
} catch (Exception e) { }

String ipaddr = " -public-ip " + ipAddress;
Expand Down Expand Up @@ -145,13 +145,13 @@ public String getMaxPort() {
return "55000";
}

public String getIpAddress()
public String getIpAddress(String hostname)
{
String ourHostname = XMPPServer.getInstance().getServerInfo().getHostname();
if (hostname == null) hostname = XMPPServer.getInstance().getServerInfo().getHostname();
String ourIpAddress = "127.0.0.1";

try {
ourIpAddress = InetAddress.getByName(ourHostname).getHostAddress();
ourIpAddress = InetAddress.getByName(hostname).getHostAddress();
} catch (Exception e) {

}
Expand Down
7 changes: 4 additions & 3 deletions src/web/pionturn.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
JiveGlobals.setProperty("pionturn.secret", turn.getSharedSecret());
JiveGlobals.setProperty("pionturn.username", turn.getRawUsername());
JiveGlobals.setProperty("pionturn.password", turn.getRawPassword());
JiveGlobals.setProperty("pionturn.ipaddr", turn.getHost());
JiveGlobals.setProperty("pionturn.password", turn.getRawPassword());
JiveGlobals.setProperty("pionturn.host", turn.getHost());
JiveGlobals.setProperty("pionturn.ipaddr", plugin.getIpAddress(turn.getHost()));
JiveGlobals.setProperty("pionturn.port", String.valueOf(turn.getPort()));
}
Expand Down Expand Up @@ -137,7 +138,7 @@
<fmt:message key="config.page.configuration.ipaddr"/>
</td>
<td><input type="text" size="50" maxlength="100" name="ipaddr" required
value="<%= JiveGlobals.getProperty("pionturn.ipaddr", plugin.getIpAddress()) %>">
value="<%= JiveGlobals.getProperty("pionturn.ipaddr", plugin.getIpAddress(null)) %>">
</td>
</tr>
<tr>
Expand Down

0 comments on commit 91fdd41

Please sign in to comment.