|
From: <ian...@us...> - 2008-02-05 04:00:21
|
Revision: 706
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=706&view=rev
Author: iansmith
Date: 2008-02-04 20:00:23 -0800 (Mon, 04 Feb 2008)
Log Message:
-----------
Added support for a new optional argument in server.xml (preferredIPAddr). This allows the
server configuration to control what IP the server will give out for itself when asked. This returned via the ServiceDocument that can be grabbed from the BaseSpace resource.
This was needed because it appears amazon uses a NAT interface via Xen to protect instances, thus servers were (wrongly, from a client point of view) reporting their IP addr as a local address, like 10.1.2.3. This interacted badly (sigh) with our workaround to the sun security
problem that appeared in java 1.6_03 that required us to use IP addresses to address the server.
Really, most people will never need this. Really.
Modified Paths:
--------------
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/VerifyEnvironmentMojo.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/WebappServletBase.java
maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/VerifyEnvironmentMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/VerifyEnvironmentMojo.java 2008-02-01 23:48:38 UTC (rev 705)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/VerifyEnvironmentMojo.java 2008-02-05 04:00:23 UTC (rev 706)
@@ -29,6 +29,11 @@
"UserDatabase",
"mailSession"
};
+
+ private static final String[] OPTIONAL_NAMES= {
+ "preferredIPAddr"
+ };
+
/**
* @parameter
*/
@@ -108,7 +113,7 @@
Iterator<String> it = resourceLinkMap.keySet().iterator();
while (it.hasNext()) {
String target = it.next();
- if (!areDefined.contains(target)) {
+ if ((!areDefined.contains(target)) && (!isOptional(target))) {
result.add(target);
}
}
@@ -116,6 +121,15 @@
}
+ private boolean isOptional(String target) {
+ for (int i=0; i<OPTIONAL_NAMES.length;++i) {
+ if (OPTIONAL_NAMES[i].equals(target)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private Map<String,String> computeExpectedLinks(XMLElement contextRoot) throws MojoExecutionException {
Map<String,String> result=new HashMap<String,String>();
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2008-02-01 23:48:38 UTC (rev 705)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2008-02-05 04:00:23 UTC (rev 706)
@@ -109,7 +109,11 @@
}
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
- ServiceDocument serviceDocument = new ServiceDocument(messageProxy.getUserCount(), messageProxy.getSimCount(), request.getLocalAddr());
+ String localAddr=request.getLocalAddr();
+ if (preferredIPAddr!=null) {
+ localAddr=preferredIPAddr;
+ }
+ ServiceDocument serviceDocument = new ServiceDocument(messageProxy.getUserCount(), messageProxy.getSimCount(), localAddr);
sendStringResponse(serviceDocument.toString(), "text/xml", response);
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/WebappServletBase.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/WebappServletBase.java 2008-02-01 23:48:38 UTC (rev 705)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/WebappServletBase.java 2008-02-05 04:00:23 UTC (rev 706)
@@ -1,6 +1,7 @@
package com.ogoglio.site;
import javax.naming.Context;
+import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -8,6 +9,7 @@
public abstract class WebappServletBase extends OgoglioServletBase {
protected boolean servletNeeded=true;
+ protected String preferredIPAddr=null;
public void init(ServletConfig config) throws ServletException {
try {
@@ -17,6 +19,11 @@
if ("false".equals(useMe.toLowerCase())) {
servletNeeded=false;
}
+ try {
+ preferredIPAddr = (String) envCtx.lookup("ogoglio/preferredIPAddr");
+ } catch (NameNotFoundException e) {
+ //this is optional
+ }
super.init(config);
} catch (NamingException e) {
bailOutOfInit(e);
Modified: maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml 2008-02-01 23:48:38 UTC (rev 705)
+++ maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml 2008-02-05 04:00:23 UTC (rev 706)
@@ -23,4 +23,6 @@
<ResourceLink name="ogoglio/simFilter" global="simFilter" type="java.lang.String"/>
<ResourceLink name="ogoglio/simFilterPort" global="simFilterPort" type="java.lang.String"/>
+ <ResourceLink name="ogoglio/preferredIPAddr" global="preferredIPAddr" type="java.lang.String"/>
+
</Context>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|