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 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
FieldsModifier and TypeFieldDescriptionprivate final List<TRHostAuthenticationListener>
private static final AEMonitor
private boolean
private TRHostConfigImpl
(package private) final AsyncDispatcher
private static boolean
private final Map
private final Map
(package private) final List
private static final int
private static final int
private static final int
private final ListenerManager<TRHostListener>
private final CopyOnWriteList<TRHostListener2>
private static final LogIDs
private boolean
private final Hashtable
private static TRHostImpl
static final int
protected final AEMonitor
private static final int
private static final int
private final Map
private static final int
private static final int
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
addExternalTorrent
(byte[] hash, int state, long date_added) void
Add and fire listener for each torrent already hostedvoid
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 OKbyte[]
authenticate
(URL resource, 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) getHostTorrent
(TOTorrent torrent) returns the host torrent for the torrent if it exists, null otherwisegetName()
int
protected TRTrackerAnnouncer
getTrackerClient
(TRHostTorrent host_torrent) boolean
boolean
handleExternalRequest
(InetSocketAddress client_address, String user, String url, URL absolute_url, String header, InputStream is, OutputStream os, AsyncController async) 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
void
postProcess
(TRTrackerServerRequest request) void
preProcess
(TRTrackerServerRequest request) publishTorrent
(TOTorrent torrent) protected void
remove
(TRHostTorrent host_torrent) void
void
void
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
protected void
-
Field Details
-
LOGID
-
URL_DEFAULT_PORT
private static final int URL_DEFAULT_PORT- See Also:
-
URL_DEFAULT_PORT_SSL
private static final int URL_DEFAULT_PORT_SSL- See Also:
-
STATS_PERIOD_SECS
public static final int STATS_PERIOD_SECS- See Also:
-
TICK_PERIOD_SECS
private static final int TICK_PERIOD_SECS- See Also:
-
TICKS_PER_STATS_PERIOD
private static final int TICKS_PER_STATS_PERIOD- See Also:
-
singleton
-
class_mon
-
config
-
server_map
-
host_torrents
-
host_torrent_hash_map
-
host_torrent_map
-
tracker_client_map
-
LDT_TORRENT_ADDED
private static final int LDT_TORRENT_ADDED- See Also:
-
LDT_TORRENT_REMOVED
private static final int LDT_TORRENT_REMOVED- See Also:
-
LDT_TORRENT_CHANGED
private static final int LDT_TORRENT_CHANGED- See Also:
-
listeners
-
listeners2
-
host_add_announce_urls
private static boolean host_add_announce_urls -
auth_listeners
-
server_factory_listener_added
private boolean server_factory_listener_added -
this_mon
-
closed
private volatile boolean closed -
dispatcher
-
-
Constructor Details
-
TRHostImpl
protected TRHostImpl()
-
-
Method Details
-
create
-
initialise
- Specified by:
initialise
in interfaceTRHost
-
getName
-
hostTorrent
public TRHostTorrent hostTorrent(TOTorrent torrent, boolean persistent, boolean passive) throws TRHostException - Specified by:
hostTorrent
in interfaceTRHost
- Throws:
TRHostException
-
publishTorrent
- 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
-
getBindIP
-
startServer
- Throws:
TRHostException
-
lookupHostTorrent
-
startHosting
-
startHosting
-
startHosting
-
remove
-
stopHosting
-
stopHosting
-
stopHosting
-
getTrackerClient
-
hostTorrentStateChange
-
getTorrents
- Specified by:
getTorrents
in interfaceTRHost
-
getTorrentCount
public int getTorrentCount()- Specified by:
getTorrentCount
in interfaceTRHost
-
clientCreated
- Specified by:
clientCreated
in interfaceTRTrackerAnnouncerFactoryListener
-
clientDestroyed
- Specified by:
clientDestroyed
in interfaceTRTrackerAnnouncerFactoryListener
-
lookupHostTorrentViaHash
-
permitted
- 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(InetSocketAddress client_address, String user, String url, URL absolute_url, String header, InputStream is, OutputStream os, AsyncController async) throws IOException - Specified by:
handleExternalRequest
in interfaceTRTrackerServerListener
- Throws:
IOException
-
handleExternalRequest
public boolean handleExternalRequest(TRTrackerServerListener2.ExternalRequest request) throws IOException - Specified by:
handleExternalRequest
in interfaceTRTrackerServerListener2
- Throws:
IOException
-
getHostTorrent
Description copied from interface:TRHost
returns the host torrent for the torrent if it exists, null otherwise- Specified by:
getHostTorrent
in interfaceTRHost
- Returns:
-
addListener
Add and fire listener for each torrent already hosted- Specified by:
addListener
in interfaceTRHost
-
removeListener
- Specified by:
removeListener
in interfaceTRHost
-
addListener2
- Specified by:
addListener2
in interfaceTRHost
-
removeListener2
- Specified by:
removeListener2
in interfaceTRHost
-
torrentListenerRegistered
protected void torrentListenerRegistered() -
serverCreated
- Specified by:
serverCreated
in interfaceTRTrackerServerFactoryListener
-
serverDestroyed
- Specified by:
serverDestroyed
in interfaceTRTrackerServerFactoryListener
-
preProcess
- Specified by:
preProcess
in interfaceTRTrackerServerRequestListener
- Throws:
TRTrackerServerException
-
postProcess
- Specified by:
postProcess
in interfaceTRTrackerServerRequestListener
- Throws:
TRTrackerServerException
-
close
public void close() -
authenticate
Description copied from interface:TRTrackerServerAuthenticationListener
checks the password against user and returns true if OK- Specified by:
authenticate
in interfaceTRTrackerServerAuthenticationListener
- Returns:
-
authenticate
Description copied from interface:TRTrackerServerAuthenticationListener
returns SHA1 hash of pw for user if available- Specified by:
authenticate
in interfaceTRTrackerServerAuthenticationListener
- Returns:
-
addAuthenticationListener
- Specified by:
addAuthenticationListener
in interfaceTRHost
-
removeAuthenticationListener
- Specified by:
removeAuthenticationListener
in interfaceTRHost
-
startTorrent
-
stopTorrent
-
addTrackerAnnounce
-