Commit 16b3d483 authored by Thiago Camargo's avatar Thiago Camargo Committed by thiago

Network options

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6627 b35dd754-fafc-0310-a699-88a17e54d16e
parent fcdeb58a
...@@ -29,12 +29,10 @@ import org.xmpp.packet.Packet; ...@@ -29,12 +29,10 @@ import org.xmpp.packet.Packet;
import org.xmpp.packet.PacketError; import org.xmpp.packet.PacketError;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException; import java.net.SocketException;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/** /**
* STUN Server and Service Module * STUN Server and Service Module
...@@ -56,7 +54,7 @@ public class STUNService extends BasicModule implements ServerItemsProvider, Rou ...@@ -56,7 +54,7 @@ public class STUNService extends BasicModule implements ServerItemsProvider, Rou
private String primaryAddress; private String primaryAddress;
private String secondaryAddress; private String secondaryAddress;
private int primaryPort = 3478; private int primaryPort = 3478;
private int secondaryPort = 3576; private int secondaryPort = 3479;
public static final String NAMESPACE = "google:jingleinfo"; public static final String NAMESPACE = "google:jingleinfo";
...@@ -94,7 +92,7 @@ public class STUNService extends BasicModule implements ServerItemsProvider, Rou ...@@ -94,7 +92,7 @@ public class STUNService extends BasicModule implements ServerItemsProvider, Rou
// Do nothing let the default values to be used. // Do nothing let the default values to be used.
} }
this.enabled=JiveGlobals.getProperty("stun.enabled") == null||Boolean.parseBoolean(JiveGlobals.getProperty("stun.enabled")); this.enabled = JiveGlobals.getProperty("stun.enabled") == null || Boolean.parseBoolean(JiveGlobals.getProperty("stun.enabled"));
} }
...@@ -371,4 +369,23 @@ public class STUNService extends BasicModule implements ServerItemsProvider, Rou ...@@ -371,4 +369,23 @@ public class STUNService extends BasicModule implements ServerItemsProvider, Rou
return primaryAddress; return primaryAddress;
} }
public List<InetAddress> getAddresses() {
List<InetAddress> list = new ArrayList<InetAddress>();
try {
Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
while (ifaces.hasMoreElements()) {
NetworkInterface iface = ifaces.nextElement();
Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
while (iaddresses.hasMoreElements()) {
InetAddress iaddress = iaddresses.nextElement();
if (!iaddress.isLoopbackAddress() && !iaddress.isLinkLocalAddress()) {
list.add(iaddress);
}
}
}
} catch (Exception e) {
}
return list;
}
} }
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
<%@ page import="org.jivesoftware.util.ParamUtils" %> <%@ page import="org.jivesoftware.util.ParamUtils" %>
<%@ page import="org.jivesoftware.wildfire.XMPPServer" %> <%@ page import="org.jivesoftware.wildfire.XMPPServer" %>
<%@ page import="org.jivesoftware.wildfire.stun.STUNService" %> <%@ page import="org.jivesoftware.wildfire.stun.STUNService" %>
<%@ page import="java.net.InetAddress" %>
<%@ page import="java.util.List" %>
<% <%
STUNService stunService = XMPPServer.getInstance().getSTUNService(); STUNService stunService = XMPPServer.getInstance().getSTUNService();
...@@ -89,19 +91,48 @@ ...@@ -89,19 +91,48 @@
<table cellpadding="3" cellspacing="0" border="0" width="100%"> <table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody> <tbody>
<tr> <tr>
<td align="left">Primary Address:&nbsp<input type="text" size="20" <td align="left">Primary Address:&nbsp<select size="1"
maxlength="100" maxlength="100"
name="primaryAddress" name="primaryAddress"
value="<%=stunService.getPrimaryAddress()%>" align="left">
align="left"> <option value="<%=stunService.getPrimaryAddress()%>"><%=stunService.getPrimaryAddress()%>
<%
List<InetAddress> addresses = stunService.getAddresses();
for(InetAddress iaddress:addresses){
%>
<option value="<%=iaddress.getHostAddress()%>"><%=iaddress.getHostAddress()%>
</option>
<%
}
String sname = JiveGlobals.getProperty("xmpp.domain", JiveGlobals.getProperty("network.interface", "localhost"));
%>
<option value="<%=sname%>"><%=sname%>
</option>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="left">Secondary Address:&nbsp<input type="text" size="20" <td align="left"> Secondary
maxlength="100" Address:&nbsp<select size="1"
name="secondaryAddress" maxlength="100"
value="<%=stunService.getSecondaryAddress()%>" name="primaryAddress"
align="left"> align="left">
<option value="<%=stunService.getSecondaryAddress()%>"><%=stunService.getSecondaryAddress()%>
</option>
<%
for (InetAddress iaddress : addresses) {
%>
<option value="<%=iaddress.getHostAddress()%>"><%=iaddress.getHostAddress()%>
</option>
<% } %>
<option value="127.0.0.1">127.0.0.1</option>
</select>
</td> </td>
</tr> </tr>
<tr> <tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment