コード例 #1
0
LRESULT FavoriteHubsFrame::onClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
	if (!m_closed)
	{
		m_closed = true;
#ifdef IRAINMAN_ENABLE_CON_STATUS_ON_FAV_HUBS
		safe_destroy_timer();
#endif
		ClientManager::getInstance()->removeListener(this);
		SettingsManager::getInstance()->removeListener(this);
		FavoriteManager::getInstance()->removeListener(this);
		WinUtil::setButtonPressed(IDC_FAVORITES, false);
		PostMessage(WM_CLOSE);
		return 0;
	}
	else
	{
		WinUtil::saveHeaderOrder(ctrlHubs, SettingsManager::FAVORITESFRAME_ORDER,
		                         SettingsManager::FAVORITESFRAME_WIDTHS, COLUMN_LAST, columnIndexes, columnSizes);
		                         
		SET_SETTING(HUBS_FAVORITES_COLUMNS_SORT, ctrlHubs.getSortColumn());
		SET_SETTING(HUBS_FAVORITES_COLUMNS_SORT_ASC, ctrlHubs.isAscending());
		bHandled = FALSE;
		return 0;
	}
}
コード例 #2
0
LRESULT RSSNewsFrame::onClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{

	if (!m_closed)
	{
		m_closed = true;
		RSSManager::getInstance()->removeListener(this);
		SettingsManager::getInstance()->removeListener(this);
		WinUtil::setButtonPressed(IDC_RSS, false);
		PostMessage(WM_CLOSE);
		return 0;
	}
	else
	{
		ctrlList.saveHeaderOrder(SettingsManager::RSS_COLUMNS_ORDER, SettingsManager::RSS_COLUMNS_WIDTHS, SettingsManager::RSS_COLUMNS_VISIBLE);
		
		SET_SETTING(RSS_COLUMNS_SORT, ctrlList.getRealSortColumn());
		SET_SETTING(RSS_COLUMNS_SORT_ASC, ctrlList.isAscending());
		
		ctrlList.DeleteAndCleanAllItems();
		
		bHandled = FALSE;
		return 0;
	}
}
コード例 #3
0
ファイル: SpyFrame.cpp プロジェクト: craxycat/flylinkdc-r5xx
LRESULT SpyFrame::onClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
	ClientManager::g_isSpyFrame = false;
	if (!m_closed)
	{
		m_closed = true;
		safe_destroy_timer();
		clear_and_destroy_task();
		if (m_log)
		{
			PostMessage(WM_SPEAKER, SAVE_LOG, (LPARAM)NULL);
		}
		ClientManager::getInstance()->removeListener(this);
		SettingsManager::getInstance()->removeListener(this);
		bHandled = TRUE;
		PostMessage(WM_CLOSE);
		return 0;
	}
	else
	{
		WinUtil::saveHeaderOrder(ctrlSearches, SettingsManager::SPYFRAME_ORDER, SettingsManager::SPYFRAME_WIDTHS, COLUMN_LAST, columnIndexes, columnSizes);
		//ctrlSearches.saveHeaderOrder(SettingsManager::SPYFRAME_ORDER, SettingsManager::SPYFRAME_WIDTHS, SettingsManager::SPYFRAME_VISIBLE); // !SMT!-UI
		
		SET_SETTING(SEARCH_SPY_COLUMNS_SORT, ctrlSearches.getSortColumn());
		SET_SETTING(SEARCH_SPY_COLUMNS_SORT_ASC, ctrlSearches.isAscending());
		
		SET_SETTING(SPY_FRAME_IGNORE_TTH_SEARCHES, m_ignoreTTH);
		SET_SETTING(SHOW_SEEKERS_IN_SPY_FRAME, m_showNick);
		SET_SETTING(LOG_SEEKERS_IN_SPY_FRAME, m_LogFile);
		safe_delete(m_log);
		WinUtil::setButtonPressed(IDC_SEARCH_SPY, false);
		bHandled = FALSE;
		return 0;
	}
}
コード例 #4
0
void ConnectivityManager::test_all_ports()
{
	if (SETTING(INCOMING_CONNECTIONS) != SettingsManager::INCOMING_FIREWALL_PASSIVE && !ClientManager::isBeforeShutdown())
	{
		// Test Port
		string l_external_ip;
		std::vector<unsigned short> l_udp_port, l_tcp_port;
		l_udp_port.push_back(SETTING(UDP_PORT));
#ifdef STRONG_USE_DHT
		l_udp_port.push_back(SETTING(DHT_PORT));
#endif
		l_tcp_port.push_back(SETTING(TCP_PORT));
		l_tcp_port.push_back(SETTING(TLS_PORT));
		if (CFlyServerJSON::pushTestPort(l_udp_port, l_tcp_port, l_external_ip, 0,
#ifdef STRONG_USE_DHT
		                                 "UDP+DHT+TCP+TLS"
#else
		                                 "UDP+TCP+TLS"
#endif
		                                ))
		{
			if (!l_external_ip.empty())
			{
				if (!BOOLSETTING(WAN_IP_MANUAL))
				{
					SET_SETTING(EXTERNAL_IP, l_external_ip);
				}
			}
		}
	}
}
コード例 #5
0
void UpdatePage::write()
{
	PropPage::write(*this, items, listItems, GetDlgItem(IDC_AUTOUPDATE_LIST));
	PropPage::write(*this, NULL, listComponents, GetDlgItem(IDC_AUTOUPDATE_COMPONENTS));
	ctrlTime.Attach(GetDlgItem(IDC_AUTOUPDATE_AT));
	SET_SETTING(AUTOUPDATE_TIME, ctrlTime.GetCurSel());
	ctrlTime.Detach();
}
コード例 #6
0
void DCLSTPage::write()
{
	PropPage::write(*this, items);
	SET_SETTING(DCLST_CREATE_IN_SAME_FOLDER,    IsDlgButtonChecked(IDC_DCLS_CREATE_IN_FOLDER) == BST_CHECKED);
	magnetClick.Attach(GetDlgItem(IDC_DCLST_CLICK));
	g_settings->set(SettingsManager::DCLST_ACTION, magnetClick.GetCurSel());
	magnetClick.Detach();
	
}
コード例 #7
0
LRESULT PublicHubsFrame::onClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
	if (!m_closed)
	{
		m_closed = true;
		SettingsManager::getInstance()->removeListener(this);
		WinUtil::setButtonPressed(ID_FILE_CONNECT, false);
		PostMessage(WM_CLOSE);
		return 0;
	}
	else
	{
		WinUtil::saveHeaderOrder(m_ctrlHubs, SettingsManager::PUBLICHUBSFRAME_ORDER,
		                         SettingsManager::PUBLICHUBSFRAME_WIDTHS, COLUMN_LAST, columnIndexes, columnSizes);
		SET_SETTING(HUBS_PUBLIC_COLUMNS_SORT, m_ctrlHubs.getSortColumn());
		SET_SETTING(HUBS_PUBLIC_COLUMNS_SORT_ASC, m_ctrlHubs.isAscending());
		SET_SETTING(FLYSERVER_HUBLIST_SPLIT, m_nProportionalPos);
		bHandled = FALSE;
		return 0;
	}
}
コード例 #8
0
ファイル: RecentsFrm.cpp プロジェクト: snarkus/flylinkdc-r5xx
LRESULT RecentHubsFrame::onClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
	if (!m_closed)
	{
		m_closed = true;
		FavoriteManager::getInstance()->removeListener(this);
		SettingsManager::getInstance()->removeListener(this);
		WinUtil::setButtonPressed(IDC_RECENTS, false);
		PostMessage(WM_CLOSE);
		return 0;
	}
	else
	{
		WinUtil::saveHeaderOrder(ctrlHubs, SettingsManager::RECENTFRAME_ORDER,
		                         SettingsManager::RECENTFRAME_WIDTHS, COLUMN_LAST, columnIndexes, columnSizes);
		                         
		SET_SETTING(HUBS_RECENTS_COLUMNS_SORT, ctrlHubs.getSortColumn());
		SET_SETTING(HUBS_RECENTS_COLUMNS_SORT_ASC, ctrlHubs.isAscending());
		bHandled = FALSE;
		return 0;
	}
}
コード例 #9
0
void ConnectivityManager::mappingFinished(const string& p_mapper)
{
	if (!ClientManager::isBeforeShutdown())
	{
		if (BOOLSETTING(AUTO_DETECT_CONNECTION))
		{
			if (p_mapper.empty())
			{
				//StrongDC++: don't disconnect when mapping fails else DHT and active mode in favorite hubs won't work
				//disconnect();
				SET_SETTING(INCOMING_CONNECTIONS, SettingsManager::INCOMING_FIREWALL_PASSIVE);
				SET_SETTING(ALLOW_NAT_TRAVERSAL, true);
				log(STRING(AUTOMATIC_SETUP_ACTIV_MODE_FAILED));
			}
#ifdef FLYLINKDC_BETA
			else
			{
				if (!MappingManager::getExternaIP().empty() && Util::isPrivateIp(MappingManager::getExternaIP()))
				{
					SET_SETTING(INCOMING_CONNECTIONS, SettingsManager::INCOMING_FIREWALL_PASSIVE);
					SET_SETTING(ALLOW_NAT_TRAVERSAL, true);
					const string l_error = "Auto passive mode: Private IP = " + MappingManager::getExternaIP();
					log(l_error);
					CFlyServerJSON::pushError(29, l_error);
				}
			}
#endif
			// FLYLINKDC_USE_DEAD_CODE fly_fire1(ConnectivityManagerListener::Finished());
		}
		log(getInformation());
		SET_SETTING(MAPPER, p_mapper);
		if (!p_mapper.empty())
		{
			test_all_ports();
		}
	}
	g_is_running = false;
}
コード例 #10
0
LRESULT UsersFrame::onClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
	if (!m_closed)
	{
		m_closed = true;
		FavoriteManager::getInstance()->removeListener(this);
		SettingsManager::getInstance()->removeListener(this);
		//WinUtil::UnlinkStaticMenus(usersMenu); // !SMT!-S
		WinUtil::setButtonPressed(IDC_FAVUSERS, false);
		PostMessage(WM_CLOSE);
		return 0;
	}
	else
	{
		ctrlUsers.saveHeaderOrder(SettingsManager::USERSFRAME_ORDER, SettingsManager::USERSFRAME_WIDTHS, SettingsManager::USERSFRAME_VISIBLE); // !SMT!-UI
		SET_SETTING(USERS_COLUMNS_SORT, ctrlUsers.getSortColumn());
		SET_SETTING(USERS_COLUMNS_SORT_ASC, ctrlUsers.isAscending());
		ctrlUsers.DeleteAndCleanAllItems();
		
		bHandled = FALSE;
		return 0;
	}
}
コード例 #11
0
LRESULT WaitingUsersFrame::onClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
	if (!m_closed)
	{
		m_closed = true;
		safe_destroy_timer();
		clear_and_destroy_task();
		UploadManager::getInstance()->removeListener(this);
		SettingsManager::getInstance()->removeListener(this);
		WinUtil::setButtonPressed(IDC_UPLOAD_QUEUE, false);
		
		PostMessage(WM_CLOSE);
		return 0;
	}
	else
	{
		HTREEITEM userNode = ctrlQueued.GetRootItem();
		
		while (userNode)
		{
			delete reinterpret_cast<UserItem *>(ctrlQueued.GetItemData(userNode));
			userNode = ctrlQueued.GetNextSiblingItem(userNode);
		}
		m_ctrlList.DeleteAllItems();
		UQFUsers.clear();
		SET_SETTING(UPLOADQUEUEFRAME_SHOW_TREE, ctrlShowTree.GetCheck() == BST_CHECKED);
		m_ctrlList.saveHeaderOrder(SettingsManager::UPLOADQUEUEFRAME_ORDER, SettingsManager::UPLOADQUEUEFRAME_WIDTHS,
		                           SettingsManager::UPLOADQUEUEFRAME_VISIBLE);
		                           
		SET_SETTING(UPLOAD_QUEUE_COLUMNS_SORT, m_ctrlList.getSortColumn());
		SET_SETTING(UPLOAD_QUEUE_COLUMNS_SORT_ASC, m_ctrlList.isAscending());
		SET_SETTING(UPLOADQUEUEFRAME_SPLIT, m_nProportionalPos);
		
		bHandled = FALSE;
		return 0;
	}
}
コード例 #12
0
void OperaColorsPage::write()
{
	PropPage::write(*this, items, listItems, GetDlgItem(IDC_OPERACOLORS_BOOLEANS));
	PropPage::write(*this, items);
	
	// Do specialized writing here
	// settings->set(XX, YY);
	SET_SETTING(MENUBAR_LEFT_COLOR, (int)crMenubarLeft);
	SET_SETTING(MENUBAR_RIGHT_COLOR, (int)crMenubarRight);
	SET_SETTING(MENUBAR_BUMPED, getCheckbox(IDC_SETTINGS_ODC_MENUBAR_BUMPED));
	SET_SETTING(MENUBAR_TWO_COLORS, getCheckbox(IDC_SETTINGS_ODC_MENUBAR_USETWO));
	
	SET_SETTING(DOWNLOAD_BAR_COLOR, (int)crProgressDown);
	SET_SETTING(UPLOAD_BAR_COLOR, (int)crProgressUp);
	SET_SETTING(PROGRESS_TEXT_COLOR_DOWN, (int)crProgressTextDown);
	SET_SETTING(PROGRESS_TEXT_COLOR_UP, (int)crProgressTextUp);
	
	OperaColors::ClearCache();
}
コード例 #13
0
LRESULT FavoriteHubsFrame::onRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	if (ctrlHubs.GetSelectedCount())
	{
		int i = -1;
		UINT checkState = BOOLSETTING(CONFIRM_HUB_REMOVAL) ? BST_UNCHECKED : BST_CHECKED; // [+] InfinitySky.
		if (checkState == BST_CHECKED || ::MessageBox(m_hWnd, CTSTRING(REALLY_REMOVE), T_APPNAME_WITH_VERSION, CTSTRING(DONT_ASK_AGAIN), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON1, checkState) == IDYES) // [~] InfinitySky.
		{
			while ((i = ctrlHubs.GetNextItem(-1, LVNI_SELECTED)) != -1)
			{
				FavoriteManager::getInstance()->removeFavorite((FavoriteHubEntry*)ctrlHubs.GetItemData(i));
			}
		}
		// Let's update the setting unchecked box means we bug user again...
		SET_SETTING(CONFIRM_HUB_REMOVAL, checkState != BST_CHECKED); // [+] InfinitySky.
	}
	return 0;
}
コード例 #14
0
LRESULT UsersFrame::onRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	if (ctrlUsers.getSelectedCount())
	{
		int i = -1;
		UINT checkState = BOOLSETTING(CONFIRM_USER_REMOVAL) ? BST_UNCHECKED : BST_CHECKED;
		if (checkState == BST_CHECKED || ::MessageBox(m_hWnd, CTSTRING(REALLY_REMOVE), T_APPNAME_WITH_VERSION, CTSTRING(DONT_ASK_AGAIN), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON1, checkState) == IDYES)
		{
			while ((i = ctrlUsers.GetNextItem(-1, LVNI_SELECTED)) != -1)
			{
				ctrlUsers.getItemData(i)->remove();
			}
		}
		// Let's update the setting unchecked box means we bug user again...
		SET_SETTING(CONFIRM_USER_REMOVAL, checkState != BST_CHECKED);
	}
	return 0;
}
コード例 #15
0
ファイル: PropPage.cpp プロジェクト: craxycat/flylinkdc-r5xx
void PropPage::write(HWND page, Item const* items, ListItem* listItems /* = NULL */, HWND list /* = NULL */)
{
#ifdef _DEBUG
	m_check_read_write--;
#endif
	dcassert(page != NULL);
	
	bool l_showUserWarning = false;// [+] IRainman
	
	if (items != NULL) // [+] SSA
	{
		for (Item const* i = items; i->type != T_END; ++i)
		{
			tstring buf;
			switch (i->type)
			{
				case T_STR:
				{
					WinUtil::GetDlgItemText(page, i->itemID, buf);
					l_showUserWarning |= g_settings->set(SettingsManager::StrSetting(i->setting), Text::fromT(buf));// [!] IRainman
					// Crash https://crash-server.com/Problem.aspx?ClientID=ppa&ProblemID=78416
					break;
				}
				case T_INT:
				{
					WinUtil::GetDlgItemText(page, i->itemID, buf);
					l_showUserWarning |= g_settings->set(SettingsManager::IntSetting(i->setting), Util::toInt(buf));// [!] IRainman
					break;
				}
				case T_BOOL:
				{
					if (GetDlgItem(page, i->itemID) == NULL)
					{
						// Control not exist ? Why ??
						dcassert(0);
						throw;
					}
					if (::IsDlgButtonChecked(page, i->itemID) == BST_CHECKED)
						l_showUserWarning |= g_settings->set(SettingsManager::IntSetting(i->setting), true);// [!] IRainman
					else
						l_showUserWarning |= g_settings->set((SettingsManager::IntSetting)i->setting, false);// [!] IRainman
					break;
				}
				case T_END:
					dcassert(0);
					break;
			}
		}
	}
	
	if (listItems != NULL)
	{
		CListViewCtrl ctrl;
		ctrl.Attach(list);
		
		for (int i = 0; listItems[i].setting != 0; i++)
		{
			l_showUserWarning |= SET_SETTING(IntSetting(listItems[i].setting), ctrl.GetCheckState(i));// [!] IRainman
		}
		
		ctrl.Detach();
	}
#ifdef _DEBUG
	if (l_showUserWarning)
	{
		MessageBox(page, _T("Values of the changed settings are automatically adjusted"), CTSTRING(WARNING), MB_OK);
	}
#endif
}
コード例 #16
0
void getGeneralSettings(JSON::Object& obj, IDatabase *db, ServerSettings &settings)
{
#define SET_SETTING(x) obj.set(#x, settings.getSettings()->x);

	SET_SETTING(backupfolder);
	SET_SETTING(no_images);
	SET_SETTING(no_file_backups);
	SET_SETTING(autoshutdown);
	SET_SETTING(autoupdate_clients);
	SET_SETTING(max_sim_backups);
	SET_SETTING(max_active_clients);
	SET_SETTING(cleanup_window);
	SET_SETTING(backup_database);
	SET_SETTING(internet_server);
	SET_SETTING(internet_server_port);
	SET_SETTING(global_local_speed);
	SET_SETTING(global_soft_fs_quota);
	SET_SETTING(global_internet_speed);
	SET_SETTING(use_tmpfiles);
	SET_SETTING(use_tmpfiles_images);
	SET_SETTING(tmpdir);
	SET_SETTING(local_full_file_transfer_mode);
	SET_SETTING(internet_full_file_transfer_mode);
	SET_SETTING(local_incr_file_transfer_mode);
	SET_SETTING(internet_incr_file_transfer_mode);
	SET_SETTING(local_image_transfer_mode);
	SET_SETTING(internet_image_transfer_mode);
	SET_SETTING(file_hash_collect_amount);
	SET_SETTING(file_hash_collect_timeout);
	SET_SETTING(file_hash_collect_cachesize);
	SET_SETTING(update_stats_cachesize);

#undef SET_SETTING
}
コード例 #17
0
JSON::Object getJSONClientSettings(ServerSettings &settings)
{
	JSON::Object ret;
#define SET_SETTING(x) ret.set(#x, settings.getSettings()->x);
	SET_SETTING(update_freq_incr);
	SET_SETTING(update_freq_full);
	SET_SETTING(update_freq_image_full);
	SET_SETTING(update_freq_image_incr);
	SET_SETTING(max_file_incr);
	SET_SETTING(min_file_incr);
	SET_SETTING(max_file_full);
	SET_SETTING(min_file_full);
	SET_SETTING(min_image_incr);
	SET_SETTING(max_image_incr);
	SET_SETTING(min_image_full);
	SET_SETTING(max_image_full);
	SET_SETTING(allow_overwrite);
	SET_SETTING(startup_backup_delay);
	SET_SETTING(backup_window);
	SET_SETTING(computername);
	SET_SETTING(exclude_files);
	SET_SETTING(include_files);
	SET_SETTING(default_dirs);
	SET_SETTING(allow_config_paths);
	SET_SETTING(allow_starting_file_backups);
	SET_SETTING(allow_starting_image_backups);
	SET_SETTING(allow_pause);
	SET_SETTING(allow_log_view);
	SET_SETTING(image_letters);
	SET_SETTING(internet_authkey);
	SET_SETTING(client_set_settings);
	SET_SETTING(internet_speed);
	SET_SETTING(local_speed);
	SET_SETTING(internet_mode_enabled);
	SET_SETTING(internet_compress);
	SET_SETTING(internet_encrypt);
	SET_SETTING(internet_image_backups);
	SET_SETTING(internet_full_file_backups);
	SET_SETTING(silent_update);
#undef SET_SETTING
	return ret;
}
コード例 #18
0
void ConnectivityManager::listen() // TODO - fix copy-paste
{
	const bool l_is_manual_connection = !BOOLSETTING(AUTO_DETECT_CONNECTION) && SETTING(INCOMING_CONNECTIONS) == SettingsManager::INCOMING_FIREWALL_NAT;
	string l_exceptions;
	for (int i = 0; i < 5; ++i)
	{
		try
		{
			ConnectionManager::getInstance()->start_tcp_tls_listener();
		}
		catch (const SocketException& e)
		{
			if (!l_is_manual_connection)
			{
				if (e.getErrorCode() == 10048)
				{
					if (i == 0)
					{
						SET_SETTING(TCP_PORT, 0);
						LogManager::message("Try bind free TCP Port");
						continue;
					}
					SettingsManager::generateNewTCPPort();
					LogManager::message("Try bind random TCP Port = " + Util::toString(SETTING(TCP_PORT)));
					continue;
				}
			}
			l_exceptions += " * TCP/TLS listen TCP Port = " + Util::toString(SETTING(TCP_PORT)) + " error = " + e.getError() + "\r\n";
			if (l_is_manual_connection)
			{
				::MessageBox(nullptr, Text::toT(l_exceptions).c_str(), getFlylinkDCAppCaptionWithVersionT().c_str(), MB_OK | MB_ICONERROR);
			}
		}
		break;
	}
	for (int j = 0; j < 2; ++j)
	{
		try
		{
			SearchManager::getInstance()->listen();
		}
		catch (const SocketException& e)
		{
			if (!l_is_manual_connection)
			{
				if (e.getErrorCode() == 10048)
				{
					if (j == 0)
					{
						SET_SETTING(UDP_PORT, 0);
						LogManager::message("Try bind free UDP Port");
						continue;
					}
					SettingsManager::generateNewUDPPort();
					LogManager::message("Try bind random UDP Port = " + Util::toString(SETTING(UDP_PORT)));
					continue;
				}
			}
			l_exceptions += " * UDP listen UDP Port = " + Util::toString(SETTING(UDP_PORT))  + " error = " + e.getError() + "\r\n";
			if (l_is_manual_connection)
			{
				::MessageBox(nullptr, Text::toT(l_exceptions).c_str(), getFlylinkDCAppCaptionWithVersionT().c_str(), MB_OK | MB_ICONERROR);
			}
		}
		catch (const Exception& e)
		{
			l_exceptions += " * UDP listen UDP Port = " + Util::toString(SETTING(UDP_PORT)) + " error = " + e.getError() + "\r\n";
		}
		break;
	}
	
#ifdef STRONG_USE_DHT
	try
	{
		if (dht::DHT::getInstance()->getPort() &&  dht::DHT::getInstance()->getPort() != SETTING(DHT_PORT))
		{
			// TODO dht::DHT::getInstance()->stop(); это не пашет - нужно разрушение
		}
		dht::DHT::getInstance()->start();
	}
	catch (const Exception& e)
	{
		l_exceptions += " * DHT listen UDP Port = " + Util::toString(SETTING(DHT_PORT)) + " error = " + e.getError() + "\r\n";
	}
#endif
	if (!l_exceptions.empty())
	{
		throw Exception("ConnectivityManager::listen() error:\r\n" + l_exceptions);
	}
}
コード例 #19
0
void ConnectivityManager::detectConnection()
{
	if (g_is_running)
		return;
	g_is_running = true;
	
	g_status.clear();
	// FLYLINKDC_USE_DEAD_CODE fly_fire1(ConnectivityManagerListener::Started());
	
	const string l_old_bind = SETTING(BIND_ADDRESS);
	// restore connectivity settings to their default value.
	if (!BOOLSETTING(WAN_IP_MANUAL))
	{
		SettingsManager::unset(SettingsManager::EXTERNAL_IP);
	}
	SettingsManager::unset(SettingsManager::BIND_ADDRESS);
	if (MappingManager::getInstance()->getOpened())
	{
		MappingManager::getInstance()->close();
	}
	
	disconnect();
	
	// FlylinkDC Team TODO: Need to check whether crowned with success port mapping via UPnP.
	// For direct connection, you must run the same test that the outside world can not connect to port!
	// ps: need to migrate this functionality from the wizard here!
	
	log(STRING(DETERMIN_CON_TYPE));
	SET_SETTING(INCOMING_CONNECTIONS, SettingsManager::INCOMING_FIREWALL_PASSIVE);
	try
	{
		listen();
	}
	catch (const Exception& e)
	{
		SET_SETTING(ALLOW_NAT_TRAVERSAL, true);
		SET_SETTING(BIND_ADDRESS, l_old_bind);
		
		AutoArray<char> buf(512);
		_snprintf(buf.data(), 512, CSTRING(UNABLE_TO_OPEN_PORT), e.getError().c_str());
		log(buf.data());
		// FLYLINKDC_USE_DEAD_CODE fly_fire1(ConnectivityManagerListener::Finished());
		g_is_running = false;
		return;
	}
	
	autoDetected = true;
	boost::logic::tribool l_is_wifi_router;
	const auto l_ip_gateway = Socket::getDefaultGateWay(l_is_wifi_router);
	if (l_is_wifi_router)
	{
		log("WiFi router detected IP = " + l_ip_gateway);
		SET_SETTING(INCOMING_CONNECTIONS, SettingsManager::INCOMING_FIREWALL_UPNP);
		// FLYLINKDC_USE_DEAD_CODE fly_fire1(ConnectivityManagerListener::Finished());
	}
	else
	{
		const auto l_ip = Util::getLocalOrBindIp(false);
		if (!Util::isPrivateIp(l_ip)) // false - для детекта внешнего IP
		{
			SET_SETTING(INCOMING_CONNECTIONS, SettingsManager::INCOMING_DIRECT); // Вот тут сомнительно
			log(STRING(PUBLIC_IP_DETECTED) + " IP = " + l_ip);
			// FLYLINKDC_USE_DEAD_CODE fly_fire1(ConnectivityManagerListener::Finished());
			g_is_running = false;
			return;
		}
	}
	log(STRING(LOCAL_NET_NAT_DETECT));
	
	if (!MappingManager::getInstance()->open())
	{
		g_is_running = false;
	}
}
コード例 #20
0
void SDCPage::write()
{
	PropPage::write(*this, items);
	SET_SETTING(SHUTDOWN_ACTION, ctrlShutdownAction.GetCurSel());
}