Merge branch 'master' into jsonapi

This commit is contained in:
Gioacchino Mazzurco 2018-08-22 16:59:42 +02:00
commit 396fe49312
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
84 changed files with 3163 additions and 1501 deletions

View File

@ -23,20 +23,16 @@ TEMPLATE = subdirs
SUBDIRS += openpgpsdk
openpgpsdk.file = openpgpsdk/src/openpgpsdk.pro
retrotor {
libretroshare.depends = openpgpsdk
} else {
SUBDIRS += libbitdht
libbitdht.file = libbitdht/src/libbitdht.pro
libretroshare.depends = openpgpsdk libbitdht
}
rs_jsonapi {
SUBDIRS += jsonapi-generator
jsonapi-generator.file = jsonapi-generator/src/jsonapi-generator.pro
libretroshare.depends += jsonapi-generator
}
SUBDIRS += libbitdht
libbitdht.file = libbitdht/src/libbitdht.pro
libretroshare.depends = openpgpsdk libbitdht
SUBDIRS += libretroshare
libretroshare.file = libretroshare/src/libretroshare.pro
@ -51,15 +47,12 @@ retroshare_gui {
retroshare_gui.target = retroshare_gui
}
retrotor {
} else {
retroshare_nogui {
SUBDIRS += retroshare_nogui
retroshare_nogui.file = retroshare-nogui/src/retroshare-nogui.pro
retroshare_nogui.depends = libretroshare libresapi
retroshare_nogui.target = retroshare_nogui
}
}
retroshare_android_service {
SUBDIRS += retroshare_android_service

View File

@ -1,88 +1,73 @@
## Compilation on Windows
### Qt Installation
The preferred build method on Windows is by using MSYS2 which is a collection
of packages providing unix-like tools to build native Windows software.
Install Qt via: [Qt Download](http://www.qt.io/download/)
Requirements: about 12 GB of free space
Use default options.
Add to the PATH environment variable
;C:\Qt\5.5\mingw492_32\bin;C:\Qt\Tools\mingw492_32\bin;C:\Qt\Tools\mingw492_32\opt\bin
Depends on wich version of Qt you use.
Change build-all-mingw32make.bat with these values too if you don't use MSys2.
The resulting binary is a 32-bit build of Retroshare which will also work
fine on a 64-bit system.
### MSYS2 INSTALLATION
Choose your MSYS2 installer here: [MSYS2](http://msys2.github.io/)
Download MSYS2 from [MSYS2](http://www.msys2.org/). Get the i686 version
if you run a 32-bit Windows or the x86_64 if you run a 64-bit Windows.
Follow install procedure.
Don't forget to sync & Update pacman.
Run the installer and install MSYS2.
pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime
At the end of the installation, it'll automatically open an MSYS shell terminal.
You can also find it on the start menu as MSYS2 MSYS. This is the shell you'll
use to install packages with pacman and do maintenance but NOT to build
RetroShare.
Restart console
First, update your MSYS2 environment to the latest version by typing:
pacman -Su
pacman -Syu
Install all default programms
Close the terminal window.
pacman -S base-devel git mercurial cvs wget p7zip gcc perl ruby python2
Run MSYS2 MSYS again and finish updating with:
Choose only w64-i686 if you want only compilation in 32b architecture.
pacman -Su
pacman -S mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain
Install the default programs needed to build:
### Install other binutils:
pacman -S mingw-w64-i686-miniupnpc mingw-w64-x86_64-miniupnpc
pacman -S mingw-w64-i686-sqlite3 mingw-w64-x86_64-sqlite3
pacman -S mingw-w64-i686-speex mingw-w64-x86_64-speex
pacman -S mingw-w64-i686-speexdsp mingw-w64-x86_64-speexdsp
pacman -S mingw-w64-i686-opencv mingw-w64-x86_64-opencv
pacman -S mingw-w64-i686-ffmpeg mingw-w64-x86_64-ffmpeg
pacman -S mingw-w64-i686-libmicrohttpd mingw-w64-x86_64-libmicrohttpd
pacman -S mingw-w64-i686-libxslt mingw-w64-x86_64-libxslt
pacman -S base-devel git wget p7zip gcc perl ruby python2
Add MSYS2 to PATH environment variable depends your windows
Install the 32-bit toolchain:
;C:\msys64\mingw32\bin
;C:\msys32\mingw32\bin
pacman -S mingw-w64-i686-toolchain
Install all needed dependencies:
### Git Installation
pacman -S mingw-w64-i686-miniupnpc
pacman -S mingw-w64-i686-libmicrohttpd
pacman -S mingw-w64-i686-libxslt
pacman -S mingw-w64-i686-xapian-core
pacman -S mingw-w64-i686-sqlcipher
pacman -S mingw-w64-i686-qt5
Install Git Gui or other client: [Git Scm](https://git-scm.com/download/win)
We're done installing MSYS2, close the shell terminal.
Create a new directory named:
### BUILDING RETROSHARE
C:\Development\GIT
Now run the MSYS2 MinGW 32-bit shell terminal (it's in the start menu).
We will use it to checkout Retroshare and build it:
Right-click on it and choose: *Git Bash Here*
git clone https://github.com/RetroShare/RetroShare.git
Paste this text on git console:
git clone https://github.com/RetroShare/RetroShare.git
Go to the RetroShare directory and configure to your liking, for example:
cd RetroShare
qmake -r -Wall -spec win32-g++ "CONFIG+=debug" "CONFIG+=rs_autologin"
### Last Settings
Now we're ready to build Retroshare. Use the '-j' option with the number of
cores you have for a faster build, for instance if you have 4 cores:
mingw32-make -j4
In QtCreator Option Git add its path: *C:\Program Files\Git\bin*
and select "Pull" with "Rebase"
Make sure your current Retroshare is not running. Then just run:
retroshare-gui/src/debug/retroshare.exe
Open an MSys2 32|64 shell
Move to build_scripts:
cd /c/Development/GIT/RetroShare/msys2_build_libs/
### Compile missing library
make
You can now compile RS into Qt Creator
For using, and debugging Plugins, you can use [Symlinker](http://amd989.github.io/Symlinker/) to link
the files in
\build-RetroShare-Desktop_Qt_X_Y_Z_MinGW_32bit-Debug\plugins\PluginName\debug\*.dll
to
*%appdata%\RetroShare\extensions6*
You'll get debug output in the terminal and a running Retroshare instance.

View File

@ -89,7 +89,7 @@ install:
# Configuring MSys2
- set PATH=C:\msys64\usr\bin;%PATH%
- set PATH=C:\msys64\mingw32\bin;%PATH%
- pacman --noconfirm -S mingw-w64-i686-qt5 mingw-w64-i686-miniupnpc mingw-w64-i686-sqlcipher mingw-w64-i686-libmicrohttpd mingw-w64-xapian-core
- pacman --noconfirm -S mingw-w64-i686-qt5 mingw-w64-i686-miniupnpc mingw-w64-i686-sqlcipher mingw-w64-i686-libmicrohttpd mingw-w64-i686-xapian-core
#- pacman --noconfirm -S mingw-w64-i686-qt5-static mingw-w64-i686-miniupnpc mingw-w64-i686-sqlcipher mingw-w64-i686-libmicrohttpd
#- set PATH=C:\msys64\mingw32\qt5-static\bin\;%PATH%

View File

@ -0,0 +1,23 @@
@echo off
setlocal
:: Initialize environment
call "%~dp0env.bat"
if errorlevel 1 goto error_env
call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
%cecho% info "Build %SourceName%"
call "%~dp0build\build.bat" 32 release tor version autologin plugins
if errorlevel 1 %cecho% error "Failed to build %SourceName%." & exit /B %ERRORLEVEL%
%cecho% info "Pack %SourceName%"
call "%~dp0build\pack.bat" 32 release tor
if errorlevel 1 %cecho% error "Failed to pack %SourceName%." & exit /B %ERRORLEVEL%
exit /B 0
:error_env
echo Failed to initialize environment.
exit /B 1

View File

@ -0,0 +1,23 @@
@echo off
setlocal
:: Initialize environment
call "%~dp0env.bat"
if errorlevel 1 goto error_env
call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
%cecho% info "Build %SourceName%"
call "%~dp0build\build.bat" 32 release version autologin plugins
if errorlevel 1 %cecho% error "Failed to build %SourceName%." & exit /B %ERRORLEVEL%
%cecho% info "Pack %SourceName%"
call "%~dp0build\pack.bat" 32 release
if errorlevel 1 %cecho% error "Failed to pack %SourceName%." & exit /B %ERRORLEVEL%
exit /B 0
:error_env
echo Failed to initialize environment.
exit /B 1

View File

@ -0,0 +1,81 @@
@echo off
setlocal
:: Initialize environment
call "%~dp0..\env.bat"
if errorlevel 1 goto error_env
call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
call "%EnvPath%\env-msys2.bat"
if errorlevel 1 goto error_env
:: Initialize base environment
call "%~dp0env-base.bat" %*
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env
:: Install needed things
%EnvMSYS2Cmd% "pacman --noconfirm --needed -S make git mingw-w64-%RsMSYS2Architecture%-toolchain mingw-w64-%RsMSYS2Architecture%-qt5 mingw-w64-%RsMSYS2Architecture%-miniupnpc mingw-w64-%RsMSYS2Architecture%-sqlcipher mingw-w64-%RsMSYS2Architecture%-libmicrohttpd mingw-w64-%RsMSYS2Architecture%-xapian-core"
:: Plugins
if "%ParamPlugins%"=="1" %EnvMSYS2Cmd% "pacman --noconfirm --needed -S mingw-w64-%RsMSYS2Architecture%-speex mingw-w64-%RsMSYS2Architecture%-speexdsp mingw-w64-%RsMSYS2Architecture%-curl mingw-w64-%RsMSYS2Architecture%-libxslt mingw-w64-%RsMSYS2Architecture%-opencv mingw-w64-%RsMSYS2Architecture%-ffmpeg"
:: Initialize environment
call "%~dp0env.bat" %*
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env
echo.
echo === Version
echo.
title Build - %SourceName%-%RsBuildConfig% [Version]
pushd "%SourcePath%\retroshare-gui\src\gui\images"
:: Touch resource file
copy /b retroshare_win.rc +,,
popd
if not exist "%RsBuildPath%" mkdir "%RsBuildPath%"
pushd "%RsBuildPath%"
echo.
echo === qmake
echo.
title Build - %SourceName%-%RsBuildConfig% [qmake]
set RS_QMAKE_CONFIG="CONFIG+=%RsBuildConfig%"
if "%ParamVersion%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=version_detail_bash_script"
if "%ParamAutologin%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=rs_autologin"
if "%ParamPlugins%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=retroshare_plugins"
if "%ParamRetroTor%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=retrotor"
call "%ToolsPath%\msys2-path.bat" "%SourcePath%" MSYS2SourcePath
call "%ToolsPath%\msys2-path.bat" "%EnvMSYS2Path%" MSYS2EnvMSYS2Path
%EnvMSYS2Cmd% "qmake "%MSYS2SourcePath%/RetroShare.pro" -r -spec win32-g++ %RS_QMAKE_CONFIG%"
if errorlevel 1 goto error
echo.
echo === make
echo.
title Build - %SourceName%-%RsBuildConfig% [make]
%EnvMSYS2Cmd% "make -j 4"
:error
popd
title %COMSPEC%
if errorlevel 1 echo.& echo Build failed& echo.
exit /B %ERRORLEVEL%
:error_env
echo Failed to initialize environment.
endlocal
exit /B 1

View File

@ -0,0 +1,25 @@
@echo off
setlocal
:: Initialize environment
call "%~dp0..\env.bat"
if errorlevel 1 goto error_env
call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
call "%EnvPath%\env-msys2.bat"
if errorlevel 1 goto error_env
call "%~dp0env.bat" %*
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env
if not exist "%RsBuildPath%" exit /B 0
call "%ToolsPath%\remove-dir.bat" "%RsBuildPath%"
exit /B %ERRORLEVEL%
:error_env
echo Failed to initialize environment.
endlocal
exit /B 1

View File

@ -0,0 +1,97 @@
:: Process commandline parameter
set Param32=0
set Param64=0
set ParamRelease=0
set ParamDebug=0
set ParamVersion=0
set ParamAutologin=0
set ParamPlugins=0
set ParamTor=0
:parameter_loop
if "%~1" NEQ "" (
for /f "tokens=1,2 delims==" %%a in ("%~1") do (
if "%%~a"=="32" (
set Param32=1
) else if "%%~a"=="64" (
set Param64=1
) else if "%%~a"=="release" (
set ParamRelease=1
) else if "%%~a"=="debug" (
set ParamDebug=1
) else if "%%~a"=="version" (
set ParamVersion=1
) else if "%%~a"=="autologin" (
set ParamAutologin=1
) else if "%%~a"=="plugins" (
set ParamPlugins=1
) else if "%%~a"=="tor" (
set ParamTor=1
) else (
echo.
echo Unknown parameter %1
goto :usage
)
)
shift /1
goto parameter_loop
)
if "%Param32%"=="1" (
if "%Param64%"=="1" (
echo.
echo 32-bit or 64-bit?
goto :usage
)
set RsBit=32
set RsArchitecture=x86
set RsMSYS2Architecture=i686
)
if "%Param64%"=="1" (
set RsBit=64
set RsArchitecture=x64
set RsMSYS2Architecture=x86_64
)
if "%RsBit%"=="" goto :usage
if "%ParamRelease%"=="1" (
if "%ParamDebug%"=="1" (
echo.
echo Release or Debug?
goto :usage
)
set RsBuildConfig=release
) else if "%ParamDebug%"=="1" (
set RsBuildConfig=debug
) else goto :usage
if "%ParamTor%"=="1" (
set RsType=-tor
) else (
set RsType=
)
exit /B 0
:usage
echo.
echo Usage: 32^|64 release^|debug [version autologin plugins]
echo.
echo Mandatory parameter
echo 32^|64 32-bit or 64-bit Version
echo release^|debug Build release or debug version
echo.
echo Optional parameter (need clean when changed)
echo version Create version information from git
echo autologin Build with autologin
echo plugins Build plugins
echo.
echo Parameter for pack
echo tor Pack tor version
echo.
exit /B 2

View File

@ -0,0 +1,29 @@
call "%~dp0env-base.bat" %*
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env
set MSYSTEM=MINGW%RsBit%
set BuildPath=%EnvRootPath%\builds
set DeployPath=%EnvRootPath%\deploy
if not exist "%BuildPath%" mkdir "%BuildPath%"
if not exist "%DeployPath%" mkdir "%DeployPath%"
:: Get Qt version
call "%ToolsPath%\get-qt-version.bat" QtVersion
if "%QtVersion%"=="" %cecho% error "Cannot get Qt version." & exit /B 1
set RsMinGWPath=%EnvMSYS2BasePath%\mingw%RsBit%
set RsBuildPath=%BuildPath%\Qt-%QtVersion%-%RsArchitecture%-%RsBuildConfig%
set RsDeployPath=%DeployPath%\Qt-%QtVersion%%RsType%-%RsArchitecture%-%RsBuildConfig%
set RsPackPath=%DeployPath%
set RsArchiveAdd=
if not exist "%~dp0env-mod.bat" goto no_mod
call "%~dp0env-mod.bat"
if errorlevel 1 exit /B %ERRORLEVEL%
:no_mod
exit /B 0

View File

@ -0,0 +1,118 @@
@echo off
setlocal
set NoAsk=
if "%~2"=="no-ask" set NoAsk=1
:: Initialize environment
call "%~dp0..\env.bat"
if errorlevel 1 goto error_env
call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
call "%EnvPath%\env-msys2.bat"
if errorlevel 1 goto error_env
call "%~dp0env.bat" %*
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env
:: Check git executable
set GitPath=
call "%ToolsPath%\find-in-path.bat" GitPath git.exe
if "%GitPath%"=="" echo Git executable not found in PATH.& exit /B 1
:: Get compiled revision
set GetRsVersion=%SourcePath%\build_scripts\Windows\tools\get-rs-version.bat
if not exist "%GetRsVersion%" (
echo File not found
echo %GetRsVersion%
exit /B 1
)
call "%GetRsVersion%" RS_REVISION_STRING RsRevision
if "%RsRevision%"=="" echo Revision not found.& exit /B 1
:: Get compiled version
call "%GetRsVersion%" RS_REVISION_STRING RsRevision
if "%RsRevision%"=="" echo Revision not found.& exit /B 1
call "%GetRsVersion%" RS_MAJOR_VERSION RsMajorVersion
if "%RsMajorVersion%"=="" echo Major version not found.& exit /B 1
call "%GetRsVersion%" RS_MINOR_VERSION RsMinorVersion
if "%RsMinorVersion%"=="" echo Minor version not found.& exit /B 1
call "%GetRsVersion%" RS_BUILD_NUMBER RsBuildNumber
if "%RsBuildNumber%"=="" echo Build number not found.& exit /B 1
call "%GetRsVersion%" RS_BUILD_NUMBER_ADD RsBuildNumberAdd
set RsVersion=%RsMajorVersion%.%RsMinorVersion%.%RsBuildNumber%%RsBuildNumberAdd%
:: Check WMIC is available
wmic.exe alias /? >nul 2>&1 || echo WMIC is not available.&& exit /B 1
:: Use WMIC to retrieve date in format YYYYMMDD
set RsDate=
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set RsDate=%%I
set RsDate=%RsDate:~0,4%%RsDate:~4,2%%RsDate:~6,2%
:: Get last revision
set RsLastRefFile=%BuildPath%\Qt-%QtVersion%%RsType%-%RsBuildConfig%-LastRef.txt
set RsLastRef=
if exist "%RsLastRefFile%" set /P RsLastRef=<"%RsLastRefFile%"
if "%NoAsk%"=="1" goto no_ask_for_last_revision
if not "%RsLastRef%"=="" echo Last Revision was %RsLastRef%
set /P RsLastRefInput=Last Revision:
if "%RsLastRefInput%" NEQ "" set RsLastRef=%RsLastRefInput%
:no_ask_for_last_revision
:: Get current revision
pushd "%SourcePath%"
call "%ToolsPath%\get-git-ref.bat" RsRef
popd
if errorlevel 1 exit /B 1
if "%RsRef%"=="" echo Cannot get git revision.& exit /B 1
echo.
echo Creating log from %RsLastRef%
echo to %RsRef%
if "%NoAsk%"=="1" goto no_confirm
choice /M "Do you want to proceed?"
if %errorlevel%==2 exit /B 1
:no_confirm
if "%RsBuildConfig%" NEQ "release" (
set RsGitLog=%DeployPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%%RsType%-msys2%RsArchiveAdd%-%RsBuildConfig%.txt
) else (
set RsGitLog=%DeployPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%%RsType%-msys2%RsArchiveAdd%.txt
)
title %SourceName%-%RsBuildConfig% [git log]
pushd "%SourcePath%"
if "%RsLastRef%"=="" (
git log %RsRef% >"%RsGitLog%"
) else (
if "%RsLastRef%"=="%RsRef%" (
git log %RsRef% --max-count=1 >"%RsGitLog%"
) else (
git log %RsLastRef%..%RsRef% >"%RsGitLog%"
)
)
popd
title %COMSPEC%
echo %RsRef%>"%RsLastRefFile%"
exit /B %ERRORLEVEL%
:error_env
echo Failed to initialize environment.
endlocal
exit /B 1

View File

@ -0,0 +1,222 @@
@echo off
setlocal
set Quite=^>nul
:: Initialize environment
call "%~dp0..\env.bat"
if errorlevel 1 goto error_env
call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
call "%EnvPath%\env-msys2.bat"
if errorlevel 1 goto error_env
:: Initialize environment
call "%~dp0env.bat" %*
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env
:: Remove deploy path
if exist "%RsDeployPath%" rmdir /S /Q "%RsDeployPath%"
:: Check compilation
if not exist "%RsBuildPath%\Makefile" echo Project is not compiled.& goto error
:: Get compiled revision
set GetRsVersion=%SourcePath%\build_scripts\Windows\tools\get-rs-version.bat
if not exist "%GetRsVersion%" (
echo File not found
echo %GetRsVersion%
goto error
)
call "%GetRsVersion%" RS_REVISION_STRING RsRevision
if "%RsRevision%"=="" echo Revision not found.& goto error
:: Get compiled version
call "%GetRsVersion%" RS_MAJOR_VERSION RsMajorVersion
if "%RsMajorVersion%"=="" echo Major version not found.& goto error
call "%GetRsVersion%" RS_MINOR_VERSION RsMinorVersion
if "%RsMinorVersion%"=="" echo Minor version not found.& goto error
call "%GetRsVersion%" RS_BUILD_NUMBER RsBuildNumber
if "%RsBuildNumber%"=="" echo Build number not found.& goto error
call "%GetRsVersion%" RS_BUILD_NUMBER_ADD RsBuildNumberAdd
set RsVersion=%RsMajorVersion%.%RsMinorVersion%.%RsBuildNumber%%RsBuildNumberAdd%
:: Check WMIC is available
wmic.exe alias /? >nul 2>&1 || echo WMIC is not available.&& goto error
:: Use WMIC to retrieve date in format YYYYMMDD
set RsDate=
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set RsDate=%%I
set RsDate=%RsDate:~0,4%%RsDate:~4,2%%RsDate:~6,2%
if "%ParamTor%"=="1" (
:: Check for tor executable
if not exist "%EnvDownloadPath%\tor\Tor\tor.exe" (
echo Tor binary not found. Please download Tor Expert Bundle from
echo https://www.torproject.org/download/download.html.en
echo and unpack to
echo %EnvDownloadPath%\tor
goto error
)
)
set QtMainVersion=%QtVersion:~0,1%
set QtSharePath=%RsMinGWPath%\share\qt%QtMainVersion%\
rem Qt 4 = QtSvg4.dll
rem Qt 5 = Qt5Svg.dll
set QtMainVersion1=
set QtMainVersion2=
if "%QtMainVersion%"=="4" set QtMainVersion2=4
if "%QtMainVersion%"=="5" set QtMainVersion1=5
if "%RsBuildConfig%" NEQ "release" (
set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%-msys2%RsType%%RsArchiveAdd%-%RsBuildConfig%.7z
) else (
set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%-msys2%RsType%%RsArchiveAdd%.7z
)
if exist "%Archive%" del /Q "%Archive%"
:: Create deploy path
mkdir "%RsDeployPath%"
title Pack - %SourceName%%RsType%-%RsBuildConfig% [copy files]
set ExtensionsFile=%SourcePath%\libretroshare\src\rsserver\rsinit.cc
set Extensions=
for /f %%e in ('type "%ExtensionsFile%" ^| sed.exe -n "s/^.*\/\(extensions[^/]*\)\/.*$/\1/p" ^| sed.exe -n "1,1p"') do set Extensions=%%e
if "%Extensions%"=="" echo Folder for extensions not found in %ExtensionsFile%& goto error
:: Copy files
mkdir "%RsDeployPath%\Data\%Extensions%"
mkdir "%RsDeployPath%\imageformats"
mkdir "%RsDeployPath%\qss"
mkdir "%RsDeployPath%\stylesheets"
mkdir "%RsDeployPath%\sounds"
mkdir "%RsDeployPath%\translations"
copy nul "%RsDeployPath%\portable" %Quite%
echo copy binaries
copy "%RsBuildPath%\retroshare-gui\src\%RsBuildConfig%\RetroShare*.exe" "%RsDeployPath%" %Quite%
copy "%RsBuildPath%\retroshare-nogui\src\%RsBuildConfig%\retroshare*-nogui.exe" "%RsDeployPath%" %Quite%
echo copy extensions
for /D %%D in ("%RsBuildPath%\plugins\*") do (
call :copy_extension "%%D" "%RsDeployPath%\Data\%Extensions%"
call :copy_dependencies "%RsDeployPath%\Data\%Extensions%\%%~nxD.dll" "%RsDeployPath%"
)
echo copy dependencies
call :copy_dependencies "%RsDeployPath%\retroshare.exe" "%RsDeployPath%"
echo copy Qt DLL's
copy "%RsMinGWPath%\bin\Qt%QtMainVersion1%Svg%QtMainVersion2%.dll" "%RsDeployPath%" %Quite%
if "%QtMainVersion%"=="5" (
mkdir "%RsDeployPath%\platforms"
copy "%QtSharePath%\plugins\platforms\qwindows.dll" "%RsDeployPath%\platforms" %Quite%
mkdir "%RsDeployPath%\audio"
copy "%QtSharePath%\plugins\audio\qtaudio_windows.dll" "%RsDeployPath%\audio" %Quite%
)
if exist "%QtSharePath%\plugins\styles\qwindowsvistastyle.dll" (
echo Copy styles
mkdir "%RsDeployPath%\styles" %Quite%
copy "%QtSharePath%\plugins\styles\qwindowsvistastyle.dll" "%RsDeployPath%\styles" %Quite%
)
copy "%QtSharePath%\plugins\imageformats\*.dll" "%RsDeployPath%\imageformats" %Quite%
del /Q "%RsDeployPath%\imageformats\*d?.dll" %Quite%
echo copy qss
xcopy /S "%SourcePath%\retroshare-gui\src\qss" "%RsDeployPath%\qss" %Quite%
echo copy stylesheets
xcopy /S "%SourcePath%\retroshare-gui\src\gui\qss\chat" "%RsDeployPath%\stylesheets" %Quite%
rmdir /S /Q "%RsDeployPath%\stylesheets\compact" %Quite%
rmdir /S /Q "%RsDeployPath%\stylesheets\standard" %Quite%
rmdir /S /Q "%RsDeployPath%\stylesheets\__MACOSX__Bubble" %Quite%
echo copy sounds
xcopy /S "%SourcePath%\retroshare-gui\src\sounds" "%RsDeployPath%\sounds" %Quite%
echo copy translation
copy "%SourcePath%\retroshare-gui\src\translations\qt_tr.qm" "%RsDeployPath%\translations" %Quite%
copy "%QtSharePath%\translations\qt_*.qm" "%RsDeployPath%\translations" %Quite%
if "%QtMainVersion%"=="5" (
copy "%QtSharePath%\translations\qtbase_*.qm" "%RsDeployPath%\translations" %Quite%
copy "%QtSharePath%\translations\qtscript_*.qm" "%RsDeployPath%\translations" %Quite%
copy "%QtSharePath%\translations\qtquick1_*.qm" "%RsDeployPath%\translations" %Quite%
copy "%QtSharePath%\translations\qtmultimedia_*.qm" "%RsDeployPath%\translations" %Quite%
copy "%QtSharePath%\translations\qtxmlpatterns_*.qm" "%RsDeployPath%\translations" %Quite%
)
echo copy bdboot.txt
copy "%SourcePath%\libbitdht\src\bitdht\bdboot.txt" "%RsDeployPath%" %Quite%
echo copy changelog.txt
copy "%SourcePath%\retroshare-gui\src\changelog.txt" "%RsDeployPath%" %Quite%
if exist "%SourcePath%\libresapi\src\webui" (
echo copy webui
mkdir "%RsDeployPath%\webui"
xcopy /S "%SourcePath%\libresapi\src\webui" "%RsDeployPath%\webui" %Quite%
)
if "%ParamTor%"=="1" (
echo copy tor
echo n | copy /-y "%EnvDownloadPath%\tor\Tor\*.*" "%RsDeployPath%" %Quite%
)
rem pack files
title Pack - %SourceName%%RsType%-%RsBuildConfig% [pack files]
"%EnvSevenZipExe%" a -mx=9 -t7z "%Archive%" "%RsDeployPath%\*"
title %COMSPEC%
call :cleanup
endlocal
exit /B 0
:error
call :Cleanup
endlocal
exit /B 1
:cleanup
goto :EOF
:error_env
echo Failed to initialize environment.
endlocal
exit /B 1
:copy_extension
if exist "%~1\%RsBuildConfig%\%~n1.dll" (
copy "%~1\%RsBuildConfig%\%~n1.dll" %2 %Quite%
)
goto :EOF
:copy_dependencies
set CopyDependenciesCopiedSomething=0
for /F "usebackq" %%A in (`%ToolsPath%\depends.bat list %1`) do (
if not exist "%~2\%%A" (
if exist "%RsMinGWPath%\bin\%%A" (
set CopyDependenciesCopiedSomething=1
copy "%RsMinGWPath%\bin\%%A" %2 %Quite%
)
)
)
if "%CopyDependenciesCopiedSomething%"=="1" goto copy_dependencies
goto :EOF

View File

@ -0,0 +1,19 @@
call :make_path SourcePath "%~dp0..\.."
call :make_path RootPath "%SourcePath%\.."
call :source_name SourceName "%SourcePath%"
set ToolsPath=%~dp0tools
set EnvPath=%~dp0env
exit /B 0
:make_path
setlocal
set Var=%~1
pushd %2
set CD=%cd%
popd
endlocal & set %Var%=%CD%
goto :EOF
:source_name
set %~1=%~nx2

View File

@ -0,0 +1,37 @@
:: Usage:
:: call env-msys2.bat [reinstall|clean]
:: Initialize environment
call "%~dp0env.bat"
if errorlevel 1 goto error_env
IF DEFINED ProgramFiles(x86) (
:: x64
set MSYS2Architecture=x86_64
set MSYS2Base=64
) else (
:: x86
set MSYS2Architecture=i686
set MSYS2Base=32
)
set CHERE_INVOKING=1
set EnvMSYS2Path=%EnvRootPath%\msys2
set EnvMSYS2BasePath=%EnvMSYS2Path%\msys%MSYS2Base%
call "%~dp0tools\prepare-msys2.bat" %1
if errorlevel 1 exit /B %ERRORLEVEL%
set EnvMSYS2SH=%EnvMSYS2BasePath%\usr\bin\sh.exe
if not exist "%EnvMSYS2SH%" if errorlevel 1 goto error_env
set EnvMSYS2Cmd="%EnvMSYS2SH%" -lc
set PATH=%EnvMSYS2BasePath%\usr\bin;%PATH%
exit /B 0
:error_env
echo Failed to initialize environment.
exit /B 1

26
build_scripts/Windows-msys2/env/env.bat vendored Normal file
View File

@ -0,0 +1,26 @@
:: Initialize environment
call "%~dp0..\env.bat"
if errorlevel 1 goto error_env
set EnvRootPath=%RootPath%\%SourceName%-msys2
set EnvToolsPath=%EnvRootPath%\tools
set EnvTempPath=%EnvRootPath%\tmp
set EnvDownloadPath=%EnvRootPath%\download
set EnvWgetExe=%EnvToolsPath%\wget.exe
set EnvSevenZipExe=%EnvToolsPath%\7z.exe
set EnvDependsExe=%EnvToolsPath%\depends.exe
set EnvCEchoExe=%EnvToolsPath%\cecho.exe
set cecho=call "%ToolsPath%\cecho.bat"
:: Create folders
if not exist "%EnvRootPath%" mkdir "%EnvRootPath%"
if not exist "%EnvToolsPath%" mkdir "%EnvToolsPath%"
if not exist "%EnvDownloadPath%" mkdir "%EnvDownloadPath%"
call "%~dp0tools\prepare-tools.bat"
exit /B %ERRORLEVEL%
:error_env
echo Failed to initialize environment.
exit /B 1

View File

@ -0,0 +1,57 @@
:: Usage:
:: call prepare-msys2.bat [reinstall|clean]
setlocal enabledelayedexpansion
if "%EnvMSYS2Path%"=="" exit /B 1
if "%MSYS2Architecture%"=="" exit /B 1
if "%MSYS2Base%"=="" exit /B 1
if not exist "%EnvRootPath%"=="" exit /B 1
copy "%~dp0root\update-msys2.bat" "%EnvRootPath%" >nul
if "%~1"=="clean" (
%cecho% info "Clean MSYS2"
call "%ToolsPath%\remove-dir.bat" "%EnvMSYS2Path%"
goto exit
)
if exist "%EnvMSYS2Path%\msys%MSYS2Base%\usr\bin\pacman.exe" (
if "%~1"=="reinstall" (
choice /M "Found existing MSYS2 version. Do you want to proceed?"
if !ERRORLEVEL!==2 goto exit
) else (
goto exit
)
)
set MSYS2Install=msys2-base-%MSYS2Architecture%-20180531.tar.xz
set MSYS2Url=http://sourceforge.net/projects/msys2/files/Base/%MSYS2Architecture%/%MSYS2Install%/download
%cecho% info "Remove previous MSYS2 version"
call "%ToolsPath%\remove-dir.bat" "%EnvMSYS2Path%"
%cecho% info "Download installation files"
if not exist "%EnvDownloadPath%\%MSYS2Install%" call "%ToolsPath%\download-file.bat" "%MSYS2Url%" "%EnvDownloadPath%\%MSYS2Install%"
if not exist "%EnvDownloadPath%\%MSYS2Install%" %cecho% error "Cannot download MSYS" & goto error
%cecho% info "Unpack MSYS2"
"%EnvSevenZipExe%" x -so "%EnvDownloadPath%\%MSYS2Install%" | "%EnvSevenZipExe%" x -y -si -ttar -o"%EnvMSYS2Path%"
set MSYS2SH=%EnvMSYS2Path%\msys%MSYS2Base%\usr\bin\sh
%cecho% info "Initialize MSYS2"
"%MSYS2SH%" -lc "pacman -Sy"
"%MSYS2SH%" -lc "pacman --noconfirm --needed -S bash pacman pacman-mirrors msys2-runtime"
call "%EnvMSYS2Path%\msys%MSYS2Base%\autorebase.bat"
call "%EnvRootPath%\update-msys2.bat"
call "%EnvRootPath%\update-msys2.bat"
:exit
endlocal
exit /B 0
:error
endlocal
exit /B 1

View File

@ -0,0 +1,79 @@
setlocal
if "%EnvRootPath%"=="" exit /B 1
set CEchoUrl=https://github.com/lordmulder/cecho/releases/download/2015-10-10/cecho.2015-10-10.zip
set CEchoInstall=cecho.2015-10-10.zip
set SevenZipUrl=https://sourceforge.net/projects/sevenzip/files/7-Zip/18.05/7z1805.msi/download
set SevenZipInstall=7z1805.msi
set WgetUrl=https://eternallybored.org/misc/wget/1.19.4/32/wget.exe
set WgetInstall=wget.exe
set DependsUrl=http://www.dependencywalker.com/depends22_x86.zip
set DependsInstall=depends22_x86.zip
if not exist "%EnvToolsPath%\wget.exe" (
echo Download Wget installation
if not exist "%EnvDownloadPath%\%WgetInstall%" call "%ToolsPath%\winhttpjs.bat" %WgetUrl% -saveTo "%EnvDownloadPath%\%WgetInstall%"
if not exist "%EnvDownloadPath%\%WgetInstall%" %cecho% error "Cannot download Wget installation" & goto error
echo Copy Wget
copy "%EnvDownloadPath%\wget.exe" "%EnvToolsPath%"
)
if not exist "%EnvToolsPath%\7z.exe" (
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
mkdir "%EnvTempPath%"
echo Download 7z installation
if not exist "%EnvDownloadPath%\%SevenZipInstall%" call "%ToolsPath%\download-file.bat" "%SevenZipUrl%" "%EnvDownloadPath%\%SevenZipInstall%"
if not exist "%EnvDownloadPath%\%SevenZipInstall%" echo Cannot download 7z installation& goto error
echo Unpack 7z
msiexec /a "%EnvDownloadPath%\%SevenZipInstall%" /qb TARGETDIR="%EnvTempPath%"
copy "%EnvTempPath%\Files\7-Zip\7z.dll" "%EnvToolsPath%"
copy "%EnvTempPath%\Files\7-Zip\7z.exe" "%EnvToolsPath%"
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
)
if not exist "%EnvToolsPath%\cecho.exe" (
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
mkdir "%EnvTempPath%"
echo Download cecho installation
if not exist "%EnvDownloadPath%\%CEchoInstall%" call "%ToolsPath%\download-file.bat" "%CEchoUrl%" "%EnvDownloadPath%\%CEchoInstall%"
if not exist "%EnvDownloadPath%\%cCEhoInstall%" echo Cannot download cecho installation& goto error
echo Unpack cecho
"%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%CEchoInstall%"
copy "%EnvTempPath%\cecho.exe" "%EnvToolsPath%"
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
)
if not exist "%EnvToolsPath%\depends.exe" (
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
mkdir "%EnvTempPath%"
%cecho% info "Download Dependency Walker installation"
if not exist "%EnvDownloadPath%\%DependsInstall%" call "%ToolsPath%\winhttpjs.bat" %DependsUrl% -saveTo "%EnvDownloadPath%\%DependsInstall%"
if not exist "%EnvDownloadPath%\%DependsInstall%" %cecho% error "Cannot download Dependendy Walker installation" & goto error
%cecho% info "Unpack Dependency Walker"
"%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%DependsInstall%"
copy "%EnvTempPath%\*" "%EnvToolsPath%"
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
)
:exit
endlocal
exit /B 0
:error
endlocal
exit /B 1

View File

@ -0,0 +1,19 @@
@echo off
setlocal
if exist "%~dp0msys2\msys32" call :update 32
if exist "%~dp0msys2\msys64" call :update 64
goto :EOF
:update
set MSYSSH=%~dp0msys2\msys%~1\usr\bin\sh
echo Update MSYS2 %~1
"%MSYSSH%" -lc "pacman -Sy"
"%MSYSSH%" -lc "pacman --noconfirm -Su"
:exit
endlocal
goto :EOF

View File

@ -0,0 +1,6 @@
:: Usage:
:: call cecho.bat [info|error|std] "text"
if "%~1"=="std" echo %~2
if "%~1"=="info" "%EnvCEchoExe%" green "%~2"
if "%~1"=="error" "%EnvCEchoExe%" red "%~2"

View File

@ -0,0 +1,40 @@
:: Usage:
:: call depends.bat [list^|missing] file
if "%2"=="" (
echo Usage: %~nx0 [list^|missing] File
exit /B 1
)
setlocal
if not exist "%EnvDependsExe%" echo depends.exe not found in %EnvToolsPath%.& exit /B 1
set CutPath=
call "%ToolsPath%\find-in-path.bat" CutPath cut.exe
if "%CutPath%"=="" echo cut.exe not found in PATH.& exit /B 1
start /wait "" "%EnvDependsExe%" /c /oc:"%~dp0depends.tmp" %2
if "%1"=="missing" (
cut.exe --delimiter=, --fields=1,2 "%~dp0depends.tmp" >"%~dp0depends1.tmp"
for /F "tokens=1,2 delims=," %%A in (%~sdp0depends1.tmp) do (
if "%%A"=="?" (
echo %%~B
)
)
)
if "%1"=="list" (
cut.exe --delimiter=, --fields=2 "%~dp0depends.tmp" >"%~dp0depends1.tmp"
for /F "tokens=1 delims=," %%A in (%~sdp0depends1.tmp) do (
if "%%A" NEQ "Module" (
echo %%~A
)
)
)
if exist "%~dp0depends.tmp" del /Q "%~dp0depends.tmp"
if exist "%~dp0depends1.tmp" del /Q "%~dp0depends1.tmp"
endlocal
exit /B 0

View File

@ -0,0 +1,13 @@
:: Usage:
:: call download-file.bat url file
if "%~2"=="" (
echo.
echo Parameter error.
exit /B 1
)
::"%EnvCurlExe%" -L -k "%~1" -o "%~2"
"%EnvWgetExe%" --no-check-certificate --continue "%~1" --output-document="%~2"
exit /B %ERRORLEVEL%

View File

@ -0,0 +1,26 @@
:: Usage:
:: call find-in-path.bat variable file
setlocal
set Var=%~1
set File=%~2
if "%File%"=="" (
echo.
echo Parameter error.
exit /B 1
)
set FoundPath=
SET PathTemp="%Path:;=";"%"
FOR %%P IN (%PathTemp%) DO (
IF EXIST "%%~P.\%File%" (
set FoundPath=%%~P
goto :found
)
)
:found
endlocal & set %Var%=%FoundPath%

View File

@ -0,0 +1,39 @@
REM Usage:
REM call get-git-ref.bat Variable [Branch]
setlocal
set Variable=%~1
if "%Variable%"=="" (
echo.
echo Parameter error
exit /B 1
)
set Ref=
:: Check git executable
set GitPath=
call "%~dp0find-in-path.bat" GitPath git.exe
if "%GitPath%"=="" (
echo.
echo Git executable not found in PATH.
goto exit
)
set GitParameter=
set Branch=%~2
if "%Branch%"=="" (
set Branch=HEAD
set GitParameter=--head
)
for /F "tokens=1*" %%A in ('git show-ref %GitParameter% %Branch%') do (
if "%%B"=="%Branch%" (
set Ref=%%A
)
)
:exit
endlocal & set %Variable%=%Ref%
exit /B 0

View File

@ -0,0 +1,27 @@
:: Usage:
:: call get-qt-version.bat variable
setlocal
set Var=%~1
if "%Var%"=="" (
echo.
echo Parameter error.
exit /B 1
)
set QtVersion=
%EnvMSYS2Cmd% "qmake -version" >"%~dp0qtversion.tmp"
for /F "tokens=1,2,3,4" %%A in (%~sdp0qtversion.tmp) do (
if "%%A"=="Using" (
set QtVersion=%%D
goto exit
)
)
:exit
if exist "%~dp0qtversion.tmp" del /Q "%~dp0qtversion.tmp"
endlocal & set %Var%=%QtVersion%
exit /B 0

View File

@ -0,0 +1,33 @@
:: Usage:
:: call get-rs-version.bat Define Variable
setlocal
set Define=%~1
set Variable=%~2
if "%Variable%"=="" (
echo.
echo Parameter error.
exit /B 1
)
set Result=
set VersionFile="%~dp0..\..\..\libretroshare\src\retroshare\rsversion.h"
if not exist "%VersionFile%" (
echo.
echo Version file doesn't exist.
echo %VersionFile%
exit /B1
)
for /F "usebackq tokens=1,2,3" %%A in (%VersionFile%) do (
if "%%A"=="#define" (
if "%%B"=="%Define%" (
set Result=%%~C
)
)
)
endlocal & set %Variable%=%Result%
exit /B 0

View File

@ -0,0 +1,20 @@
:: Usage:
:: call msys2-path.bat path variable
setlocal
set WinPath=%~1
set MSYS2Var=%~2
if "%MSYS2Var%"=="" (
echo.
echo Parameter error.
exit /B 1
)
set MSYS2Path=/%WinPath:~0,1%/%WinPath:~3%
set MSYS2Path=%MSYS2Path:\=/%
endlocal & set %MSYS2Var%=%MSYS2Path%
exit /B 0

View File

@ -0,0 +1,15 @@
:: Usage:
:: call remove-dir.bat path
if "%~1"=="" (
echo.
echo Parameter error.
exit /B 1
)
if exist %1 (
del /s /f /q %1 >nul
rmdir /s /q %1
)
exit /B 0

View File

@ -0,0 +1,584 @@
@if (@X) == (@Y) @end /* JScript comment
@echo off
rem :: the first argument is the script name as it will be used for proper help message
cscript //E:JScript //nologo "%~f0" "%~nx0" %*
exit /b %errorlevel%
@if (@X)==(@Y) @end JScript comment */
// used resources
// update 12.10.15
// osvikvi(https://github.com/osvikvi) has nodited that the -password option is not set , so this is fixed
//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384058(v=vs.85).aspx
//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384055(v=vs.85).aspx
//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384059(v=vs.85).aspx
// global variables and constants
// ----------------------------------
// -- asynch requests not included --
// ----------------------------------
//todo - save responceStream instead of responceBody !!
//todo - set all winthttp options ->//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384108(v=vs.85).aspx
//todo - log all options
//todo - improve help message . eventual verbose option
var ARGS = WScript.Arguments;
var scriptName = ARGS.Item(0);
var url = "";
var saveTo = "";
var user = 0;
var pass = 0;
var proxy = 0;
var bypass = 0;
var proxy_user = 0;
var proxy_pass = 0;
var certificate = 0;
var force = true;
var body = "";
//ActiveX objects
var WinHTTPObj = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
var FileSystemObj = new ActiveXObject("Scripting.FileSystemObject");
var AdoDBObj = new ActiveXObject("ADODB.Stream");
// HttpRequest SetCredentials flags.
var proxy_settings = 0;
//
HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0;
HTTPREQUEST_SETCREDENTIALS_FOR_PROXY = 1;
//timeouts and their default values
var RESOLVE_TIMEOUT = 0;
var CONNECT_TIMEOUT = 90000;
var SEND_TIMEOUT = 90000;
var RECEIVE_TIMEOUT = 90000;
//HttpRequestMethod
var http_method = 'GET';
//header
var header_file = "";
//report
var reportfile = "";
//test-this:
var use_stream = false;
//autologon policy
var autologon_policy = 1; //0,1,2
//headers will be stored as multi-dimensional array
var headers = [];
//user-agent
var ua = "";
//escape URL
var escape = false;
function printHelp() {
WScript.Echo(scriptName + " - sends HTTP request and saves the request body as a file and/or a report of the sent request");
WScript.Echo(scriptName + " url [-force yes|no] [-user username -password password] [-proxy proxyserver:port] [-bypass bypass_list]");
WScript.Echo(" [-proxyuser proxy_username -proxypassword proxy_password] [-certificate certificateString]");
WScript.Echo(" [-method GET|POST|PATCH|DELETE|HEAD|OPTIONS|CONNECT]");
WScript.Echo(" [-saveTo file] - to print response to console use con");
WScript.Echo(" [-sendTimeout int(milliseconds)]");
WScript.Echo(" [-resolveTimeout int(milliseconds)]");
WScript.Echo(" [-connectTimeout int(milliseconds)]");
WScript.Echo(" [-receiveTimeout int(milliseconds)]");
WScript.Echo(" [-autologonPolicy 1|2|3]");
WScript.Echo(" [-proxySettings 1|2|3] (https://msdn.microsoft.com/en-us/library/windows/desktop/aa384059(v=vs.85).aspx)");
//header
WScript.Echo(" [-headers-file header_file]");
//reportfile
WScript.Echo(" [-reportfile reportfile]");
WScript.Echo(" [-ua user-agent]");
WScript.Echo(" [-ua-file user-agent-file]");
WScript.Echo(" [-escape yes|no]");
WScript.Echo(" [-body body-string]");
WScript.Echo(" [-body-file body-file]");
WScript.Echo("-force - decide to not or to overwrite if the local files exists");
WScript.Echo("proxyserver:port - the proxy server");
WScript.Echo("bypass- bypass list");
WScript.Echo("proxy_user , proxy_password - credentials for proxy server");
WScript.Echo("user , password - credentials for the server");
WScript.Echo("certificate - location of SSL certificate");
WScript.Echo("method - what HTTP method will be used.Default is GET");
WScript.Echo("saveTo - save the responce as binary file");
WScript.Echo(" ");
WScript.Echo("Header file should contain key:value pairs.Lines starting with \"#\" will be ignored.");
WScript.Echo("value should NOT be enclosed with quotes");
WScript.Echo(" ");
WScript.Echo("Examples:");
WScript.Echo(scriptName + " http://somelink.com/somefile.zip -saveTo c:\\somefile.zip -certificate \"LOCAL_MACHINE\\Personal\\My Middle-Tier Certificate\"");
WScript.Echo(scriptName + " http://somelink.com/something.html -method POST -certificate \"LOCAL_MACHINE\\Personal\\My Middle-Tier Certificate\" -header c:\\header_file -reportfile c:\\reportfile.txt");
WScript.Echo(scriptName + "\"http://somelink\" -method POST -header hdrs.txt -reportfile reportfile2.txt -saveTo responsefile2 -ua \"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36\" -body-file some.json");
}
function parseArgs() {
//
if (ARGS.Length < 2) {
WScript.Echo("insufficient arguments");
printHelp();
WScript.Quit(43);
}
// !!!
url = ARGS.Item(1);
// !!!
if (ARGS.Length % 2 != 0) {
WScript.Echo("illegal arguments");
printHelp();
WScript.Quit(44);
}
for (var i = 2; i < ARGS.Length - 1; i = i + 2) {
var arg = ARGS.Item(i).toLowerCase();
var next = ARGS.Item(i + 1);
try {
switch (arg) { // the try-catch is set mainly because of the parseInts
case "-force":
if (next == "no") {
force = false;
}
break;
case "-escape":
if (next == "yes") {
escape = true;
}
break;
case "-saveto":
saveTo = next;
break;
case "-user":
case "-u":
user = next;
break;
case "-pass":
case "-password":
case "-p":
pass = next;
break;
case "-proxy":
proxy = next;
break;
case "-bypass":
bypass = next;
break;
case "-proxyuser":
case "-pu":
proxy_user = next;
break;
case "-proxypassword":
case "-pp":
proxy_pass = next;
break;
case "-ua":
ua = next;
break;
case "-ua-file":
ua = readFile(next);
break;
case "-body":
body = next;
break;
case "-usestream":
//WScript.Echo("~~");
if (next.toLowerCase() === "yes") {
use_stream = true
};
break;
case "-body-file":
body = readFile(next);
break;
case "-certificate":
certificate = next;
break;
case "-method":
switch (next.toLowerCase()) {
case "post":
http_method = 'POST';
break;
case "get":
http_method = 'GET';
break;
case "head":
http_method = 'HEAD';
break;
case "put":
http_method = 'PUT';
break;
case "options":
http_method = 'OPTIONS';
break;
case "connect":
http_method = 'CONNECT';
break;
case "patch":
http_method = 'PATCH';
break;
case "delete":
http_method = 'DELETE';
break;
default:
WScript.Echo("Invalid http method passed " + next);
WScript.Echo("possible values are GET,POST,DELETE,PUT,CONNECT,PATCH,HEAD,OPTIONS");
WScript.Quit(1326);
break;
}
break;
case "-headers-file":
case "-header":
headers = readPropFile(next);
break;
case "-reportfile":
reportfile = next;
break;
//timeouts
case "-sendtimeout":
SEND_TIMEOUT = parseInt(next);
break;
case "-connecttimeout":
CONNECT_TIMEOUT = parseint(next);
break;
case "-resolvetimeout":
RESOLVE_TIMEOUT = parseInt(next);
break;
case "-receivetimeout":
RECEIVE_TIMEOUT = parseInt(next);
break;
case "-autologonpolicy":
autologon_policy = parseInt(next);
if (autologon_policy > 2 || autologon_policy < 0) {
WScript.Echo("out of autologon policy range");
WScript.Quit(87);
};
break;
case "-proxysettings":
proxy_settings = parseInt(next);
if (proxy_settings > 2 || proxy_settings < 0) {
WScript.Echo("out of proxy settings range");
WScript.Quit(87);
};
break;
default:
WScript.Echo("Invalid command line switch: " + arg);
WScript.Quit(1405);
break;
}
} catch (err) {
WScript.Echo(err.message);
WScript.Quit(1348);
}
}
}
stripTrailingSlash = function(path) {
while (path.substr(path.length - 1, path.length) == '\\') {
path = path.substr(0, path.length - 1);
}
return path;
}
function existsItem(path) {
return FileSystemObj.FolderExists(path) || FileSystemObj.FileExists(path);
}
function deleteItem(path) {
if (FileSystemObj.FileExists(path)) {
FileSystemObj.DeleteFile(path);
return true;
} else if (FileSystemObj.FolderExists(path)) {
FileSystemObj.DeleteFolder(stripTrailingSlash(path));
return true;
} else {
return false;
}
}
//-------------------------------
//----------------------
//----------
//-----
//--
function request(url) {
try {
WinHTTPObj.Open(http_method, url, false);
if (proxy != 0 && bypass != 0) {
WinHTTPObj.SetProxy(proxy_settings, proxy, bypass);
}
if (proxy != 0) {
WinHTTPObj.SetProxy(proxy_settings, proxy);
}
if (user != 0 && pass != 0) {
WinHTTPObj.SetCredentials(user, pass, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER);
}
if (proxy_user != 0 && proxy_pass != 0) {
WinHTTPObj.SetCredentials(proxy_user, proxy_pass, HTTPREQUEST_SETCREDENTIALS_FOR_PROXY);
}
if (certificate != 0) {
WinHTTPObj.SetClientCertificate(certificate);
}
//set autologin policy
WinHTTPObj.SetAutoLogonPolicy(autologon_policy);
//set timeouts
WinHTTPObj.SetTimeouts(RESOLVE_TIMEOUT, CONNECT_TIMEOUT, SEND_TIMEOUT, RECEIVE_TIMEOUT);
if (headers.length !== 0) {
WScript.Echo("Sending with headers:");
for (var i = 0; i < headers.length; i++) {
WinHTTPObj.SetRequestHeader(headers[i][0], headers[i][1]);
WScript.Echo(headers[i][0] + ":" + headers[i][1]);
}
WScript.Echo("");
}
if (ua !== "") {
//user-agent option from:
//WinHttpRequestOption enumeration
// other options can be added like bellow
//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384108(v=vs.85).aspx
WinHTTPObj.Option(0) = ua;
}
if (escape) {
WinHTTPObj.Option(3) = true;
}
if (trim(body) === "") {
WinHTTPObj.Send();
} else {
WinHTTPObj.Send(body);
}
var status = WinHTTPObj.Status
} catch (err) {
WScript.Echo(err.message);
WScript.Quit(666);
}
////////////////////////
// report //
////////////////////////
if (reportfile != "") {
//var report_string="";
var n = "\r\n";
var report_string = "Status:" + n;
report_string = report_string + " " + WinHTTPObj.Status;
report_string = report_string + " " + WinHTTPObj.StatusText + n;
report_string = report_string + " " + n;
report_string = report_string + "Response:" + n;
report_string = report_string + WinHTTPObj.ResponseText + n;
report_string = report_string + " " + n;
report_string = report_string + "Headers:" + n;
report_string = report_string + WinHTTPObj.GetAllResponseHeaders() + n;
WinHttpRequestOption_UserAgentString = 0; // Name of the user agent
WinHttpRequestOption_URL = 1; // Current URL
WinHttpRequestOption_URLCodePage = 2; // Code page
WinHttpRequestOption_EscapePercentInURL = 3; // Convert percents
// in the URL
// rest of the options can be seen and eventually added using this as reference
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa384108(v=vs.85).aspx
report_string = report_string + "URL:" + n;
report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_URL) + n;
report_string = report_string + "URL Code Page:" + n;
report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_URLCodePage) + n;
report_string = report_string + "User Agent:" + n;
report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_UserAgentString) + n;
report_string = report_string + "Escapped URL:" + n;
report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_EscapePercentInURL) + n;
prepareateFile(force, reportfile);
WScript.Echo("Writing report to " + reportfile);
writeFile(reportfile, report_string);
}
switch (status) {
case 200:
WScript.Echo("Status: 200 OK");
break;
default:
WScript.Echo("Status: " + status);
WScript.Echo("Status was not OK. More info -> https://en.wikipedia.org/wiki/List_of_HTTP_status_codes");
}
//if as binary
if (saveTo.toLowerCase() === "con") {
WScript.Echo(WinHTTPObj.ResponseText);
}
if (saveTo !== "" && saveTo.toLowerCase() !== "con") {
prepareateFile(force, saveTo);
try {
if (use_stream) {
writeBinFile(saveTo, WinHTTPObj.ResponseStream);
} else {
writeBinFile(saveTo, WinHTTPObj.ResponseBody);
}
} catch (err) {
WScript.Echo("Failed to save the file as binary.Attempt to save it as text");
AdoDBObj.Close();
prepareateFile(true, saveTo);
writeFile(saveTo, WinHTTPObj.ResponseText);
}
}
WScript.Quit(status);
}
//--
//-----
//----------
//----------------------
//-------------------------------
function prepareateFile(force, file) {
if (force && existsItem(file)) {
if (!deleteItem(file)) {
WScript.Echo("Unable to delete " + file);
WScript.Quit(8);
}
} else if (existsItem(file)) {
WScript.Echo("Item " + file + " already exist");
WScript.Quit(9);
}
}
function writeBinFile(fileName, data) {
AdoDBObj.Type = 1;
AdoDBObj.Open();
AdoDBObj.Position = 0;
AdoDBObj.Write(data);
AdoDBObj.SaveToFile(fileName, 2);
AdoDBObj.Close();
}
function writeFile(fileName, data) {
AdoDBObj.Type = 2;
AdoDBObj.CharSet = "iso-8859-1";
AdoDBObj.Open();
AdoDBObj.Position = 0;
AdoDBObj.WriteText(data);
AdoDBObj.SaveToFile(fileName, 2);
AdoDBObj.Close();
}
function readFile(fileName) {
//check existence
try {
if (!FileSystemObj.FileExists(fileName)) {
WScript.Echo("file " + fileName + " does not exist!");
WScript.Quit(13);
}
if (FileSystemObj.GetFile(fileName).Size === 0) {
return "";
}
var fileR = FileSystemObj.OpenTextFile(fileName, 1);
var content = fileR.ReadAll();
fileR.Close();
return content;
} catch (err) {
WScript.Echo("Error while reading file: " + fileName);
WScript.Echo(err.message);
WScript.Echo("Will return empty string");
return "";
}
}
function readPropFile(fileName) {
//check existence
resultArray = [];
if (!FileSystemObj.FileExists(fileName)) {
WScript.Echo("(headers)file " + fileName + " does not exist!");
WScript.Quit(15);
}
if (FileSystemObj.GetFile(fileName).Size === 0) {
return resultArray;
}
var fileR = FileSystemObj.OpenTextFile(fileName, 1);
var line = "";
var k = "";
var v = "";
var lineN = 0;
var index = 0;
try {
WScript.Echo("parsing headers form " + fileName + " property file ");
while (!fileR.AtEndOfStream) {
line = fileR.ReadLine();
lineN++;
index = line.indexOf(":");
if (line.indexOf("#") === 0 || trim(line) === "") {
continue;
}
if (index === -1 || index === line.length - 1 || index === 0) {
WScript.Echo("Invalid line " + lineN);
WScript.Quit(93);
}
k = trim(line.substring(0, index));
v = trim(line.substring(index + 1, line.length));
resultArray.push([k, v]);
}
fileR.Close();
return resultArray;
} catch (err) {
WScript.Echo("Error while reading headers file: " + fileName);
WScript.Echo(err.message);
WScript.Echo("Will return empty array");
return resultArray;
}
}
function trim(str) {
return str.replace(/^\s+/, '').replace(/\s+$/, '');
}
function main() {
parseArgs();
request(url);
}
main();

View File

@ -13,12 +13,13 @@ SQLCIPHER_VERSION=2.2.1
LIBMICROHTTPD_VERSION=0.9.59
FFMPEG_VERSION=3.4
RAPIDJSON_VERSION=1.1.0
XAPIAN_VERSION=1.4.7
DOWNLOAD_PATH?=download
BUILD_PATH=build
LIBS_PATH?=libs
all: dirs zlib bzip2 miniupnpc openssl speex speexdsp opencv libxml2 libxslt curl sqlcipher libmicrohttpd ffmpeg rapidjson copylibs
all: dirs zlib bzip2 miniupnpc openssl speex speexdsp opencv libxml2 libxslt curl sqlcipher libmicrohttpd ffmpeg rapidjson xapian copylibs
download: \
$(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz \
@ -35,7 +36,8 @@ download: \
$(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz \
$(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz \
$(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz \
$(DOWNLOAD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tar.gz
$(DOWNLOAD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tar.gz \
$(DOWNLOAD_PATH)/xapian-core-$(XAPIAN_VERSION).tar.xz
clean:
rm -r -f $(BUILD_PATH)
@ -360,6 +362,30 @@ $(BUILD_PATH)/rapidjson-$(RAPIDJSON_VERSION): $(DOWNLOAD_PATH)/rapidjson-$(RAPID
rm -r -f rapidjson-$(RAPIDJSON_VERSION)
mv $(BUILD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tmp $(BUILD_PATH)/rapidjson-$(RAPIDJSON_VERSION)
xapian: $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION)
$(DOWNLOAD_PATH)/xapian-core-$(XAPIAN_VERSION).tar.xz:
wget --no-check-certificate https://oligarchy.co.uk/xapian/$(XAPIAN_VERSION)/xapian-core-$(XAPIAN_VERSION).tar.xz -O $(DOWNLOAD_PATH)/xapian-core-$(XAPIAN_VERSION).tar.xz
$(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION): $(DOWNLOAD_PATH)/xapian-core-$(XAPIAN_VERSION).tar.xz
# prepare
rm -r -f $(BUILD_PATH)/xapian-core-*
tar xvf $(DOWNLOAD_PATH)/xapian-core-$(XAPIAN_VERSION).tar.xz
# build
#cd xapian-core-$(XAPIAN_VERSION) && ./configure --disable-shared --enable-static --prefix="`pwd`/../$(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp"
#cd xapian-core-$(XAPIAN_VERSION) && make install
cd xapian-core-$(XAPIAN_VERSION) && ./configure --disable-shared --enable-static
cd xapian-core-$(XAPIAN_VERSION) && make
# copy files
mkdir -p $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp/include
cp -r xapian-core-$(XAPIAN_VERSION)/include/* $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp/include/
rm $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp/include/Makefile*
mkdir -p $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp/lib
cp -r xapian-core-$(XAPIAN_VERSION)/.libs/libxapian.a $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp/lib/
# cleanup
rm -r -f xapian-core-$(XAPIAN_VERSION)
mv $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION)
copylibs:
rm -r -f $(LIBS_PATH) ; \
mkdir -p $(LIBS_PATH) ; \

View File

@ -13,11 +13,11 @@ call "%~dp0build-libs\build-libs.bat"
if errorlevel 1 %cecho% error "Failed to build libraries." & exit /B %ERRORLEVEL%
%cecho% info "Build %SourceName%"
call "%~dp0build\build.bat" retrotor
call "%~dp0build\build.bat" release tor version autologin plugins
if errorlevel 1 %cecho% error "Failed to build %SourceName%." & exit /B %ERRORLEVEL%
%cecho% info "Pack %SourceName%"
call "%~dp0build\pack.bat" retrotor
call "%~dp0build\pack.bat" release tor
if errorlevel 1 %cecho% error "Failed to pack %SourceName%." & exit /B %ERRORLEVEL%
exit /B 0

View File

@ -13,11 +13,11 @@ call "%~dp0build-libs\build-libs.bat"
if errorlevel 1 %cecho% error "Failed to build libraries." & exit /B %ERRORLEVEL%
%cecho% info "Build %SourceName%"
call "%~dp0build\build.bat" standard
call "%~dp0build\build.bat" release version autologin plugins
if errorlevel 1 %cecho% error "Failed to build %SourceName%." & exit /B %ERRORLEVEL%
%cecho% info "Pack %SourceName%"
call "%~dp0build\pack.bat" standard
call "%~dp0build\pack.bat" release
if errorlevel 1 %cecho% error "Failed to pack %SourceName%." & exit /B %ERRORLEVEL%
%cecho% info "Build installer"

View File

@ -9,7 +9,7 @@ call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
:: Initialize environment
call "%~dp0env.bat" standard
call "%~dp0env.bat" release
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env
@ -29,6 +29,7 @@ set NSIS_PARAM=%NSIS_PARAM% /DQTDIR="%QtPath%\.."
set NSIS_PARAM=%NSIS_PARAM% /DMINGWDIR="%MinGWPath%\.."
set NSIS_PARAM=%NSIS_PARAM% /DOUTDIR="%RsPackPath%"
set NSIS_PARAM=%NSIS_PARAM% /DINSTALLERADD="%RsArchiveAdd%"
set NSIS_PARAM=%NSIS_PARAM% /DEXTERNAL_LIB_DIR="%BuildLibsPath%\libs"
:: Scan version from source
set RsRevision=

View File

@ -22,6 +22,7 @@ set /P LibsGCCVersion=<"%BuildLibsPath%\libs\gcc-version"
if "%LibsGCCVersion%" NEQ "%GCCVersion%" %cecho% error "Please use correct version of external libraries. (gcc %GCCVersion% ^<^> libs %LibsGCCVersion%)." & exit /B 1
:: Check git executable
if "%ParamVersion%"=="0" goto found_git
set GitPath=
call "%ToolsPath%\find-in-path.bat" GitPath git.exe
if "%GitPath%" NEQ "" goto found_git
@ -33,7 +34,7 @@ echo.
echo === Version
echo.
title Build - %SourceName%%RsType%-%RsBuildConfig% [Version]
title Build - %SourceName%-%RsBuildConfig% [Version]
pushd "%SourcePath%\retroshare-gui\src\gui\images"
:: Touch resource file
@ -47,10 +48,12 @@ echo.
echo === qmake
echo.
title Build - %SourceName%%RsType%-%RsBuildConfig% [qmake]
title Build - %SourceName%-%RsBuildConfig% [qmake]
set RS_QMAKE_CONFIG=%RsBuildConfig% version_detail_bash_script rs_autologin retroshare_plugins
if "%RsRetroTor%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% retrotor
set RS_QMAKE_CONFIG=%RsBuildConfig%
if "%ParamVersion%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% version_detail_bash_script
if "%ParamAutologin%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% rs_autologin
if "%ParamPlugins%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% retroshare_plugins
qmake "%SourcePath%\RetroShare.pro" -r -spec win32-g++ "CONFIG+=%RS_QMAKE_CONFIG%" "EXTERNAL_LIB_DIR=%BuildLibsPath%\libs"
if errorlevel 1 goto error
@ -59,7 +62,7 @@ echo.
echo === make
echo.
title Build - %SourceName%%RsType%-%RsBuildConfig% [make]
title Build - %SourceName%-%RsBuildConfig% [make]
if exist "%EnvJomExe%" (
"%EnvJomExe%"

View File

@ -7,7 +7,9 @@ call "%~dp0..\env.bat"
if errorlevel 1 goto error_env
call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
call "%~dp0env.bat" %*
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env
if not exist "%RsBuildPath%" exit /B 0

View File

@ -1,16 +1,52 @@
if "%~1"=="standard" (
set RsRetroTor=
set RsType=
) else (
if "%~1"=="retrotor" (
set RsRetroTor=1
set RsType=-tor
) else (
echo.
echo Usage: standard^|retrotor
echo.
exit /B 2
:: Process commandline parameter
set ParamRelease=0
set ParamDebug=0
set ParamVersion=0
set ParamAutologin=0
set ParamPlugins=0
set ParamTor=0
:parameter_loop
if "%~1" NEQ "" (
for /f "tokens=1,2 delims==" %%a in ("%~1") do (
if "%%~a"=="release" (
set ParamRelease=1
) else if "%%~a"=="debug" (
set ParamDebug=1
) else if "%%~a"=="version" (
set ParamVersion=1
) else if "%%~a"=="autologin" (
set ParamAutologin=1
) else if "%%~a"=="plugins" (
set ParamPlugins=1
) else if "%%~a"=="tor" (
set ParamTor=1
) else (
echo.
echo Unknown parameter %1
goto :usage
)
)
shift /1
goto parameter_loop
)
if "%ParamRelease%"=="1" (
if "%ParamDebug%"=="1" (
echo.
echo Release or Debug?
goto :usage
)
set RsBuildConfig=release
) else if "%ParamDebug%"=="1" (
set RsBuildConfig=debug
) else goto :usage
if "%ParamTor%"=="1" (
set RsType=-tor
) else (
set RsType=
)
set BuildPath=%EnvRootPath%\builds
@ -39,8 +75,7 @@ if "%GCCVersion%"=="" %cecho% error "Cannot get gcc version." & exit /B 1
set BuildLibsPath=%EnvRootPath%\build-libs\gcc-%GCCVersion%
set RsBuildConfig=release
set RsBuildPath=%BuildPath%\Qt-%QtVersion%%RsType%-%RsBuildConfig%
set RsBuildPath=%BuildPath%\Qt-%QtVersion%-%RsBuildConfig%
set RsDeployPath=%DeployPath%\Qt-%QtVersion%%RsType%-%RsBuildConfig%
set RsPackPath=%DeployPath%
set RsArchiveAdd=
@ -51,3 +86,20 @@ if errorlevel 1 exit /B %ERRORLEVEL%
:no_mod
exit /B 0
:usage
echo.
echo Usage: release^|debug [version autologin plugins]
echo.
echo Mandatory parameter
echo release^|debug Build release or debug version
echo.
echo Optional parameter (need clean when changed)
echo version Create version information from git
echo autologin Build with autologin
echo plugins Build plugins
echo.
echo Parameter for pack
echo tor Pack tor version
echo.
exit /B 2

View File

@ -1,6 +1,3 @@
:: Usage:
:: call git-log.bat standard|retrotor [no-ask]
@echo off
setlocal
@ -13,7 +10,9 @@ call "%~dp0..\env.bat"
if errorlevel 1 goto error_env
call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
call "%~dp0env.bat" %1
call "%~dp0env.bat" %*
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env
:: Check git executable

View File

@ -62,8 +62,8 @@ set RsDate=
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set RsDate=%%I
set RsDate=%RsDate:~0,4%%RsDate:~4,2%%RsDate:~6,2%
if "%RsRetroTor%"=="1" (
:: Check Retrotor
if "%ParamTor%"=="1" (
:: Check for tor executable
if not exist "%EnvDownloadPath%\tor\Tor\tor.exe" (
echo Tor binary not found. Please download Tor Expert Bundle from
echo https://www.torproject.org/download/download.html.en
@ -121,7 +121,7 @@ for /D %%D in ("%RsBuildPath%\plugins\*") do (
)
echo copy external binaries
copy "%RootPath%\libs\bin\*.dll" "%RsDeployPath%" %Quite%
copy "%BuildLibsPath%\libs\bin\*.dll" "%RsDeployPath%" %Quite%
echo copy dependencies
call :copy_dependencies "%RsDeployPath%\retroshare.exe" "%RsDeployPath%"
@ -180,7 +180,7 @@ if exist "%SourcePath%\libresapi\src\webui" (
xcopy /S "%SourcePath%\libresapi\src\webui" "%RsDeployPath%\webui" %Quite%
)
if "%RsRetroTor%"=="1" (
if "%ParamTor%"=="1" (
echo copy tor
echo n | copy /-y "%EnvDownloadPath%\tor\Tor\*.*" "%RsDeployPath%" %Quite%
)
@ -217,13 +217,19 @@ if exist "%~1\%RsBuildConfig%\%~n1.dll" (
goto :EOF
:copy_dependencies
set CopyDependenciesCopiedSomething=0
for /F "usebackq" %%A in (`%ToolsPath%\depends.bat list %1`) do (
if exist "%QtPath%\%%A" (
copy "%QtPath%\%%A" %2 %Quite%
) else (
if exist "%MinGWPath%\%%A" (
copy "%MinGWPath%\%%A" %2 %Quite%
if not exist "%~2\%%A" (
if exist "%QtPath%\%%A" (
set CopyDependenciesCopiedSomething=1
copy "%QtPath%\%%A" %2 %Quite%
) else (
if exist "%MinGWPath%\%%A" (
set CopyDependenciesCopiedSomething=1
copy "%MinGWPath%\%%A" %2 %Quite%
)
)
)
)
if "%CopyDependenciesCopiedSomething%"=="1" goto copy_dependencies
goto :EOF

View File

@ -1,224 +0,0 @@
Compling for Windows.
-----------------------------------
For Version V0.5.0+ we are switching to GPGme libraries.
This documents a clean compilation of V0.5 for Windows.
Tested on: WinXP July 2009.
You will need:
* Qt4.5 Development Libraries (from TrollTech)
* MinGw/MinSys full installation (from sourceforge.net)
* Cygwin (for OpenSSL compilation / SVN / Unix Tools)
* OpenSSL standard libraries.
* GPG Windows Install (includes gpg.exe)
* MiniUpnp library
* gpgme Library.
* libgpg-error Library.
This compilation is a little tricky as different environments
are needed to compile different libraries.
a) Cygwin: libssl.a libcrypto.a
b) MinGW/MSYS: libgpg-error, libgpgme.a, libretroshare.a, libminiupnp.a
c) Qt/MinGW: Retroshare.exe
/***************** Installation of Development Tools **************/
In this section we install: cygwin, mingw/msys and Qt4.5
1) Install Cygwin
a) download the installer and run.
b) be sure to select from the development packages:
* mingw
* svn
* gcc/gdb
* make
links:
http://www.cygwin.org/
2) install the MinGW/Msys package.
a) Download MinGW-5.1.4 installer and run.
b) Download MSYS-1.0.11 installer and run.
links:
http://downloads.sourceforge.net/mingw/MinGW-5.1.4.exe
http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe
http://www.mingw.org/
http://sourceforge.net/projects/mingw/files/
3) Install Qt4.5 LGPL Version. (Qt SDK 2009.03)
a) Download from website and run.
b) Select all options (including MinGW)
links:
http://www.qtsoftware.com/downloads
/***************** Installation of Development Tools **************/
/******************* Compiling Support Libraries ******************/
1) Compile OpenSSL using Cygwin.
a) launch cygwin xterm
b) untar openssl source package.
c) Configure mingw
d) make.
2) Compile gpg-error
a) Download from gpg
b) load up MinGW/MSYS Bash shell.
c) extract code.
d) configure
e) make
f) make install
The library will end up in /local/lib
3) Compile gpgme
a) Download from gpg
b) load up MinGW/MSYS Bash shell.
c) extract code.
d) configure
e) make
f) make install
The library will end up in /local/lib
4) Compile MiniUPnP.
up to release v1.3 now.
links:
http://miniupnp.free.fr/
http://miniupnp.free.fr/files/
5) Install pthreads
links:
http://sourceware.org/pthreads-win32/
ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-8-0-release.exe
/******************* Compiling Support Libraries ******************/
/*********************** Compiling Retroshare *********************/
1) Setup Source Code TAR (TODO: Update for windows).
This is useful as it provides a standard structure to work against,
we will update this with the required support libraries soon.
a) Open MSYS Bash shell, and change to this location.
c:/msys/1.0/home/XXX/retroshare
b) create a working directory under this.
1) c:/msys/1.0/home/XXX/miniupnpc-1.3
2) c:/msys/1.0/home/XXX/pthreads-w32-2-8-0-release
3) c:/msys/1.0/home/XXX/zlib-1.2.3
4) c:/msys/1.0/home/XXX/gpgme-1.1.8
5) c:/msys/1.0/home/XXX/libgpg-error-1.7
c) Install OpenSSL to this directory (get from http://www.slproweb.com/download/Win32OpenSSL-0_9_8k.exe)
1) c:/msys/1.0/home/XXX/OpenSSL
d) get the latest svn trunk and unzip to (get from http://retroshare.svn.sourceforge.net/viewvc/retroshare/trunk.tar.gz) .
1) c:/msys/1.0/home/XXX/retroshare
2) Compile libretroshare
a) change to the libretroshare directory.
1) cd c:/msys/1.0/home/XXX/retroshare/libretroshare/src
b) modify support directory paths to point at correct locations.
1) open scripts/config.mk and enable OS = Win # MinGw.
2) open scripts/config-mingw.mk
3) disable lines (line 20-29)
4) enable lines 34-42 and 118-119
#### Enable this section for compiling with MSYS/MINGW compile
SRC_ROOT=/home/linux
SSL_DIR=$(SRC_ROOT)/OpenSSL
GPGME_DIR=$(SRC_ROOT)/gpgme-1.1.8
GPG_ERROR_DIR=$(SRC_ROOT)/libgpg-error-1.7
ZLIB_DIR=$(SRC_ROOT)/zlib-1.2.3
UPNPC_DIR=$(SRC_ROOT)/miniupnpc-1.0
PTHREADS_DIR=$(SRC_ROOT)/pthreads-w32-2-8-0-release
### Enable this for GPGME and GPG ERROR dirs
CFLAGS += -I$(GPGME_DIR)/src
CFLAGS += -I$(GPG_ERROR_DIR)/src
5) Edit your SRC_ROOT to your /home/xxxx dir
c) compile libretroshare
1) make
3) Copy all the required support libraries into the library directory:
c:/msys/1.0/home/XXX/lib
This should include:
gpg-error / gpgme libraries:
libgpg-error.a
libgpg-error.dll.a
libgpg-error.la
libgpgme.dll.a
libgpgme.la
openssl libraries:
libcrypto.a
libssl.a
miniupnpc / pthreads / libz
libminiupnpc.a
miniupnpc.dll
libpthreadGCE2.a
pthreadGCE2.dll
libz.a
extra library from cygwin. (renamed from libcrypt32.a)
libcrypt32-cygwin.a
libretroshare
libretroshare.a
4) Compile GUI.
/*********************** Compiling Retroshare *********************/
/************************ Running Retroshare **********************/
1) Collect Relevant DLL's with Application.
a) make retroshare application directory.
b) copy Retroshare.exe executable into directory.
c) Copy required DLL's into that directory.
These include:
mingw runtime:
mingwm10.dll
gpgme/gpg-error:
libgpg-error-0.dll
libgpgme-11.dll
other support libraries:
miniupnpc.dll
pthreadGCE2.dll
Qt DLLs:
QtCore4.dll,
QtGui4.dll,...
etc.
d) You should be able to run Retroshare from this directory now!
2) Install gpg4win package... for gpg.exe
3) Create an OpenGPG identity using gpa or Enigmail or other PGP tool.
4) You should be able to use Retroshare on your PC now.
/************************ Running Retroshare **********************/
/******************************** FAQs ****************************/
Ask and it might be answered!
/******************************** FAQs ****************************/
This is obviously a work in progress -
drBob.

View File

@ -53,7 +53,7 @@ if not exist "%EnvToolsPath%\cecho.exe" (
echo Download cecho installation
if not exist "%EnvDownloadPath%\%CEchoInstall%" call "%ToolsPath%\winhttpjs.bat" "%CEchoUrl%" -saveTo "%EnvDownloadPath%\%CEchoInstall%"
if not exist "%EnvDownloadPath%\%CEchoInstall%" call "%ToolsPath%\download-file.bat" "%CEchoUrl%" "%EnvDownloadPath%\%CEchoInstall%"
if not exist "%EnvDownloadPath%\%cCEhoInstall%" echo Cannot download cecho installation& goto error
echo Unpack cecho

View File

@ -0,0 +1,15 @@
; See http://nsis.sourceforge.net/Check_if_a_file_exists_at_compile_time for documentation
!macro !defineifexist _VAR_NAME _FILE_NAME
!tempfile _TEMPFILE
!ifdef NSIS_WIN32_MAKENSIS
; Windows - cmd.exe
!system 'if exist "${_FILE_NAME}" echo !define ${_VAR_NAME} > "${_TEMPFILE}"'
!else
; Posix - sh
!system 'if [ -e "${_FILE_NAME}" ]; then echo "!define ${_VAR_NAME}" > "${_TEMPFILE}"; fi'
!endif
!include '${_TEMPFILE}'
!delfile '${_TEMPFILE}'
!undef _TEMPFILE
!macroend
!define !defineifexist "!insertmacro !defineifexist"

View File

@ -1,6 +1,8 @@
; Script generated with the Venis Install Wizard & modified by defnax
; Reworked by Thunder
!include ifexist.nsh
# Needed defines
;!define BUILDADD ""
;!define RELEASEDIR ""
@ -197,9 +199,9 @@ Section $(Section_Main) Section_Main
File "${MINGWDIR}\bin\libwinpthread-1.dll"
; External binaries
File "${SOURCEDIR}\..\libs\bin\miniupnpc.dll"
File "${SOURCEDIR}\..\libs\bin\libeay32.dll"
File "${SOURCEDIR}\..\libs\bin\ssleay32.dll"
File "${EXTERNAL_LIB_DIR}\bin\miniupnpc.dll"
File "${EXTERNAL_LIB_DIR}\bin\libeay32.dll"
File "${EXTERNAL_LIB_DIR}\bin\ssleay32.dll"
; Other files
File "${SOURCEDIR}\retroshare-gui\src\changelog.txt"
@ -234,17 +236,33 @@ Section $(Section_Main) Section_Main
SectionEnd
# Plugins
SectionGroup $(Section_Plugins) Section_Plugins
Section $(Section_Plugin_FeedReader) Section_Plugin_FeedReader
SetOutPath "$DataDir\extensions6"
File "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll"
SectionEnd
${!defineifexist} PLUGIN_FEEDREADER_EXISTS "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll"
${!defineifexist} PLUGIN_VOIP_EXISTS "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll"
Section $(Section_Plugin_VOIP) Section_Plugin_VOIP
SetOutPath "$DataDir\extensions6"
File "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll"
SectionEnd
SectionGroupEnd
!ifdef PLUGIN_FEEDREADER_EXISTS
!define /ifndef PLUGIN_EXISTS
!endif
!ifdef PLUGIN_VOIP_EXISTS
!define /ifndef PLUGIN_EXISTS
!endif
!ifdef PLUGIN_EXISTS
SectionGroup $(Section_Plugins) Section_Plugins
!ifdef PLUGIN_FEEDREADER_EXISTS
Section $(Section_Plugin_FeedReader) Section_Plugin_FeedReader
SetOutPath "$DataDir\extensions6"
File "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll"
SectionEnd
!endif
!ifdef PLUGIN_VOIP_EXISTS
Section $(Section_Plugin_VOIP) Section_Plugin_VOIP
SetOutPath "$DataDir\extensions6"
File "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll"
SectionEnd
!endif
SectionGroupEnd
!endif
# Data (Styles)
Section $(Section_Data) Section_Data

View File

@ -1,6 +1,8 @@
; Script generated with the Venis Install Wizard & modified by defnax
; Reworked by Thunder
!include ifexist.nsh
# Needed defines
;!define BUILDADD ""
;!define RELEASEDIR ""
@ -212,9 +214,9 @@ Section $(Section_Main) Section_Main
File "${MINGWDIR}\bin\libwinpthread-1.dll"
; External binaries
File "${SOURCEDIR}\..\libs\bin\miniupnpc.dll"
File "${SOURCEDIR}\..\libs\bin\libeay32.dll"
File "${SOURCEDIR}\..\libs\bin\ssleay32.dll"
File "${EXTERNAL_LIB_DIR}\bin\miniupnpc.dll"
File "${EXTERNAL_LIB_DIR}\bin\libeay32.dll"
File "${EXTERNAL_LIB_DIR}\bin\ssleay32.dll"
; Other files
File "${SOURCEDIR}\retroshare-gui\src\changelog.txt"
@ -256,17 +258,33 @@ Section $(Section_Main) Section_Main
SectionEnd
# Plugins
SectionGroup $(Section_Plugins) Section_Plugins
Section $(Section_Plugin_FeedReader) Section_Plugin_FeedReader
SetOutPath "$DataDir\extensions6"
File "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll"
SectionEnd
${!defineifexist} PLUGIN_FEEDREADER_EXISTS "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll"
${!defineifexist} PLUGIN_VOIP_EXISTS "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll"
Section $(Section_Plugin_VOIP) Section_Plugin_VOIP
SetOutPath "$DataDir\extensions6"
File "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll"
SectionEnd
SectionGroupEnd
!ifdef PLUGIN_FEEDREADER_EXISTS
!define /ifndef PLUGIN_EXISTS
!endif
!ifdef PLUGIN_VOIP_EXISTS
!define /ifndef PLUGIN_EXISTS
!endif
!ifdef PLUGIN_EXISTS
SectionGroup $(Section_Plugins) Section_Plugins
!ifdef PLUGIN_FEEDREADER_EXISTS
Section $(Section_Plugin_FeedReader) Section_Plugin_FeedReader
SetOutPath "$DataDir\extensions6"
File "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll"
SectionEnd
!endif
!ifdef PLUGIN_VOIP_EXISTS
Section $(Section_Plugin_VOIP) Section_Plugin_VOIP
SetOutPath "$DataDir\extensions6"
File "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll"
SectionEnd
!endif
SectionGroupEnd
!endif
# Data (Styles)
Section $(Section_Data) Section_Data

View File

@ -1,15 +1,15 @@
:: Usage:
:: call depends.bat [list^|missing] file
setlocal
if "%2"=="" (
echo Usage: %~nx0 [list^|missing] File
goto :exit
exit /B 1
)
if not exist "%EnvDependsExe%" echo depends.exe not found in %EnvToolsPath%.& goto exit
if not exist "%EnvCutExe%" echo cut.exe not found in %EnvToolsPath%.& goto exit
setlocal
if not exist "%EnvDependsExe%" echo depends.exe not found in %EnvToolsPath%.& exit /B 1
if not exist "%EnvCutExe%" echo cut.exe not found in %EnvToolsPath%.& exit /B 1
start /wait "" "%EnvDependsExe%" /c /oc:"%~dp0depends.tmp" %2
if "%1"=="missing" (
@ -33,5 +33,5 @@ if "%1"=="list" (
if exist "%~dp0depends.tmp" del /Q "%~dp0depends.tmp"
if exist "%~dp0depends1.tmp" del /Q "%~dp0depends1.tmp"
:exit
endlocal
exit /B 0

View File

@ -94,7 +94,7 @@ namespace resource_api{
std::string getDefaultDocroot()
{
return RsAccounts::DataDirectory(false) + "/webui";
return RsAccounts::systemDataDirectory(false) + "/webui";
}
const char* API_ENTRY_PATH = "/api/v2";

View File

@ -467,6 +467,8 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp)
req.mStream << makeKeyValueReference("hidden_adress", hidden_address)
<< makeKeyValueReference("hidden_port", hidden_port_str);
uint16_t hidden_port = 0;
bool auto_tor = false ; // to be set by API, so disabled until then.
if(hidden_address.empty() != hidden_port_str.empty())
{
resp.setFail("you must both specify string hidden_adress and string hidden_port to create a hidden node.");
@ -539,7 +541,7 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp)
mPassword = pgp_password;
mFixedPassword = pgp_password;
}
bool ssl_ok = RsAccounts::GenerateSSLCertificate(pgp_id, "", ssl_name, "", hidden_port!=0, ssl_password, ssl_id, err_string);
bool ssl_ok = RsAccounts::createNewAccount(pgp_id, "", ssl_name, "", hidden_port!=0, auto_tor!=0, ssl_password, ssl_id, err_string);
// clear fixed password to restore normal password operation
// {

View File

@ -194,10 +194,10 @@ bool FileListIO::loadEncryptedDataFromFile(const std::string& fname,unsigned cha
{
uint64_t file_size ;
if(!RsDirUtil::checkFile( fname,file_size,false ) )
if(!RsDirUtil::checkFile( fname,file_size,true ) )
{
#ifdef FIM_DEBUG
std::cerr << "Encrypted file " << fname << " not available." << std::endl;
std::cerr << "Encrypted file " << fname << " not available or empty." << std::endl;
#endif
return false;
}

View File

@ -27,6 +27,7 @@
#include "hash_cache.h"
#include "filelist_io.h"
#include "file_sharing_defaults.h"
#include "retroshare/rsinit.h"
//#define HASHSTORAGE_DEBUG 1
@ -478,7 +479,7 @@ bool HashStorage::try_load_import_old_hash_cache()
{
// compute file name
std::string base_dir = rsAccounts->PathAccountDirectory();
std::string base_dir = RsAccounts::AccountDirectory();
std::string old_cache_filename = base_dir + "/" + "file_cache.bin" ;
// check for unencrypted

View File

@ -29,7 +29,7 @@
#include "retroshare/rsids.h"
#include "retroshare/rspeers.h"
#include "rsserver/rsaccounts.h"
#include "retroshare/rsinit.h"
#include "rsserver/p3face.h"
@ -48,7 +48,7 @@ p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers)
{
// make sure the base directory exists
std::string base_dir = rsAccounts->PathAccountDirectory();
std::string base_dir = RsAccounts::AccountDirectory();
if(base_dir.empty())
throw std::runtime_error("Cannot create base directory to store/access file sharing files.") ;

View File

@ -39,12 +39,12 @@
#include "retroshare/rstypes.h"
#include "retroshare/rspeers.h"
#include "retroshare/rsinit.h"
#include "rsitems/rsfiletransferitems.h"
#include "rsitems/rsserviceids.h"
#include "rsserver/p3face.h"
#include "rsserver/rsaccounts.h"
#include "turtle/p3turtle.h"
#include "util/rsdebug.h"
@ -148,8 +148,9 @@ void ftServer::SetupFtServer()
mFtController = new ftController(mFtDataplex, mServiceCtrl, getServiceInfo().mServiceType);
mFtController -> setFtSearchNExtra(mFtSearch, mFtExtra);
std::string emergencySaveDir = rsAccounts->PathAccountDirectory();
std::string emergencyPartialsDir = rsAccounts->PathAccountDirectory();
std::string emergencySaveDir = RsAccounts::AccountDirectory();
std::string emergencyPartialsDir = RsAccounts::AccountDirectory();
if (emergencySaveDir != "")
{
emergencySaveDir += "/";

View File

@ -1369,13 +1369,18 @@ RsServiceInfo::RsServiceInfo(
const uint16_t min_version_major,
const uint16_t min_version_minor)
:mServiceName(service_name),
mServiceType((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) service_type) << 8)),
mServiceType(RsServiceInfoUIn16ToFullServiceId(service_type)),
mVersionMajor(version_major),
mVersionMinor(version_minor),
mMinVersionMajor(min_version_major),
mMinVersionMinor(min_version_minor)
{
return;
return;
}
unsigned int RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(uint16_t serviceType)
{
return (((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) serviceType) << 8);
}

View File

@ -32,9 +32,6 @@ static struct RsLog::logInfo pqipersongrpzoneInfo = {RsLog::Default, "pqipersong
/****
* #define PQI_DISABLE_UDP 1
***/
#ifdef RETROTOR
#define PQI_DISABLE_UDP 1
#endif
/********************************** SSL Specific features ***************************/

View File

@ -181,7 +181,7 @@ public:
StringExpression(enum StringOperator op, const std::list<std::string> &t, bool ic): Op(op),terms(t), IgnoreCase(ic){}
virtual void linearize(LinearizedExpression& e) const ;
virtual std::string toStdString(const std::string& varstr) const;
virtual std::string toStdStringWithParam(const std::string& varstr) const;
protected:
bool evalStr(const std::string &str);
@ -197,7 +197,7 @@ public:
RelExpression(enum RelOperator op, T lv, T hv): Op(op), LowerValue(lv), HigherValue(hv) {}
virtual void linearize(LinearizedExpression& e) const ;
virtual std::string toStdString(const std::string& typestr) const;
virtual std::string toStdStringWithParam(const std::string& typestr) const;
protected:
bool evalRel(T val);
@ -229,7 +229,7 @@ bool RelExpression<T>::evalRel(T val) {
}
template <class T>
std::string RelExpression<T>::toStdString(const std::string& typestr) const
std::string RelExpression<T>::toStdStringWithParam(const std::string& typestr) const
{
std::string LowerValueStr = RsUtil::NumberToString(LowerValue) ;
@ -275,7 +275,7 @@ public:
StringExpression(op,t,ic) {}
bool eval(const ExpFileEntry& file);
virtual std::string toStdString() const { return StringExpression::toStdString("NAME"); }
virtual std::string toStdString() const { return StringExpression::toStdStringWithParam("NAME"); }
virtual void linearize(LinearizedExpression& e) const
{
@ -290,7 +290,7 @@ public:
StringExpression(op,t,ic) {}
bool eval(const ExpFileEntry& file);
virtual std::string toStdString()const { return StringExpression::toStdString("PATH"); }
virtual std::string toStdString()const { return StringExpression::toStdStringWithParam("PATH"); }
virtual void linearize(LinearizedExpression& e) const
{
@ -305,7 +305,7 @@ public:
StringExpression(op,t,ic) {}
bool eval(const ExpFileEntry& file);
virtual std::string toStdString()const { return StringExpression::toStdString("EXTENSION"); }
virtual std::string toStdString()const { return StringExpression::toStdStringWithParam("EXTENSION"); }
virtual void linearize(LinearizedExpression& e) const
{
@ -320,7 +320,7 @@ public:
StringExpression(op,t, true) {}
bool eval(const ExpFileEntry& file);
virtual std::string toStdString() const { return StringExpression::toStdString("HASH"); }
virtual std::string toStdString() const { return StringExpression::toStdStringWithParam("HASH"); }
virtual void linearize(LinearizedExpression& e) const
{
@ -342,7 +342,7 @@ public:
RelExpression<int>(op,lv,hv) {}
bool eval(const ExpFileEntry& file);
virtual std::string toStdString() const { return RelExpression<int>::toStdString("DATE"); }
virtual std::string toStdString() const { return RelExpression<int>::toStdStringWithParam("DATE"); }
virtual void linearize(LinearizedExpression& e) const
{
@ -359,7 +359,7 @@ public:
RelExpression<int>(op,lv,hv) {}
bool eval(const ExpFileEntry& file);
virtual std::string toStdString() const { return RelExpression<int>::toStdString("SIZE"); }
virtual std::string toStdString() const { return RelExpression<int>::toStdStringWithParam("SIZE"); }
virtual void linearize(LinearizedExpression& e) const
{
@ -376,7 +376,7 @@ public:
RelExpression<int>(op,lv,hv) {}
bool eval(const ExpFileEntry& file);
virtual std::string toStdString() const { return RelExpression<int>::toStdString("SIZE"); }
virtual std::string toStdString() const { return RelExpression<int>::toStdStringWithParam("SIZE"); }
virtual void linearize(LinearizedExpression& e) const
{
@ -392,7 +392,7 @@ public:
PopExpression(const LinearizedExpression& e) ;
bool eval(const ExpFileEntry& file);
virtual std::string toStdString() const { return RelExpression<int>::toStdString("POPULARITY"); }
virtual std::string toStdString() const { return RelExpression<int>::toStdStringWithParam("POPULARITY"); }
virtual void linearize(LinearizedExpression& e) const
{

View File

@ -130,52 +130,85 @@ private:
/* Seperate Class for dealing with Accounts */
/* Seperate static Class for dealing with Accounts */
namespace RsAccounts
class RsAccountsDetail ;
class RsAccounts
{
/**
* @brief ConfigDirectory (normally ~/.retroshare) you can call this method
* even before initialisation (you can't with some other methods)
* @see RsAccountsDetail::PathBaseDirectory()
*/
std::string ConfigDirectory();
public:
// Should be called once before everything else.
static bool init(const std::string &opt_base_dir, int& error_code);
/**
* @brief DataDirectory
* you can call this method even before initialisation (you can't with some other methods)
* @param check if set to true and directory does not exist, return empty string
* @return path where global platform independent files are stored, like bdboot.txt or webinterface files
*/
std::string DataDirectory(bool check = true);
* @brief ConfigDirectory (normally ~/.retroshare) you can call this method
* even before initialisation (you can't with some other methods)
*
* On linux: ~/.retroshare/
*
* @see RsAccountsDetail::PathBaseDirectory()
*/
static std::string ConfigDirectory();
std::string PGPDirectory();
std::string AccountDirectory();
/**
* @brief DataDirectory
* you can call this method even before initialisation (you can't with some other methods)
* @param check if set to true and directory does not exist, return empty string
* @return path where global platform independent files are stored, like bdboot.txt or webinterface files
*/
static std::string systemDataDirectory(bool check = true);
static std::string PGPDirectory();
// PGP Accounts.
int GetPGPLogins(std::list<RsPgpId> &pgpIds);
int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
static int GetPGPLogins(std::list<RsPgpId> &pgpIds);
static int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
static bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
// PGP Support Functions.
bool ExportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
bool ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
bool ImportIdentityFromString(const std::string& data,RsPgpId& imported_pgp_id,std::string& import_error) ;
void GetUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
bool CopyGnuPGKeyrings() ;
static bool ExportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
static bool ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
static bool ImportIdentityFromString(const std::string& data,RsPgpId& imported_pgp_id,std::string& import_error) ;
static void GetUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
static bool CopyGnuPGKeyrings() ;
// Rs Accounts
bool SelectAccount(const RsPeerId& id);
static bool SelectAccount(const RsPeerId& id);
static bool GetPreferredAccountId(RsPeerId &id);
static bool GetAccountIds(std::list<RsPeerId> &ids);
bool GetPreferredAccountId(RsPeerId &id);
bool GetAccountIds(std::list<RsPeerId> &ids);
bool GetAccountDetails(const RsPeerId &id,
RsPgpId &gpgId, std::string &gpgName,
std::string &gpgEmail, std::string &location);
static bool GetAccountDetails(const RsPeerId &id, RsPgpId &gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location);
bool GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString);
static bool createNewAccount(
const RsPgpId& pgp_id, const std::string& org,
const std::string& loc, const std::string& country,
bool ishiddenloc, bool is_auto_tor, const std::string& passwd,
RsPeerId &sslId, std::string &errString );
}
static void storeSelectedAccount() ;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// All methods bellow can only be called ones SelectAccount() as been called. //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static bool getCurrentAccountOptions(bool& is_hidden,bool& is_tor_auto,bool& is_first_time) ;
static bool checkCreateAccountDirectory(); // Generate the hierarchy of directories below ~/.retroshare/[SSL dir]/
static bool isHiddenNode() ; // true if the running node is a hidden node. Used to choose which services to start.
static bool isTorAuto() ; // true if the running node is a hidden node using automated Tor management
static std::string AccountDirectory(); // linux: ~/.retroshare/[SSL dir]/
static std::string AccountKeysDirectory(); // linux: ~/.retroshare/[SSL dir]/keys/
static std::string AccountPathCertFile(); // linux: ~/.retroshare/[SSL dir]/keys/user_cert.pem
static std::string AccountPathKeyFile(); // linux: ~/.retroshare/[SSL dir]/keys/user_pk.pem
static std::string AccountLocationName();
static bool lockPreferredAccount() ; // are these methods any useful??
static void unlockPreferredAccount() ;
private:
static RsAccountsDetail *rsAccounts ;
};
/**

View File

@ -53,6 +53,8 @@ class RsServiceInfo
// minimum version can communicate with.
uint16_t mMinVersionMajor;
uint16_t mMinVersionMinor;
static unsigned int RsServiceInfoUIn16ToFullServiceId(uint16_t serviceType);
};

View File

@ -49,7 +49,7 @@
#include <openssl/ssl.h>
// Global singleton declaration of data.
RsAccountsDetail *rsAccounts;
RsAccountsDetail *RsAccounts::rsAccounts;
/* Uses private class - so must be hidden */
static bool checkAccount(const std::string &accountdir, AccountDetails &account,std::map<std::string,std::vector<std::string> >& unsupported_keys);
@ -67,11 +67,8 @@ RsAccountsDetail::RsAccountsDetail() : mAccountsLocked(false), mPreferredId("")
bool RsAccountsDetail::loadAccounts()
{
int failing_accounts ;
#ifdef RETROTOR
getAvailableAccounts(mAccounts,failing_accounts,mUnsupportedKeys,true);
#else
#warning we might need some switch here for hidden nodes only
getAvailableAccounts(mAccounts,failing_accounts,mUnsupportedKeys,false);
#endif
loadPreferredAccount();
checkPreferredId();
@ -105,7 +102,7 @@ bool RsAccountsDetail::checkAccountDirectory()
return false;
}
return setupAccount(PathAccountDirectory());
return setupAccount(getCurrentAccountPathAccountDirectory());
}
#warning we need to clean that up. Login should only ask for a SSL id, instead of a std::string.
@ -219,7 +216,7 @@ std::string RsAccountsDetail::PathBaseDirectory()
}
std::string RsAccountsDetail::PathAccountDirectory()
std::string RsAccountsDetail::getCurrentAccountPathAccountDirectory()
{
std::string path;
@ -235,9 +232,9 @@ std::string RsAccountsDetail::PathAccountDirectory()
return path;
}
std::string RsAccountsDetail::PathAccountKeysDirectory()
std::string RsAccountsDetail::getCurrentAccountPathAccountKeysDirectory()
{
std::string path = PathAccountDirectory();
std::string path = getCurrentAccountPathAccountDirectory();
if (path.empty())
{
return path;
@ -247,9 +244,9 @@ std::string RsAccountsDetail::PathAccountKeysDirectory()
return path;
}
std::string RsAccountsDetail::PathKeyFile()
std::string RsAccountsDetail::getCurrentAccountPathKeyFile()
{
std::string path = PathAccountKeysDirectory();
std::string path = getCurrentAccountPathAccountKeysDirectory();
if (path.empty())
{
return path;
@ -259,9 +256,9 @@ std::string RsAccountsDetail::PathKeyFile()
return path;
}
std::string RsAccountsDetail::PathCertFile()
std::string RsAccountsDetail::getCurrentAccountPathCertFile()
{
std::string path = PathAccountKeysDirectory();
std::string path = getCurrentAccountPathAccountKeysDirectory();
if (path.empty())
{
return path;
@ -270,7 +267,7 @@ std::string RsAccountsDetail::PathCertFile()
return path;
}
std::string RsAccountsDetail::LocationName()
std::string RsAccountsDetail::getCurrentAccountLocationName()
{
std::map<RsPeerId, AccountDetails>::const_iterator it;
it = mAccounts.find(mPreferredId);
@ -450,7 +447,7 @@ bool RsAccountsDetail::storePreferredAccount()
*
*/
bool RsAccountsDetail::getPreferredAccountId(RsPeerId &id)
bool RsAccountsDetail::getCurrentAccountId(RsPeerId &id)
{
id = mPreferredId;
return (!mPreferredId.isNull());
@ -479,7 +476,7 @@ bool RsAccountsDetail::getAccountIds(std::list<RsPeerId> &ids)
}
bool RsAccountsDetail::getAccountDetails(const RsPeerId &id,
bool RsAccountsDetail::getCurrentAccountDetails(const RsPeerId &id,
RsPgpId &gpgId, std::string &gpgName,
std::string &gpgEmail, std::string &location)
{
@ -496,14 +493,16 @@ bool RsAccountsDetail::getAccountDetails(const RsPeerId &id,
return false;
}
bool RsAccountsDetail::getAccountOptions(bool &ishidden, bool &isFirstTimeRun)
bool RsAccountsDetail::getCurrentAccountOptions(bool &ishidden,bool& isautotor, bool &isFirstTimeRun)
{
std::map<RsPeerId, AccountDetails>::iterator it;
it = mAccounts.find(mPreferredId);
if (it != mAccounts.end())
{
ishidden = it->second.mIsHiddenLoc;
ishidden = it->second.mIsHiddenLoc;
isFirstTimeRun = it->second.mFirstRun;
isautotor = it->second.mIsAutoTor;
return true;
}
return false;
@ -598,7 +597,9 @@ bool RsAccountsDetail::getAvailableAccounts(std::map<RsPeerId, AccountDetails> &
std::string lochex = (*it).substr(6); // rest of string.
bool hidden_location = false;
bool auto_tor = false;
bool valid_prefix = false;
if (prefix == "LOC06_")
{
valid_prefix = true;
@ -607,6 +608,8 @@ bool RsAccountsDetail::getAvailableAccounts(std::map<RsPeerId, AccountDetails> &
{
valid_prefix = true;
hidden_location = true;
auto_tor = RsDirUtil::checkDirectory(mBaseDirectory+"/"+*it+"/hidden_service");
}
else
{
@ -626,7 +629,9 @@ bool RsAccountsDetail::getAvailableAccounts(std::map<RsPeerId, AccountDetails> &
AccountDetails tmpId;
tmpId.mIsHiddenLoc = hidden_location;
tmpId.mIsAutoTor = auto_tor;
tmpId.mAccountDir = *it;
if (checkAccount(accountdir, tmpId,unsupported_keys))
{
#ifdef GPG_DEBUG
@ -692,7 +697,7 @@ static bool checkAccount(const std::string &accountdir, AccountDetails &account,
std::cerr << "issuerName: " << account.mPgpId << " id: " << account.mSslId << std::endl;
#endif
if(! rsAccounts->GetPGPLoginDetails(account.mPgpId, account.mPgpName, account.mPgpEmail))
if(! RsAccounts::GetPGPLoginDetails(account.mPgpId, account.mPgpName, account.mPgpEmail))
return false ;
if(!AuthGPG::getAuthGPG()->haveSecretKey(account.mPgpId))
@ -983,7 +988,7 @@ bool RsAccountsDetail::copyGnuPGKeyrings()
/* Create SSL Certificates */
bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, bool ishiddenloc,bool isautotor, const std::string& passwd, RsPeerId &sslId, std::string &errString)
{
/* select the PGP Identity first */
if (!SelectPGPAccount(pgp_id))
@ -1136,6 +1141,7 @@ bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const s
newAccount.mLocation = loc;
newAccount.mIsHiddenLoc = ishiddenloc;
newAccount.mIsAutoTor = isautotor;
newAccount.mFirstRun = true;
@ -1259,11 +1265,51 @@ bool RsInit::LoadPassword(const std::string& id, const std::string& inPwd)
* PUBLIC INTERFACE FUNCTIONS
********************************************************************************/
bool RsAccounts::init(const std::string& opt_base_dir,int& error_code)
{
rsAccounts = new RsAccountsDetail ;
// first check config directories, and set bootstrap values.
if(!rsAccounts->setupBaseDirectory(opt_base_dir))
{
error_code = RS_INIT_BASE_DIR_ERROR ;
return false ;
}
// Setup PGP stuff.
std::string pgp_dir = rsAccounts->PathPGPDirectory();
if(!RsDirUtil::checkCreateDirectory(pgp_dir))
throw std::runtime_error("Cannot create pgp directory " + pgp_dir) ;
AuthGPG::init( pgp_dir + "/retroshare_public_keyring.gpg",
pgp_dir + "/retroshare_secret_keyring.gpg",
pgp_dir + "/retroshare_trustdb.gpg",
pgp_dir + "/lock");
// load Accounts.
if (!rsAccounts->loadAccounts())
{
error_code = RS_INIT_NO_KEYRING ;
return false ;
}
return true;
}
// Directories.
std::string RsAccounts::ConfigDirectory() { return RsAccountsDetail::PathBaseDirectory(); }
std::string RsAccounts::DataDirectory(bool check) { return RsAccountsDetail::PathDataDirectory(check); }
std::string RsAccounts::systemDataDirectory(bool check) { return RsAccountsDetail::PathDataDirectory(check); }
std::string RsAccounts::PGPDirectory() { return rsAccounts->PathPGPDirectory(); }
std::string RsAccounts::AccountDirectory() { return rsAccounts->PathAccountDirectory(); }
std::string RsAccounts::AccountDirectory() { return rsAccounts->getCurrentAccountPathAccountDirectory(); }
std::string RsAccounts::AccountKeysDirectory() { return rsAccounts->getCurrentAccountPathAccountKeysDirectory(); }
std::string RsAccounts::AccountPathCertFile() { return rsAccounts->getCurrentAccountPathCertFile(); }
std::string RsAccounts::AccountPathKeyFile() { return rsAccounts->getCurrentAccountPathKeyFile(); }
std::string RsAccounts::AccountLocationName() { return rsAccounts->getCurrentAccountLocationName(); }
bool RsAccounts::lockPreferredAccount() { return rsAccounts->lockPreferredAccount();} // are these methods any useful??
void RsAccounts::unlockPreferredAccount() { rsAccounts->unlockPreferredAccount(); }
bool RsAccounts::checkCreateAccountDirectory() { return rsAccounts->checkAccountDirectory(); }
// PGP Accounts.
int RsAccounts::GetPGPLogins(std::list<RsPgpId> &pgpIds)
@ -1307,6 +1353,7 @@ bool RsAccounts::CopyGnuPGKeyrings()
return rsAccounts->copyGnuPGKeyrings();
}
void RsAccounts::storeSelectedAccount() { rsAccounts->storePreferredAccount() ;}
// Rs Accounts
bool RsAccounts::SelectAccount(const RsPeerId &id)
{
@ -1315,7 +1362,40 @@ bool RsAccounts::SelectAccount(const RsPeerId &id)
bool RsAccounts::GetPreferredAccountId(RsPeerId &id)
{
return rsAccounts->getPreferredAccountId(id);
return rsAccounts->getCurrentAccountId(id);
}
bool RsAccounts::getCurrentAccountOptions(bool& is_hidden,bool& is_tor_auto,bool& is_first_time)
{
return rsAccounts->getCurrentAccountOptions(is_hidden,is_tor_auto,is_first_time);
}
bool RsAccounts::isHiddenNode()
{
bool hidden = false ;
bool is_tor_only = false ;
bool is_first_time = false ;
if(!getCurrentAccountOptions(hidden,is_tor_only,is_first_time))
{
std::cerr << "(EE) Critical problem: RsAccounts::getCurrentAccountOptions() called but no account chosen!" << std::endl;
throw std::runtime_error("inconsistent configuration") ;
}
return hidden ;
}
bool RsAccounts::isTorAuto()
{
bool hidden = false ;
bool is_tor_only = false ;
bool is_first_time = false ;
if(!getCurrentAccountOptions(hidden,is_tor_only,is_first_time))
{
std::cerr << "(EE) Critical problem: RsAccounts::getCurrentAccountOptions() called but no account chosen!" << std::endl;
throw std::runtime_error("inconsistent configuration") ;
}
return is_tor_only ;
}
bool RsAccounts::GetAccountIds(std::list<RsPeerId> &ids)
@ -1327,12 +1407,12 @@ bool RsAccounts::GetAccountDetails(const RsPeerId &id,
RsPgpId &pgpId, std::string &pgpName,
std::string &pgpEmail, std::string &location)
{
return rsAccounts->getAccountDetails(id, pgpId, pgpName, pgpEmail, location);
return rsAccounts->getCurrentAccountDetails(id, pgpId, pgpName, pgpEmail, location);
}
bool RsAccounts::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
bool RsAccounts::createNewAccount(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, bool ishiddenloc, bool isautotor, const std::string& passwd, RsPeerId &sslId, std::string &errString)
{
return rsAccounts->GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, passwd, sslId, errString);
return rsAccounts->GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, isautotor, passwd, sslId, errString);
}
/*********************************************************************************

View File

@ -49,6 +49,7 @@ class AccountDetails
std::string mLocation;
bool mIsHiddenLoc;
bool mFirstRun;
bool mIsAutoTor;
};
@ -58,9 +59,6 @@ class RsAccountsDetail
RsAccountsDetail();
// These functions are externally accessible via RsAccounts namespace.
// These functions are accessible from inside libretroshare.
bool setupBaseDirectory(std::string alt_basedir);
@ -87,52 +85,43 @@ class RsAccountsDetail
// PGP Path is only dependent on BaseDirectory.
std::string PathPGPDirectory();
// Below are dependent on mPreferredId.
std::string PathAccountDirectory();
std::string PathAccountKeysDirectory();
std::string PathKeyFile();
std::string PathCertFile();
std::string LocationName();
// Generate a new account based on a given PGP key returns its SSL id and sets it to be the preferred account.
bool GenerateSSLCertificate(const RsPgpId& gpg_id, const std::string& org, const std::string& loc, const std::string& country, bool ishiddenloc, bool is_auto_tor,const std::string& passwd, RsPeerId &sslId, std::string &errString);
// PGP Accounts.
int GetPGPLogins(std::list<RsPgpId> &pgpIds);
int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
bool SelectPGPAccount(const RsPgpId& pgpId);
bool SelectPGPAccount(const RsPgpId& pgpId);
// PGP Support Functions.
bool exportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
bool importIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
bool importIdentityFromString(const std::string& data,RsPgpId& imported_pgp_id,std::string& import_error) ;
void getUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
void getUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
bool copyGnuPGKeyrings() ;
// Selecting Rs Account.
bool getAccountIds(std::list<RsPeerId> &ids);
bool selectAccountByString(const std::string &prefUserString);
bool selectId(const RsPeerId& preferredId);
// Details of Rs Account.
bool getPreferredAccountId(RsPeerId &id);
bool getAccountDetails(const RsPeerId &id, RsPgpId& gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location);
bool getAccountOptions(bool &ishidden, bool &isFirstTimeRun);
bool getAccountIds(std::list<RsPeerId> &ids);
bool GenerateSSLCertificate(const RsPgpId& gpg_id,
const std::string& org, const std::string& loc,
const std::string& country, const bool ishiddenloc,
const std::string& passwd, RsPeerId &sslId,
std::string &errString);
// From init file.
bool storePreferredAccount();
bool loadPreferredAccount();
// Details of current Rs Account.
bool getCurrentAccountId(RsPeerId &id);
bool getCurrentAccountDetails(const RsPeerId &id, RsPgpId& gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location);
bool getCurrentAccountOptions(bool &ishidden, bool &isautotor, bool &isFirstTimeRun);
std::string getCurrentAccountPathAccountDirectory();
std::string getCurrentAccountPathAccountKeysDirectory();
std::string getCurrentAccountPathKeyFile();
std::string getCurrentAccountPathCertFile();
std::string getCurrentAccountLocationName();
private:
bool checkPreferredId();
@ -155,6 +144,4 @@ class RsAccountsDetail
std::map<std::string,std::vector<std::string> > mUnsupportedKeys ;
};
// Global singleton declaration of data.
extern RsAccountsDetail *rsAccounts;

View File

@ -434,26 +434,11 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */)
AuthSSL::getAuthSSL() -> InitAuth(NULL, NULL, NULL, "");
rsLoginHelper = new RsLoginHelper;
rsAccounts = new RsAccountsDetail;
// first check config directories, and set bootstrap values.
if(!rsAccounts->setupBaseDirectory(opt_base_dir))
return RS_INIT_BASE_DIR_ERROR ;
int error_code ;
// Setup PGP stuff.
std::string pgp_dir = rsAccounts->PathPGPDirectory();
if(!RsDirUtil::checkCreateDirectory(pgp_dir))
throw std::runtime_error("Cannot create pgp directory " + pgp_dir) ;
AuthGPG::init( pgp_dir + "/retroshare_public_keyring.gpg",
pgp_dir + "/retroshare_secret_keyring.gpg",
pgp_dir + "/retroshare_trustdb.gpg",
pgp_dir + "/lock");
// load Accounts.
if (!rsAccounts->loadAccounts())
return RS_INIT_NO_KEYRING ;
if(!RsAccounts::init(opt_base_dir,error_code))
return error_code ;
// choose alternative account.
if(prefUserString != "")
@ -467,7 +452,7 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */)
return RS_INIT_AUTH_FAILED ;
}
if(rsAccounts->selectId(ssl_id))
if(RsAccounts::SelectAccount(ssl_id))
{
std::cerr << "Auto-selectng account ID " << ssl_id << std::endl;
return RS_INIT_HAVE_ACCOUNT;
@ -477,7 +462,7 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */)
#ifdef RS_AUTOLOGIN
/* check that we have selected someone */
RsPeerId preferredId;
bool existingUser = rsAccounts->getPreferredAccountId(preferredId);
bool existingUser = RsAccounts::GetPreferredAccountId(preferredId);
if (existingUser)
{
@ -553,44 +538,44 @@ bool RsInit::LoadPassword(const std::string& inPwd)
RsInit::LoadCertificateStatus RsInit::LockAndLoadCertificates(
bool autoLoginNT, std::string& lockFilePath )
{
if (!rsAccounts->lockPreferredAccount())
try
{
return RsInit::ERR_UNKOWN; // invalid PreferredAccount.
if (!RsAccounts::lockPreferredAccount())
throw RsInit::ERR_UNKOWN; // invalid PreferredAccount.
// Logic that used to be external to RsInit...
RsPeerId accountId;
if (!RsAccounts::GetPreferredAccountId(accountId))
throw RsInit::ERR_UNKOWN; // invalid PreferredAccount;
RsPgpId pgpId;
std::string pgpName, pgpEmail, location;
if(!RsAccounts::GetAccountDetails(accountId, pgpId, pgpName, pgpEmail, location))
throw RsInit::ERR_UNKOWN; // invalid PreferredAccount;
if(0 == AuthGPG::getAuthGPG() -> GPGInit(pgpId))
throw RsInit::ERR_UNKOWN; // PGP Error.
LoadCertificateStatus retVal =
LockConfigDirectory(RsAccounts::AccountDirectory(), lockFilePath);
if(retVal > 0)
throw retVal ;
if(LoadCertificates(autoLoginNT) != 1)
{
UnlockConfigDirectory();
throw RsInit::ERR_UNKOWN;
}
return RsInit::OK;
}
LoadCertificateStatus retVal = RsInit::OK;
// Logic that used to be external to RsInit...
RsPeerId accountId;
if (!rsAccounts->getPreferredAccountId(accountId))
{
retVal = RsInit::ERR_UNKOWN; // invalid PreferredAccount;
}
RsPgpId pgpId;
std::string pgpName, pgpEmail, location;
if (retVal == RsInit::OK &&
!rsAccounts->getAccountDetails(
accountId, pgpId, pgpName, pgpEmail, location ) )
retVal = RsInit::ERR_UNKOWN; // invalid PreferredAccount;
if (retVal == RsInit::OK && !rsAccounts->SelectPGPAccount(pgpId))
retVal = RsInit::ERR_UNKOWN; // PGP Error.
if(retVal == RsInit::OK)
retVal = LockConfigDirectory(
rsAccounts->PathAccountDirectory(), lockFilePath );
if(retVal == RsInit::OK && LoadCertificates(autoLoginNT) != 1)
{
UnlockConfigDirectory();
retVal = RsInit::ERR_UNKOWN;
}
if(retVal != RsInit::OK) rsAccounts->unlockPreferredAccount();
return retVal;
catch(LoadCertificateStatus retVal)
{
RsAccounts::unlockPreferredAccount();
return retVal ;
}
}
@ -606,20 +591,20 @@ RsInit::LoadCertificateStatus RsInit::LockAndLoadCertificates(
int RsInit::LoadCertificates(bool autoLoginNT)
{
RsPeerId preferredId;
if (!rsAccounts->getPreferredAccountId(preferredId))
if (!RsAccounts::GetPreferredAccountId(preferredId))
{
std::cerr << "No Account Selected" << std::endl;
return 0;
}
if (rsAccounts->PathCertFile() == "")
if (RsAccounts::AccountPathCertFile() == "")
{
std::cerr << "RetroShare needs a certificate" << std::endl;
return 0;
}
if (rsAccounts->PathKeyFile() == "")
if (RsAccounts::AccountPathKeyFile() == "")
{
std::cerr << "RetroShare needs a key" << std::endl;
return 0;
@ -641,9 +626,10 @@ int RsInit::LoadCertificates(bool autoLoginNT)
}
}
std::cerr << "rsAccounts->PathKeyFile() : " << rsAccounts->PathKeyFile() << std::endl;
std::cerr << "rsAccounts->PathKeyFile() : " << RsAccounts::AccountPathKeyFile() << std::endl;
if(0 == AuthSSL::getAuthSSL() -> InitAuth(rsAccounts->PathCertFile().c_str(), rsAccounts->PathKeyFile().c_str(), rsInitConfig->passwd.c_str(), rsAccounts->LocationName()))
if(0 == AuthSSL::getAuthSSL() -> InitAuth(RsAccounts::AccountPathCertFile().c_str(), RsAccounts::AccountPathKeyFile().c_str(), rsInitConfig->passwd.c_str(),
RsAccounts::AccountLocationName()))
{
std::cerr << "SSL Auth Failed!";
return 0 ;
@ -668,7 +654,7 @@ int RsInit::LoadCertificates(bool autoLoginNT)
rsInitConfig->gxs_passwd = rsInitConfig->passwd;
rsInitConfig->passwd = "";
rsAccounts->storePreferredAccount();
RsAccounts::storeSelectedAccount();
return 1;
}
@ -676,7 +662,7 @@ int RsInit::LoadCertificates(bool autoLoginNT)
bool RsInit::RsClearAutoLogin()
{
RsPeerId preferredId;
if (!rsAccounts->getPreferredAccountId(preferredId))
if (!RsAccounts::GetPreferredAccountId(preferredId))
{
std::cerr << "RsInit::RsClearAutoLogin() No Account Selected" << std::endl;
return 0;
@ -836,11 +822,8 @@ RsGRouter *rsGRouter = NULL ;
#include "pqi/p3linkmgr.h"
#include "pqi/p3netmgr.h"
#ifndef RETROTOR
#include "tcponudp/tou.h"
#include "tcponudp/rsudpstack.h"
#endif
#ifdef RS_USE_BITDHT
#include "dht/p3bitdht.h"
@ -887,6 +870,17 @@ RsControl *RsControl::instance()
int RsServer::StartupRetroShare()
{
RsPeerId ownId = AuthSSL::getAuthSSL()->OwnId();
std::cerr << "========================================================================" << std::endl;
std::cerr << "== RsInit:: starting up Retroshare core ==" << std::endl;
std::cerr << "== ==" << std::endl;
std::cerr << "== Account/SSL ID : " << ownId << " ==" << std::endl;
std::cerr << "== Node type : " << (RsAccounts::isHiddenNode()?"Hidden":"Normal") << " ==" << std::endl;
if(RsAccounts::isHiddenNode())
std::cerr << "== Tor/I2P configuration : " << (RsAccounts::isTorAuto()?"Tor Auto":"Manual ") << " ==" << std::endl;
std::cerr << "========================================================================" << std::endl;
/**************************************************************************/
/* STARTUP procedure */
/**************************************************************************/
@ -902,8 +896,6 @@ int RsServer::StartupRetroShare()
return false ;
}
RsPeerId ownId = AuthSSL::getAuthSSL()->OwnId();
/**************************************************************************/
/* Any Initial Configuration (Commandline Options) */
/**************************************************************************/
@ -912,7 +904,7 @@ int RsServer::StartupRetroShare()
std::cerr << "set the debugging to crashMode." << std::endl;
if ((!rsInitConfig->haveLogFile) && (!rsInitConfig->outStderr))
{
std::string crashfile = rsAccounts->PathAccountDirectory();
std::string crashfile = RsAccounts::AccountDirectory();
crashfile += "/" + configLogFileName;
setDebugCrashMode(crashfile.c_str());
}
@ -924,7 +916,7 @@ int RsServer::StartupRetroShare()
}
/* check account directory */
if (!rsAccounts->checkAccountDirectory())
if (!RsAccounts::checkCreateAccountDirectory())
{
std::cerr << "RsServer::StartupRetroShare() - Fatal Error....." << std::endl;
std::cerr << "checkAccount failed!" << std::endl;
@ -936,8 +928,8 @@ int RsServer::StartupRetroShare()
// Load up Certificates, and Old Configuration (if present)
std::cerr << "Load up Certificates, and Old Configuration (if present)." << std::endl;
std::string emergencySaveDir = rsAccounts->PathAccountDirectory();
std::string emergencyPartialsDir = rsAccounts->PathAccountDirectory();
std::string emergencySaveDir = RsAccounts::AccountDirectory();
std::string emergencyPartialsDir = RsAccounts::AccountDirectory();
if (emergencySaveDir != "")
{
emergencySaveDir += "/";
@ -951,13 +943,15 @@ int RsServer::StartupRetroShare()
/**************************************************************************/
std::cerr << "Load Configuration" << std::endl;
mConfigMgr = new p3ConfigMgr(rsAccounts->PathAccountDirectory());
mConfigMgr = new p3ConfigMgr(RsAccounts::AccountDirectory());
mGeneralConfig = new p3GeneralConfig();
// Get configuration options from rsAccounts.
bool isHiddenNode = false;
bool isFirstTimeRun = false;
rsAccounts->getAccountOptions(isHiddenNode, isFirstTimeRun);
bool isTorAuto = false;
RsAccounts::getCurrentAccountOptions(isHiddenNode,isTorAuto, isFirstTimeRun);
/**************************************************************************/
/* setup classes / structures */
@ -998,36 +992,40 @@ int RsServer::StartupRetroShare()
sockaddr_clear(&tmpladdr);
tmpladdr.sin_port = htons(rsInitConfig->port);
rsUdpStack *mDhtStack = NULL ;
if(!RsAccounts::isHiddenNode())
{
#ifdef LOCALNET_TESTING
rsUdpStack *mDhtStack = new rsUdpStack(UDP_TEST_RESTRICTED_LAYER, tmpladdr);
mDhtStack = new rsUdpStack(UDP_TEST_RESTRICTED_LAYER, tmpladdr);
/* parse portRestrictions */
unsigned int lport, uport;
/* parse portRestrictions */
unsigned int lport, uport;
if (doPortRestrictions)
{
if (2 == sscanf(portRestrictions.c_str(), "%u-%u", &lport, &uport))
if (doPortRestrictions)
{
std::cerr << "Adding Port Restriction (" << lport << "-" << uport << ")";
std::cerr << std::endl;
}
else
{
std::cerr << "Failed to parse Port Restrictions ... exiting";
std::cerr << std::endl;
exit(1);
}
if (2 == sscanf(portRestrictions.c_str(), "%u-%u", &lport, &uport))
{
std::cerr << "Adding Port Restriction (" << lport << "-" << uport << ")";
std::cerr << std::endl;
}
else
{
std::cerr << "Failed to parse Port Restrictions ... exiting";
std::cerr << std::endl;
exit(1);
}
RestrictedUdpLayer *url = (RestrictedUdpLayer *) mDhtStack->getUdpLayer();
url->addRestrictedPortRange(lport, uport);
}
RestrictedUdpLayer *url = (RestrictedUdpLayer *) mDhtStack->getUdpLayer();
url->addRestrictedPortRange(lport, uport);
}
#else //LOCALNET_TESTING
#ifdef RS_USE_BITDHT
rsUdpStack *mDhtStack = new rsUdpStack(tmpladdr);
mDhtStack = new rsUdpStack(tmpladdr);
#endif
#endif //LOCALNET_TESTING
}
#ifdef RS_USE_BITDHT
@ -1035,12 +1033,12 @@ int RsServer::StartupRetroShare()
#define BITDHT_FILTERED_IP_FILENAME "bdfilter.txt"
std::string bootstrapfile = rsAccounts->PathAccountDirectory();
std::string bootstrapfile = RsAccounts::AccountDirectory();
if (bootstrapfile != "")
bootstrapfile += "/";
bootstrapfile += BITDHT_BOOTSTRAP_FILENAME;
std::string filteredipfile = rsAccounts->PathAccountDirectory();
std::string filteredipfile = RsAccounts::AccountDirectory();
if (filteredipfile != "")
filteredipfile += "/";
filteredipfile += BITDHT_FILTERED_IP_FILENAME;
@ -1080,7 +1078,7 @@ int RsServer::StartupRetroShare()
bdbootRF.close();
}
#else
std::string installfile = rsAccounts->PathDataDirectory();
std::string installfile = RsAccounts::systemDataDirectory();
installfile += "/";
installfile += BITDHT_BOOTSTRAP_FILENAME;
@ -1107,96 +1105,105 @@ int RsServer::StartupRetroShare()
/* construct the rest of the stack, important to build them in the correct order! */
/* MOST OF THIS IS COMMENTED OUT UNTIL THE REST OF libretroshare IS READY FOR IT! */
UdpSubReceiver *udpReceivers[RSUDP_NUM_TOU_RECVERS];
int udpTypes[RSUDP_NUM_TOU_RECVERS];
p3BitDht *mBitDht = NULL ;
rsDht = NULL ;
rsFixedUdpStack *mProxyStack = NULL ;
#ifdef RS_USE_DHT_STUNNER
// FIRST DHT STUNNER.
UdpStunner *mDhtStunner = new UdpStunner(mDhtStack);
mDhtStunner->setTargetStunPeriod(300); /* slow (5mins) */
mDhtStack->addReceiver(mDhtStunner);
#ifdef LOCALNET_TESTING
mDhtStunner->SetAcceptLocalNet();
#endif
#endif // RS_USE_DHT_STUNNER
// NEXT BITDHT.
p3BitDht *mBitDht = new p3BitDht(ownId, mLinkMgr, mNetMgr, mDhtStack, bootstrapfile, filteredipfile);
/* install external Pointer for Interface */
rsDht = mBitDht;
// NEXT THE RELAY (NEED to keep a reference for installing RELAYS)
UdpRelayReceiver *mRelay = new UdpRelayReceiver(mDhtStack);
udpReceivers[RSUDP_TOU_RECVER_RELAY_IDX] = mRelay; /* RELAY Connections (DHT Port) */
udpTypes[RSUDP_TOU_RECVER_RELAY_IDX] = TOU_RECEIVER_TYPE_UDPRELAY;
mDhtStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_RELAY_IDX]);
// LAST ON THIS STACK IS STANDARD DIRECT TOU
udpReceivers[RSUDP_TOU_RECVER_DIRECT_IDX] = new UdpPeerReceiver(mDhtStack); /* standard DIRECT Connections (DHT Port) */
udpTypes[RSUDP_TOU_RECVER_DIRECT_IDX] = TOU_RECEIVER_TYPE_UDPPEER;
mDhtStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_DIRECT_IDX]);
// NOW WE BUILD THE SECOND STACK.
// Create the Second UdpStack... Port should be random (but openable!).
// We do this by binding to xx.xx.xx.xx:0 which which gives us a random port.
struct sockaddr_in sndladdr;
sockaddr_clear(&sndladdr);
#ifdef LOCALNET_TESTING
// // HACK Proxy Port near Dht Port - For Relay Testing.
// uint16_t rndport = rsInitConfig->port + 3;
// sndladdr.sin_port = htons(rndport);
rsFixedUdpStack *mProxyStack = new rsFixedUdpStack(UDP_TEST_RESTRICTED_LAYER, sndladdr);
/* portRestrictions already parsed */
if (doPortRestrictions)
if(!RsAccounts::isHiddenNode())
{
RestrictedUdpLayer *url = (RestrictedUdpLayer *) mProxyStack->getUdpLayer();
url->addRestrictedPortRange(lport, uport);
}
#else
rsFixedUdpStack *mProxyStack = new rsFixedUdpStack(sndladdr);
#endif
UdpSubReceiver *udpReceivers[RSUDP_NUM_TOU_RECVERS];
int udpTypes[RSUDP_NUM_TOU_RECVERS];
#ifdef RS_USE_DHT_STUNNER
// FIRSTLY THE PROXY STUNNER.
UdpStunner *mProxyStunner = new UdpStunner(mProxyStack);
mProxyStunner->setTargetStunPeriod(300); /* slow (5mins) */
mProxyStack->addReceiver(mProxyStunner);
// FIRST DHT STUNNER.
UdpStunner *mDhtStunner = new UdpStunner(mDhtStack);
mDhtStunner->setTargetStunPeriod(300); /* slow (5mins) */
mDhtStack->addReceiver(mDhtStunner);
#ifdef LOCALNET_TESTING
mProxyStunner->SetAcceptLocalNet();
mDhtStunner->SetAcceptLocalNet();
#endif
#endif // RS_USE_DHT_STUNNER
// FINALLY THE PROXY UDP CONNECTIONS
udpReceivers[RSUDP_TOU_RECVER_PROXY_IDX] = new UdpPeerReceiver(mProxyStack); /* PROXY Connections (Alt UDP Port) */
udpTypes[RSUDP_TOU_RECVER_PROXY_IDX] = TOU_RECEIVER_TYPE_UDPPEER;
mProxyStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_PROXY_IDX]);
// NEXT BITDHT.
// REAL INITIALISATION - WITH THREE MODES
tou_init((void **) udpReceivers, udpTypes, RSUDP_NUM_TOU_RECVERS);
mBitDht = new p3BitDht(ownId, mLinkMgr, mNetMgr, mDhtStack, bootstrapfile, filteredipfile);
// NEXT THE RELAY (NEED to keep a reference for installing RELAYS)
UdpRelayReceiver *mRelay = new UdpRelayReceiver(mDhtStack);
udpReceivers[RSUDP_TOU_RECVER_RELAY_IDX] = mRelay; /* RELAY Connections (DHT Port) */
udpTypes[RSUDP_TOU_RECVER_RELAY_IDX] = TOU_RECEIVER_TYPE_UDPRELAY;
mDhtStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_RELAY_IDX]);
// LAST ON THIS STACK IS STANDARD DIRECT TOU
udpReceivers[RSUDP_TOU_RECVER_DIRECT_IDX] = new UdpPeerReceiver(mDhtStack); /* standard DIRECT Connections (DHT Port) */
udpTypes[RSUDP_TOU_RECVER_DIRECT_IDX] = TOU_RECEIVER_TYPE_UDPPEER;
mDhtStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_DIRECT_IDX]);
/* install external Pointer for Interface */
rsDht = mBitDht;
// NOW WE BUILD THE SECOND STACK.
// Create the Second UdpStack... Port should be random (but openable!).
// We do this by binding to xx.xx.xx.xx:0 which which gives us a random port.
struct sockaddr_in sndladdr;
sockaddr_clear(&sndladdr);
#ifdef LOCALNET_TESTING
// // HACK Proxy Port near Dht Port - For Relay Testing.
// uint16_t rndport = rsInitConfig->port + 3;
// sndladdr.sin_port = htons(rndport);
mProxyStack = new rsFixedUdpStack(UDP_TEST_RESTRICTED_LAYER, sndladdr);
/* portRestrictions already parsed */
if (doPortRestrictions)
{
RestrictedUdpLayer *url = (RestrictedUdpLayer *) mProxyStack->getUdpLayer();
url->addRestrictedPortRange(lport, uport);
}
#else
mProxyStack = new rsFixedUdpStack(sndladdr);
#endif
#ifdef RS_USE_DHT_STUNNER
mBitDht->setupConnectBits(mDhtStunner, mProxyStunner, mRelay);
// FIRSTLY THE PROXY STUNNER.
UdpStunner *mProxyStunner = new UdpStunner(mProxyStack);
mProxyStunner->setTargetStunPeriod(300); /* slow (5mins) */
mProxyStack->addReceiver(mProxyStunner);
#ifdef LOCALNET_TESTING
mProxyStunner->SetAcceptLocalNet();
#endif
#endif // RS_USE_DHT_STUNNER
// FINALLY THE PROXY UDP CONNECTIONS
udpReceivers[RSUDP_TOU_RECVER_PROXY_IDX] = new UdpPeerReceiver(mProxyStack); /* PROXY Connections (Alt UDP Port) */
udpTypes[RSUDP_TOU_RECVER_PROXY_IDX] = TOU_RECEIVER_TYPE_UDPPEER;
mProxyStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_PROXY_IDX]);
// REAL INITIALISATION - WITH THREE MODES
tou_init((void **) udpReceivers, udpTypes, RSUDP_NUM_TOU_RECVERS);
#ifdef RS_USE_DHT_STUNNER
mBitDht->setupConnectBits(mDhtStunner, mProxyStunner, mRelay);
#else // RS_USE_DHT_STUNNER
mBitDht->setupConnectBits(mRelay);
mBitDht->setupConnectBits(mRelay);
#endif // RS_USE_DHT_STUNNER
#ifdef RS_USE_DHT_STUNNER
mNetMgr->setAddrAssist(new stunAddrAssist(mDhtStunner), new stunAddrAssist(mProxyStunner));
mNetMgr->setAddrAssist(new stunAddrAssist(mDhtStunner), new stunAddrAssist(mProxyStunner));
#endif // RS_USE_DHT_STUNNER
// #else //RS_USE_BITDHT
// /* install NULL Pointer for rsDht Interface */
// rsDht = NULL;
// #else //RS_USE_BITDHT
// /* install NULL Pointer for rsDht Interface */
// rsDht = NULL;
#endif //RS_USE_BITDHT
}
/**************************** BITDHT ***********************************/
@ -1211,7 +1218,7 @@ int RsServer::StartupRetroShare()
/****** New Ft Server **** !!! */
ftServer *ftserver = new ftServer(mPeerMgr, serviceCtrl);
ftserver->setConfigDirectory(rsAccounts->PathAccountDirectory());
ftserver->setConfigDirectory(RsAccounts::AccountDirectory());
ftserver->SetupFtServer() ;
@ -1227,12 +1234,12 @@ int RsServer::StartupRetroShare()
std::vector<std::string> plugins_directories ;
#ifdef __APPLE__
plugins_directories.push_back(rsAccounts->PathDataDirectory()) ;
plugins_directories.push_back(RsAccounts::systemDataDirectory()) ;
#endif
#if !defined(WINDOWS_SYS) && defined(PLUGIN_DIR)
plugins_directories.push_back(std::string(PLUGIN_DIR)) ;
#endif
std::string extensions_dir = rsAccounts->PathBaseDirectory() + "/extensions6/" ;
std::string extensions_dir = RsAccounts::ConfigDirectory() + "/extensions6/" ;
plugins_directories.push_back(extensions_dir) ;
if(!RsDirUtil::checkCreateDirectory(extensions_dir))
@ -1275,7 +1282,7 @@ int RsServer::StartupRetroShare()
#ifdef RS_ENABLE_GXS
std::string currGxsDir = rsAccounts->PathAccountDirectory() + "/gxs";
std::string currGxsDir = RsAccounts::AccountDirectory() + "/gxs";
RsDirUtil::checkCreateDirectory(currGxsDir);
RsNxsNetMgr* nxsMgr = new RsNxsNetMgrImpl(serviceCtrl);
@ -1560,17 +1567,17 @@ int RsServer::StartupRetroShare()
#endif
// new services to test.
#ifndef RETROTOR
p3BanList *mBanList = new p3BanList(serviceCtrl, mNetMgr);
rsBanList = mBanList ;
pqih -> addService(mBanList, true);
#else
rsBanList = NULL ;
#endif
#ifdef RS_USE_BITDHT
mBitDht->setupPeerSharer(mBanList);
#endif
p3BanList *mBanList = NULL;
if(!RsAccounts::isHiddenNode())
{
mBanList = new p3BanList(serviceCtrl, mNetMgr);
rsBanList = mBanList ;
pqih -> addService(mBanList, true);
}
else
rsBanList = NULL ;
p3BandwidthControl *mBwCtrl = new p3BandwidthControl(pqih);
pqih -> addService(mBwCtrl, true);
@ -1584,30 +1591,34 @@ int RsServer::StartupRetroShare()
/**************************************************************************/
if(!RsAccounts::isHiddenNode())
{
#ifdef RS_USE_BITDHT
mNetMgr->addNetAssistConnect(1, mBitDht);
mNetMgr->addNetListener(mDhtStack);
mNetMgr->addNetListener(mProxyStack);
mBitDht->setupPeerSharer(mBanList);
mNetMgr->addNetAssistConnect(1, mBitDht);
mNetMgr->addNetListener(mDhtStack);
mNetMgr->addNetListener(mProxyStack);
#endif
#ifdef RS_ENABLE_ZEROCONF
p3ZeroConf *mZeroConf = new p3ZeroConf(
AuthGPG::getAuthGPG()->getGPGOwnId(), ownId,
mLinkMgr, mNetMgr, mPeerMgr);
mNetMgr->addNetAssistConnect(2, mZeroConf);
mNetMgr->addNetListener(mZeroConf);
p3ZeroConf *mZeroConf = new p3ZeroConf(
AuthGPG::getAuthGPG()->getGPGOwnId(), ownId,
mLinkMgr, mNetMgr, mPeerMgr);
mNetMgr->addNetAssistConnect(2, mZeroConf);
mNetMgr->addNetListener(mZeroConf);
#endif
#ifdef RS_ENABLE_ZCNATASSIST
// Apple's UPnP & NAT-PMP assistance.
p3zcNatAssist *mZcNatAssist = new p3zcNatAssist();
mNetMgr->addNetAssistFirewall(1, mZcNatAssist);
// Apple's UPnP & NAT-PMP assistance.
p3zcNatAssist *mZcNatAssist = new p3zcNatAssist();
mNetMgr->addNetAssistFirewall(1, mZcNatAssist);
#else
// Original UPnP Interface.
pqiNetAssistFirewall *mUpnpMgr = new upnphandler();
mNetMgr->addNetAssistFirewall(1, mUpnpMgr);
// Original UPnP Interface.
pqiNetAssistFirewall *mUpnpMgr = new upnphandler();
mNetMgr->addNetAssistFirewall(1, mUpnpMgr);
#endif
}
/**************************************************************************/
/* need to Monitor too! */
@ -1640,9 +1651,10 @@ int RsServer::StartupRetroShare()
mConfigMgr->addConfiguration("p3History.cfg" , mHistoryMgr);
mConfigMgr->addConfiguration("p3Status.cfg" , mStatusSrv);
mConfigMgr->addConfiguration("turtle.cfg" , tr);
#ifndef RETROTOR
mConfigMgr->addConfiguration("banlist.cfg" , mBanList);
#endif
if(mBanList != NULL)
mConfigMgr->addConfiguration("banlist.cfg" , mBanList);
mConfigMgr->addConfiguration("servicecontrol.cfg", serviceCtrl);
mConfigMgr->addConfiguration("reputations.cfg" , mReputations);
#ifdef ENABLE_GROUTER
@ -1650,7 +1662,8 @@ int RsServer::StartupRetroShare()
#endif
#ifdef RS_USE_BITDHT
mConfigMgr->addConfiguration("bitdht.cfg" , mBitDht);
if(mBitDht != NULL)
mConfigMgr->addConfiguration("bitdht.cfg" , mBitDht);
#endif
#ifdef RS_ENABLE_GXS
@ -1877,7 +1890,8 @@ int RsServer::StartupRetroShare()
//mDhtMgr->start();
#ifdef RS_USE_BITDHT
mBitDht->start();
if(mBitDht != NULL)
mBitDht->start();
#endif
/**************************************************************************/
@ -1913,6 +1927,10 @@ int RsServer::StartupRetroShare()
/* Startup this thread! */
start("rs main") ;
std::cerr << "========================================================================" << std::endl;
std::cerr << "== RsInit:: Retroshare core started ==" << std::endl;
std::cerr << "========================================================================" << std::endl;
return 1;
}
@ -1973,10 +1991,10 @@ bool RsLoginHelper::createLocation(
if(!rsNotify->cachePgpPassphrase(password)) return false;
if(!rsNotify->setDisableAskPassword(true)) return false;
bool ret = RsAccounts::GenerateSSLCertificate(
l.mPgpId, "", l.mLocationName, "", false,
RSRandom::random_alphaNumericString(
RsInit::getSslPwdLen() ), l.mLocationId, errorMessage );
bool ret = RsAccounts::createNewAccount(
l.mPgpId, "", l.mLocationName, "", false, false,
RSRandom::random_alphaNumericString(RsInit::getSslPwdLen()),
l.mLocationId, errorMessage );
rsNotify->setDisableAskPassword(false);
return ret;

View File

@ -3,7 +3,7 @@
#include <pqi/authgpg.h>
#include "rsloginhandler.h"
#include "util/rsdir.h"
#include "rsaccounts.h"
#include "retroshare/rsinit.h"
//#define DEBUG_RSLOGINHANDLER 1
@ -91,7 +91,7 @@ bool RsLoginHandler::getSSLPasswdFromGPGFile(const RsPeerId& ssl_id,std::string&
std::string RsLoginHandler::getSSLPasswdFileName(const RsPeerId& /*ssl_id*/)
{
return rsAccounts->PathAccountKeysDirectory() + "/" + "ssl_passphrase.pgp";
return RsAccounts::AccountKeysDirectory() + "/" + "ssl_passphrase.pgp";
}
#ifdef RS_AUTOLOGIN
@ -755,7 +755,7 @@ bool RsLoginHandler::clearAutoLogin(const RsPeerId& ssl_id)
std::string RsLoginHandler::getAutologinFileName(const RsPeerId& /*ssl_id*/)
{
return rsAccounts->PathAccountKeysDirectory() + "/" + "help.dta" ;
return RsAccounts::AccountKeysDirectory() + "/" + "help.dta" ;
}
#endif // RS_AUTOLOGIN

View File

@ -65,6 +65,7 @@ linux-* {
rs_deep_search {
mLibs += xapian
win32-g++:mLibs += rpcrt4
}
static {

View File

@ -196,7 +196,6 @@ void* doExtAddrSearch(void *p)
af->mFoundTS = time(NULL) ;
af->mSearching = false ;
}
pthread_exit(NULL);
return NULL ;
}
@ -213,7 +212,6 @@ void* doExtAddrSearch(void *p)
af->mFoundTS = time(NULL) ;
af->mSearching = false ;
}
pthread_exit(NULL);
return NULL ;
}
@ -224,7 +222,6 @@ void* doExtAddrSearch(void *p)
af->mSearching = false ;
}
pthread_exit(NULL);
return NULL ;
}

View File

@ -25,7 +25,7 @@
#include "rsserver/p3face.h"
#include "retroshare/rsfiles.h"
#include "retroshare/rsiface.h"
#include "rsserver/rsaccounts.h"
#include "retroshare/rsinit.h"
#include "rsdiscspace.h"
#include <util/rsthreads.h>
@ -166,13 +166,13 @@ bool RsDiscSpace::checkForDiscSpace(RsDiscSpace::DiscLocation loc)
#endif
break ;
case RS_CONFIG_DIRECTORY: rs = crossSystemDiskStats(rsAccounts->PathAccountDirectory().c_str(),free_blocks,block_size) ;
case RS_CONFIG_DIRECTORY: rs = crossSystemDiskStats(RsAccounts::AccountDirectory().c_str(),free_blocks,block_size) ;
#ifdef DEBUG_RSDISCSPACE
std::cerr << " path = " << RsInit::RsConfigDirectory() << std::endl ;
#endif
break ;
case RS_PGP_DIRECTORY: rs = crossSystemDiskStats(rsAccounts->PathPGPDirectory().c_str(),free_blocks,block_size) ;
case RS_PGP_DIRECTORY: rs = crossSystemDiskStats(RsAccounts::PGPDirectory().c_str(),free_blocks,block_size) ;
#ifdef DEBUG_RSDISCSPACE
std::cerr << " path = " << RsInit::RsPGPDirectory() << std::endl ;
#endif

View File

@ -128,7 +128,7 @@ static bool StrContains( const std::string & str1, const std::string & str2,
}
std::string StringExpression::toStdString(const std::string& varstr) const
std::string StringExpression::toStdStringWithParam(const std::string& varstr) const
{
std::string strlist ;
for (auto iter = terms.begin(); iter != terms.end(); ++iter )

View File

@ -216,7 +216,7 @@ QTranslator* VOIPPlugin::qt_translator(QApplication */*app*/, const QString& lan
void VOIPPlugin::qt_sound_events(SoundEvents &events) const
{
QDir baseDir = QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str()) + "/sounds");
QDir baseDir = QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()) + "/sounds");
events.addEvent(QApplication::translate("VOIP", "VOIP")
, QApplication::translate("VOIP", "Incoming audio call")

View File

@ -67,17 +67,17 @@ public:
enum Status
{
Error = -1,
NotConnected,
Connecting,
Authenticating,
Connected
NotConnected = 0x00,
Connecting = 0x01,
Authenticating = 0x02,
Connected = 0x03
};
enum TorStatus
{
TorUnknown,
TorOffline,
TorReady
TorUnknown = 0x00,
TorOffline = 0x01,
TorReady = 0x02
};

View File

@ -118,12 +118,17 @@ TorProcess *TorManager::process()
return d->process;
}
QString TorManager::dataDirectory() const
bool TorManager::isTorAvailable()
{
return !instance()->d->torExecutablePath().isNull();
}
QString TorManager::torDataDirectory() const
{
return d->dataDir;
}
void TorManager::setDataDirectory(const QString &path)
void TorManager::setTorDataDirectory(const QString &path)
{
d->dataDir = QDir::fromNativeSeparators(path);

View File

@ -58,18 +58,18 @@ class TorManager : public QObject
Q_PROPERTY(Tor::TorControl* control READ control CONSTANT)
Q_PROPERTY(bool hasError READ hasError NOTIFY errorChanged)
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorChanged)
Q_PROPERTY(QString dataDirectory READ dataDirectory WRITE setDataDirectory)
Q_PROPERTY(QString torDataDirectory READ torDataDirectory WRITE setTorDataDirectory)
public:
explicit TorManager(QObject *parent = 0);
static bool isTorAvailable() ;
static TorManager *instance();
TorProcess *process();
TorControl *control();
QString dataDirectory() const;
void setDataDirectory(const QString &path);
QString torDataDirectory() const;
void setTorDataDirectory(const QString &path);
QString hiddenServiceDirectory() const;
void setHiddenServiceDirectory(const QString &path);
@ -100,6 +100,7 @@ signals:
void errorChanged();
private:
explicit TorManager(QObject *parent = 0);
TorManagerPrivate *d;
};

View File

@ -34,6 +34,7 @@
#include <rshare.h>
#include "gui/settings/rsharesettings.h"
#include "TorControl/TorManager.h"
#include "util/misc.h"
#include <retroshare/rsidentity.h>
@ -136,7 +137,7 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent)
//ui.headerFrame->setHeaderText(tr("Create a new profile"));
connect(ui.reuse_existing_node_CB, SIGNAL(triggered()), this, SLOT(switchReuseExistingNode()));
connect(ui.adv_checkbox, SIGNAL(triggered()), this, SLOT(setupState()));
connect(ui.adv_checkbox, SIGNAL(toggled(bool)), this, SLOT(setupState()));
connect(ui.nodeType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(setupState()));
connect(ui.genButton, SIGNAL(clicked()), this, SLOT(genPerson()));
@ -181,10 +182,10 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent)
* mark last one as default.
*/
QMenu *menu = new QMenu(tr("Advanced options"));
menu->addAction(ui.adv_checkbox);
menu->addAction(ui.reuse_existing_node_CB);
ui.optionsButton->setMenu(menu);
//QMenu *menu = new QMenu(tr("Advanced options"));
//menu->addAction(ui.adv_checkbox);
//menu->addAction(ui.reuse_existing_node_CB);
// ui.optionsButton->setMenu(menu);
mAllFieldsOk = false ;
mEntropyOk = false ;
@ -195,10 +196,10 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent)
ui.nodeType_CB->setCurrentIndex(1);
ui.nodeType_CB->setEnabled(false);
#endif
#ifdef RETROTOR
ui.adv_checkbox->setChecked(false);
ui.adv_checkbox->setVisible(true);
#endif
//#ifdef RETROTOR
// ui.adv_checkbox->setChecked(false);
// ui.adv_checkbox->setVisible(true);
//#endif
initKeyList();
setupState();
@ -259,30 +260,39 @@ void GenCertDialog::setupState()
{
bool adv_state = ui.adv_checkbox->isChecked();
#ifdef RETROTOR
bool retrotor = true ;
#else
bool retrotor = false ;
#endif
if(!adv_state)
{
ui.reuse_existing_node_CB->setChecked(false) ;
ui.nodeType_CB->setCurrentIndex(retrotor?1:0) ;
ui.keylength_comboBox->setCurrentIndex(0) ;
// ui.nodeType_CB->setCurrentIndex(0);
}
bool hidden_state = ui.nodeType_CB->currentIndex()==1;
ui.reuse_existing_node_CB->setVisible(adv_state) ;
// ui.nodeType_CB->setVisible(adv_state) ;
// ui.nodeType_LB->setVisible(adv_state) ;
// ui.nodeTypeExplanation_TE->setVisible(adv_state) ;
bool hidden_state = ui.nodeType_CB->currentIndex()==1 || ui.nodeType_CB->currentIndex()==2;
bool generate_new = !ui.reuse_existing_node_CB->isChecked();
bool tor_auto = ui.nodeType_CB->currentIndex()==1;
genNewGPGKey = generate_new;
switch(ui.nodeType_CB->currentIndex())
{
case 0: ui.nodeTypeExplanation_TE->setText(tr("<b>Your IP is visible to trusted nodes only. You can also connect to hidden nodes if running Tor on your machine. Best choice for sharing with trusted friends.</b>"));
break;
case 1: ui.nodeTypeExplanation_TE->setText(tr("<b>Your IP is hidden. All traffic happens over the Tor network. Best choice if you cannot trust friend nodes with your own IP.</b>"));
break;
case 2: ui.nodeTypeExplanation_TE->setText(tr("<b>Hidden node for advanced users only. Allows to use other proxy solutions such as I2P.</b>"));
break;
}
//ui.no_node_label->setVisible(false);
setWindowTitle(generate_new?tr("Create new profile and new Retroshare node"):tr("Create new Retroshare node"));
//ui.headerFrame->setHeaderText(generate_new?tr("Create a new profile and node"):tr("Create a new node"));
ui.label_nodeType->setVisible(adv_state && !retrotor) ;
ui.nodeType_CB->setVisible(adv_state && !retrotor) ;
ui.reuse_existing_node_CB->setEnabled(adv_state) ;
ui.importIdentity_PB->setVisible(adv_state && !generate_new) ;
ui.exportIdentity_PB->setVisible(adv_state && !generate_new) ;
@ -318,13 +328,13 @@ void GenCertDialog::setupState()
ui.entropy_bar->setVisible(true);
ui.genButton->setVisible(true);
ui.hiddenaddr_input->setVisible(hidden_state && !retrotor);
ui.hiddenaddr_label->setVisible(hidden_state && !retrotor);
ui.hiddenaddr_input->setVisible(hidden_state && !tor_auto);
ui.hiddenaddr_label->setVisible(hidden_state && !tor_auto);
ui.hiddenport_label->setVisible(hidden_state && !retrotor);
ui.hiddenport_spinBox->setVisible(hidden_state && !retrotor);
ui.hiddenport_label->setVisible(hidden_state && !tor_auto);
ui.hiddenport_spinBox->setVisible(hidden_state && !tor_auto);
ui.cbUseBob->setVisible(hidden_state && !retrotor);
ui.cbUseBob->setVisible(hidden_state && !tor_auto);
if(!mAllFieldsOk)
{
@ -470,7 +480,6 @@ void GenCertDialog::genPerson()
/* Check the data from the GUI. */
std::string genLoc = ui.node_input->text().toUtf8().constData();
RsPgpId PGPId;
bool isHiddenLoc = false;
if(ui.nickname_input->isVisible())
{
@ -503,18 +512,26 @@ void GenCertDialog::genPerson()
}
}
if (ui.nodeType_CB->currentIndex()==1)
bool isHiddenLoc = (ui.nodeType_CB->currentIndex()>0);
bool isAutoTor = (ui.nodeType_CB->currentIndex()==1);
if(isAutoTor && !Tor::TorManager::isTorAvailable())
{
QMessageBox::critical(this,tr("Tor is not available"),tr("No Tor executable has been found on your system. You need to install Tor before creating a hidden identity.")) ;
return ;
}
if(isHiddenLoc)
{
std::string hl = ui.hiddenaddr_input->text().toStdString();
uint16_t port = ui.hiddenport_spinBox->value();
bool useBob = ui.cbUseBob->isChecked();
if (useBob && hl.empty())
hl = "127.0.0.1";
RsInit::SetHiddenLocation(hl, port, useBob); /* parses it */
isHiddenLoc = true;
}
@ -620,7 +637,7 @@ void GenCertDialog::genPerson()
std::string err;
this->hide();//To show dialog asking password PGP Key.
std::cout << "RsAccounts::GenerateSSLCertificate" << std::endl;
bool okGen = RsAccounts::GenerateSSLCertificate(PGPId, "", genLoc, "", isHiddenLoc, sslPasswd, sslId, err);
bool okGen = RsAccounts::createNewAccount(PGPId, "", genLoc, "", isHiddenLoc, isAutoTor, sslPasswd, sslId, err);
if (okGen)
{

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>569</width>
<height>426</height>
<width>978</width>
<height>826</height>
</rect>
</property>
<property name="windowTitle">
@ -50,10 +50,7 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="profileframeVLayout">
<property name="leftMargin">
<number>9</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="RSLabel">
<property name="text">
@ -71,7 +68,45 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="toolBarHLayout">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="nodeType_LB">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Node type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="nodeType_CB">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Standard node</string>
</property>
</item>
<item>
<property name="text">
<string>Hidden node (over Tor)</string>
</property>
</item>
<item>
<property name="text">
<string>Hidden node (Tor/I2P - Manually configured)</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="toolBarHSpacer">
<property name="orientation">
@ -86,13 +121,9 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="optionsButton">
<widget class="QCheckBox" name="adv_checkbox">
<property name="text">
<string>Options</string>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/svg/options.svg</normaloff>:/icons/svg/options.svg</iconset>
<string>advanced options</string>
</property>
<property name="iconSize">
<size>
@ -100,16 +131,23 @@
<height>24</height>
</size>
</property>
<property name="default">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="nodeTypeExplanation_TE">
<property name="text">
<string>TextLabel</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="profile_groupBox">
<property name="styleSheet">
@ -233,26 +271,6 @@
</property>
</widget>
</item>
<item row="15" column="2">
<widget class="QComboBox" name="nodeType_CB">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Standard node</string>
</property>
</item>
<item>
<property name="text">
<string>TOR/I2P Hidden node</string>
</property>
</item>
</widget>
</item>
<item row="5" column="2">
<widget class="QLineEdit" name="node_input">
<property name="sizePolicy">
@ -357,6 +375,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="reuse_existing_node_CB">
<property name="text">
<string>Use existing profile...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="3">
@ -675,28 +700,6 @@
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QLabel" name="label_nodeType">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="icons.qrc">:/icons/svg/netgraph.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
@ -729,22 +732,6 @@
</widget>
</item>
</layout>
<action name="adv_checkbox">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Advanced options</string>
</property>
</action>
<action name="reuse_existing_node_CB">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Use existing profile</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>name_input</tabstop>

View File

@ -84,12 +84,13 @@
#include "statusbar/ToasterDisable.h"
#include "statusbar/SysTrayStatus.h"
#include "statusbar/torstatus.h"
#include <retroshare/rsstatus.h>
#include <retroshare/rsiface.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsfiles.h>
#include <retroshare/rsnotify.h>
#include "retroshare/rsstatus.h"
#include "retroshare/rsiface.h"
#include "retroshare/rspeers.h"
#include "retroshare/rsfiles.h"
#include "retroshare/rsnotify.h"
#include "retroshare/rsinit.h"
#include "gui/gxschannels/GxsChannelDialog.h"
#include "gui/gxsforums/GxsForumsDialog.h"
@ -250,14 +251,15 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags)
if(hiddenmode)
{
#ifdef RETROTOR
torstatus = new TorStatus();
torstatus->setVisible(Settings->valueFromGroup("StatusBar", "ShowTor", QVariant(true)).toBool());
statusBar()->addWidget(torstatus);
torstatus->getTorStatus();
#else
torstatus = NULL ;
#endif
if(RsAccounts::isHiddenNode())
{
torstatus = new TorStatus();
torstatus->setVisible(Settings->valueFromGroup("StatusBar", "ShowTor", QVariant(true)).toBool());
statusBar()->addWidget(torstatus);
torstatus->getTorStatus();
}
else
torstatus = NULL ;
natstatus = NULL ;
dhtstatus = NULL ;

View File

@ -76,7 +76,7 @@ SoundManager::SoundManager() : QObject()
void SoundManager::soundEvents(SoundEvents &events)
{
QDir baseDir = QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str()) + "/sounds");
QDir baseDir = QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()) + "/sounds");
events.mDefaultPath = baseDir.absolutePath();

View File

@ -149,7 +149,7 @@ static QStringList getBaseDirList()
// Search chat styles in config dir and data dir (is application dir for portable)
QStringList baseDirs;
baseDirs.append(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str()));
baseDirs.append(QString::fromUtf8(RsAccounts::DataDirectory().c_str()));
baseDirs.append(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()));
return baseDirs;
}

View File

@ -191,7 +191,9 @@ ChatWidget::ChatWidget(QWidget *parent)
fontmenu->addAction(ui->actionResetFont);
fontmenu->addAction(ui->actionNoEmbed);
fontmenu->addAction(ui->actionSendAsPlainText);
#ifdef USE_CMARK
fontmenu->addAction(ui->actionSend_as_CommonMark);
#endif
QMenu *menu = new QMenu();
menu->addAction(ui->actionClearChatHistory);
@ -205,9 +207,11 @@ ChatWidget::ChatWidget(QWidget *parent)
ui->chatTextEdit->setOnlyPlainText(ui->actionSendAsPlainText->isChecked());
connect(ui->actionSendAsPlainText, SIGNAL(toggled(bool)), ui->chatTextEdit, SLOT(setOnlyPlainText(bool)) );
#ifdef USE_CMARK
connect(ui->actionSend_as_CommonMark, SIGNAL(toggled(bool)), this, SLOT(setUseCMark(bool)) );
ui->cmPreview->setVisible(false);
connect(ui->chatTextEdit, SIGNAL(textChanged()), this, SLOT(updateCMPreview()) );
#endif
ui->cmPreview->setVisible(false);
ui->textBrowser->resetImagesStatus(Settings->getChatLoadEmbeddedImages());
ui->textBrowser->installEventFilter(this);
@ -983,10 +987,12 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const RsGxsId gx
formatTextFlag |= RSHTML_FORMATTEXT_EMBED_SMILEYS;
}
#ifdef USE_CMARK
//Use CommonMark
if (message.contains("CMark=\"true\"")) {
formatTextFlag |= RSHTML_FORMATTEXT_USE_CMARK;
}
#endif
// Always fix colors
formatTextFlag |= RSHTML_FORMATTEXT_FIX_COLORS;

View File

@ -107,7 +107,7 @@ QVariant RSTextBrowser::loadResource(int type, const QUrl &name)
if(fi.exists() && fi.isFile()) {
QString cpath = fi.canonicalFilePath();
if (cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive)
|| cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive))
|| cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive))
return QTextBrowser::loadResource(type, name);
}}
@ -251,53 +251,22 @@ bool RSTextBrowser::checkImage(QPoint pos, QString &imageStr)
*/
QString RSTextBrowser::anchorForPosition(const QPoint &pos) const
{
// Many calls when time label shows up
QTextCursor cursor = cursorForPosition(pos);
cursor.select(QTextCursor::WordUnderCursor);
QString word = cursor.selectedText();
QString anchor = "";
if (word.isEmpty())
return anchor;
// For finding positions
QTextCursor cursor_line = cursorForPosition(pos);
cursor_line.select(QTextCursor::LineUnderCursor);
QString line = cursor_line.selectedText();
// End of nickname (more or less, of course, because some can has colon in
// name)
int end_of_name = line.indexOf(": ") + 1;
// Start of nickname (after time)
int space_index = line.indexOf(' ') + 1;
int word_index = line.indexOf(word) + 1;
int once = 1;
cursor_line.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor, once);
bool after_name = cursor_line.position() + end_of_name < cursor.position();
bool cursor_after_time = space_index < word_index;
bool cursor_within_name = word_index <= end_of_name;
if (!after_name && cursor_after_time && cursor_within_name) {
cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor, once);
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor,
space_index);
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor,
end_of_name - space_index);
if (cursor.selectedText().isEmpty()) {
return anchor;
if (!cursor.selectedText().isEmpty()){
QRegExp rx("<a name=\"(.*)\"",Qt::CaseSensitive, QRegExp::RegExp2);
rx.setMinimal(true);
QString sel = cursor.selection().toHtml();
QStringList anchors;
int pos=0;
while ((pos = rx.indexIn(sel,pos)) != -1) {
anchors << rx.cap(1);
pos += rx.matchedLength();
}
if (!anchors.isEmpty()){
anchor = anchors.at(0);
}
} else {
return anchor;
}
QRegExp rx("<a name=\"(.*)\"",Qt::CaseSensitive, QRegExp::RegExp2);
rx.setMinimal(true);
QString sel = cursor.selection().toHtml();
QStringList anchors;
int position = 0;
while ((position = rx.indexIn(sel, position)) != -1) {
anchors << rx.cap(1);
position += rx.matchedLength();
}
if (!anchors.isEmpty()) {
anchor = anchors.at(0);
}
return anchor;
}

View File

@ -28,6 +28,7 @@
#include <QFile>
#include <QTextStream>
#include <QTextCodec>
#include <QDesktopServices>
#include "gui/notifyqt.h"
#include "gui/RetroShareLink.h"
@ -756,18 +757,19 @@ void MessageWidget::anchorClicked(const QUrl &url)
{
RetroShareLink link(url);
if (link.valid() == false) {
return;
if(link.valid())
{
if (link.type() == RetroShareLink::TYPE_CERTIFICATE && currMsgFlags & RS_MSG_USER_REQUEST) {
std::cerr << "(WW) Calling some disabled code in MessageWidget::anchorClicked(). Please contact the developpers." << std::endl;
// link.setSubType(RSLINK_SUBTYPE_CERTIFICATE_USER_REQUEST);
}
QList<RetroShareLink> links;
links.append(link);
RetroShareLink::process(links);
}
if (link.type() == RetroShareLink::TYPE_CERTIFICATE && currMsgFlags & RS_MSG_USER_REQUEST) {
std::cerr << "(WW) Calling some disabled code in MessageWidget::anchorClicked(). Please contact the developpers." << std::endl;
// link.setSubType(RSLINK_SUBTYPE_CERTIFICATE_USER_REQUEST);
}
QList<RetroShareLink> links;
links.append(link);
RetroShareLink::process(links);
else
QDesktopServices::openUrl(url) ;
}
void MessageWidget::loadImagesAlways()

View File

@ -29,11 +29,12 @@
#include <iostream>
#include <retroshare/rsbanlist.h>
#include <retroshare/rsconfig.h>
#include <retroshare/rsdht.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsturtle.h>
#include "retroshare/rsbanlist.h"
#include "retroshare/rsconfig.h"
#include "retroshare/rsdht.h"
#include "retroshare/rspeers.h"
#include "retroshare/rsturtle.h"
#include "retroshare/rsinit.h"
#include <QCheckBox>
#include <QMovie>
@ -62,23 +63,14 @@
///
// Tabs numbers *after* non relevant tabs are removed. So do not use them to add/remove tabs!!
#ifdef RETROTOR
static const uint32_t TAB_HIDDEN_SERVICE_OUTGOING = 0;
static const uint32_t TAB_HIDDEN_SERVICE_INCOMING = 1;
static const uint32_t TAB_NETWORK = 0;
static const uint32_t TAB_HIDDEN_SERVICE = 1;
static const uint32_t TAB_IP_FILTERS = 99; // This is a trick: these tabs do not exist, so enabling/disabling them has no effect
static const uint32_t TAB_RELAYS = 99;
#else
const static uint32_t TAB_HIDDEN_SERVICE_OUTGOING = 0;
const static uint32_t TAB_HIDDEN_SERVICE_INCOMING = 2;
const static uint32_t TAB_HIDDEN_SERVICE_INCOMING = 1;
const static uint32_t TAB_HIDDEN_SERVICE_I2P_BOB = 2;
const static uint32_t TAB_NETWORK = 0;
const static uint32_t TAB_IP_FILTERS = 1;
const static uint32_t TAB_HIDDEN_SERVICE = 2;
const static uint32_t TAB_HIDDEN_SERVICE = 1;
const static uint32_t TAB_IP_FILTERS = 2;
const static uint32_t TAB_RELAYS = 3;
#endif
//#define SERVER_DEBUG 1
@ -90,13 +82,15 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
manager = NULL ;
#ifdef RETROTOR
if(RsAccounts::isTorAuto())
{
// Here we use absolute numbers instead of consts defined above, because the consts correspond to the tab number *after* this tab removal.
ui.tabWidget->removeTab(3) ; // remove relays. Not useful in Tor mode.
ui.tabWidget->removeTab(1) ; // remove IP filters. Not useful in Tor mode.
ui.tabWidget->removeTab(TAB_RELAYS) ; // remove relays. Not useful in Tor mode.
ui.tabWidget->removeTab(TAB_IP_FILTERS) ; // remove IP filters. Not useful in Tor mode.
ui.hiddenServiceTab->removeTab(TAB_HIDDEN_SERVICE_I2P_BOB) ; // remove the Automatic I2P/BOB tab
ui.hiddenServiceTab->removeTab(1) ; // remove the Automatic I2P/BOB tab
ui.hiddenpage_proxyAddress_i2p->hide() ;
ui.hiddenpage_proxyLabel_i2p->hide() ;
ui.hiddenpage_proxyPort_i2p->hide() ;
@ -109,7 +103,8 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
ui.hiddenpage_outHeader->setText(tr("Tor has been automatically configured by Retroshare. You shouldn't need to change anything here.")) ;
ui.hiddenpage_inHeader->setText(tr("Tor has been automatically configured by Retroshare. You shouldn't need to change anything here.")) ;
#endif
}
ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_RANGE,new QTableWidgetItem(tr("IP Range"))) ;
ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_STATUS,new QTableWidgetItem(tr("Status"))) ;
ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_ORIGIN,new QTableWidgetItem(tr("Origin"))) ;
@ -137,7 +132,6 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
for(std::list<std::string>::const_iterator it(ip_servers.begin());it!=ip_servers.end();++it)
ui.IPServersLV->addItem(QString::fromStdString(*it)) ;
ui.hiddenServiceTab->setTabEnabled(TAB_HIDDEN_SERVICE_INCOMING, false);
ui.gbBob->setEnabled(false);
ui.swBobAdvanced->setCurrentIndex(0);
@ -340,8 +334,8 @@ void ServerPage::load()
if (mIsHiddenNode)
{
mHiddenType = detail.hiddenType;
ui.tabWidget->setTabEnabled(TAB_IP_FILTERS,false) ; // ip filter
ui.tabWidget->setTabEnabled(TAB_RELAYS,false) ; // relay
//ui.tabWidget->setTabEnabled(TAB_IP_FILTERS,false) ; // ip filter
//ui.tabWidget->setTabEnabled(TAB_RELAYS,false) ; // relay
loadHiddenNode();
return;
}

View File

@ -26,7 +26,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabNetConf">
<attribute name="title">
@ -525,277 +525,6 @@ behind a firewall or a VPN.</string>
<zorder>IPServersLV</zorder>
<zorder>ipAddressList</zorder>
</widget>
<widget class="QWidget" name="tabIPFilters">
<attribute name="title">
<string>IP Filters</string>
</attribute>
<layout class="QVBoxLayout" name="tabIPFiltersVLayout">
<item>
<widget class="QCheckBox" name="denyAll_CB">
<property name="text">
<string>Activate IP filtering</string>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="ipTabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="ipBlackListTabWidget">
<attribute name="title">
<string>IP blacklist</string>
</attribute>
<layout class="QVBoxLayout" name="ipBlackListTabWidgetVLayout">
<item>
<widget class="QTableWidget" name="filteredIpsTable">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This list gets automatically filled with information gathered at multiple sources: masquerading peers reported by the DHT, IP ranges entered by you, and IP ranges reported by your friends. Default settings should protect you against large scale traffic relaying.&lt;/p&gt;&lt;p&gt;Automatically guessing masquerading IPs can put your friends IPs in the blacklist. In this case, use the context menu to whitelist them.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>IP range</string>
</property>
</column>
<column>
<property name="text">
<string>Status</string>
</property>
</column>
<column>
<property name="text">
<string>Origin</string>
</property>
</column>
<column>
<property name="text">
<string>Reason</string>
</property>
</column>
<column>
<property name="text">
<string>Comment</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QCheckBox" name="includeFromFriends_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is very drastic, be careful. Since masquerading IPs might be actual real IPs, this option might cause disconnection, and will probably force you to add your friends' IPs into the whitelist.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Ban every IP reported by your friends</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="includeFromDHT_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Another drastic option. If you use it, be prepared to add your friends' IPs into the whitelist when needed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Ban every masquerading IP reported by your DHT</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="groupIPRangesHLayout">
<item>
<widget class="QCheckBox" name="groupIPRanges_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If used alone, this option protects you quite well from large scale IP masquerading.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Automatically ban ranges of DHT masquerading IPs starting at</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="groupIPRanges_SB">
<property name="suffix">
<string> IPs</string>
</property>
<property name="minimum">
<number>2</number>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item>
<spacer name="groupIPRangesHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="ipWhiteListTabWidget">
<attribute name="title">
<string>IP whitelist</string>
</attribute>
<layout class="QGridLayout" name="ipWhiteListTabWidgetGLayout">
<item row="0" column="0">
<widget class="QTableWidget" name="whiteListIpsTable">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;White listed IPs are gathered from the following sources: IPs coming inside a manually exchanged certificate, IP ranges entered by you in this window, or in the security feed items.&lt;/p&gt;&lt;p&gt;The default behavior for Retroshare is to (1) always allow connection to peers with IP in the whitelist, even if that IP is also blacklisted; (2) optionally require IPs to be in the whitelist. You can change this behavior for each peer in the &amp;quot;Details&amp;quot; window of each Retroshare node. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>IP range</string>
</property>
</column>
<column>
<property name="text">
<string>Status</string>
</property>
</column>
<column>
<property name="text">
<string>Origin</string>
</property>
</column>
<column>
<property name="text">
<string>Reason</string>
</property>
</column>
<column>
<property name="text">
<string>Comment</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="manualInputGBox">
<property name="title">
<string>Manual input</string>
</property>
<layout class="QVBoxLayout" name="manualInputGBoxVLayout">
<item>
<layout class="QHBoxLayout" name="ipinputHLayout">
<item>
<widget class="QLineEdit" name="ipInput_LE">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter an IP range. Accepted formats:&lt;/p&gt;&lt;p&gt;193.190.209.15&lt;/p&gt;&lt;p&gt;193.190.209.15/24&lt;/p&gt;&lt;p&gt;193.190.209.15/16&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="ipInputRange_SB">
<property name="minimum">
<number>16</number>
</property>
<property name="maximum">
<number>32</number>
</property>
<property name="singleStep">
<number>8</number>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="ipInputComment_LE">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter any comment you'd like&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ipInputAddBlackList_PB">
<property name="text">
<string>Add to blacklist</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ipInputAddWhiteList_PB">
<property name="text">
<string>Add to whitelist</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="manualInputVSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabHiddenConf">
<attribute name="title">
<string>Hidden Service Configuration</string>
@ -810,7 +539,7 @@ behind a firewall or a VPN.</string>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="hiddenServiceTabManual">
<attribute name="title">
@ -981,6 +710,204 @@ You can connect to Hidden Nodes, even if you are running a standard Node, so why
</item>
</layout>
</widget>
<widget class="QWidget" name="hiddenServiceTabIncoming">
<attribute name="title">
<string>Incoming</string>
</attribute>
<layout class="QVBoxLayout" name="hiddenServiceTabIncomingVLayout">
<item>
<widget class="QLabel" name="hiddenpage_inHeader">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Setup your hidden address (and port if needed)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="incomingAddressGLayout">
<item row="0" column="2">
<widget class="QSpinBox" name="hiddenpage_localPort">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item row="0" column="3">
<layout class="QHBoxLayout" name="testIncomingHLayout">
<item>
<widget class="QPushButton" name="testIncoming_PB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This button simulates a SSL connection to your hidden address using the corresponding proxy. If your hidden node is reachable, it should cause a SSL handshake error, which RS will interpret as a valid connection state. This operation might also cause several &amp;quot;security warning&amp;quot; about connections from your local host IP (127.0.0.1) in the News Feed if you enabled it, which you should interpret as a sign of good communication.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="hiddenpage_servicePort">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="l_serviceAddress">
<property name="text">
<string>Service Address</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="l_localAddress">
<property name="text">
<string>Local Address</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="hiddenpage_serviceAddress">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is your hidden address. It should look like &lt;span style=&quot; font-weight:600;&quot;&gt;[something].onion&lt;/span&gt; or &lt;span style=&quot; font-weight:600;&quot;&gt;[something].b32.i2p. &lt;/span&gt;If you configured a hidden service with Tor, the onion address is generated automatically by Tor. You can get it in e.g. &lt;span style=&quot; font-weight:600;&quot;&gt;/var/lib/tor/[service name]/hostname&lt;/span&gt;. For I2P: Setup a server tunnel ( http://127.0.0.1:7657/i2ptunnelmgr ) and copy it's base32 address when it is started (should end with .b32.i2p)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="hiddenpage_localAddress">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is the local address to which the hidden service points at your localhost. Most of the time, &lt;span style=&quot; font-weight:600;&quot;&gt;127.0.0.1&lt;/span&gt; is the right answer.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="3">
<layout class="QHBoxLayout" name="serviceIncomingHLayout">
<item>
<widget class="QLabel" name="iconlabel_service_incoming">
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/ledoff1.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="l_incomingTestResult">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This led turns green only if you launch an active test using the above button. &lt;/p&gt;&lt;p&gt;When it does, it means that your hidden node can be reached from anywhere, using the Tor (resp. I2P) &lt;/p&gt;&lt;p&gt;network. Congratulations!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>incoming ok</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="hiddenpage_configurationVLayout">
<item>
<widget class="QLabel" name="l_hiddenpage_configuration">
<property name="text">
<string>Expected Configuration:</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="hiddenpage_configuration">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="plainText">
<string>Please fill in a service address</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="hiddenpageInHelpPlainTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="plainText">
<string>To Receive Connections, you must first setup a Tor/I2P Hidden Service.
For Tor: See torrc and documentation for HOWTO details.
For I2P: See http://127.0.0.1:7657/i2ptunnelmgr for setting up a server tunnel:
Tunnel Wizard -&gt; Server Tunnel -&gt; Standard -&gt; enter a name -&gt; enter the address and port your RS is using (see Local Address above) -&gt; check 'Auto Start' -&gt; finish!
Once this is done, paste the Onion/I2P (Base32) Address in the box above.
This is your external address on the Tor/I2P network.
Finally make sure that the Ports match the configuration.
If you have issues connecting over Tor check the Tor logs too.</string>
</property>
</widget>
</item>
<item>
<spacer name="vspacerHiddenIn">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="hiddenServiceTabI2PBOB">
<attribute name="title">
<string>Automatic I2P/BOB</string>
@ -1456,204 +1383,277 @@ You can connect to Hidden Nodes, even if you are running a standard Node, so why
</item>
</layout>
</widget>
<widget class="QWidget" name="hiddenServiceTabIncoming">
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabIPFilters">
<attribute name="title">
<string>IP Filters</string>
</attribute>
<layout class="QVBoxLayout" name="tabIPFiltersVLayout">
<item>
<widget class="QCheckBox" name="denyAll_CB">
<property name="text">
<string>Activate IP filtering</string>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="ipTabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="ipBlackListTabWidget">
<attribute name="title">
<string>Incoming</string>
<string>IP blacklist</string>
</attribute>
<layout class="QVBoxLayout" name="hiddenServiceTabIncomingVLayout">
<layout class="QVBoxLayout" name="ipBlackListTabWidgetVLayout">
<item>
<widget class="QLabel" name="hiddenpage_inHeader">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Setup your hidden address (and port if needed)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<widget class="QTableWidget" name="filteredIpsTable">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="incomingAddressGLayout">
<item row="0" column="2">
<widget class="QSpinBox" name="hiddenpage_localPort">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item row="0" column="3">
<layout class="QHBoxLayout" name="testIncomingHLayout">
<item>
<widget class="QPushButton" name="testIncoming_PB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This button simulates a SSL connection to your hidden address using the corresponding proxy. If your hidden node is reachable, it should cause a SSL handshake error, which RS will interpret as a valid connection state. This operation might also cause several &amp;quot;security warning&amp;quot; about connections from your local host IP (127.0.0.1) in the News Feed if you enabled it, which you should interpret as a sign of good communication.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="hiddenpage_servicePort">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="l_serviceAddress">
<property name="text">
<string>Service Address</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="l_localAddress">
<property name="text">
<string>Local Address</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="hiddenpage_serviceAddress">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is your hidden address. It should look like &lt;span style=&quot; font-weight:600;&quot;&gt;[something].onion&lt;/span&gt; or &lt;span style=&quot; font-weight:600;&quot;&gt;[something].b32.i2p. &lt;/span&gt;If you configured a hidden service with Tor, the onion address is generated automatically by Tor. You can get it in e.g. &lt;span style=&quot; font-weight:600;&quot;&gt;/var/lib/tor/[service name]/hostname&lt;/span&gt;. For I2P: Setup a server tunnel ( http://127.0.0.1:7657/i2ptunnelmgr ) and copy it's base32 address when it is started (should end with .b32.i2p)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="hiddenpage_localAddress">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is the local address to which the hidden service points at your localhost. Most of the time, &lt;span style=&quot; font-weight:600;&quot;&gt;127.0.0.1&lt;/span&gt; is the right answer.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="3">
<layout class="QHBoxLayout" name="serviceIncomingHLayout">
<item>
<widget class="QLabel" name="iconlabel_service_incoming">
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/ledoff1.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="l_incomingTestResult">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This led turns green only if you launch an active test using the above button. &lt;/p&gt;&lt;p&gt;When it does, it means that your hidden node can be reached from anywhere, using the Tor (resp. I2P) &lt;/p&gt;&lt;p&gt;network. Congratulations!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>incoming ok</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="hiddenpage_configurationVLayout">
<item>
<widget class="QLabel" name="l_hiddenpage_configuration">
<property name="text">
<string>Expected Configuration:</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="hiddenpage_configuration">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="plainText">
<string>Please fill in a service address</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="hiddenpageInHelpPlainTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This list gets automatically filled with information gathered at multiple sources: masquerading peers reported by the DHT, IP ranges entered by you, and IP ranges reported by your friends. Default settings should protect you against large scale traffic relaying.&lt;/p&gt;&lt;p&gt;Automatically guessing masquerading IPs can put your friends IPs in the blacklist. In this case, use the context menu to whitelist them.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="readOnly">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="plainText">
<string>To Receive Connections, you must first setup a Tor/I2P Hidden Service.
For Tor: See torrc and documentation for HOWTO details.
For I2P: See http://127.0.0.1:7657/i2ptunnelmgr for setting up a server tunnel:
Tunnel Wizard -&gt; Server Tunnel -&gt; Standard -&gt; enter a name -&gt; enter the address and port your RS is using (see Local Address above) -&gt; check 'Auto Start' -&gt; finish!
Once this is done, paste the Onion/I2P (Base32) Address in the box above.
This is your external address on the Tor/I2P network.
Finally make sure that the Ports match the configuration.
If you have issues connecting over Tor check the Tor logs too.</string>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>IP range</string>
</property>
</column>
<column>
<property name="text">
<string>Status</string>
</property>
</column>
<column>
<property name="text">
<string>Origin</string>
</property>
</column>
<column>
<property name="text">
<string>Reason</string>
</property>
</column>
<column>
<property name="text">
<string>Comment</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QCheckBox" name="includeFromFriends_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is very drastic, be careful. Since masquerading IPs might be actual real IPs, this option might cause disconnection, and will probably force you to add your friends' IPs into the whitelist.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Ban every IP reported by your friends</string>
</property>
</widget>
</item>
<item>
<spacer name="vspacerHiddenIn">
<property name="orientation">
<enum>Qt::Vertical</enum>
<widget class="QCheckBox" name="includeFromDHT_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Another drastic option. If you use it, be prepared to add your friends' IPs into the whitelist when needed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="text">
<string>Ban every masquerading IP reported by your DHT</string>
</property>
</spacer>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="groupIPRangesHLayout">
<item>
<widget class="QCheckBox" name="groupIPRanges_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If used alone, this option protects you quite well from large scale IP masquerading.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Automatically ban ranges of DHT masquerading IPs starting at</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="groupIPRanges_SB">
<property name="suffix">
<string> IPs</string>
</property>
<property name="minimum">
<number>2</number>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item>
<spacer name="groupIPRangesHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="ipWhiteListTabWidget">
<attribute name="title">
<string>IP whitelist</string>
</attribute>
<layout class="QGridLayout" name="ipWhiteListTabWidgetGLayout">
<item row="0" column="0">
<widget class="QTableWidget" name="whiteListIpsTable">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;White listed IPs are gathered from the following sources: IPs coming inside a manually exchanged certificate, IP ranges entered by you in this window, or in the security feed items.&lt;/p&gt;&lt;p&gt;The default behavior for Retroshare is to (1) always allow connection to peers with IP in the whitelist, even if that IP is also blacklisted; (2) optionally require IPs to be in the whitelist. You can change this behavior for each peer in the &amp;quot;Details&amp;quot; window of each Retroshare node. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>IP range</string>
</property>
</column>
<column>
<property name="text">
<string>Status</string>
</property>
</column>
<column>
<property name="text">
<string>Origin</string>
</property>
</column>
<column>
<property name="text">
<string>Reason</string>
</property>
</column>
<column>
<property name="text">
<string>Comment</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="manualInputGBox">
<property name="title">
<string>Manual input</string>
</property>
<layout class="QVBoxLayout" name="manualInputGBoxVLayout">
<item>
<layout class="QHBoxLayout" name="ipinputHLayout">
<item>
<widget class="QLineEdit" name="ipInput_LE">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter an IP range. Accepted formats:&lt;/p&gt;&lt;p&gt;193.190.209.15&lt;/p&gt;&lt;p&gt;193.190.209.15/24&lt;/p&gt;&lt;p&gt;193.190.209.15/16&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="ipInputRange_SB">
<property name="minimum">
<number>16</number>
</property>
<property name="maximum">
<number>32</number>
</property>
<property name="singleStep">
<number>8</number>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="ipInputComment_LE">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter any comment you'd like&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ipInputAddBlackList_PB">
<property name="text">
<string>Add to blacklist</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ipInputAddWhiteList_PB">
<property name="text">
<string>Add to whitelist</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="manualInputVSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>

View File

@ -187,9 +187,7 @@ public:
/** Sets whether the bandwidth graph is always on top. */
void setBWGraphAlwaysOnTop(bool alwaysOnTop);
#ifdef RETROTOR
void setHiddenServiceKey() ;
#endif
uint getNewsFeedFlags();
void setNewsFeedFlags(uint flags);

View File

@ -117,7 +117,7 @@ void BandwidthStatsWidget::updateComboBoxes()
{
if(*it != ui.service_CB->itemData(indx).toInt())
{
QString sname = QString::fromUtf8(service_info_map.mServiceList[ ((*it)<<8) + 0x02000000].mServiceName.c_str()) ;
QString sname = QString::fromUtf8(service_info_map.mServiceList[RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(*it)].mServiceName.c_str()) ;
if(ui.service_CB->count() <= indx)
ui.service_CB->addItem(sname + " (0x"+QString::number(*it,16)+")",QVariant(*it)) ;

View File

@ -10,6 +10,7 @@
#include <QPainter>
#include <QStylePainter>
#include <algorithm> // for sort
#include <time.h>
#include "gui/settings/rsharesettings.h"
@ -467,7 +468,7 @@ static QString getServiceNameString(uint16_t service_id)
if(ownServices.mServiceList.find(service_id) == ownServices.mServiceList.end())
rsServiceControl->getOwnServices(ownServices);
return QString::fromUtf8(ownServices.mServiceList[service_id].mServiceName.c_str()) ;
return QString::fromUtf8(ownServices.mServiceList[RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(service_id)].mServiceName.c_str()) ;
}
static QString getVirtualPeerStatusString(uint8_t status)
@ -573,7 +574,7 @@ void GxsNetTunnelsDialog::updateDisplay()
for(auto it(groups.begin());it!=groups.end();++it)
{
painter.drawText(ox+4*cellx,oy+celly,tr("Service: %1 (%2) - Group ID: %3,\t policy: %4, \tstatus: %5, \tlast contact: %6")
.arg(QString::number(it->second.service_id))
.arg("0x" + QString::number(it->second.service_id, 16))
.arg(getServiceNameString(it->second.service_id))
.arg(QString::fromStdString(it->first.toStdString()))
.arg(getGroupPolicyString(it->second.group_policy))

View File

@ -26,12 +26,11 @@
#include <QPixmap>
#include "retroshare/rsconfig.h"
#include "retroshare/rsinit.h"
#include "util/misc.h"
#ifdef RETROTOR
#include "TorControl/TorManager.h"
#include "TorControl/TorControl.h"
#endif
#include <iomanip>
@ -86,53 +85,56 @@ void TorStatus::getTorStatus()
int S = QFontMetricsF(torstatusLabel->font()).height();
#ifdef RETROTOR
// get Tor status
int tor_control_status = Tor::TorManager::instance()->control()->status();
int torstatus = Tor::TorManager::instance()->control()->torStatus();
QString tor_control_status_str,torstatus_str ;
bool tor_control_ok ;
switch(tor_control_status)
if(RsAccounts::isTorAuto())
{
default:
case Tor::TorControl::Error : tor_control_ok = false ; tor_control_status_str = "Error" ; break ;
case Tor::TorControl::NotConnected: tor_control_ok = false ; tor_control_status_str = "Not connected" ; break ;
case Tor::TorControl::Connecting: tor_control_ok = false ; tor_control_status_str = "Connecting" ; break ;
case Tor::TorControl::Authenticating: tor_control_ok = false ; tor_control_status_str = "Authenticating" ; break ;
case Tor::TorControl::Connected: tor_control_ok = true ; tor_control_status_str = "Connected" ; break ;
}
// get Tor status
int tor_control_status = Tor::TorManager::instance()->control()->status();
int torstatus = Tor::TorManager::instance()->control()->torStatus();
switch(torstatus)
{
default:
case Tor::TorControl::TorUnknown: torstatus_str = "Unknown" ; break ;
case Tor::TorControl::TorOffline: torstatus_str = "Tor offline" ; break ;
case Tor::TorControl::TorReady: torstatus_str = "Tor ready" ; break ;
}
QString tor_control_status_str,torstatus_str ;
bool tor_control_ok ;
switch(tor_control_status)
{
default:
case Tor::TorControl::Error : tor_control_ok = false ; tor_control_status_str = "Error" ; break ;
case Tor::TorControl::NotConnected: tor_control_ok = false ; tor_control_status_str = "Not connected" ; break ;
case Tor::TorControl::Connecting: tor_control_ok = false ; tor_control_status_str = "Connecting" ; break ;
case Tor::TorControl::Authenticating: tor_control_ok = false ; tor_control_status_str = "Authenticating" ; break ;
case Tor::TorControl::Connected: tor_control_ok = true ; tor_control_status_str = "Connected" ; break ;
}
switch(torstatus)
{
default:
case Tor::TorControl::TorUnknown: torstatus_str = "Unknown" ; break ;
case Tor::TorControl::TorOffline: torstatus_str = "Tor offline" ; break ;
case Tor::TorControl::TorReady: torstatus_str = "Tor ready" ; break ;
}
#define MIN_RS_NET_SIZE 10
if(torstatus == Tor::TorControl::TorOffline || !online || !tor_control_ok)
if(torstatus == Tor::TorControl::TorOffline || !online || !tor_control_ok)
{
// RED - some issue.
torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("Tor is currently offline"));
}
else if(torstatus == Tor::TorControl::TorReady && online && tor_control_ok)
{
torstatusLabel->setPixmap(QPixmap(":/icons/tor-on.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("Tor is OK"));
}
else // torstatus == Tor::TorControl::TorUnknown
{
// GRAY.
torstatusLabel->setPixmap(QPixmap(":/icons/no-tor.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("No tor configuration"));
}
}
else
{
// RED - some issue.
torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("Tor is currently offline"));
}
else if(torstatus == Tor::TorControl::TorReady && online && tor_control_ok)
{
torstatusLabel->setPixmap(QPixmap(":/icons/tor-on.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("Tor is OK"));
}
else // torstatus == Tor::TorControl::TorUnknown
{
// GRAY.
torstatusLabel->setPixmap(QPixmap(":/icons/no-tor.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("No tor configuration"));
}
#else
torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("Tor is currently offline"));
#endif
}

View File

@ -31,7 +31,7 @@
static QMap<RsPlugin*, QTranslator*> translatorPlugins;
#define EXTERNAL_TRANSLATION_DIR QString::fromUtf8(RsAccounts::DataDirectory().c_str())
#define EXTERNAL_TRANSLATION_DIR QString::fromUtf8(RsAccounts::systemDataDirectory().c_str())
/** Initializes the list of available languages. */
QMap<QString, QString>

View File

@ -51,10 +51,8 @@
# include "gui/settings/WebuiPage.h"
#endif
#ifdef RETROTOR
# include "TorControl/TorManager.h"
# include "TorControl/TorControlWindow.h"
#endif
#include "TorControl/TorManager.h"
#include "TorControl/TorControlWindow.h"
#include "retroshare/rsidentity.h"
#include "retroshare/rspeers.h"
@ -349,51 +347,58 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
SoundManager::create();
#ifdef RETROTOR
// Now that we know the Tor service running, and we know the SSL id, we can make sure it provides a viable hidden service
bool is_hidden_node = false;
bool is_auto_tor = false ;
bool is_first_time = false ;
QString tor_hidden_service_dir = QString::fromStdString(RsAccounts::AccountDirectory()) + QString("/hidden_service/") ;
RsAccounts::getCurrentAccountOptions(is_hidden_node,is_auto_tor,is_first_time);
Tor::TorManager *torManager = Tor::TorManager::instance();
torManager->setDataDirectory(Rshare::dataDirectory() + QString("/tor/"));
torManager->setHiddenServiceDirectory(tor_hidden_service_dir); // re-set it, because now it's changed to the specific location that is run
RsDirUtil::checkCreateDirectory(std::string(tor_hidden_service_dir.toUtf8())) ;
torManager->setupHiddenService();
if(! torManager->start() || torManager->hasError())
if(is_auto_tor)
{
QMessageBox::critical(NULL,QObject::tr("Cannot start Tor Manager!"),QObject::tr("Tor cannot be started on your system: \n\n")+torManager->errorMessage()) ;
return 1 ;
}
// Now that we know the Tor service running, and we know the SSL id, we can make sure it provides a viable hidden service
{
TorControlDialog tcd(torManager) ;
QString error_msg ;
tcd.show();
QString tor_hidden_service_dir = QString::fromStdString(RsAccounts::AccountDirectory()) + QString("/hidden_service/") ;
while(tcd.checkForTor(error_msg) != TorControlDialog::TOR_STATUS_OK || tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK) // runs until some status is reached: either tor works, or it fails.
Tor::TorManager *torManager = Tor::TorManager::instance();
torManager->setTorDataDirectory(Rshare::dataDirectory() + QString("/tor/"));
torManager->setHiddenServiceDirectory(tor_hidden_service_dir); // re-set it, because now it's changed to the specific location that is run
RsDirUtil::checkCreateDirectory(std::string(tor_hidden_service_dir.toUtf8())) ;
torManager->setupHiddenService();
if(! torManager->start() || torManager->hasError())
{
QCoreApplication::processEvents();
rstime::rs_usleep(0.2*1000*1000) ;
if(!error_msg.isNull())
{
QMessageBox::critical(NULL,QObject::tr("Cannot start Tor"),QObject::tr("Sorry but Tor cannot be started on your system!\n\nThe error reported is:\"")+error_msg+"\"") ;
return 1;
}
}
tcd.hide();
if(tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK)
{
QMessageBox::critical(NULL,QObject::tr("Cannot start a hidden tor service!"),QObject::tr("It was not possible to start a hidden service.")) ;
QMessageBox::critical(NULL,QObject::tr("Cannot start Tor Manager!"),QObject::tr("Tor cannot be started on your system: \n\n")+torManager->errorMessage()) ;
return 1 ;
}
{
TorControlDialog tcd(torManager) ;
QString error_msg ;
tcd.show();
while(tcd.checkForTor(error_msg) != TorControlDialog::TOR_STATUS_OK || tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK) // runs until some status is reached: either tor works, or it fails.
{
QCoreApplication::processEvents();
rstime::rs_usleep(0.2*1000*1000) ;
if(!error_msg.isNull())
{
QMessageBox::critical(NULL,QObject::tr("Cannot start Tor"),QObject::tr("Sorry but Tor cannot be started on your system!\n\nThe error reported is:\"")+error_msg+"\"") ;
return 1;
}
}
tcd.hide();
if(tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK)
{
QMessageBox::critical(NULL,QObject::tr("Cannot start a hidden tor service!"),QObject::tr("It was not possible to start a hidden service.")) ;
return 1 ;
}
}
}
#endif
QSplashScreen splashScreen(QPixmap(":/images/logo/logo_splash.png")/* , Qt::WindowStaysOnTopHint*/);
@ -409,33 +414,35 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
return 1;
}
#ifdef RETROTOR
// Tor works with viable hidden service. Let's use it!
if(is_auto_tor)
{
// Tor works with viable hidden service. Let's use it!
QString service_id ;
QString onion_address ;
uint16_t service_port ;
uint16_t service_target_port ;
uint16_t proxy_server_port ;
QHostAddress service_target_address ;
QHostAddress proxy_server_address ;
QString service_id ;
QString onion_address ;
uint16_t service_port ;
uint16_t service_target_port ;
uint16_t proxy_server_port ;
QHostAddress service_target_address ;
QHostAddress proxy_server_address ;
torManager->getHiddenServiceInfo(service_id,onion_address,service_port,service_target_address,service_target_port);
torManager->getProxyServerInfo(proxy_server_address,proxy_server_port) ;
Tor::TorManager *torManager = Tor::TorManager::instance();
torManager->getHiddenServiceInfo(service_id,onion_address,service_port,service_target_address,service_target_port);
torManager->getProxyServerInfo(proxy_server_address,proxy_server_port) ;
std::cerr << "Got hidden service info: " << std::endl;
std::cerr << " onion address : " << onion_address.toStdString() << std::endl;
std::cerr << " service_id : " << service_id.toStdString() << std::endl;
std::cerr << " service port : " << service_port << std::endl;
std::cerr << " target port : " << service_target_port << std::endl;
std::cerr << " target address : " << service_target_address.toString().toStdString() << std::endl;
std::cerr << "Got hidden service info: " << std::endl;
std::cerr << " onion address : " << onion_address.toStdString() << std::endl;
std::cerr << " service_id : " << service_id.toStdString() << std::endl;
std::cerr << " service port : " << service_port << std::endl;
std::cerr << " target port : " << service_target_port << std::endl;
std::cerr << " target address : " << service_target_address.toString().toStdString() << std::endl;
std::cerr << "Setting proxy server to " << service_target_address.toString().toStdString() << ":" << service_target_port << std::endl;
std::cerr << "Setting proxy server to " << service_target_address.toString().toStdString() << ":" << service_target_port << std::endl;
rsPeers->setLocalAddress(rsPeers->getOwnId(), service_target_address.toString().toStdString(), service_target_port);
rsPeers->setHiddenNode(rsPeers->getOwnId(), onion_address.toStdString(), service_port);
rsPeers->setProxyServer(RS_HIDDEN_TYPE_TOR, proxy_server_address.toString().toStdString(),proxy_server_port) ;
#endif
rsPeers->setLocalAddress(rsPeers->getOwnId(), service_target_address.toString().toStdString(), service_target_port);
rsPeers->setHiddenNode(rsPeers->getOwnId(), onion_address.toStdString(), service_port);
rsPeers->setProxyServer(RS_HIDDEN_TYPE_TOR, proxy_server_address.toString().toStdString(),proxy_server_port) ;
}
Rshare::initPlugins();

View File

@ -19,11 +19,9 @@ libresapihttpserver {
!include("../../libretroshare/src/use_libretroshare.pri"):error("Including")
retrotor {
FORMS += TorControl/TorControlWindow.ui
SOURCES += TorControl/TorControlWindow.cpp
HEADERS += TorControl/TorControlWindow.h
}
FORMS += TorControl/TorControlWindow.ui
SOURCES += TorControl/TorControlWindow.cpp
HEADERS += TorControl/TorControlWindow.h
#QMAKE_CFLAGS += -fmudflap
#LIBS *= /usr/lib/gcc/x86_64-linux-gnu/4.4/libmudflap.a /usr/lib/gcc/x86_64-linux-gnu/4.4/libmudflapth.a
@ -285,7 +283,8 @@ wikipoos {
LIBS *= $$OUT_PWD/../../supportlibs/pegmarkdown/lib/libpegmarkdown.a
}
retrotor {
# Tor controller
HEADERS += TorControl/AddOnionCommand.h \
TorControl/AuthenticateCommand.h \
TorControl/GetConfCommand.h \
@ -324,7 +323,6 @@ SOURCES += TorControl/AddOnionCommand.cpp \
TorControl/SecureRNG.cpp \
TorControl/Settings.cpp \
TorControl/StrUtil.cpp
}
# Input
HEADERS += rshare.h \

View File

@ -748,7 +748,7 @@ void Rshare::loadStyleSheet(const QString &sheetName)
/* external stylesheet */
file.setFileName(QString("%1/qss/%2%3.qss").arg(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str()), name, sheetName));
if (!file.exists()) {
file.setFileName(QString("%1/qss/%2%3.qss").arg(QString::fromUtf8(RsAccounts::DataDirectory().c_str()), name, sheetName));
file.setFileName(QString("%1/qss/%2%3.qss").arg(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()), name, sheetName));
}
}
if (file.open(QFile::ReadOnly)) {
@ -787,7 +787,7 @@ void Rshare::getAvailableStyleSheets(QMap<QString, QString> &styleSheets)
styleSheets.insert(name, name);
}
}
fileInfoList = QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str()) + "/qss/").entryInfoList(QStringList("*.qss"));
fileInfoList = QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()) + "/qss/").entryInfoList(QStringList("*.qss"));
foreach (fileInfo, fileInfoList) {
if (fileInfo.isFile()) {
QString name = fileInfo.baseName();

View File

@ -91,15 +91,6 @@ no_sqlcipher:CONFIG -= sqlcipher
CONFIG *= no_rs_autologin
rs_autologin:CONFIG -= no_rs_autologin
# To build RetroShare Tor only version with automatic hidden node setup append
# the following assignation to qmake command line "CONFIG+=retrotor"
CONFIG *= no_retrotor
retrotor {
CONFIG -= no_retrotor
CONFIG *= rs_onlyhiddennode
DEFINES *= RETROTOR
}
# To have only hidden node generation append the following assignation
# to qmake command line "CONFIG+=rs_onlyhiddennode"
CONFIG *= no_rs_onlyhiddennode
@ -149,7 +140,7 @@ CONFIG *= no_rs_jsonapi
rs_jsonapi:CONFIG -= no_rs_jsonapi
# To disable deep search append the following assignation to qmake command line
# "CONFIG+=no_rs_deep_search"
CONFIG+=no_rs_deep_search
CONFIG *= rs_deep_search
no_rs_deep_search:CONFIG -= rs_deep_search
@ -363,6 +354,12 @@ rs_jsonapi {
rs_deep_search {
DEFINES *= RS_DEEP_SEARCH
linux {
exists("/usr/include/xapian-1.3") {
INCLUDEPATH += /usr/include/xapian-1.3
}
}
}
debug {