提交 396f2998 编写于 作者: K kohsuke

the server name in the arguments also need to take the reverse proxy into account.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@10543 71c3de6d-444a-0410-be80-ed276b4c234a
上级 dacf9604
...@@ -55,6 +55,8 @@ import java.lang.management.ThreadInfo; ...@@ -55,6 +55,8 @@ import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean; import java.lang.management.ThreadMXBean;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
...@@ -885,5 +887,26 @@ public class Functions { ...@@ -885,5 +887,26 @@ public class Functions {
return System.getProperty(key); return System.getProperty(key);
} }
/**
* Obtains the host name of the Hudson server that clients can use to talk back to.
* <p>
* This is primarily used in <tt>slave-agent.jnlp.jelly</tt> to specify the destination
* that the slaves talk to.
*/
public String getServerName() {
// try to infer this from the request URL
String url = Hudson.getInstance().getRootUrl();
try {
if(url!=null) {
String host = new URL(url).getHost();
if(host!=null)
return host;
}
} catch (MalformedURLException e) {
// fall back to HTTP request
}
return Stapler.getCurrentRequest().getServerName();
}
private static final Pattern SCHEME = Pattern.compile("[a-z]+://.+"); private static final Pattern SCHEME = Pattern.compile("[a-z]+://.+");
} }
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
</resources> </resources>
<application-desc main-class="hudson.jnlp.Main"> <application-desc main-class="hudson.jnlp.Main">
<argument>${request.serverName}</argument> <argument>${h.getServerName()}</argument>
<argument>${rootURL}/tcpSlaveAgentListener/</argument> <argument>${rootURL}/tcpSlaveAgentListener/</argument>
<argument>${app.secretKey}</argument> <argument>${app.secretKey}</argument>
<argument>${it.node.nodeName}</argument> <argument>${it.node.nodeName}</argument>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册