Class SocketServer
java.lang.Object
com.biglybt.ui.telnet.SocketServer
- All Implemented Interfaces:
Runnable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Setprivate final intprivate final ServerSocketprivate final UIprivate final UserManager -
Constructor Summary
ConstructorsConstructorDescriptionSocketServer(UI ui, int port, Set allowedHosts, UserManager userManager, int maxLoginAttempts) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleancompare 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 booleanisAllowed(InetSocketAddress addr) check that the specified host/ip is allowedprivate UserProfilelogin(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 uservoidrun()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
-
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
-