public void PauseResumeSession() { if (_torrentSession.is_paused()) { _torrentSession.resume(); } else { _torrentSession.pause(); } }
public TsunamiViewModel() { Settings.Logger.Inizialize(); _preference = new Models.Preferences(); _torrentList = new ObservableCollection <Models.TorrentItem>(); System.Windows.Data.BindingOperations.EnableCollectionSynchronization(TorrentList, _lock); _sessionStatistic = new SessionStatistics(); IsTsunamiEnabled = false; //_notifyIcon = new Models.NotifyIcon(); _torrentSession = new Core.Session(); CoreLog.Debug("created"); if (System.IO.File.Exists(".session_state")) { var data = System.IO.File.ReadAllBytes(".session_state"); using (var entry = Core.Util.lazy_bdecode(data)) { _torrentSession.load_state(entry); } } CoreLog.Debug("session_state loaded. pausing"); _torrentSession.pause(); Core.SessionSettings ss = _torrentSession.settings(); //ss.connections_limit = 500; // 200 //ss.tick_interval = 250; // 500 //ss.torrent_connect_boost = 20; // 10 //ss.connection_speed = -1; // -1 = 200 ; default 10 //ss.num_want = 400; // 200 //ss.cache_size = -1; // -1 = 1/8 RAM; default 1024 //ss.coalesce_reads = true; // false //ss.coalesce_writes = true; // false string ua = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Major.ToString() + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString() + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Build.ToString(); ss.user_agent = string.Format(Tsunami.Settings.Application.TSUNAMI_USER_AGENT, ua); log.Debug("using user agent {0}", ss.user_agent); // from qbit torrent ss.upnp_ignore_nonrouters = true; ss.use_dht_as_fallback = false; ss.ssl_listen = 0; // Disable support for SSL torrents for now ss.lazy_bitfields = true; // To prevent ISPs from blocking seeding ss.stop_tracker_timeout = 1; // Speed up exit ss.auto_scrape_interval = 1200; // 20 minutes ss.announce_to_all_trackers = true; // from pref->announceToAllTrackers(); ss.announce_to_all_tiers = true; // from pref->announceToAllTrackers(); ss.auto_scrape_min_interval = 900; // 15 minutes ss.cache_size = -1; ss.cache_expiry = 60; ss.disk_io_read_mode = 0; // enable_os_cache ss.anonymous_mode = false; ss.active_seeds = 3; // MaxActiveUploads ss.dont_count_slow_torrents = false; ss.active_downloads = 3; // MaxActiveDownloads + m_extraLimit ss.active_limit = 5; // MaxActiveTorrents + m_extraLimit ss.active_tracker_limit = -1; ss.active_dht_limit = -1; ss.active_lsd_limit = -1; ss.ignore_limits_on_local_network = true; // Ignore limits on LAN ss.rate_limit_ip_overhead = false; // Include overhead in transfer limits //ss.announce_ip = Utils::String::toStdString(pref->getNetworkAddress()); // IP address to announce to trackers ss.strict_super_seeding = false; // Super seeding ss.half_open_limit = 20; // * Max Half-open connections ss.connections_limit = 500; // * Max connections limit ss.unchoke_slots_limit = -1; // * Global max upload slots ss.enable_incoming_utp = true; // uTP ss.enable_outgoing_utp = true; // uTP ss.rate_limit_utp = true; // uTP rate limiting ss.mixed_mode_algorithm = 0; // prefer_tcp ss.connection_speed = 20; //default is 10 ss.no_connect_privileged_ports = false; ss.seed_choking_algorithm = 1; // fastest_upload ss.apply_ip_filter_to_trackers = false; // FilterTracker _torrentSession.set_settings(ss); // MISSING ENCRYPTION // libt::pe_settings encryptionSettings; (835 of session.cpp) Core.DhtSettings dhts = _torrentSession.get_dht_settings(); //dhts.aggressive_lookups = true; _torrentSession.set_dht_settings(dhts); var alertMask = Core.AlertMask.error_notification | Core.AlertMask.peer_notification | Core.AlertMask.port_mapping_notification | Core.AlertMask.storage_notification | Core.AlertMask.tracker_notification | Core.AlertMask.status_notification | Core.AlertMask.ip_block_notification | Core.AlertMask.progress_notification | Core.AlertMask.stats_notification | Core.AlertMask.dht_notification ; _torrentSession.set_alert_mask(alertMask); _torrentSession.set_alert_callback(HandlePendingAlertCallback); _torrentSession.set_session_callback(HandleAlertCallback); if (Settings.Application.DISPATCHER_INTERVAL < 500) { log.Warn("DISPATCHER_INTERVAL {0} should not be lower than 500", Settings.Application.DISPATCHER_INTERVAL); } _dispatcherTimer.Elapsed += new System.Timers.ElapsedEventHandler(dispatcherTimer_Tick); _dispatcherTimer.Interval = Settings.Application.DISPATCHER_INTERVAL; _dispatcherTimer.Start(); LoadFastResumeData(); _torrentSession.start_natpmp(); _torrentSession.start_upnp(); _torrentSession.start_dht(); _torrentSession.start_lsd(); _torrentSession.resume(); log.Info("created"); //Dht = new Core.AdunanzaDht(); //Dht.start(); //Dht.bootstrap("bootstrap.ring.cx", "4222"); }