This file is indexed.

/usr/include/libktorrent/net/trafficshapedsocket.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
/***************************************************************************
 *   Copyright (C) 2011 by Joris Guisson                                   *
 *   joris.guisson@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 NET_TRAFFICSHAPEDSOCKET_H
#define NET_TRAFFICSHAPEDSOCKET_H

#include <QMutex>
#include <net/socketdevice.h>
#include <util/constants.h>

namespace net 
{
	class Speed;
	
	class SocketReader
	{
	public:
		SocketReader() {}
		virtual ~SocketReader() {}
		
		/**
		 * Function which will be called whenever data has been read from the socket.
		 * This data should be dealt with, otherwise it will be discarded.
		 * @param buf The buffer
		 * @param size The size of the buffer
		 */
		virtual void onDataReady(bt::Uint8* buf, bt::Uint32 size) = 0;	
	};

	/**
	 * Socket which supports traffic shaping
	 */
	class  TrafficShapedSocket
	{
	public:
		TrafficShapedSocket(SocketDevice* sock);
		TrafficShapedSocket(int fd,int ip_version);
		TrafficShapedSocket(bool tcp,int ip_version);
		virtual ~TrafficShapedSocket();
		
		/// Get the SocketDevice
		SocketDevice* socketDevice() {return sock;}
		
		/// Get the SocketDevice (const vesion)
		const SocketDevice* socketDevice() const {return sock;}
		
		/// Set the reader
		void setReader(SocketReader* r) {rdr = r;}
		
		/**
		 * Reads data from the socket and pass it to the SocketReader.
		 * @param max_bytes_to_read Maximum number of bytes to read (0 is no limit)
		 * @param now Current time stamp
		 * @return The number of bytes read
		 */
		virtual Uint32 read(Uint32 max_bytes_to_read, bt::TimeStamp now);
		
		/**
		 * Writes data to the socket. Subclasses should implement the data source.
		 * @param max The maximum number of bytes to send over the socket (0 = no limit)
		 * @param now Current time stamp
		 * @return The number of bytes written
		 */
		virtual Uint32 write(Uint32 max, bt::TimeStamp now) = 0;
		
		/// See if the socket has something ready to write
		virtual bool bytesReadyToWrite() const = 0;
		
		/// Get the current download rate
		int getDownloadRate() const;
		
		/// Get the current download rate
		int getUploadRate() const;
		
		/// Update up and down speed
		void updateSpeeds(bt::TimeStamp now);
		
		/**
		 * Set the group ID of the socket
		 * @param gid THe ID (0 is default group)
		 * @param upload Whether this is an upload group or a download group
		 */
		void setGroupID(Uint32 gid,bool upload);
		
		/// Get the download group ID
		Uint32 downloadGroupID() const {return down_gid;}
		
		/// Get the upload group ID
		Uint32 uploadGroupID() const {return up_gid;}
	protected:
		/**
		 * Post process received data. Default implementation does nothing.
		 * @param data The data
		 * @param size The size of the data
		 **/
		virtual void postProcess(bt::Uint8* data, bt::Uint32 size);
		
	protected:
		SocketReader* rdr;
		Speed* down_speed;
		Speed* up_speed;
		Uint32 up_gid;
		Uint32 down_gid; // group id which this torrent belongs to, group 0 means the default group
		SocketDevice* sock;
		mutable QMutex mutex;
	};

}

#endif // NET_TRAFFICSHAPEDSOCKET_H