[JENKINS-50095] Update X-Remoting-Minimum-Version header in /tcpSlaveAgentListener

This commit is contained in:
Nguyen Le Vu Long committed 2019-03-18 23:36:33 +07:00
1 parent 1c9eb43283
commit 05d9675d85
2 files changed
+11 -1

No files matched your search

@@ -33,6 +33,7 @@ import java.security.interfaces.RSAPublicKey;
import javax.annotation.Nullable;
import hudson.model.AperiodicWork;
import hudson.util.VersionNumber;
import jenkins.model.Jenkins;
import jenkins.model.identity.InstanceIdentityProvider;
import jenkins.security.stapler.StaplerAccessibleType;
@@ -153,6 +154,13 @@ public final class TcpSlaveAgentListener extends Thread {
return StringUtils.join(Jenkins.getInstance().getAgentProtocols(), ", ");
}
/**
* Gets Remoting minimum supported version to prevent unsupported agents from connecting
*/
public VersionNumber getRemotingMinimumVersion() {
return RemotingVersionInfo.getMinimumSupportedVersion();
}
@Override
public void run() {
try {
@@ -304,7 +312,7 @@ public final class TcpSlaveAgentListener extends Thread {
o.write("Jenkins-Session: " + Jenkins.SESSION_HASH + "\r\n");
o.write("Client: " + s.getInetAddress().getHostAddress() + "\r\n");
o.write("Server: " + s.getLocalAddress().getHostAddress() + "\r\n");
o.write("Remoting-Minimum-Version: " + RemotingVersionInfo.getMinimumSupportedVersion() + "\r\n");
o.write("Remoting-Minimum-Version: " + getRemotingMinimumVersion() + "\r\n");
o.flush();
s.shutdownOutput();
} else {
@@ -39,6 +39,8 @@ THE SOFTWARE.
<st:header name="X-Instance-Identity" value="${app.tcpSlaveAgentListener.identityPublicKey}" />
<!-- reduce the number of client connection attempts during protocol negotiation -->
<st:header name="X-Jenkins-Agent-Protocols" value="${app.tcpSlaveAgentListener.agentProtocolNames}"/>
<!-- publish minimum supported version of remoting agent -->
<st:header name="X-Remoting-Minimum-Version" value="${app.tcpSlaveAgentListener.remotingMinimumVersion}"/>
Jenkins
</j:jelly>