org.gudy.azureus2.core3.tracker.host.impl
Class TRHostImpl

java.lang.Object
  extended by org.gudy.azureus2.core3.tracker.host.impl.TRHostImpl
All Implemented Interfaces:
TRTrackerAnnouncerFactoryListener, TRHost, TRTrackerServerAuthenticationListener, TRTrackerServerFactoryListener, TRTrackerServerListener, TRTrackerServerListener2, TRTrackerServerRequestListener

public class TRHostImpl
extends Object
implements TRHost, TRTrackerAnnouncerFactoryListener, TRTrackerServerListener2, TRTrackerServerListener, TRTrackerServerFactoryListener, TRTrackerServerRequestListener, TRTrackerServerAuthenticationListener


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.gudy.azureus2.core3.tracker.server.TRTrackerServerListener2
TRTrackerServerListener2.ExternalRequest
 
Field Summary
static int STATS_PERIOD_SECS
           
protected  AEMonitor this_mon
           
 
Fields inherited from interface org.gudy.azureus2.core3.tracker.host.TRHost
DEFAULT_ANNOUNCE_CACHE_PEER_THRESHOLD, DEFAULT_ANNOUNCE_CACHE_PERIOD, DEFAULT_INC_BY, DEFAULT_INC_PER, DEFAULT_MAX_RETRY_DELAY, DEFAULT_MIN_RETRY_DELAY, DEFAULT_PORT, DEFAULT_PORT_SSL, DEFAULT_SCRAPE_CACHE_PERIOD, DEFAULT_SCRAPE_RETRY_PERCENTAGE
 
Constructor Summary
protected TRHostImpl()
           
 
Method Summary
 void addAuthenticationListener(TRHostAuthenticationListener l)
           
protected  void addExternalTorrent(byte[] hash, int state, long date_added)
           
 void addListener(TRHostListener l)
          Add and fire listener for each torrent already hosted
 void addListener2(TRHostListener2 l)
           
protected  TRHostTorrent addTorrent(TOTorrent torrent, int state, boolean persistent, boolean passive, long date_added)
           
protected  void addTrackerAnnounce(TOTorrent torrent)
           
 boolean authenticate(String headers, URL resource, String user, String password)
          checks the password against user and returns true if OK
 byte[] authenticate(URL resource, String user)
          returns SHA1 hash of pw for user if available
 void clientCreated(TRTrackerAnnouncer client)
           
 void clientDestroyed(TRTrackerAnnouncer client)
           
 void close()
           
static TRHost create()
           
 boolean denied(byte[] hash, boolean permitted)
           
 InetAddress getBindIP()
           
 TRHostTorrent getHostTorrent(TOTorrent torrent)
          returns the host torrent for the torrent if it exists, null otherwise
 String getName()
           
 TRHostTorrent[] getTorrents()
           
protected  TRTrackerAnnouncer getTrackerClient(TRHostTorrent host_torrent)
           
 boolean handleExternalRequest(InetSocketAddress client_address, String user, String url, URL absolute_url, String header, InputStream is, OutputStream os, AsyncController async)
           
 boolean handleExternalRequest(TRTrackerServerListener2.ExternalRequest request)
           
 TRHostTorrent hostTorrent(TOTorrent torrent, boolean persistent, boolean passive)
           
protected  void hostTorrentStateChange(TRHostTorrent host_torrent)
           
 void initialise(TRHostTorrentFinder finder)
           
protected  TRHostTorrent lookupHostTorrent(TOTorrent torrent)
           
protected  TRHostTorrent lookupHostTorrentViaHash(byte[] hash)
           
 boolean permitted(String originator, byte[] hash, boolean explicit)
           
 void postProcess(TRTrackerServerRequest request)
           
 void preProcess(TRTrackerServerRequest request)
           
 TRHostTorrent publishTorrent(TOTorrent torrent)
           
protected  void remove(TRHostTorrent host_torrent)
           
 void removeAuthenticationListener(TRHostAuthenticationListener l)
           
 void removeListener(TRHostListener l)
           
 void removeListener2(TRHostListener2 l)
           
 void serverCreated(TRTrackerServer server)
           
 void serverDestroyed(TRTrackerServer server)
           
protected  void startHosting(TRHostTorrentHostImpl host_torrent)
           
protected  void startHosting(TRHostTorrentHostImpl host_torrent, TRTrackerAnnouncer tracker_client)
           
protected  void startHosting(TRTrackerAnnouncer tracker_client)
           
protected  TRTrackerServer startServer(int protocol, int port, boolean ssl)
           
protected  void startTorrent(TRHostTorrentHostImpl torrent)
           
protected  void stopHosting(TRHostTorrentHostImpl host_torrent)
           
protected  void stopHosting(TRHostTorrentHostImpl host_torrent, TRTrackerAnnouncer tracker_client)
           
protected  void stopHosting(TRTrackerAnnouncer tracker_client)
           
protected  void stopTorrent(TRHostTorrentHostImpl torrent)
           
protected  void torrentListenerRegistered()
           
protected  void torrentUpdated(TRHostTorrentHostImpl hti)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATS_PERIOD_SECS

public static final int STATS_PERIOD_SECS
See Also:
Constant Field Values

this_mon

protected final AEMonitor this_mon
Constructor Detail

TRHostImpl

protected TRHostImpl()
Method Detail

create

public static TRHost create()

initialise

public void initialise(TRHostTorrentFinder finder)
Specified by:
initialise in interface TRHost

getName

public String getName()
Specified by:
getName in interface TRHost

hostTorrent

public TRHostTorrent hostTorrent(TOTorrent torrent,
                                 boolean persistent,
                                 boolean passive)
                          throws TRHostException
Specified by:
hostTorrent in interface TRHost
Throws:
TRHostException

publishTorrent

public TRHostTorrent publishTorrent(TOTorrent torrent)
                             throws TRHostException
Specified by:
publishTorrent in interface TRHost
Throws:
TRHostException

addTorrent

protected TRHostTorrent addTorrent(TOTorrent torrent,
                                   int state,
                                   boolean persistent,
                                   boolean passive,
                                   long date_added)
                            throws TRHostException
Throws:
TRHostException

torrentUpdated

protected void torrentUpdated(TRHostTorrentHostImpl hti)

getBindIP

public InetAddress getBindIP()
Specified by:
getBindIP in interface TRHost

startServer

protected TRTrackerServer startServer(int protocol,
                                      int port,
                                      boolean ssl)
                               throws TRHostException
Throws:
TRHostException

lookupHostTorrent

protected TRHostTorrent lookupHostTorrent(TOTorrent torrent)

startHosting

protected void startHosting(TRHostTorrentHostImpl host_torrent)

startHosting

protected void startHosting(TRTrackerAnnouncer tracker_client)

startHosting

protected void startHosting(TRHostTorrentHostImpl host_torrent,
                            TRTrackerAnnouncer tracker_client)

remove

protected void remove(TRHostTorrent host_torrent)

stopHosting

protected void stopHosting(TRHostTorrentHostImpl host_torrent)

stopHosting

protected void stopHosting(TRTrackerAnnouncer tracker_client)

stopHosting

protected void stopHosting(TRHostTorrentHostImpl host_torrent,
                           TRTrackerAnnouncer tracker_client)

getTrackerClient

protected TRTrackerAnnouncer getTrackerClient(TRHostTorrent host_torrent)

hostTorrentStateChange

protected void hostTorrentStateChange(TRHostTorrent host_torrent)

getTorrents

public TRHostTorrent[] getTorrents()
Specified by:
getTorrents in interface TRHost

clientCreated

public void clientCreated(TRTrackerAnnouncer client)
Specified by:
clientCreated in interface TRTrackerAnnouncerFactoryListener

clientDestroyed

public void clientDestroyed(TRTrackerAnnouncer client)
Specified by:
clientDestroyed in interface TRTrackerAnnouncerFactoryListener

lookupHostTorrentViaHash

protected TRHostTorrent lookupHostTorrentViaHash(byte[] hash)

permitted

public boolean permitted(String originator,
                         byte[] hash,
                         boolean explicit)
Specified by:
permitted in interface TRTrackerServerListener

addExternalTorrent

protected void addExternalTorrent(byte[] hash,
                                  int state,
                                  long date_added)

denied

public boolean denied(byte[] hash,
                      boolean permitted)
Specified by:
denied in interface TRTrackerServerListener

handleExternalRequest

public boolean handleExternalRequest(InetSocketAddress client_address,
                                     String user,
                                     String url,
                                     URL absolute_url,
                                     String header,
                                     InputStream is,
                                     OutputStream os,
                                     AsyncController async)
                              throws IOException
Specified by:
handleExternalRequest in interface TRTrackerServerListener
Throws:
IOException

handleExternalRequest

public boolean handleExternalRequest(TRTrackerServerListener2.ExternalRequest request)
                              throws IOException
Specified by:
handleExternalRequest in interface TRTrackerServerListener2
Throws:
IOException

getHostTorrent

public TRHostTorrent getHostTorrent(TOTorrent torrent)
Description copied from interface: TRHost
returns the host torrent for the torrent if it exists, null otherwise

Specified by:
getHostTorrent in interface TRHost
Returns:

addListener

public void addListener(TRHostListener l)
Add and fire listener for each torrent already hosted

Specified by:
addListener in interface TRHost

removeListener

public void removeListener(TRHostListener l)
Specified by:
removeListener in interface TRHost

addListener2

public void addListener2(TRHostListener2 l)
Specified by:
addListener2 in interface TRHost

removeListener2

public void removeListener2(TRHostListener2 l)
Specified by:
removeListener2 in interface TRHost

torrentListenerRegistered

protected void torrentListenerRegistered()

serverCreated

public void serverCreated(TRTrackerServer server)
Specified by:
serverCreated in interface TRTrackerServerFactoryListener

serverDestroyed

public void serverDestroyed(TRTrackerServer server)
Specified by:
serverDestroyed in interface TRTrackerServerFactoryListener

preProcess

public void preProcess(TRTrackerServerRequest request)
                throws TRTrackerServerException
Specified by:
preProcess in interface TRTrackerServerRequestListener
Throws:
TRTrackerServerException

postProcess

public void postProcess(TRTrackerServerRequest request)
                 throws TRTrackerServerException
Specified by:
postProcess in interface TRTrackerServerRequestListener
Throws:
TRTrackerServerException

close

public void close()
Specified by:
close in interface TRHost

authenticate

public boolean authenticate(String headers,
                            URL resource,
                            String user,
                            String password)
Description copied from interface: TRTrackerServerAuthenticationListener
checks the password against user and returns true if OK

Specified by:
authenticate in interface TRTrackerServerAuthenticationListener
Returns:

authenticate

public byte[] authenticate(URL resource,
                           String user)
Description copied from interface: TRTrackerServerAuthenticationListener
returns SHA1 hash of pw for user if available

Specified by:
authenticate in interface TRTrackerServerAuthenticationListener
Returns:

addAuthenticationListener

public void addAuthenticationListener(TRHostAuthenticationListener l)
Specified by:
addAuthenticationListener in interface TRHost

removeAuthenticationListener

public void removeAuthenticationListener(TRHostAuthenticationListener l)
Specified by:
removeAuthenticationListener in interface TRHost

startTorrent

protected void startTorrent(TRHostTorrentHostImpl torrent)

stopTorrent

protected void stopTorrent(TRHostTorrentHostImpl torrent)

addTrackerAnnounce

protected void addTrackerAnnounce(TOTorrent torrent)