Class SocketServer

java.lang.Object
com.biglybt.ui.telnet.SocketServer
All Implemented Interfaces:
Runnable

final class SocketServer extends Object implements Runnable
this class is used to receive incoming connections for the telnet UI and then authenticate and create a console session for the connection
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Set
     
    private final int
     
    private final ServerSocket
     
    private final UI
     
    private final UserManager
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    SocketServer(UI ui, int port, Set allowedHosts, UserManager userManager, int maxLoginAttempts)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private boolean
    checkHost(String hostName)
    compare the specified host (might be a hostname or an IP - dont really care) and see if it is a match against one of the allowed hosts
    private boolean
    check that the specified host/ip is allowed
    private UserProfile
    if usermanager is null (ie: multi user is not enabled), returns the default user profile otherwise, requests username and password and authenticates user before returning the user profile for this user
    void
    run()
    start up the server socket and when a new connection is received, check that the source address is in our permitted list and if so, start a new console input on that socket.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • serverSocket

      private final ServerSocket serverSocket
    • allowedHosts

      private final Set allowedHosts
    • maxLoginAttempts

      private final int maxLoginAttempts
    • userManager

      private final UserManager userManager
    • ui

      private final UI ui
  • Constructor Details

  • Method Details

    • run

      public void run()
      start up the server socket and when a new connection is received, check that the source address is in our permitted list and if so, start a new console input on that socket.
      Specified by:
      run in interface Runnable
    • login

      private UserProfile login(InputStream in, OutputStream out) throws IOException
      if usermanager is null (ie: multi user is not enabled), returns the default user profile otherwise, requests username and password and authenticates user before returning the user profile for this user
      Parameters:
      in - input stream to read from
      out - stream to write messages to
      Returns:
      username if login was successful, null otherwise
      Throws:
      IOException
    • isAllowed

      private boolean isAllowed(InetSocketAddress addr)
      check that the specified host/ip is allowed
      Parameters:
      addr -
      Returns:
    • checkHost

      private boolean checkHost(String hostName)
      compare the specified host (might be a hostname or an IP - dont really care) and see if it is a match against one of the allowed hosts
      Parameters:
      hostName -
      Returns:
      true if this hostname matches one in our allowed hosts