2009-09-25 21:05:59 +00:00
|
|
|
/*
|
2014-01-18 20:56:57 +00:00
|
|
|
* This file Copyright (C) 2010-2014 Mnemosyne LLC
|
2009-09-25 21:05:59 +00:00
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
2009-09-25 21:05:59 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-11-14 20:21:28 +00:00
|
|
|
#pragma once
|
|
|
|
|
2009-09-25 21:05:59 +00:00
|
|
|
#ifndef __TRANSMISSION__
|
2017-04-19 12:04:45 +00:00
|
|
|
#error only libtransmission should #include this header.
|
2009-09-25 21:05:59 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "transmission.h"
|
2021-11-02 23:00:01 +00:00
|
|
|
#include "quark.h"
|
2009-09-25 21:05:59 +00:00
|
|
|
|
|
|
|
struct tr_announcer;
|
2021-12-14 20:59:40 +00:00
|
|
|
struct tr_announcer_tiers;
|
2009-09-25 21:05:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* *** Tracker Publish / Subscribe
|
|
|
|
* **/
|
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum TrackerEventType
|
2009-09-25 21:05:59 +00:00
|
|
|
{
|
|
|
|
TR_TRACKER_WARNING,
|
|
|
|
TR_TRACKER_ERROR,
|
|
|
|
TR_TRACKER_ERROR_CLEAR,
|
2021-09-09 20:25:30 +00:00
|
|
|
TR_TRACKER_PEERS,
|
|
|
|
TR_TRACKER_COUNTS,
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2011-01-22 17:45:54 +00:00
|
|
|
struct tr_pex;
|
|
|
|
|
2010-01-19 19:37:00 +00:00
|
|
|
/** @brief Notification object to tell listeners about announce or scrape occurences */
|
2021-10-06 14:26:07 +00:00
|
|
|
struct tr_tracker_event
|
2009-09-25 21:05:59 +00:00
|
|
|
{
|
|
|
|
/* what type of event this is */
|
2017-04-19 12:04:45 +00:00
|
|
|
TrackerEventType messageType;
|
2009-09-25 21:05:59 +00:00
|
|
|
|
|
|
|
/* for TR_TRACKER_WARNING and TR_TRACKER_ERROR */
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* text;
|
2021-11-02 23:00:01 +00:00
|
|
|
tr_quark announce_url;
|
2009-09-25 21:05:59 +00:00
|
|
|
|
|
|
|
/* for TR_TRACKER_PEERS */
|
2017-04-20 16:02:19 +00:00
|
|
|
struct tr_pex const* pex;
|
2011-01-22 17:45:54 +00:00
|
|
|
size_t pexCount;
|
2010-04-20 21:54:03 +00:00
|
|
|
|
2021-09-09 20:25:30 +00:00
|
|
|
/* for TR_TRACKER_PEERS and TR_TRACKER_COUNTS */
|
|
|
|
int leechers;
|
|
|
|
int seeders;
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
using tr_tracker_callback = void (*)(tr_torrent* tor, tr_tracker_event const* event, void* client_data);
|
2010-06-19 14:33:10 +00:00
|
|
|
|
2009-09-25 21:05:59 +00:00
|
|
|
/**
|
|
|
|
*** Session ctor/dtor
|
|
|
|
**/
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_announcerInit(tr_session*);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_announcerClose(tr_session*);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*** For torrent customers
|
|
|
|
**/
|
|
|
|
|
2021-12-14 20:59:40 +00:00
|
|
|
struct tr_announcer_tiers* tr_announcerAddTorrent(tr_torrent* torrent, tr_tracker_callback cb, void* cbdata);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_announcerResetTorrent(struct tr_announcer*, tr_torrent*);
|
2009-10-02 04:54:02 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_announcerRemoveTorrent(struct tr_announcer*, tr_torrent*);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_announcerChangeMyPort(tr_torrent*);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_announcerCanManualAnnounce(tr_torrent const*);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_announcerManualAnnounce(tr_torrent*);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_announcerTorrentStarted(tr_torrent*);
|
|
|
|
void tr_announcerTorrentStopped(tr_torrent*);
|
|
|
|
void tr_announcerTorrentCompleted(tr_torrent*);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TR_ANN_UP,
|
|
|
|
TR_ANN_DOWN,
|
|
|
|
TR_ANN_CORRUPT
|
|
|
|
};
|
|
|
|
|
|
|
|
void tr_announcerAddBytes(tr_torrent*, int up_down_or_corrupt, uint32_t byteCount);
|
2010-02-08 16:47:30 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
time_t tr_announcerNextManualAnnounce(tr_torrent const*);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2021-12-08 16:55:52 +00:00
|
|
|
tr_tracker_view tr_announcerTracker(tr_torrent const* torrent, size_t i);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2021-12-10 02:03:26 +00:00
|
|
|
size_t tr_announcerTrackerCount(tr_torrent const* tor);
|
|
|
|
|
2011-03-17 18:51:31 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_tracker_udp_upkeep(tr_session* session);
|
2011-03-17 18:51:31 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_tracker_udp_close(tr_session* session);
|
2011-03-17 18:51:31 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_tracker_udp_is_idle(tr_session const* session);
|