Skip to content

Commit

Permalink
[JENKINS-50095] Update X-Remoting-Minimum-Version header in /tcpSlave…
Browse files Browse the repository at this point in the history
…AgentListener
  • Loading branch information
longngn committed Mar 18, 2019
1 parent 1c9eb43 commit 05d9675
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/src/main/java/hudson/TcpSlaveAgentListener.java
Expand Up @@ -33,6 +33,7 @@
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;
Expand Down Expand Up @@ -153,6 +154,13 @@ public String getAgentProtocolNames() {
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 {
Expand Down Expand Up @@ -304,7 +312,7 @@ private void respondHello(String header, Socket s) throws IOException {
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 {
Expand Down
Expand Up @@ -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>

0 comments on commit 05d9675

Please sign in to comment.