Commit 6beb6d22 authored by Thiago Camargo's avatar Thiago Camargo Committed by thiago

[JM-1032] - Fixes on STUN Server Start and Stop

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8039 b35dd754-fafc-0310-a699-88a17e54d16e
parent efbf1c23
......@@ -105,12 +105,10 @@ public class STUNService extends BasicModule {
//
if (enabled && !oldValue) {
startSTUNService();
}
else if (!enabled && oldValue) {
} else if (!enabled && oldValue) {
stop();
}
}
else if (property.equals("stun.local.enabled")) {
} else if (property.equals("stun.local.enabled")) {
localEnabled = JiveGlobals.getBooleanProperty("stun.local.enabled", false);
}
}
......@@ -118,8 +116,7 @@ public class STUNService extends BasicModule {
public void propertyDeleted(String property, Map<String, Object> params) {
if (property.equals("stun.enabled")) {
enabled = true;
}
else if (property.equals("stun.local.enabled")) {
} else if (property.equals("stun.local.enabled")) {
localEnabled = false;
}
}
......@@ -151,8 +148,7 @@ public class STUNService extends BasicModule {
if (primary != null && secondary != null) {
stunServer = new StunServer(primaryPort, primary, secondaryPort, secondary);
stunServer.start();
}
else {
} else {
setLocalEnabled(false);
}
}
......@@ -178,9 +174,11 @@ public class STUNService extends BasicModule {
private void stopSTUNService() {
XMPPServer server = XMPPServer.getInstance();
server.getIQDiscoInfoHandler().removeServerFeature(NAMESPACE);
if (stunIQHandler != null) {
server.getIQRouter().removeHandler(stunIQHandler);
stunIQHandler = null;
}
}
public void stop() {
super.stop();
......@@ -259,8 +257,7 @@ public class STUNService extends BasicModule {
if (isLocalEnabled()) {
startLocalServer();
}
}
else {
} else {
stopSTUNService();
}
this.enabled = enabled;
......@@ -276,8 +273,7 @@ public class STUNService extends BasicModule {
this.localEnabled = enabled;
if (isLocalEnabled()) {
startLocalServer();
}
else {
} else {
stopLocal();
}
}
......@@ -413,8 +409,7 @@ public class STUNService extends BasicModule {
}
}
}
else {
} else {
// Answer an error since the server can't handle the requested namespace
reply.setError(PacketError.Condition.service_unavailable);
}
......
......@@ -52,7 +52,7 @@
boolean add = request.getParameter("add") != null;
int remove = ParamUtils.getIntParameter(request, "remove", -1);
boolean success = false;
boolean enabled = false;
boolean enabled = true;
boolean localEnabled = false;
String primaryAddress;
......@@ -73,8 +73,7 @@
secondaryAddress = ParamUtils.getParameter(request, "secondaryAddress", true);
JiveGlobals.setProperty("stun.address.secondary", secondaryAddress);
enabled = ParamUtils.getBooleanParameter(request, "enabled", enabled);
JiveGlobals.setProperty("stun.enabled", String.valueOf(enabled));
enabled = JiveGlobals.getBooleanProperty("stun.enabled", enabled);
localEnabled = ParamUtils.getBooleanParameter(request, "localEnabled", localEnabled);
JiveGlobals.setProperty("stun.local.enabled", String.valueOf(localEnabled));
......@@ -86,12 +85,10 @@
success = stunService.isEnabled() == enabled && stunService.isLocalEnabled() == localEnabled;
}
else if (remove > -1) {
} else if (remove > -1) {
stunService.removeExternalServer(remove);
success = true;
}
else if (add) {
} else if (add) {
String server = ParamUtils.getParameter(request, "externalServer", true);
String port = ParamUtils.getParameter(request, "externalPort", true);
......@@ -176,14 +173,14 @@
<form action="" method="post" name="settings">
<div class="jive-contentBoxHeader">
<div class="jive-contentBoxHeader">
<fmt:message key="stun.settings.title"/>
</div>
<div class="jive-contentBox">
</div>
<div class="jive-contentBox">
<table cellpadding="3" cellspacing="5" border="0">
<tbody>
<tr>
<table cellpadding="3" cellspacing="5" border="0">
<tbody>
<tr>
<td align="left" colspan="2">
<fmt:message key="stun.settings.localenabled"/>
:&nbsp<input type="checkbox"
......@@ -191,28 +188,37 @@
<%=stunService.isLocalEnabled()?"checked":""%>
align="left">
</td>
</tr>
<tr>
</tr>
<tr>
<td align="left">
<fmt:message key="stun.settings.primaryaddress"/>:
</td><td>
<fmt:message key="stun.settings.primaryaddress"/>
:
</td>
<td>
<select size="1" name="primaryAddress">
<option value="CHOOSE">-- Select Address --</option>
<%
List<InetAddress> addresses = stunService.getAddresses();
for (InetAddress iaddress : addresses) {
String hostAddress = iaddress.getHostAddress();
boolean isPrimaryAddress = hostAddress.equals(stunService.getPrimaryAddress());
%>
<option value="<%= hostAddress %>" <% if(isPrimaryAddress) { %>selected <% } %> ><%= hostAddress %>
<option value="<%= hostAddress %>" <% if (isPrimaryAddress) { %>
selected <% } %> ><%= hostAddress %>
</option>
<% } %>
</td>
</tr>
<tr>
</tr>
<tr>
<td align="left">
<fmt:message key="stun.settings.secondaryaddress"/>:
</td><td>
<fmt:message key="stun.settings.secondaryaddress"/>
:
</td>
<td>
<select size="1" name="secondaryAddress">
<option value="CHOOSE">-- Select Address --</option>
<%
......@@ -220,44 +226,49 @@
String hostAddress = iaddress.getHostAddress();
boolean isSecondaryAddress = hostAddress.equals(stunService.getSecondaryAddress());
%>
<option value="<%= hostAddress %>" <% if(isSecondaryAddress) { %>selected <% } %> ><%= hostAddress %>
<option value="<%= hostAddress %>" <% if (isSecondaryAddress) { %>
selected <% } %> ><%= hostAddress %>
</option>
<% } %>
</select>
</td>
</tr>
<tr>
</tr>
<tr>
<td align="left">
<fmt:message key="stun.settings.primaryport"/>:
</td><td>
<fmt:message key="stun.settings.primaryport"/>
:
</td>
<td>
<input type="text" size="6"
maxlength="10"
name="primaryPort"
value="<%=stunService.getPrimaryPort()%>"
align="left">
</td>
</tr>
<tr>
</tr>
<tr>
<td align="left">
<fmt:message key="stun.settings.secondaryport"/>:
</td><td>
<fmt:message key="stun.settings.secondaryport"/>
:
</td>
<td>
<input type="text" size="6"
maxlength="10"
name="secondaryPort"
value="<%=stunService.getSecondaryPort()%>"
align="left">
</td>
</tr>
<tr>
</tr>
<tr>
<td>
<input type="hidden" name="save">
<input type="button" name="set" value="<fmt:message key="global.save_settings" />"
onclick="checkAndSubmit()">
</td>
</tr>
</tbody>
</table>
</div>
</tr>
</tbody>
</table>
</div>
</form>
<form action="" method="post" name="add">
<div class="jive-contentBoxHeader">
......
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