⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 session_impl.hpp

📁 LINUX下
💻 HPP
📖 第 1 页 / 共 2 页
字号:
			void set_peer_proxy(proxy_settings const& s)			{ m_peer_proxy = s; }			void set_web_seed_proxy(proxy_settings const& s)			{ m_web_seed_proxy = s; }			void set_tracker_proxy(proxy_settings const& s)			{ m_tracker_proxy = s; }			proxy_settings const& peer_proxy() const			{ return m_peer_proxy; }			proxy_settings const& web_seed_proxy() const			{ return m_web_seed_proxy; }			proxy_settings const& tracker_proxy() const			{ return m_tracker_proxy; }#ifndef TORRENT_DISABLE_DHT			void set_dht_proxy(proxy_settings const& s)			{ m_dht_proxy = s; }			proxy_settings const& dht_proxy() const			{ return m_dht_proxy; }#endif			void start_lsd();			void start_natpmp();			void start_upnp();			void stop_lsd();			void stop_natpmp();			void stop_upnp();			// handles delayed alerts			alert_manager m_alerts;			//		private:			void on_lsd_peer(tcp::endpoint peer, sha1_hash const& ih);			// this is where all active sockets are stored.			// the selector can sleep while there's no activity on			// them			io_service m_io_service;			asio::strand m_strand;			// the file pool that all storages in this session's			// torrents uses. It sets a limit on the number of			// open files by this session.			// file pool must be destructed after the torrents			// since they will still have references to it			// when they are destructed.			file_pool m_files;			// handles disk io requests asynchronously			disk_io_thread m_disk_thread;			// this is a list of half-open tcp connections			// (only outgoing connections)			// this has to be one of the last			// members to be destructed			connection_queue m_half_open;			// the bandwidth manager is responsible for			// handing out bandwidth to connections that			// asks for it, it can also throttle the			// rate.			bandwidth_manager<peer_connection, torrent> m_download_channel;			bandwidth_manager<peer_connection, torrent> m_upload_channel;			bandwidth_manager<peer_connection, torrent>* m_bandwidth_manager[2];			tracker_manager m_tracker_manager;			torrent_map m_torrents;			// this maps sockets to their peer_connection			// object. It is the complete list of all connected			// peers.			connection_map m_connections;						// filters incoming connections			ip_filter m_ip_filter;			// filters outgoing connections			port_filter m_port_filter;						// the peer id that is generated at the start of the session			peer_id m_peer_id;			// the key is an id that is used to identify the			// client with the tracker only. It is randomized			// at startup			int m_key;			// the range of ports we try to listen on			std::pair<int, int> m_listen_port_range;			// the ip-address of the interface			// we are supposed to listen on.			// if the ip is set to zero, it means			// that we should let the os decide which			// interface to listen on			tcp::endpoint m_listen_interface;						// this is typically set to the same as the local			// listen port. In case a NAT port forward was			// successfully opened, this will be set to the			// port that is open on the external (NAT) interface			// on the NAT box itself. This is the port that has			// to be published to peers, since this is the port			// the client is reachable through.			int m_external_listen_port;			boost::shared_ptr<socket_acceptor> m_listen_socket;			// the settings for the client			session_settings m_settings;			// the proxy settings for different			// kinds of connections			proxy_settings m_peer_proxy;			proxy_settings m_web_seed_proxy;			proxy_settings m_tracker_proxy;#ifndef TORRENT_DISABLE_DHT			proxy_settings m_dht_proxy;#endif			// set to true when the session object			// is being destructed and the thread			// should exit			volatile bool m_abort;			int m_max_uploads;			int m_max_connections;			// the number of unchoked peers			int m_num_unchoked;			// this is initialized to the unchoke_interval			// session_setting and decreased every second.			// when it reaches zero, it is reset to the			// unchoke_interval and the unchoke set is			// recomputed.			int m_unchoke_time_scaler;			// works like unchoke_time_scaler but it			// is only decresed when the unchoke set			// is recomputed, and when it reaches zero,			// the optimistic unchoke is moved to another peer.			int m_optimistic_unchoke_time_scaler;			// works like unchoke_time_scaler. Each time			// it reaches 0, and all the connections are			// used, the worst connection will be disconnected			// from the torrent with the most peers			int m_disconnect_time_scaler;			// statistics gathered from all torrents.			stat m_stat;			// is false by default and set to true when			// the first incoming connection is established			// this is used to know if the client is behind			// NAT or not.			bool m_incoming_connection;						void second_tick(asio::error_code const& e);			ptime m_last_tick;#ifndef TORRENT_DISABLE_DHT			boost::intrusive_ptr<dht::dht_tracker> m_dht;			dht_settings m_dht_settings;			// if this is set to true, the dht listen port			// will be set to the same as the tcp listen port			// and will be synchronlized with it as it changes			// it defaults to true			bool m_dht_same_port;						// see m_external_listen_port. This is the same			// but for the udp port used by the DHT.			int m_external_udp_port;#endif#ifndef TORRENT_DISABLE_ENCRYPTION			pe_settings m_pe_settings;#endif			boost::shared_ptr<natpmp> m_natpmp;			boost::shared_ptr<upnp> m_upnp;			boost::shared_ptr<lsd> m_lsd;			// the timer used to fire the second_tick			deadline_timer m_timer;			// the index of the torrent that will be offered to			// connect to a peer next time second_tick is called.			// This implements a round robin.			int m_next_connect_torrent;#ifndef NDEBUG			void check_invariant(const char *place = 0);#endif#ifdef TORRENT_STATS			// logger used to write bandwidth usage statistics			std::ofstream m_stats_logger;			int m_second_counter;#endif#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)			boost::shared_ptr<logger> create_log(std::string const& name				, int instance, bool append = true);						// this list of tracker loggers serves as tracker_callbacks when			// shutting down. This list is just here to keep them alive during			// whe shutting down process			std::list<boost::shared_ptr<tracker_logger> > m_tracker_loggers;		public:			boost::shared_ptr<logger> m_logger;		private:#endif#ifndef TORRENT_DISABLE_EXTENSIONS			typedef std::list<boost::function<boost::shared_ptr<				torrent_plugin>(torrent*)> > extension_list_t;			extension_list_t m_extensions;#endif			// data shared between the main thread			// and the checker thread			checker_impl m_checker_impl;			// the main working thread			boost::scoped_ptr<boost::thread> m_thread;			// the thread that calls initialize_pieces()			// on all torrents before they start downloading			boost::scoped_ptr<boost::thread> m_checker_thread;		};		#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)		struct tracker_logger : request_callback		{			tracker_logger(session_impl& ses): m_ses(ses) {}			void tracker_warning(std::string const& str)			{				debug_log("*** tracker warning: " + str);			}			void tracker_response(tracker_request const&				, std::vector<peer_entry>& peers				, int interval				, int complete				, int incomplete)			{				std::stringstream s;				s << "TRACKER RESPONSE:\n"					"interval: " << interval << "\n"					"peers:\n";				for (std::vector<peer_entry>::const_iterator i = peers.begin();					i != peers.end(); ++i)				{					s << "  " << std::setfill(' ') << std::setw(16) << i->ip						<< " " << std::setw(5) << std::dec << i->port << "  ";					if (!i->pid.is_all_zeros()) s << " " << i->pid;					s << "\n";				}				debug_log(s.str());			}			void tracker_request_timed_out(				tracker_request const&)			{				debug_log("*** tracker timed out");			}			void tracker_request_error(				tracker_request const&				, int response_code				, const std::string& str)			{				debug_log(std::string("*** tracker error: ")					+ boost::lexical_cast<std::string>(response_code) + ": "					+ str);			}						void debug_log(const std::string& line)			{				(*m_ses.m_logger) << line << "\n";			}			session_impl& m_ses;		};#endif	}}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -