Package com.biglybt.ui.telnet
Class SocketServer
java.lang.Object
com.biglybt.ui.telnet.SocketServer
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionprivate final Set
private final int
private final ServerSocket
private final UI
private final UserManager
-
Constructor Summary
ConstructorsConstructorDescriptionSocketServer
(UI ui, int port, Set allowedHosts, UserManager userManager, int maxLoginAttempts) -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
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 hostsprivate boolean
isAllowed
(InetSocketAddress addr) check that the specified host/ip is allowedprivate UserProfile
login
(InputStream in, OutputStream out) 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 uservoid
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.
-
Field Details
-
serverSocket
-
allowedHosts
-
maxLoginAttempts
private final int maxLoginAttempts -
userManager
-
ui
-
-
Constructor Details
-
SocketServer
public SocketServer(UI ui, int port, Set allowedHosts, UserManager userManager, int maxLoginAttempts) throws IOException - Throws:
IOException
-
-
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. -
login
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 fromout
- stream to write messages to- Returns:
- username if login was successful, null otherwise
- Throws:
IOException
-
isAllowed
check that the specified host/ip is allowed- Parameters:
addr
-- Returns:
-
checkHost
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
-