This file is indexed.

/usr/include/libktorrent/download/webseed.h is in libktorrent-dev 1.3.1-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/***************************************************************************
 *   Copyright (C) 2008 by Joris Guisson and Ivan Vasic                    *
 *   joris.guisson@gmail.com                                               *
 *   ivasic@gmail.com                                                      *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
 ***************************************************************************/
#ifndef BTWEBSEED_H
#define BTWEBSEED_H

#include <QTimer>
#include <kurl.h>
#include <ktorrent_export.h>
#include <util/constants.h>
#include <interfaces/webseedinterface.h>
#include <interfaces/chunkdownloadinterface.h>
#include <diskio/piecedata.h>
#include <peer/connectionlimit.h>



namespace bt
{
	class Torrent;
	class HttpConnection;
	class ChunkManager;
	class Chunk;
	class WebSeedChunkDownload;

	/**
		@author Joris Guisson
		Class which handles downloading from a webseed
	*/
	class KTORRENT_EXPORT WebSeed : public QObject,public WebSeedInterface
	{
		Q_OBJECT
	public:
		WebSeed(const KUrl & url,bool user,const Torrent & tor,ChunkManager & cman);
		virtual ~WebSeed();
		
		/// Is this webseed busy ?
		bool busy() const;
		
		/// Check if a chunk lies in the current range we are downloading
		bool inCurrentRange(Uint32 chunk) const {return chunk >= first_chunk && chunk <= last_chunk;}
		
		/**
		 * Download a range of chunks
		 * @param first The first chunk
		 * @param last The last chunk
		 */
		void download(Uint32 first,Uint32 last);
		
		/**
		 * A range has been excluded, if we are fully
		 * downloading in this range, reset.
		 * @param from Start of range
		 * @param to End of range
		 */
		void onExcluded(Uint32 from,Uint32 to);
		
		/**
		 * Check if the connection has received some data and handle it.
		 * @return The number of bytes downloaded
		 */
		Uint32 update();
		
		/**
		 * A chunk has been downloaded.
		 * @param chunk The chunk
		 */
		void chunkDownloaded(Uint32 chunk);
		
		/**
		* Cancel the current download and kill the connection
		*/
		void cancel();
		
		/// Get the current download rate
		Uint32 getDownloadRate() const;
		
			
		/**
		 * Set the group ID's of the http connection (for speed limits)
		 * @param up Upload group id
		 * @param down Download group id
		 */
		void setGroupIDs(Uint32 up,Uint32 down);
		
		
		/**
		 * Set the proxy to use for all WebSeeds
		 * @param host Hostname or IP address of the proxy
		 * @param port Port number of the proxy
		 */
		static void setProxy(const QString & host,bt::Uint16 port);
		
		/**
		 * Whether or not to enable or disable the use of a proxy.
		 * When the proxy is disabled, we will use the KDE proxy settings.
		 * @param on On or not
		 */
		static void setProxyEnabled(bool on);
		
		/// Get the current webseed download
		WebSeedChunkDownload* currentChunkDownload() {return current;}
		
		virtual void setEnabled(bool on);
		
		/// Disable the webseed 
		void disable(const QString & reason);
		
		/// Get the number of failed attempts
		Uint32 failedAttempts() const {return num_failures;}
		
	public slots:
		/**
		 * Reset the webseed (kills the connection)
		 */
		void reset();
		
	signals:
		/**
		 * Emitted when a chunk is downloaded
		 * @param c The chunk
		 */
		void chunkReady(Chunk* c);
		
		/**
		 * Emitted when a range has been fully downloaded
		 */
		void finished();
		
		/**
		 * A ChunkDownload was started
		 * @param cd The ChunkDownloadInterface
		 * @param chunk The chunk which is being started
		 */
		void chunkDownloadStarted(WebSeedChunkDownload* cd,Uint32 chunk);
		
		/**
		 * A ChunkDownload was finished
		 * @param cd The ChunkDownloadInterface
		 * @param chunk The chunk which is being stopped
		 */
		void chunkDownloadFinished(WebSeedChunkDownload* cd,Uint32 chunk);
		
	private slots:
		void redirected(const KUrl & to_url);
		
	private:
		struct Range
		{
			Uint32 file;
			Uint64 off;
			Uint64 len;
		};
		
		class AutoDisabled {}; // Exception
		
		void fillRangeList(Uint32 chunk);
		void handleData(const QByteArray & data);
		void chunkStarted(Uint32 chunk);
		void chunkStopped();
		void connectToServer();
		void continueCurChunk();
		void readData();
		void retryLater();
		
	private:
		const Torrent & tor;
		ChunkManager & cman;
		HttpConnection* conn;
		QList<QByteArray> chunks;
		Uint32 first_chunk;
		Uint32 last_chunk;
		Uint32 cur_chunk;
		Uint32 bytes_of_cur_chunk;
		Uint32 num_failures;
		Uint32 downloaded;
		WebSeedChunkDownload* current;
		Uint32 up_gid,down_gid;
		QList<Range> range_queue;
		KUrl redirected_url;
		PieceData::Ptr cur_piece;
		QTimer retry_timer;
		ConnectionLimit::Token::Ptr token;
		
		static QString proxy_host;
		static Uint16 proxy_port;
		static bool proxy_enabled;
	};
	
	class WebSeedChunkDownload : public ChunkDownloadInterface
	{
	public:
		WebSeedChunkDownload(WebSeed* ws,const QString & url,Uint32 index,Uint32 total);
		virtual ~WebSeedChunkDownload();
	
		virtual void getStats(Stats & s);
	
		WebSeed* ws;
		QString url;
		Uint32 chunk;
		Uint32 total_pieces;
		Uint32 pieces_downloaded;
	};

}

#endif