Class TRHostImpl
- java.lang.Object
-
- com.biglybt.core.tracker.host.impl.TRHostImpl
-
- All Implemented Interfaces:
TRTrackerAnnouncerFactoryListener
,TRHost
,TRTrackerServerAuthenticationListener
,TRTrackerServerFactoryListener
,TRTrackerServerListener
,TRTrackerServerListener2
,TRTrackerServerRequestListener
public class TRHostImpl extends java.lang.Object implements TRHost, TRTrackerAnnouncerFactoryListener, TRTrackerServerListener2, TRTrackerServerListener, TRTrackerServerFactoryListener, TRTrackerServerRequestListener, TRTrackerServerAuthenticationListener
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.biglybt.core.tracker.server.TRTrackerServerListener2
TRTrackerServerListener2.ExternalRequest
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<TRHostAuthenticationListener>
auth_listeners
private static AEMonitor
class_mon
private boolean
closed
private TRHostConfigImpl
config
(package private) AsyncDispatcher
dispatcher
private static boolean
host_add_announce_urls
private java.util.Map
host_torrent_hash_map
private java.util.Map
host_torrent_map
(package private) java.util.List
host_torrents
private static int
LDT_TORRENT_ADDED
private static int
LDT_TORRENT_CHANGED
private static int
LDT_TORRENT_REMOVED
private ListenerManager<TRHostListener>
listeners
private CopyOnWriteList<TRHostListener2>
listeners2
private static LogIDs
LOGID
private boolean
server_factory_listener_added
private java.util.Hashtable
server_map
private static TRHostImpl
singleton
static int
STATS_PERIOD_SECS
protected AEMonitor
this_mon
private static int
TICK_PERIOD_SECS
private static int
TICKS_PER_STATS_PERIOD
private java.util.Map
tracker_client_map
private static int
URL_DEFAULT_PORT
private static int
URL_DEFAULT_PORT_SSL
-
Fields inherited from interface com.biglybt.core.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
Constructors Modifier Constructor Description protected
TRHostImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 hostedvoid
addListener2(TRHostListener2 l)
protected TRHostTorrent
addTorrent(TOTorrent torrent, int state, boolean persistent, boolean passive, long date_added)
protected void
addTrackerAnnounce(TOTorrent torrent)
boolean
authenticate(java.lang.String headers, java.net.URL resource, java.lang.String user, java.lang.String password)
checks the password against user and returns true if OKbyte[]
authenticate(java.net.URL resource, java.lang.String user)
returns SHA1 hash of pw for user if availablevoid
clientCreated(TRTrackerAnnouncer client)
void
clientDestroyed(TRTrackerAnnouncer client)
void
close()
static TRHost
create()
boolean
denied(byte[] hash, boolean permitted)
java.net.InetAddress
getBindIP()
TRHostTorrent
getHostTorrent(TOTorrent torrent)
returns the host torrent for the torrent if it exists, null otherwisejava.lang.String
getName()
int
getTorrentCount()
TRHostTorrent[]
getTorrents()
protected TRTrackerAnnouncer
getTrackerClient(TRHostTorrent host_torrent)
boolean
handleExternalRequest(TRTrackerServerListener2.ExternalRequest request)
boolean
handleExternalRequest(java.net.InetSocketAddress client_address, java.lang.String user, java.lang.String url, java.net.URL absolute_url, java.lang.String header, java.io.InputStream is, java.io.OutputStream os, AsyncController async)
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(java.lang.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(TRTrackerAnnouncer tracker_client)
protected void
startHosting(TRHostTorrentHostImpl host_torrent)
protected void
startHosting(TRHostTorrentHostImpl host_torrent, TRTrackerAnnouncer tracker_client)
protected TRTrackerServer
startServer(int protocol, int port, boolean ssl)
protected void
startTorrent(TRHostTorrentHostImpl torrent)
protected void
stopHosting(TRTrackerAnnouncer tracker_client)
protected void
stopHosting(TRHostTorrentHostImpl host_torrent)
protected void
stopHosting(TRHostTorrentHostImpl host_torrent, TRTrackerAnnouncer tracker_client)
protected void
stopTorrent(TRHostTorrentHostImpl torrent)
protected void
torrentListenerRegistered()
protected void
torrentUpdated(TRHostTorrentHostImpl hti)
-
-
-
Field Detail
-
LOGID
private static final LogIDs LOGID
-
URL_DEFAULT_PORT
private static final int URL_DEFAULT_PORT
- See Also:
- Constant Field Values
-
URL_DEFAULT_PORT_SSL
private static final int URL_DEFAULT_PORT_SSL
- See Also:
- Constant Field Values
-
STATS_PERIOD_SECS
public static final int STATS_PERIOD_SECS
- See Also:
- Constant Field Values
-
TICK_PERIOD_SECS
private static final int TICK_PERIOD_SECS
- See Also:
- Constant Field Values
-
TICKS_PER_STATS_PERIOD
private static final int TICKS_PER_STATS_PERIOD
- See Also:
- Constant Field Values
-
singleton
private static TRHostImpl singleton
-
class_mon
private static final AEMonitor class_mon
-
config
private TRHostConfigImpl config
-
server_map
private final java.util.Hashtable server_map
-
host_torrents
final java.util.List host_torrents
-
host_torrent_hash_map
private final java.util.Map host_torrent_hash_map
-
host_torrent_map
private final java.util.Map host_torrent_map
-
tracker_client_map
private final java.util.Map tracker_client_map
-
LDT_TORRENT_ADDED
private static final int LDT_TORRENT_ADDED
- See Also:
- Constant Field Values
-
LDT_TORRENT_REMOVED
private static final int LDT_TORRENT_REMOVED
- See Also:
- Constant Field Values
-
LDT_TORRENT_CHANGED
private static final int LDT_TORRENT_CHANGED
- See Also:
- Constant Field Values
-
listeners
private final ListenerManager<TRHostListener> listeners
-
listeners2
private final CopyOnWriteList<TRHostListener2> listeners2
-
host_add_announce_urls
private static boolean host_add_announce_urls
-
auth_listeners
private final java.util.List<TRHostAuthenticationListener> auth_listeners
-
server_factory_listener_added
private boolean server_factory_listener_added
-
this_mon
protected final AEMonitor this_mon
-
closed
private volatile boolean closed
-
dispatcher
final AsyncDispatcher dispatcher
-
-
Method Detail
-
create
public static TRHost create()
-
initialise
public void initialise(TRHostTorrentFinder finder)
- Specified by:
initialise
in interfaceTRHost
-
hostTorrent
public TRHostTorrent hostTorrent(TOTorrent torrent, boolean persistent, boolean passive) throws TRHostException
- Specified by:
hostTorrent
in interfaceTRHost
- Throws:
TRHostException
-
publishTorrent
public TRHostTorrent publishTorrent(TOTorrent torrent) throws TRHostException
- Specified by:
publishTorrent
in interfaceTRHost
- 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)
-
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 interfaceTRHost
-
getTorrentCount
public int getTorrentCount()
- Specified by:
getTorrentCount
in interfaceTRHost
-
clientCreated
public void clientCreated(TRTrackerAnnouncer client)
- Specified by:
clientCreated
in interfaceTRTrackerAnnouncerFactoryListener
-
clientDestroyed
public void clientDestroyed(TRTrackerAnnouncer client)
- Specified by:
clientDestroyed
in interfaceTRTrackerAnnouncerFactoryListener
-
lookupHostTorrentViaHash
protected TRHostTorrent lookupHostTorrentViaHash(byte[] hash)
-
permitted
public boolean permitted(java.lang.String originator, byte[] hash, boolean explicit)
- Specified by:
permitted
in interfaceTRTrackerServerListener
-
addExternalTorrent
protected void addExternalTorrent(byte[] hash, int state, long date_added)
-
denied
public boolean denied(byte[] hash, boolean permitted)
- Specified by:
denied
in interfaceTRTrackerServerListener
-
handleExternalRequest
public boolean handleExternalRequest(java.net.InetSocketAddress client_address, java.lang.String user, java.lang.String url, java.net.URL absolute_url, java.lang.String header, java.io.InputStream is, java.io.OutputStream os, AsyncController async) throws java.io.IOException
- Specified by:
handleExternalRequest
in interfaceTRTrackerServerListener
- Throws:
java.io.IOException
-
handleExternalRequest
public boolean handleExternalRequest(TRTrackerServerListener2.ExternalRequest request) throws java.io.IOException
- Specified by:
handleExternalRequest
in interfaceTRTrackerServerListener2
- Throws:
java.io.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 interfaceTRHost
- Returns:
-
addListener
public void addListener(TRHostListener l)
Add and fire listener for each torrent already hosted- Specified by:
addListener
in interfaceTRHost
-
removeListener
public void removeListener(TRHostListener l)
- Specified by:
removeListener
in interfaceTRHost
-
addListener2
public void addListener2(TRHostListener2 l)
- Specified by:
addListener2
in interfaceTRHost
-
removeListener2
public void removeListener2(TRHostListener2 l)
- Specified by:
removeListener2
in interfaceTRHost
-
torrentListenerRegistered
protected void torrentListenerRegistered()
-
serverCreated
public void serverCreated(TRTrackerServer server)
- Specified by:
serverCreated
in interfaceTRTrackerServerFactoryListener
-
serverDestroyed
public void serverDestroyed(TRTrackerServer server)
- Specified by:
serverDestroyed
in interfaceTRTrackerServerFactoryListener
-
preProcess
public void preProcess(TRTrackerServerRequest request) throws TRTrackerServerException
- Specified by:
preProcess
in interfaceTRTrackerServerRequestListener
- Throws:
TRTrackerServerException
-
postProcess
public void postProcess(TRTrackerServerRequest request) throws TRTrackerServerException
- Specified by:
postProcess
in interfaceTRTrackerServerRequestListener
- Throws:
TRTrackerServerException
-
authenticate
public boolean authenticate(java.lang.String headers, java.net.URL resource, java.lang.String user, java.lang.String password)
Description copied from interface:TRTrackerServerAuthenticationListener
checks the password against user and returns true if OK- Specified by:
authenticate
in interfaceTRTrackerServerAuthenticationListener
- Returns:
-
authenticate
public byte[] authenticate(java.net.URL resource, java.lang.String user)
Description copied from interface:TRTrackerServerAuthenticationListener
returns SHA1 hash of pw for user if available- Specified by:
authenticate
in interfaceTRTrackerServerAuthenticationListener
- Returns:
-
addAuthenticationListener
public void addAuthenticationListener(TRHostAuthenticationListener l)
- Specified by:
addAuthenticationListener
in interfaceTRHost
-
removeAuthenticationListener
public void removeAuthenticationListener(TRHostAuthenticationListener l)
- Specified by:
removeAuthenticationListener
in interfaceTRHost
-
startTorrent
protected void startTorrent(TRHostTorrentHostImpl torrent)
-
stopTorrent
protected void stopTorrent(TRHostTorrentHostImpl torrent)
-
addTrackerAnnounce
protected void addTrackerAnnounce(TOTorrent torrent)
-
-