Package hudson

Class TcpSlaveAgentListener

  • All Implemented Interfaces:
    Runnable

    @StaplerAccessibleType
    public final class TcpSlaveAgentListener
    extends Thread
    Listens to incoming TCP connections, for example from agents.

    Aside from the HTTP endpoint, Jenkins runs TcpSlaveAgentListener that listens on a TCP socket. Historically this was used for inbound connection from agents (hence the name), but over time it was extended and made generic, so that multiple protocols of different purposes can co-exist on the same socket.

    This class accepts the socket, then after a short handshaking, it dispatches to appropriate AgentProtocols.

    Author:
    Kohsuke Kawaguchi
    See Also:
    AgentProtocol
    • Field Detail

      • configuredPort

        public final int configuredPort
      • CLI_HOST_NAME

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static String CLI_HOST_NAME
        Host name that we advertise protocol clients to connect to. This is primarily for those who have reverse proxies in place such that the HTTP host name and the TCP/IP connection host names are different. (Note: despite the name, this is used for any client, not only deprecated Remoting-based CLI.) TODO: think about how to expose this (including whether this needs to be exposed at all.)
      • CLI_PORT

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static Integer CLI_PORT
        Port number that we advertise protocol clients to connect to. This is primarily for the case where the port that Jenkins runs is different from the port that external world should connect to, because of the presence of NAT / port-forwarding / TCP reverse proxy. (Note: despite the name, this is used for any client, not only deprecated Remoting-based CLI.) If left to null, fall back to getPort()
        Since:
        1.611
    • Constructor Detail

      • TcpSlaveAgentListener

        public TcpSlaveAgentListener​(int port)
                              throws IOException
        Parameters:
        port - Use 0 to choose a random port.
        Throws:
        IOException
    • Method Detail

      • getPort

        public int getPort()
        Gets the TCP port number in which we are listening.
      • getAdvertisedPort

        public int getAdvertisedPort()
        Gets the TCP port number in which we are advertising.
        Since:
        1.656
      • getAdvertisedHost

        public String getAdvertisedHost()
        Gets the host name that we advertise protocol clients to connect to.
        Since:
        2.198
      • getIdentityPublicKey

        @Nullable
        public String getIdentityPublicKey()
        Gets the Base64 encoded public key that forms part of this instance's identity keypair.
        Returns:
        the Base64 encoded public key
        Since:
        2.16
      • getAgentProtocolNames

        public String getAgentProtocolNames()
        Returns a comma separated list of the enabled AgentProtocol.getName() implementations so that clients can avoid creating additional work for the server attempting to connect with unsupported protocols.
        Returns:
        a comma separated list of the enabled AgentProtocol.getName() implementations
        Since:
        2.16
      • getRemotingMinimumVersion

        public VersionNumber getRemotingMinimumVersion()
        Gets Remoting minimum supported version to prevent unsupported agents from connecting
        Since:
        2.171
      • run

        public void run()
        Specified by:
        run in interface Runnable
        Overrides:
        run in class Thread
      • shutdown

        public void shutdown()
        Initiates the shuts down of the listener.