2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright © 2010-2022 Mnemosyne LLC.
|
2022-08-08 18:05:39 +00:00
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
|
2022-01-20 18:27:56 +00:00
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
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
|
|
|
|
|
2021-12-15 21:25:42 +00:00
|
|
|
#include <cstddef> // size_t
|
2022-04-08 01:50:26 +00:00
|
|
|
#include <cstdint> // uint32_t
|
2022-01-13 02:13:58 +00:00
|
|
|
#include <ctime>
|
|
|
|
#include <string_view>
|
2022-01-23 05:41:01 +00:00
|
|
|
#include <vector>
|
2021-12-15 21:25:42 +00:00
|
|
|
|
2009-09-25 21:05:59 +00:00
|
|
|
#include "transmission.h"
|
2021-12-15 21:25:42 +00:00
|
|
|
|
2022-01-09 16:55:09 +00:00
|
|
|
#include "interned-string.h"
|
2009-09-25 21:05:59 +00:00
|
|
|
|
|
|
|
struct tr_announcer;
|
2022-01-23 05:41:01 +00:00
|
|
|
struct tr_torrent_announcer;
|
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;
|
|
|
|
|
2022-04-21 14:28:38 +00:00
|
|
|
/** @brief Notification object to tell listeners about announce or scrape occurrences */
|
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 */
|
2021-12-23 17:16:05 +00:00
|
|
|
std::string_view text;
|
|
|
|
tr_interned_string announce_url;
|
2009-09-25 21:05:59 +00:00
|
|
|
|
|
|
|
/* for TR_TRACKER_PEERS */
|
2022-01-23 05:41:01 +00:00
|
|
|
std::vector<tr_pex> pex;
|
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
|
|
|
|
**/
|
|
|
|
|
2022-08-03 06:15:37 +00:00
|
|
|
struct tr_torrent_announcer* tr_announcerAddTorrent(tr_torrent* torrent, tr_tracker_callback callback, void* callback_data);
|
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
|
|
|
|
};
|
|
|
|
|
2022-09-07 16:04:28 +00:00
|
|
|
void tr_announcerAddBytes(tr_torrent*, int type, uint32_t n_bytes);
|
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
|
|
|
|
2022-08-03 06:15:37 +00:00
|
|
|
tr_tracker_view tr_announcerTracker(tr_torrent const* torrent, size_t nth);
|
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);
|