Refactored list of update mirrors into a separate file.

This commit is contained in:
LoRd_MuldeR 2017-11-26 15:22:37 +01:00
parent 3b6051393d
commit 4d2aaa304f
10 changed files with 167 additions and 230 deletions

View File

@ -51,6 +51,7 @@
<ClInclude Include="include\MUtils\Hash.h" /> <ClInclude Include="include\MUtils\Hash.h" />
<ClInclude Include="include\MUtils\IPCChannel.h" /> <ClInclude Include="include\MUtils\IPCChannel.h" />
<ClInclude Include="include\MUtils\JobObject.h" /> <ClInclude Include="include\MUtils\JobObject.h" />
<ClInclude Include="include\MUtils\Lazy.h" />
<ClInclude Include="include\MUtils\OSSupport.h" /> <ClInclude Include="include\MUtils\OSSupport.h" />
<ClInclude Include="include\MUtils\Registry.h" /> <ClInclude Include="include\MUtils\Registry.h" />
<ClInclude Include="include\MUtils\Sound.h" /> <ClInclude Include="include\MUtils\Sound.h" />
@ -63,6 +64,7 @@
<ClInclude Include="src\3rd_party\keccak\include\keccak_impl.h" /> <ClInclude Include="src\3rd_party\keccak\include\keccak_impl.h" />
<ClInclude Include="src\3rd_party\strnatcmp\include\strnatcmp.h" /> <ClInclude Include="src\3rd_party\strnatcmp\include\strnatcmp.h" />
<ClInclude Include="src\DirLocker.h" /> <ClInclude Include="src\DirLocker.h" />
<ClInclude Include="src\Mirrors.h" />
<ClInclude Include="src\Utils_Win32.h" /> <ClInclude Include="src\Utils_Win32.h" />
<CustomBuild Include="include\Mutils\UpdateChecker.h"> <CustomBuild Include="include\Mutils\UpdateChecker.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
@ -149,8 +151,7 @@
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
<PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;MUTILS_DLL_EXPORT;_DEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;MUTILS_DLL_EXPORT;_DEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -172,8 +173,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</PrecompiledHeader>
<Optimization>Full</Optimization> <Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
@ -189,6 +189,9 @@
<AdditionalIncludeDirectories>$(ProjectDir)\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<CompileAsManaged>false</CompileAsManaged> <CompileAsManaged>false</CompileAsManaged>
<MinimalRebuild>false</MinimalRebuild>
<ControlFlowGuard>false</ControlFlowGuard>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -197,13 +200,13 @@
<AdditionalLibraryDirectories>$(SolutionDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\lib;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\lib\Win32</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(SolutionDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\lib;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\lib\Win32</AdditionalLibraryDirectories>
<AdditionalDependencies>QtCore4.lib;QtGui4.lib;Winmm.lib;Psapi.lib;Sensapi.lib;PowrProf.lib;Shlwapi.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>QtCore4.lib;QtGui4.lib;Winmm.lib;Psapi.lib;Sensapi.lib;PowrProf.lib;Shlwapi.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>false</GenerateDebugInformation> <GenerateDebugInformation>false</GenerateDebugInformation>
<ShowProgress>LinkVerboseLib</ShowProgress>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</PrecompiledHeader>
<Optimization>Full</Optimization> <Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
@ -219,6 +222,9 @@
<AdditionalIncludeDirectories>$(ProjectDir)\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<CompileAsManaged>false</CompileAsManaged> <CompileAsManaged>false</CompileAsManaged>
<MinimalRebuild>false</MinimalRebuild>
<ControlFlowGuard>false</ControlFlowGuard>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>

View File

@ -102,6 +102,9 @@
<ClCompile Include="src\Utils_Win32.cpp"> <ClCompile Include="src\Utils_Win32.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\Hash.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src\CriticalSection_Win32.h"> <ClInclude Include="src\CriticalSection_Win32.h">
@ -161,18 +164,24 @@
<ClInclude Include="include\MUtils\Translation.h"> <ClInclude Include="include\MUtils\Translation.h">
<Filter>Public Headers</Filter> <Filter>Public Headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="include\MUtils\Hash_Blake2.h">
<Filter>Public Headers</Filter>
</ClInclude>
<ClInclude Include="include\MUtils\Hash_Keccak.h">
<Filter>Public Headers</Filter>
</ClInclude>
<ClInclude Include="src\3rd_party\blake2\include\blake2.h"> <ClInclude Include="src\3rd_party\blake2\include\blake2.h">
<Filter>Header Files\3rd Party</Filter> <Filter>Header Files\3rd Party</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="include\MUtils\Registry.h"> <ClInclude Include="include\MUtils\Registry.h">
<Filter>Public Headers</Filter> <Filter>Public Headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\Utils_Win32.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\MUtils\Hash.h">
<Filter>Public Headers</Filter>
</ClInclude>
<ClInclude Include="include\MUtils\Lazy.h">
<Filter>Public Headers</Filter>
</ClInclude>
<ClInclude Include="src\Mirrors.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CustomBuild Include="include\Mutils\UpdateChecker.h"> <CustomBuild Include="include\Mutils\UpdateChecker.h">

View File

@ -51,6 +51,7 @@
<ClInclude Include="include\MUtils\Hash.h" /> <ClInclude Include="include\MUtils\Hash.h" />
<ClInclude Include="include\MUtils\IPCChannel.h" /> <ClInclude Include="include\MUtils\IPCChannel.h" />
<ClInclude Include="include\MUtils\JobObject.h" /> <ClInclude Include="include\MUtils\JobObject.h" />
<ClInclude Include="include\MUtils\Lazy.h" />
<ClInclude Include="include\MUtils\OSSupport.h" /> <ClInclude Include="include\MUtils\OSSupport.h" />
<ClInclude Include="include\MUtils\Registry.h" /> <ClInclude Include="include\MUtils\Registry.h" />
<ClInclude Include="include\MUtils\Sound.h" /> <ClInclude Include="include\MUtils\Sound.h" />
@ -63,6 +64,7 @@
<ClInclude Include="src\3rd_party\keccak\include\keccak_impl.h" /> <ClInclude Include="src\3rd_party\keccak\include\keccak_impl.h" />
<ClInclude Include="src\3rd_party\strnatcmp\include\strnatcmp.h" /> <ClInclude Include="src\3rd_party\strnatcmp\include\strnatcmp.h" />
<ClInclude Include="src\DirLocker.h" /> <ClInclude Include="src\DirLocker.h" />
<ClInclude Include="src\Mirrors.h" />
<ClInclude Include="src\Utils_Win32.h" /> <ClInclude Include="src\Utils_Win32.h" />
<CustomBuild Include="include\Mutils\UpdateChecker.h"> <CustomBuild Include="include\Mutils\UpdateChecker.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
@ -149,8 +151,7 @@
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
<PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;MUTILS_DLL_EXPORT;_DEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;MUTILS_DLL_EXPORT;_DEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -172,8 +173,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</PrecompiledHeader>
<Optimization>Full</Optimization> <Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
@ -189,6 +189,9 @@
<AdditionalIncludeDirectories>$(ProjectDir)\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<CompileAsManaged>false</CompileAsManaged> <CompileAsManaged>false</CompileAsManaged>
<MinimalRebuild>false</MinimalRebuild>
<ControlFlowGuard>false</ControlFlowGuard>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -197,13 +200,13 @@
<AdditionalLibraryDirectories>$(SolutionDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\lib;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\lib\Win32</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(SolutionDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\lib;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\lib\Win32</AdditionalLibraryDirectories>
<AdditionalDependencies>notelemetry.obj;QtCore4.lib;QtGui4.lib;Winmm.lib;Psapi.lib;Sensapi.lib;PowrProf.lib;Shlwapi.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>notelemetry.obj;QtCore4.lib;QtGui4.lib;Winmm.lib;Psapi.lib;Sensapi.lib;PowrProf.lib;Shlwapi.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>false</GenerateDebugInformation> <GenerateDebugInformation>false</GenerateDebugInformation>
<ShowProgress>LinkVerboseLib</ShowProgress>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</PrecompiledHeader>
<Optimization>Full</Optimization> <Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
@ -219,6 +222,9 @@
<AdditionalIncludeDirectories>$(ProjectDir)\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<CompileAsManaged>false</CompileAsManaged> <CompileAsManaged>false</CompileAsManaged>
<MinimalRebuild>false</MinimalRebuild>
<ControlFlowGuard>false</ControlFlowGuard>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>

View File

@ -176,6 +176,12 @@
<ClInclude Include="include\MUtils\Hash.h"> <ClInclude Include="include\MUtils\Hash.h">
<Filter>Public Headers</Filter> <Filter>Public Headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="include\MUtils\Lazy.h">
<Filter>Public Headers</Filter>
</ClInclude>
<ClInclude Include="src\Mirrors.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CustomBuild Include="include\Mutils\UpdateChecker.h"> <CustomBuild Include="include\Mutils\UpdateChecker.h">

View File

@ -64,6 +64,7 @@
<ClInclude Include="src\3rd_party\keccak\include\keccak_impl.h" /> <ClInclude Include="src\3rd_party\keccak\include\keccak_impl.h" />
<ClInclude Include="src\3rd_party\strnatcmp\include\strnatcmp.h" /> <ClInclude Include="src\3rd_party\strnatcmp\include\strnatcmp.h" />
<ClInclude Include="src\DirLocker.h" /> <ClInclude Include="src\DirLocker.h" />
<ClInclude Include="src\Mirrors.h" />
<ClInclude Include="src\Utils_Win32.h" /> <ClInclude Include="src\Utils_Win32.h" />
<CustomBuild Include="include\Mutils\UpdateChecker.h"> <CustomBuild Include="include\Mutils\UpdateChecker.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>

View File

@ -179,6 +179,9 @@
<ClInclude Include="include\MUtils\Lazy.h"> <ClInclude Include="include\MUtils\Lazy.h">
<Filter>Public Headers</Filter> <Filter>Public Headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\Mirrors.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CustomBuild Include="include\Mutils\UpdateChecker.h"> <CustomBuild Include="include\Mutils\UpdateChecker.h">

View File

@ -98,7 +98,7 @@ namespace MUtils
protected: protected:
void run(void); void run(void);
void checkForUpdates(void); void checkForUpdates(void);
void testKnownHosts(void); void testMirrorsList(void);
signals: signals:
void statusChanged(const int status); void statusChanged(const int status);

1
src/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/Mirrors.h

42
src/Mirrors.h.TEMPLATE Normal file
View File

@ -0,0 +1,42 @@
///////////////////////////////////////////////////////////////////////////////
// MuldeR's Utilities for Qt
// Copyright (C) 2004-2017 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// http://www.gnu.org/licenses/lgpl-2.1.txt
//////////////////////////////////////////////////////////////////////////////////
#include <cstdlib>
/*
* Update mirrors, for automatic update check
*/
static const char *update_mirrors[] =
{
"http://mirror01.org/",
"http://mirror02.org/",
NULL
};
/*
* List of known hosts, for connectivity test
*/
static const char *known_hosts[] =
{
"example.com",
"example.net",
NULL
};

View File

@ -34,7 +34,7 @@
#include <QElapsedTimer> #include <QElapsedTimer>
#include <QSet> #include <QSet>
using namespace MUtils; #include "Mirrors.h"
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// CONSTANTS // CONSTANTS
@ -49,185 +49,9 @@ static const char *mirror_url_postfix[] =
NULL NULL
}; };
static const char *update_mirrors[] =
{
"http://muldersoft.com/",
"http://mulder.bplaced.net/",
"http://mulder.6te.net/",
"http://mulder.000webhostapp.com/", //"http://mulder.webuda.com/",
"http://mulder.pe.hu/",
"http://muldersoft.square7.ch/",
"http://muldersoft.co.nf/",
"http://muldersoft.eu.pn/",
"http://muldersoft.lima-city.de/",
"http://www.muldersoft.keepfree.de/",
"http://lamexp.sourceforge.net/",
"http://lordmulder.github.io/LameXP/",
"http://muldersoft.bitbucket.io/", //http://lord_mulder.bitbucket.org/
"http://www.tricksoft.de/",
"http://repo.or.cz/LameXP.git/blob_plain/gh-pages:/",
"http://gitlab.com/lamexp/lamexp/raw/gh-pages/",
NULL
};
static const char *known_hosts[] = //Taken form: http://www.alexa.com/topsites !!!
{
"www.163.com",
"www.7-zip.org",
"www.ac3filter.net",
"clbianco.altervista.org",
"status.aws.amazon.com",
"build.antergos.com",
"www.aol.com",
"www.apache.org",
"www.apple.com",
"www.adobe.com",
"archive.org",
"www.artlebedev.ru",
"web.audacityteam.org",
"status.automattic.com",
"www.avidemux.org",
"www.babylon.com",
"www.baidu.com",
"bandcamp.com",
"www.bbc.co.uk",
"www.berlios.de",
"www.bing.com",
"www.bingeandgrab.com",
"www.bucketheadpikes.com",
"www.buzzfeed.com",
"www.cam.ac.uk",
"www.ccc.de",
"home.cern",
"www.citizeninsomniac.com",
"www.cnet.com",
"cnzz.com",
"www.cuhk.edu.hk",
"www.codeplex.com",
"www.codeproject.com",
"www.der-postillon.com",
"www.ebay.com",
"www.equation.com",
"www.ethz.ch",
"www.farbrausch.de",
"fc2.com",
"fedoraproject.org",
"blog.fefe.de",
"www.ffmpeg.org",
"blog.flickr.net",
"www.fraunhofer.de",
"free-codecs.com",
"git-scm.com",
"doc.gitlab.com",
"www.gmx.net",
"news.gnome.org",
"www.gnu.org",
"go.com",
"code.google.com",
"haali.su",
"www.harvard.edu",
"www.heise.de",
"www.helmholtz.de",
"www.huffingtonpost.co.uk",
"www.hu-berlin.de",
"www.iana.org",
"www.imdb.com",
"www.imgburn.com",
"imgur.com",
"www.iuj.ac.jp",
"www.jd.com",
"www.jiscdigitalmedia.ac.uk",
"kannmanumdieuhrzeitschonnbierchentrinken.de",
"mirrors.kernel.org",
"komisar.gin.by",
"lame.sourceforge.net",
"www.libav.org",
"blog.linkedin.com",
"www.linuxmint.com",
"www.livedoor.com",
"www.livejournal.com",
"longplayer.org",
"go.mail.ru",
"marknelson.us",
"www.mediafire.com",
"web.mit.edu",
"www.mod-technologies.com",
"ftp.mozilla.org",
"www.mpg.de",
"mplayerhq.hu",
"www.msn.com",
"wiki.multimedia.cx",
"www.nch.com.au",
"neocities.org",
"mirror.netcologne.de",
"oss.netfarm.it",
"blog.netflix.com",
"netrenderer.de",
"www.nytimes.com",
"www.opera.com",
"www.oxford.gov.uk",
"www.ox-fanzine.de",
"www.partha.com",
"pastebin.com",
"pastie.org",
"portableapps.com",
"www.portablefreeware.com",
"support.proboards.com",
"www.qq.com",
"www.qt.io",
"www.quakelive.com",
"rationalqm.us",
"www.reddit.com",
"www.rwth-aachen.de",
"www.seamonkey-project.org",
"selfhtml.org",
"www.sina.com.cn",
"www.sohu.com",
"help.sogou.com",
"sourceforge.net",
"www.spiegel.de",
"www.sputnikmusic.com",
"stackoverflow.com",
"www.stanford.edu",
"www.t-online.de",
"www.tagesschau.de",
"tdm-gcc.tdragon.net",
"www.tdrsmusic.com",
"tu-dresden.de",
"www.ubuntu.com",
"portal.uned.es",
"www.unibuc.ro",
"www.uniroma1.it",
"www.univ-paris1.fr",
"www.univer.kharkov.ua",
"www.univie.ac.at",
"www.uol.com.br",
"www.uva.nl",
"www.uw.edu.pl",
"www.videohelp.com",
"www.videolan.org",
"virtualdub.org",
"blog.virustotal.com",
"www.vkgoeswild.com",
"www.warr.org",
"www.weibo.com",
"status.wikimedia.org",
"www.winamp.com",
"www.winhoros.de",
"wpde.org",
"x265.org",
"xhmikosr.1f0.de",
"xiph.org",
"us.mail.yahoo.com",
"www.youtube.com",
"www.zedo.com",
"ffmpeg.zeranoe.com",
NULL
};
static const int MIN_CONNSCORE = 5; static const int MIN_CONNSCORE = 5;
static const int QUICK_MIRRORS = 3; static const int QUICK_MIRRORS = 3;
static const int MAX_CONN_TIMEOUT = 8000; static const int MAX_CONN_TIMEOUT = 16000;
static const int DOWNLOAD_TIMEOUT = 30000; static const int DOWNLOAD_TIMEOUT = 30000;
static const int VERSION_INFO_EXPIRES_MONTHS = 6; static const int VERSION_INFO_EXPIRES_MONTHS = 6;
@ -266,7 +90,7 @@ static QStringList buildRandomList(const char *const values[])
QStringList list; QStringList list;
for (int index = 0; values[index]; index++) for (int index = 0; values[index]; index++)
{ {
const int pos = next_rand_u32() % (index + 1); const int pos = MUtils::next_rand_u32() % (index + 1);
list.insert(pos, QString::fromLatin1(values[index])); list.insert(pos, QString::fromLatin1(values[index]));
} }
return list; return list;
@ -276,12 +100,12 @@ static QStringList buildRandomList(const char *const values[])
// Update Info Class // Update Info Class
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
UpdateCheckerInfo::UpdateCheckerInfo(void) MUtils::UpdateCheckerInfo::UpdateCheckerInfo(void)
{ {
resetInfo(); resetInfo();
} }
void UpdateCheckerInfo::resetInfo(void) void MUtils::UpdateCheckerInfo::resetInfo(void)
{ {
m_buildNo = 0; m_buildNo = 0;
m_buildDate.setDate(1900, 1, 1); m_buildDate.setDate(1900, 1, 1);
@ -292,7 +116,7 @@ void UpdateCheckerInfo::resetInfo(void)
m_downloadChecksum.clear(); m_downloadChecksum.clear();
} }
bool UpdateCheckerInfo::isComplete(void) bool MUtils::UpdateCheckerInfo::isComplete(void)
{ {
if(this->m_buildNo < 1) return false; if(this->m_buildNo < 1) return false;
if(this->m_buildDate.year() < 2010) return false; if(this->m_buildDate.year() < 2010) return false;
@ -309,7 +133,7 @@ bool UpdateCheckerInfo::isComplete(void)
// Constructor & Destructor // Constructor & Destructor
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
UpdateChecker::UpdateChecker(const QString &binWGet, const QString &binMCat, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode) MUtils::UpdateChecker::UpdateChecker(const QString &binWGet, const QString &binMCat, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode)
: :
m_updateInfo(new UpdateCheckerInfo()), m_updateInfo(new UpdateCheckerInfo()),
m_binaryWGet(binWGet), m_binaryWGet(binWGet),
@ -331,7 +155,7 @@ UpdateChecker::UpdateChecker(const QString &binWGet, const QString &binMCat, con
} }
} }
UpdateChecker::~UpdateChecker(void) MUtils::UpdateChecker::~UpdateChecker(void)
{ {
} }
@ -339,7 +163,7 @@ UpdateChecker::~UpdateChecker(void)
// Public slots // Public slots
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void UpdateChecker::start(Priority priority) void MUtils::UpdateChecker::start(Priority priority)
{ {
m_success.fetchAndStoreOrdered(0); m_success.fetchAndStoreOrdered(0);
m_cancelled.fetchAndStoreOrdered(0); m_cancelled.fetchAndStoreOrdered(0);
@ -350,14 +174,14 @@ void UpdateChecker::start(Priority priority)
// Protected functions // Protected functions
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void UpdateChecker::run(void) void MUtils::UpdateChecker::run(void)
{ {
qDebug("Update checker thread started!"); qDebug("Update checker thread started!");
MUTILS_EXCEPTION_HANDLER(m_testMode ? testKnownHosts() : checkForUpdates()); MUTILS_EXCEPTION_HANDLER(m_testMode ? testMirrorsList() : checkForUpdates());
qDebug("Update checker thread completed."); qDebug("Update checker thread completed.");
} }
void UpdateChecker::checkForUpdates(void) void MUtils::UpdateChecker::checkForUpdates(void)
{ {
// ----- Initialization ----- // // ----- Initialization ----- //
@ -385,7 +209,7 @@ void UpdateChecker::checkForUpdates(void)
int connectionScore = 0; int connectionScore = 0;
QStringList mirrorList = buildRandomList(known_hosts); QStringList mirrorList = buildRandomList(known_hosts);
for(int connectionTimout = 250; connectionTimout <= MAX_CONN_TIMEOUT; connectionTimout *= 2) for(int connectionTimout = 500; connectionTimout <= MAX_CONN_TIMEOUT; connectionTimout *= 2)
{ {
QElapsedTimer elapsedTimer; QElapsedTimer elapsedTimer;
elapsedTimer.start(); elapsedTimer.start();
@ -477,12 +301,48 @@ endLoop:
} }
} }
void UpdateChecker::testKnownHosts(void) void MUtils::UpdateChecker::testMirrorsList(void)
{ {
QStringList hostList; // ----- Test update mirrors ----- //
QStringList mirrorList;
for(int i = 0; update_mirrors[i]; i++)
{
mirrorList << QString::fromLatin1(update_mirrors[i]);
}
qDebug("\n[Known Hosts]");
log("Testing all known hosts...", "", "---");
UpdateCheckerInfo updateInfo;
while (!mirrorList.isEmpty())
{
const QString currentMirror = mirrorList.takeFirst();
bool success = false;
qDebug("Testing: %s", MUTILS_L1STR(currentMirror));
log("", "Testing:", currentMirror, "");
for (quint8 attempt = 0; attempt < 3; ++attempt)
{
updateInfo.resetInfo();
if (tryUpdateMirror(&updateInfo, currentMirror, (!attempt)))
{
success = true;
break;
}
}
if (!success)
{
qWarning("\nUpdate mirror seems to be unavailable:\n%s\n", MUTILS_L1STR(currentMirror));
}
log("", "---");
}
// ----- Test known hosts ----- //
QStringList knownHostList;
for (int i = 0; known_hosts[i]; i++) for (int i = 0; known_hosts[i]; i++)
{ {
hostList << QString::fromLatin1(known_hosts[i]); knownHostList << QString::fromLatin1(known_hosts[i]);
} }
qDebug("\n[Known Hosts]"); qDebug("\n[Known Hosts]");
@ -490,11 +350,11 @@ void UpdateChecker::testKnownHosts(void)
QSet<quint32> ipAddrSet; QSet<quint32> ipAddrSet;
quint32 ipAddr; quint32 ipAddr;
while(!hostList.isEmpty()) while(!knownHostList.isEmpty())
{ {
const QString currentHost = hostList.takeFirst(); const QString currentHost = knownHostList.takeFirst();
qDebug("Testing: %s", currentHost.toLatin1().constData()); qDebug("Testing: %s", MUTILS_L1STR(currentHost));
log("", "Testing:", currentHost, ""); log(QLatin1String(""), "Testing:", currentHost, "");
if (tryContactHost(currentHost, DOWNLOAD_TIMEOUT, &ipAddr)) if (tryContactHost(currentHost, DOWNLOAD_TIMEOUT, &ipAddr))
{ {
if (ipAddrSet.contains(ipAddr)) if (ipAddrSet.contains(ipAddr))
@ -508,7 +368,7 @@ void UpdateChecker::testKnownHosts(void)
} }
else else
{ {
qWarning("\nConnectivity test FAILED on the following host:\n%s\n", currentHost.toLatin1().constData()); qWarning("\nConnectivity test FAILED on the following host:\n%s\n", MUTILS_L1STR(currentHost));
} }
log("", "---"); log("", "---");
} }
@ -518,7 +378,7 @@ void UpdateChecker::testKnownHosts(void)
// PRIVATE FUNCTIONS // PRIVATE FUNCTIONS
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void UpdateChecker::setStatus(const int status) void MUtils::UpdateChecker::setStatus(const int status)
{ {
if(m_status != status) if(m_status != status)
{ {
@ -527,7 +387,7 @@ void UpdateChecker::setStatus(const int status)
} }
} }
void UpdateChecker::setProgress(const int progress) void MUtils::UpdateChecker::setProgress(const int progress)
{ {
if(m_progress != progress) if(m_progress != progress)
{ {
@ -536,7 +396,7 @@ void UpdateChecker::setProgress(const int progress)
} }
} }
void UpdateChecker::log(const QString &str1, const QString &str2, const QString &str3, const QString &str4) void MUtils::UpdateChecker::log(const QString &str1, const QString &str2, const QString &str3, const QString &str4)
{ {
if(!str1.isNull()) emit messageLogged(str1); if(!str1.isNull()) emit messageLogged(str1);
if(!str2.isNull()) emit messageLogged(str2); if(!str2.isNull()) emit messageLogged(str2);
@ -544,16 +404,19 @@ void UpdateChecker::log(const QString &str1, const QString &str2, const QString
if(!str4.isNull()) emit messageLogged(str4); if(!str4.isNull()) emit messageLogged(str4);
} }
bool UpdateChecker::tryUpdateMirror(UpdateCheckerInfo *updateInfo, const QString &url, const bool &quick) bool MUtils::UpdateChecker::tryUpdateMirror(UpdateCheckerInfo *updateInfo, const QString &url, const bool &quick)
{ {
bool success = false; bool success = false;
log("", "Trying mirror:", url, ""); log("", "Trying mirror:", url, "");
if (!tryContactHost(QUrl(url).host(), quick ? (MAX_CONN_TIMEOUT / 10) : MAX_CONN_TIMEOUT)) if (quick)
{ {
log("", quick ? "Mirror is too slow!" :"Mirror is unreachable!"); if (!tryContactHost(QUrl(url).host(), (MAX_CONN_TIMEOUT / 10)))
{
log("", "Mirror is too slow, skipping!");
return false; return false;
} }
}
const QString randPart = next_rand_str(); const QString randPart = next_rand_str();
const QString outFileVers = QString("%1/%2.ver").arg(temp_folder(), randPart); const QString outFileVers = QString("%1/%2.ver").arg(temp_folder(), randPart);
@ -583,7 +446,7 @@ bool UpdateChecker::tryUpdateMirror(UpdateCheckerInfo *updateInfo, const QString
return success; return success;
} }
bool UpdateChecker::getUpdateInfo(const QString &url, const QString &outFileVers, const QString &outFileSign) bool MUtils::UpdateChecker::getUpdateInfo(const QString &url, const QString &outFileVers, const QString &outFileSign)
{ {
log("Downloading update info:", ""); log("Downloading update info:", "");
if(getFile(QString("%1%2").arg(url, mirror_url_postfix[m_betaUpdates ? 1 : 0]), outFileVers)) if(getFile(QString("%1%2").arg(url, mirror_url_postfix[m_betaUpdates ? 1 : 0]), outFileVers))
@ -600,7 +463,7 @@ bool UpdateChecker::getUpdateInfo(const QString &url, const QString &outFileVers
return false; return false;
} }
bool UpdateChecker::parseVersionInfo(const QString &file, UpdateCheckerInfo *updateInfo) bool MUtils::UpdateChecker::parseVersionInfo(const QString &file, UpdateCheckerInfo *updateInfo)
{ {
QRegExp value("^(\\w+)=(.+)$"); QRegExp value("^(\\w+)=(.+)$");
QRegExp section("^\\[(.+)\\]$"); QRegExp section("^\\[(.+)\\]$");
@ -707,7 +570,7 @@ bool UpdateChecker::parseVersionInfo(const QString &file, UpdateCheckerInfo *upd
// EXTERNAL TOOLS // EXTERNAL TOOLS
//---------------------------------------------------------- //----------------------------------------------------------
bool UpdateChecker::getFile(const QString &url, const QString &outFile, const unsigned int maxRedir) bool MUtils::UpdateChecker::getFile(const QString &url, const QString &outFile, const unsigned int maxRedir)
{ {
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
@ -723,7 +586,7 @@ bool UpdateChecker::getFile(const QString &url, const QString &outFile, const un
return false; return false;
} }
bool UpdateChecker::getFile(const QString &url, const bool forceIp4, const QString &outFile, const unsigned int maxRedir) bool MUtils::UpdateChecker::getFile(const QString &url, const bool forceIp4, const QString &outFile, const unsigned int maxRedir)
{ {
QFileInfo output(outFile); QFileInfo output(outFile);
output.setCaching(false); output.setCaching(false);
@ -797,7 +660,7 @@ bool UpdateChecker::getFile(const QString &url, const bool forceIp4, const QStri
return (process.exitCode() == 0) && output.exists() && output.isFile(); return (process.exitCode() == 0) && output.exists() && output.isFile();
} }
bool UpdateChecker::tryContactHost(const QString &hostname, const int &timeoutMsec, quint32 *const ipAddrOut) bool MUtils::UpdateChecker::tryContactHost(const QString &hostname, const int &timeoutMsec, quint32 *const ipAddrOut)
{ {
log(QString("Connecting to host: %1").arg(hostname), ""); log(QString("Connecting to host: %1").arg(hostname), "");
@ -877,7 +740,7 @@ bool UpdateChecker::tryContactHost(const QString &hostname, const int &timeoutMs
return (process.exitCode() == 0); return (process.exitCode() == 0);
} }
bool UpdateChecker::checkSignature(const QString &file, const QString &signature) bool MUtils::UpdateChecker::checkSignature(const QString &file, const QString &signature)
{ {
if (QFileInfo(file).absolutePath().compare(QFileInfo(signature).absolutePath(), Qt::CaseInsensitive) != 0) if (QFileInfo(file).absolutePath().compare(QFileInfo(signature).absolutePath(), Qt::CaseInsensitive) != 0)
{ {