ants.p2p.filesharing
Class WarriorAnt

java.lang.Object
  extended by java.lang.Thread
      extended by ants.p2p.Ant
          extended by ants.p2p.filesharing.WarriorAnt
All Implemented Interfaces:
java.lang.Runnable

public class WarriorAnt
extends Ant


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static boolean autoresumeFilesOnRun
           
static int blockSizeInDownload
           
static java.lang.String chunksHome
           
static java.lang.String chunksPath
           
static java.lang.String downloadPath
           
static java.lang.String ed2kPath
           
 java.util.List inputSecureConnections
           
 java.util.List inServiceFilePullRequests
           
 java.util.List inServiceFilePushRequests
           
static boolean isServer
           
static int maxOwnPullRequestsToTrace
           
static int maxPartialFiles
           
static int maxPullRequestsToServe
           
static int maxScheduledDownloads
           
static int maxScheduledHttpProxy
           
static int maxSecureConnections
           
 java.util.List outputSecureConnections
           
static long partialFilesTimeout
           
static java.lang.String password
           
 java.util.List pendingFilePullRequests
           
 java.util.List pendingSecureRequest
           
static java.lang.String previewsPath
           
static int processProbability
           
 java.util.List scheduledDownloads
           
 java.util.List scheduledHttpProxy
           
static java.lang.String workingPath
           
 java.lang.Integer writingFileLock
           
 
Fields inherited from class ants.p2p.Ant
acceptTCPDirectConnections, beingRoutedMessages, ConnectionType, failedMessages, inTransitMessages, inTransitMessageSizeMax, localNattedInetAddress, localNattedPort, maxFailedMessageToTrace, maxMessagesToRouteToghether, maxNeighbours, maxRetransmissions, maxRetransmissionsForceDirection, messageTimeout, myMessages, myMessageSizeMax, netModificationsTimeout, probeCheckInterval, propertyChangeSupport, proxied, routeInactiveTimeout, routingTable, ss, underRateConnections
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
WarriorAnt(java.lang.String id, int maxNeighbours, int serverPort, boolean acceptDC, java.lang.String localInetAddress, boolean UPnP)
           
 
Method Summary
 boolean areInFailedMessages(java.util.ArrayList list)
           
 boolean areInMyMessages(java.util.ArrayList list)
           
static void checkChuncksHome()
           
static void checkChunksPath()
           
static void checkDownloadPath()
           
static void checked2kPath()
           
 boolean checkInServiceFilePullRequests(boolean addThis, FilePullMessage fpm)
           
static void checkPreviewPath()
           
static boolean compareHash(byte[] h1, byte[] h2)
           
 void createProxy(EndpointSecurityManager esm)
           
 void createSecureConnection(java.lang.String peerId, boolean force)
           
 void disconnectWarrior()
           
 MessageWrapper doQuery(QueryNode query, PublicHeader ph)
           
 QueryMessage doRandomQuery(long timeToLive)
           
 MessageWrapper doSupernodeQuery()
           
 MessageWrapper[] doSupernodeQuery(QueryNode query, PublicHeader ph, java.util.List supernodeSet)
           
 void getALanServer()
           
 HttpProxy getCurrentProxy()
           
static int getHttpLocalServerPort()
           
static int getHttpProxyPort()
           
static java.lang.String getHttpServerDescription()
           
static java.lang.String getHttpServerHomePage()
           
 void getHttpServers()
           
 EndpointSecurityManager getInputSecureConnectionManager(java.lang.String peerId)
           
 EndpointSecurityManager getOutputSecureConnectionManager(java.lang.String peerId)
           
 EndpointSecurityManager getPendingSecureConnectionRequest(java.lang.String peerId, SecurityResponseMessage srm)
           
 void getServersWithFreeSlots()
           
 java.util.ArrayList getServersWithFreeSlots(java.net.InetAddress host, int port, java.net.InetAddress localhost)
           
static void httpEnabled(boolean enabled)
           
static boolean isHttpEnabled()
           
static boolean isSupernode()
           
protected  void processMessage(Message m, Router r)
           
protected  void processMessageThread(Message m, Router r)
           
 void prunePartialFiles()
           
 void pullFile(java.lang.String fileName, java.lang.String fileHash, long offset, long blocks, java.lang.String peerId, int blockSize, java.lang.String localFileName, boolean resume)
           
 void pullFileInfos(java.lang.String hash, java.lang.String peerId, boolean getChunkHashes)
           
 void pullFileSize(java.lang.String fileName, java.lang.String fileHash, java.lang.String peerId)
           
 java.util.ArrayList removeDeliveredMessagesFromList(java.util.ArrayList list)
           
 void removeInputSecureConnection(java.lang.String peerId)
           
 void removeOutputSecureConnection(java.lang.String peerId)
           
 void resetCurrentProxy()
           
 void resetWritingFile()
           
 void scheduleDownload(QueryFileTuple qft)
           
 void scheduleHttpProxy(HttpServerInfo httpServer)
           
 void sendPrivateChatMessage(java.lang.String peerId, java.lang.String message, boolean initiator)
           
static void setHttpLocalServerPort(int port)
           
static void setHttpProxyPort(int port)
           
static void setHttpServerProperties(java.lang.String homePage, java.lang.String description)
           
 void setWritingFile()
           
 void unscheduleDownload(java.lang.String fileHash)
           
 
Methods inherited from class ants.p2p.Ant
acceptTCPDirectConnections, activateNewRouterProcess, addNeighbour, addP2PNeighbour, checkForRoute, checkForRoute, decBeingRoutedMessages, disconnect, equals, existRouteTo, generateNetModificationAlert, generateNetModificationAlert, generateNetModificationAlert, getApplicationName, getFailedMessages, getIdent, getLanAddress, getLocalInetAddress, getMaxNeighbours, getMessage, getNeighbour, getNeighbours, getNeighboursNumber, getNetName, getPropertyChangeSupport, getProtocolVersion, getRateThresold, getServerPort, getShortId, getUnderRatedNeighbours, getVersion, isDisconnected, isInternetPublicAddress, processNetModificationAlert, removeNeighbour, route, run, sendBroadcastMessage, sendMessage, setDirectConnection, setLocalInetAddress, setMaxNeighbours, setProxied, traceDeliveredMessage, traceHints, traceMessage, traceMyMessage, uPnPMapping, verifyAndIncBeingRoutedMessages
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

outputSecureConnections

public java.util.List outputSecureConnections

inputSecureConnections

public java.util.List inputSecureConnections

pendingSecureRequest

public java.util.List pendingSecureRequest

inServiceFilePullRequests

public java.util.List inServiceFilePullRequests

inServiceFilePushRequests

public java.util.List inServiceFilePushRequests

pendingFilePullRequests

public java.util.List pendingFilePullRequests

scheduledHttpProxy

public java.util.List scheduledHttpProxy

maxScheduledHttpProxy

public static int maxScheduledHttpProxy

scheduledDownloads

public java.util.List scheduledDownloads

maxScheduledDownloads

public static int maxScheduledDownloads

workingPath

public static java.lang.String workingPath

ed2kPath

public static java.lang.String ed2kPath

previewsPath

public static java.lang.String previewsPath

chunksHome

public static java.lang.String chunksHome

chunksPath

public static java.lang.String chunksPath

downloadPath

public static java.lang.String downloadPath

maxPullRequestsToServe

public static int maxPullRequestsToServe

maxOwnPullRequestsToTrace

public static int maxOwnPullRequestsToTrace

maxSecureConnections

public static int maxSecureConnections

maxPartialFiles

public static int maxPartialFiles

partialFilesTimeout

public static long partialFilesTimeout

blockSizeInDownload

public static int blockSizeInDownload

isServer

public static boolean isServer

password

public static java.lang.String password

processProbability

public static int processProbability

autoresumeFilesOnRun

public static boolean autoresumeFilesOnRun

writingFileLock

public java.lang.Integer writingFileLock
Constructor Detail

WarriorAnt

public WarriorAnt(java.lang.String id,
                  int maxNeighbours,
                  int serverPort,
                  boolean acceptDC,
                  java.lang.String localInetAddress,
                  boolean UPnP)
Method Detail

setWritingFile

public void setWritingFile()

resetWritingFile

public void resetWritingFile()

disconnectWarrior

public void disconnectWarrior()

scheduleDownload

public void scheduleDownload(QueryFileTuple qft)

unscheduleDownload

public void unscheduleDownload(java.lang.String fileHash)

scheduleHttpProxy

public void scheduleHttpProxy(HttpServerInfo httpServer)

setHttpServerProperties

public static void setHttpServerProperties(java.lang.String homePage,
                                           java.lang.String description)

getHttpServerDescription

public static java.lang.String getHttpServerDescription()

getHttpServerHomePage

public static java.lang.String getHttpServerHomePage()

getHttpLocalServerPort

public static int getHttpLocalServerPort()

getHttpProxyPort

public static int getHttpProxyPort()

setHttpLocalServerPort

public static void setHttpLocalServerPort(int port)

setHttpProxyPort

public static void setHttpProxyPort(int port)

httpEnabled

public static void httpEnabled(boolean enabled)

getHttpServers

public void getHttpServers()

getCurrentProxy

public HttpProxy getCurrentProxy()

resetCurrentProxy

public void resetCurrentProxy()

isHttpEnabled

public static boolean isHttpEnabled()

isSupernode

public static boolean isSupernode()

createSecureConnection

public void createSecureConnection(java.lang.String peerId,
                                   boolean force)

removeInputSecureConnection

public void removeInputSecureConnection(java.lang.String peerId)

removeOutputSecureConnection

public void removeOutputSecureConnection(java.lang.String peerId)

sendPrivateChatMessage

public void sendPrivateChatMessage(java.lang.String peerId,
                                   java.lang.String message,
                                   boolean initiator)
                            throws java.lang.Exception
Throws:
java.lang.Exception

pullFile

public void pullFile(java.lang.String fileName,
                     java.lang.String fileHash,
                     long offset,
                     long blocks,
                     java.lang.String peerId,
                     int blockSize,
                     java.lang.String localFileName,
                     boolean resume)
              throws java.lang.Exception
Throws:
java.lang.Exception

pullFileInfos

public void pullFileInfos(java.lang.String hash,
                          java.lang.String peerId,
                          boolean getChunkHashes)
                   throws java.lang.Exception
Throws:
java.lang.Exception

pullFileSize

public void pullFileSize(java.lang.String fileName,
                         java.lang.String fileHash,
                         java.lang.String peerId)
                  throws java.lang.Exception
Throws:
java.lang.Exception

getALanServer

public void getALanServer()

getServersWithFreeSlots

public void getServersWithFreeSlots()

doSupernodeQuery

public MessageWrapper doSupernodeQuery()

getServersWithFreeSlots

public java.util.ArrayList getServersWithFreeSlots(java.net.InetAddress host,
                                                   int port,
                                                   java.net.InetAddress localhost)

doQuery

public MessageWrapper doQuery(QueryNode query,
                              PublicHeader ph)
                       throws java.lang.Exception
Throws:
java.lang.Exception

doSupernodeQuery

public MessageWrapper[] doSupernodeQuery(QueryNode query,
                                         PublicHeader ph,
                                         java.util.List supernodeSet)
                                  throws java.lang.Exception
Throws:
java.lang.Exception

doRandomQuery

public QueryMessage doRandomQuery(long timeToLive)

areInMyMessages

public boolean areInMyMessages(java.util.ArrayList list)

removeDeliveredMessagesFromList

public java.util.ArrayList removeDeliveredMessagesFromList(java.util.ArrayList list)

areInFailedMessages

public boolean areInFailedMessages(java.util.ArrayList list)

checkChunksPath

public static void checkChunksPath()

checkPreviewPath

public static void checkPreviewPath()

checked2kPath

public static void checked2kPath()

checkChuncksHome

public static void checkChuncksHome()

checkDownloadPath

public static void checkDownloadPath()

createProxy

public void createProxy(EndpointSecurityManager esm)

processMessage

protected void processMessage(Message m,
                              Router r)
Overrides:
processMessage in class Ant

processMessageThread

protected void processMessageThread(Message m,
                                    Router r)

checkInServiceFilePullRequests

public boolean checkInServiceFilePullRequests(boolean addThis,
                                              FilePullMessage fpm)

prunePartialFiles

public void prunePartialFiles()

getOutputSecureConnectionManager

public EndpointSecurityManager getOutputSecureConnectionManager(java.lang.String peerId)

getInputSecureConnectionManager

public EndpointSecurityManager getInputSecureConnectionManager(java.lang.String peerId)

getPendingSecureConnectionRequest

public EndpointSecurityManager getPendingSecureConnectionRequest(java.lang.String peerId,
                                                                 SecurityResponseMessage srm)

compareHash

public static boolean compareHash(byte[] h1,
                                  byte[] h2)