|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.elite.jdcbot.framework.DCIO org.elite.jdcbot.framework.InputThreadTarget org.elite.jdcbot.framework.jDCBot org.ag.sheriffbot.SheriffBot
public class SheriffBot
SheriffBot is a derived class from jDCBot apstract class overriding some methods.
This bot's task is to periodically download all the users' file list. It downloads all the
users' file list and packs them into a single xml file named in the format shown below.
Hub name-yyyy-MM-dd_HH.mm.ss.bz2
where yyyy-MM-dd_HH.mm.ss is the date and time of creation of the file.
This file is compressed using bzip2 algorithm. When any new user logs in for the first time
in-between the file list dumping cycle then that user's file list is downloaded and saved
separately and the file is named as
Hub name_User name-yyyy-MM-dd_HH.mm.ss.bz2
The reason of creating this was that my college laid down the condition that DC++ will only
be allowed on college LAN network if the hub maintains a list of users' file list. So, that
later if required the originator of any illegal file can be traced back.
Nested Class Summary | |
---|---|
private class |
SheriffBot.UserListDownloadThread
|
Field Summary | |
---|---|
private java.lang.String |
_filelistDir
|
private java.lang.String |
_hubIP
|
private int |
_updateInterval
|
private java.util.HashMap<java.lang.String,java.lang.String> |
authorizedUsers
|
private java.util.Vector<java.lang.String> |
downloadedUsers
|
private java.util.Vector<java.lang.String> |
indexedUsers
|
private boolean |
isShuttingDown
|
private boolean |
isUpdateInProgress
|
private boolean |
listUpdatedAtleastOnce
|
private java.util.Vector<java.lang.String> |
spareUsers
|
private TimerThread |
tt
|
private java.util.Vector<java.lang.String> |
users2Index
|
private SheriffBot.UserListDownloadThread |
uth
|
java.lang.String |
version
|
Fields inherited from class org.elite.jdcbot.framework.jDCBot |
---|
_botname, _conn_type, _description, _email, _hubname, _ip, _passive, _password, _port, _sharesize, downloadManager, log, shareManager, socket, socketServer, um, uploadManager, VERSION |
Constructor Summary | |
---|---|
SheriffBot(java.io.PrintStream outputLog)
|
|
SheriffBot(java.lang.String hubIP,
int hubPort,
java.lang.String botIP,
int listenPort,
java.lang.String sharesizeInBytes,
int noOfSlots,
int updateInterval,
java.lang.String filelistDir,
java.lang.String hubPass,
boolean passive,
java.io.PrintStream outputLog)
|
|
SheriffBot(java.lang.String hubIP,
int hubPort,
java.lang.String sharesizeInBytes,
java.lang.String hubpass,
java.lang.String botIP,
int listenPort,
java.lang.String filelistDir,
boolean active,
java.io.PrintStream outputLog)
|
Method Summary | |
---|---|
private boolean |
authorized(java.lang.String user)
|
protected void |
clearIndexedUsersList()
|
byte[] |
getFileListBytes(User user,
int settings)
|
static void |
main(java.lang.String[] args)
|
void |
onBotQuit()
It is called when the bot quits. |
void |
onConnect()
Prints on main chat that we are here and starts flood thread. |
void |
onDisconnect()
Called upon disconnecting from hub. |
protected void |
onDownloadComplete(User user,
DUEntity due,
boolean sucess,
BotException e)
Called when download is complete. Note: This method is called by DownloadHandler using jDCBot-EventDispatchThread thread. |
void |
onJoin(java.lang.String user)
Called when user enter the hub. |
void |
onPrivateMessage(java.lang.String user,
java.lang.String message)
Sends user who wants to talk to us a feedback that we're (still) stupid. |
private void |
updateFilelists()
|
Methods inherited from class org.elite.jdcbot.framework.DCIO |
---|
parseCmdArgs, parseCmdName, parseRawCmd, ReadCommand, ReadCommand, SendCommand, SendCommand, set_IOExceptionMsg |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final java.lang.String version
private TimerThread tt
private int _updateInterval
private java.lang.String _hubIP
private java.lang.String _filelistDir
private java.util.HashMap<java.lang.String,java.lang.String> authorizedUsers
private SheriffBot.UserListDownloadThread uth
private java.util.Vector<java.lang.String> users2Index
private java.util.Vector<java.lang.String> spareUsers
private java.util.Vector<java.lang.String> indexedUsers
private java.util.Vector<java.lang.String> downloadedUsers
private volatile boolean isShuttingDown
private volatile boolean listUpdatedAtleastOnce
private volatile boolean isUpdateInProgress
Constructor Detail |
---|
public SheriffBot(java.io.PrintStream outputLog)
public SheriffBot(java.lang.String hubIP, int hubPort, java.lang.String sharesizeInBytes, java.lang.String hubpass, java.lang.String botIP, int listenPort, java.lang.String filelistDir, boolean active, java.io.PrintStream outputLog)
public SheriffBot(java.lang.String hubIP, int hubPort, java.lang.String botIP, int listenPort, java.lang.String sharesizeInBytes, int noOfSlots, int updateInterval, java.lang.String filelistDir, java.lang.String hubPass, boolean passive, java.io.PrintStream outputLog)
Method Detail |
---|
public void onConnect()
onConnect
in class jDCBot
protected void clearIndexedUsersList()
public void onPrivateMessage(java.lang.String user, java.lang.String message)
onPrivateMessage
in class jDCBot
user
- Name of user who sent us private message.message
- Contents of private message.public void onBotQuit()
jDCBot
onBotQuit
in class jDCBot
public void onDisconnect()
jDCBot
The implementation of this method in the jDCBot abstract class resets the _inputThread to null hence when overridden super.onDisconnect() must be called first.
onDisconnect
in class jDCBot
private void updateFilelists()
private boolean authorized(java.lang.String user)
public void onJoin(java.lang.String user)
jDCBot
The implementation of this method in the jDCBot abstract class performs no actions and may be overridden as required.
onJoin
in class jDCBot
user
- Nema of the user who entered hub.public byte[] getFileListBytes(User user, int settings)
protected void onDownloadComplete(User user, DUEntity due, boolean sucess, BotException e)
jDCBot
onDownloadComplete
in class jDCBot
user
- The user from whom the file was downloaded.due
- The informations about the file downloaded is in this.sucess
- It is true if download was successful else false.e
- The exception that occured when sucess is false else it is null.public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |