fixed merge with upstream

This commit is contained in:
csoler 2018-06-22 23:38:31 +02:00
commit 5b9666855d
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
241 changed files with 20561 additions and 3381 deletions

View File

@ -13,28 +13,16 @@ matrix:
before_install:
- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get update; fi
- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -y build-essential checkinstall cmake libavutil-dev libavcodec-dev libavformat-dev libbz2-dev libcurl4-openssl-dev libcv-dev libopencv-highgui-dev libhighgui-dev libgnome-keyring-dev libgstreamer-plugins-base0.10-dev libgstreamer0.10-dev libjasper-dev libjpeg-dev libmicrohttpd-dev libopencv-dev libprotobuf-dev libqt4-dev libspeex-dev libspeexdsp-dev libsqlite3-dev libssl-dev libswscale-dev libtbb-dev libtiff4-dev libupnp-dev libv4l-dev libxine-dev libxslt1-dev libxss-dev pkg-config protobuf-compiler python-dev qtmobility-dev gdb ; fi
- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -y build-essential libssl-dev libsqlcipher-dev libbz2-dev libmicrohttpd-dev libsqlite3-dev libupnp-dev pkg-config qt5-default libxss-dev qtmultimedia5-dev libqt5x11extras5-dev libqt5designer5 qttools5-dev; fi
# - if [ $TRAVIS_OS_NAME == osx ]; then xcode-select --install ; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew update ; fi
# - if [ $TRAVIS_OS_NAME == osx ]; then brew install qt55 openssl miniupnpc libmicrohttpd speex homebrew/science/opencv ffmpeg sqlcipher ; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew install qt55 openssl miniupnpc libmicrohttpd speex speexdsp ffmpeg sqlcipher ; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew install qt55 openssl miniupnpc libmicrohttpd sqlcipher; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew link --force qt55 ; fi
#Fix for opencv and numpy already installed by system
- if [ $TRAVIS_OS_NAME == osx ]; then rm '/usr/local/bin/f2py'; fi
- if [ $TRAVIS_OS_NAME == osx ]; then rm -r '/usr/local/lib/python2.7/site-packages/numpy'; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew install opencv; fi
# FIX: Now openssl is not linked in /usr/local/include and lib
- if [ $TRAVIS_OS_NAME == osx ]; then ln -s /usr/local/opt/openssl/include/* /usr/local/include/; fi
- if [ $TRAVIS_OS_NAME == osx ]; then ln -s /usr/local/opt/openssl/lib/*.a /usr/local/lib/; fi
- if [ $TRAVIS_OS_NAME == osx ]; then ln -s /usr/local/opt/openssl/lib/*.dylib /usr/local/lib/; fi
# - if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get update && sudo apt-get install -y llvm-3.4 llvm-3.4-dev; fi
# - rvm use $RVM --install --binary --fuzzy
# - gem update --system
# - gem --version
- wget https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz
- tar -xf v1.1.0.tar.gz
- if [ $TRAVIS_OS_NAME == osx ]; then cp -r rapidjson-1.1.0/include/rapidjson/ /usr/local/include/rapidjson ; fi
- if [ $TRAVIS_OS_NAME == linux ]; then sudo cp -r rapidjson-1.1.0/include/rapidjson/ /usr/include/rapidjson ; fi
env:
global:
@ -48,16 +36,16 @@ addons:
name: "RetroShare/RetroShare"
description: "RetroShare Build submitted via Travis CI"
build_command_prepend: "qmake CONFIG+=no_sqlcipher; make clean"
build_command: "make -j 4"
build_command: "make -j4"
branch_pattern: coverity_scan
before_script:
- if [ $TRAVIS_OS_NAME == linux ]; then qmake QMAKE_CC=$CC QMAKE_CXX=$CXX CONFIG+=no_sqlcipher CONFIG+=tests ; fi
- if [ $TRAVIS_OS_NAME == osx ]; then qmake QMAKE_CC=$CC QMAKE_CXX=$CXX CONFIG+=no_sqlcipher CONFIG+=tests CONFIG+=rs_macos10.12 ; fi
- if [ $TRAVIS_OS_NAME == linux ]; then qmake QMAKE_CC=$CC QMAKE_CXX=$CXX; fi
- if [ $TRAVIS_OS_NAME == osx ]; then qmake QMAKE_CC=$CC QMAKE_CXX=$CXX CONFIG+=rs_macos10.12 INCLUDEPATH+=/usr/local/opt/openssl/include/ QMAKE_LIBDIR+=/usr/local/opt/openssl/lib/; fi
script:
- if [ $TRAVIS_OS_NAME == linux ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make && tests/unittests/unittests >/dev/null 2>&1 ; fi
- if [ $TRAVIS_OS_NAME == osx ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make -j 4 ; fi
- if [ $TRAVIS_OS_NAME == linux ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make -j2; fi
- if [ $TRAVIS_OS_NAME == osx ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make -j2; fi
#after_success:

View File

@ -32,19 +32,19 @@ Compilation on Linux
libqt4-dev libssl-dev libxss-dev libgnome-keyring-dev libbz2-dev \
libqt4-opengl-dev libqtmultimediakit1 qtmobility-dev libsqlcipher-dev \
libspeex-dev libspeexdsp-dev libxslt1-dev libcurl4-openssl-dev \
libopencv-dev tcl8.5 libmicrohttpd-dev
libopencv-dev tcl8.5 libmicrohttpd-dev rapidjson-dev
```
* openSUSE
```bash
sudo zypper install gcc-c++ libqt4-devel libgnome-keyring-devel \
glib2-devel speex-devel libssh-devel protobuf-devel libcurl-devel \
libxml2-devel libxslt-devel sqlcipher-devel libmicrohttpd-devel \
opencv-devel speexdsp-devel libupnp-devel libavcodec-devel
opencv-devel speexdsp-devel libupnp-devel libavcodec-devel rapidjson
```
* Arch Linux
```bash
pacman -S base-devel libgnome-keyring libmicrohttpd libupnp libxslt \
libxss opencv qt4 speex speexdsp sqlcipher
libxss opencv qt4 speex speexdsp sqlcipher rapidjson
```
2. Checkout the source code

View File

@ -1,13 +1,12 @@
!include("retroshare.pri"): error("Could not include file retroshare.pri")
TEMPLATE = subdirs
#CONFIG += tests
SUBDIRS += openpgpsdk
openpgpsdk.file = openpgpsdk/src/openpgpsdk.pro
retrotor {
libretroshare.depends = openpgpsdk
libretroshare.depends = openpgpsdk
} else {
SUBDIRS += libbitdht
libbitdht.file = libbitdht/src/libbitdht.pro

View File

@ -248,8 +248,8 @@ build_sqlite()
make -j${HOST_NUM_CPU}
make install
rm -f ${SYSROOT}/usr/lib/libsqlite3.so*
${CC} -shared -o libsqlite3.so -fPIC sqlite3.o -ldl
cp libsqlite3.so "${SYSROOT}/usr/lib"
# ${CC} -shared -o libsqlite3.so -fPIC sqlite3.o -ldl
# cp libsqlite3.so "${SYSROOT}/usr/lib"
cd ..
}
@ -313,6 +313,14 @@ build_libmicrohttpd()
cd ..
}
build_rapidjson()
{
B_dir="rapidjson-1.1.0"
[ -f $B_dir.tar.gz ] || wget -O $B_dir.tar.gz https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz
tar -xf $B_dir.tar.gz
cp -r rapidjson-1.1.0/include/rapidjson/ "${SYSROOT}/usr/include/rapidjson"
}
build_toolchain
[ "${INSTALL_QT_ANDROID}X" == "trueX" ] && install_qt_android
build_bzlib
@ -320,5 +328,6 @@ build_openssl
build_sqlite
build_sqlcipher
build_libupnp
build_rapidjson
echo NATIVE_LIBS_TOOLCHAIN_PATH=${NATIVE_LIBS_TOOLCHAIN_PATH}

View File

@ -12,7 +12,7 @@
#---------------------------------#
# version format
version: RetroShare 0.6.0.{build}-{branch}
version: RetroShare-git-{branch}-{build}
# you can use {branch} name in version format too
# version: 1.0.{build}-{branch}
@ -52,7 +52,7 @@ on_finish:
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
# clone directory
clone_folder: c:\projects\RetroShare
clone_folder: C:\projects\RetroShare
# fetch repository as zip archive
#shallow_clone: true # default is "false"
@ -62,19 +62,18 @@ clone_depth: 1 # clone entire repository history if not de
environment:
global:
#Qt: https://www.appveyor.com/docs/installed-software#qt
QTDIR: C:\Qt\5.4\mingw491_32
## Qt: https://www.appveyor.com/docs/installed-software#qt
# QTDIR: C:\Qt\5.10.1\mingw53_32
MSYS2_ARCH: i686
TARGET: i686_32-pc-msys
MINGW_PREFIX: C:\msys64\mingw32
RS_DEPLOY: RetroShare_deploy
# build cache to preserve files/folders between builds
cache:
- c:\projects\libs
# - packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified
# - projectA\libs
# - node_modules # local npm modules
# - %APPDATA%\npm-cache # npm cache
#cache:
# Disabled because it's bigger then supported by appveyor free plan
# - C:\msys64\var\cache\pacman\pkg
# scripts that run after cloning repository
#install:
@ -89,23 +88,12 @@ 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
#- 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%
# Configuring Qt
- set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw491_32\bin;%PATH%
# Install all default programms
#- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy base-devel git mercurial cvs wget p7zip gcc perl ruby python2" #Already installed
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy openssl-devel"
# Install toolchain
#- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain" #Already installed
# Install other binutils
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-curl mingw-w64-x86_64-curl"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-miniupnpc mingw-w64-x86_64-miniupnpc"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-sqlite3 mingw-w64-x86_64-sqlite3"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-speex mingw-w64-x86_64-speex"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-speexdsp mingw-w64-x86_64-speexdsp"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-opencv mingw-w64-x86_64-opencv"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-ffmpeg mingw-w64-x86_64-ffmpeg"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-libmicrohttpd mingw-w64-x86_64-libmicrohttpd"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-libxslt mingw-w64-x86_64-libxslt"
# - set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw491_32\bin;%PATH%
# Hack for new MSys2
- copy C:\msys64\mingw32\i686-w64-mingw32\bin\ar.exe C:\msys64\mingw32\bin\i686-w64-mingw32-ar.exe
@ -114,10 +102,6 @@ install:
- copy C:\msys64\mingw64\x86_64-w64-mingw32\bin\ar.exe C:\msys64\mingw64\bin\x86_64-w64-mingw32-ar.exe
- copy C:\msys64\mingw64\x86_64-w64-mingw32\bin\ranlib.exe C:\msys64\mingw64\bin\x86_64-w64-mingw32-ranlib.exe
- copy C:\msys64\mingw64\bin\windres.exe C:\msys64\mingw64\bin\x86_64-w64-mingw32-windres.exe
# Build missing Libs
#- C:\msys64\mingw32.exe -lc "cd /c/projects/RetroShare/msys2_build_libs/ && make"
# Clone RetroShare
#- git clone -q --branch={branch} https://github.com/RetroShare/RetroShare.git C:\projects\RetroShare
#---------------------------------#
@ -142,18 +126,112 @@ configuration: Release
# scripts to run before build
before_build:
- cd C:\projects\RetroShare
# - find C:\ > filelist.txt
# scripts to run *after* solution is built and *before* automatic packaging occurs (web apps, NuGet packages, Azure Cloud Services)
before_package:
# scripts to run after build
after_build:
# to run your custom scripts instead of automatic MSBuild
build_script:
- cd C:\projects\RetroShare
- qmake CONFIG+=no_sqlcipher
- make
- qmake -Wall -spec win32-g++ "CONFIG=debug"
- mingw32-make -j3
# scripts to run after build
after_build:
- mkdir %RS_DEPLOY%
- copy retroshare-nogui\src\retroshare-nogui.exe %RS_DEPLOY%\
- copy retroshare-gui\src\retroshare.exe %RS_DEPLOY%\
## In Debug build winedeplyqt forget the non debug Qt libs
- copy C:\msys64\mingw32\bin\Qt5Svg.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5Core.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5Multimedia.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5Widgets.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5Xml.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5PrintSupport.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5Gui.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5Network.dll %RS_DEPLOY%\
- mkdir %RS_DEPLOY%\playlistformats\
- copy C:\msys64\mingw32\share\qt5\plugins\playlistformats\qtmultimedia_m3u.dll %RS_DEPLOY%\playlistformats
- mkdir %RS_DEPLOY%\printsupport\
- copy C:\msys64\mingw32\share\qt5\plugins\printsupport\windowsprintersupport.dll %RS_DEPLOY%\printsupport\
- mkdir %RS_DEPLOY%\iconengines\
- copy C:\msys64\mingw32\share\qt5\plugins\iconengines\qsvgicon.dll %RS_DEPLOY%\iconengines\
- mkdir %RS_DEPLOY%\bearer\
- copy C:\msys64\mingw32\share\qt5\plugins\bearer\qgenericbearer.dll %RS_DEPLOY%\bearer\
- mkdir %RS_DEPLOY%\mediaservice\
- copy C:\msys64\mingw32\share\qt5\plugins\mediaservice\qtmedia_audioengine.dll %RS_DEPLOY%\mediaservice\
- copy C:\msys64\mingw32\share\qt5\plugins\mediaservice\dsengine.dll %RS_DEPLOY%\mediaservice\
- mkdir %RS_DEPLOY%\styles\
- copy C:\msys64\mingw32\share\qt5\plugins\styles\qwindowsvistastyle.dll %RS_DEPLOY%\styles\
- mkdir %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qwebp.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qicns.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qjpeg.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qtiff.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qtga.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qjp2.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qico.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qwbmp.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qicns.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qgif.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qsvg.dll %RS_DEPLOY%\imageformats\
- mkdir %RS_DEPLOY%\platforms\
- copy C:\msys64\mingw32\share\qt5\plugins\platforms\qwindows.dll %RS_DEPLOY%\platforms\
- mkdir %RS_DEPLOY%\audio\
- copy C:\msys64\mingw32\share\qt5\plugins\audio\qtaudio_windows.dll %RS_DEPLOY%\audio\
- windeployqt %RS_DEPLOY%\retroshare.exe
- copy C:\msys64\mingw32\bin\libbz2*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libeay32.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libminiupnpc.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libsqlcipher*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libsqlite3*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\ssleay32.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\zlib*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libgcc_s_dw2*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libstdc*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libwinpthread*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libicu*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libpcre*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libharfbuzz*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libpng*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libfreetype*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libglib*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libgraphite2.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libintl*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libiconv*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libjasper*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libjpeg*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libtiff*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libwebp*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libwebpdemux*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\liblzma*.dll %RS_DEPLOY%\
## Needed for libresapi http
- copy C:\msys64\mingw32\bin\libmicrohttpd*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libgnutls*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libgmp*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libhogweed*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libidn2*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libnettle*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libp11-kit*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libtasn1*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libunistring*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libffi*.dll %RS_DEPLOY%\
- find C:\projects\RetroShare >> filelist.txt
# to disable automatic builds
#build: off
@ -162,7 +240,10 @@ build_script:
# artifacts configuration #
#---------------------------------#
#artifacts:
artifacts:
- path: $(RS_DEPLOY)
- path: '**\*.exe'
- path: filelist.txt
#
# # pushing a single file
# - path: test.zip

View File

@ -1,5 +1,125 @@
retroshare (ZZZZZZ-1.XXXXXX~YYYYYY) YYYYYY; urgency=low
f663600 csoler Fri, 1 Jun 2018 22:27:59 +0200 fixed makeSourcePackage.sh
9b16e33 csoler Fri, 11 May 2018 20:53:29 +0200 removed conflicts to retroshare06 in debian control file
57dde55 csoler Sat, 26 May 2018 11:23:33 +0200 Merge pull request #1269 from PhenomRetroShare/Add_NeverAskMeForExternalLinkActivated
33fe823 csoler Sat, 26 May 2018 11:22:47 +0200 Merge pull request #1271 from sehraf/pr_compile-fix-unused-services
65beb2c csoler Sat, 26 May 2018 11:09:41 +0200 Merge pull request #1275 from sehraf/pr_fix-IDdialog-chat-link
d8b3fc0 csoler Sat, 26 May 2018 11:08:46 +0200 Merge pull request #1274 from PhenomRetroShare/Fix_AppVeyorCompil
f53e5e8 sehraf Fri, 25 May 2018 23:59:02 +0200 Fix displayed chat link name in id dialog before (decimal): Message in chat room 5327517029776505601 after (proper id): Message in chat room LFD6E08C33A98C658
428b331 sehraf Fri, 25 May 2018 23:12:35 +0200 fix for Qt 5.11
7c77e93 Phenom Fri, 25 May 2018 17:32:36 +0200 Fix AppVeyor Compilation
de65cb6 csoler Tue, 22 May 2018 23:59:26 +0200 Merge pull request #1272 from G10h4ck/net_little_fixes
1ad1fdc Gioacc Tue, 22 May 2018 19:17:37 +0200 p3NetMgrIMPL::checkNetAddress() notify if port change
0bf02e2 Gioacc Tue, 22 May 2018 19:14:25 +0200 pqissludp::Initiate_Connection() check remote_addr to be IPv4 before use
0c19a56 sehraf Mon, 21 May 2018 14:55:10 +0200 compile fix gxsphoto
92b21d7 sehraf Mon, 21 May 2018 14:26:46 +0200 compile fix wikipoos
8f107cc Phenom Sat, 19 May 2018 16:37:29 +0200 Add Never Ask Me For External Link Activated
186617f Gioacc Thu, 17 May 2018 16:43:14 +0200 Fix missing include
28981b6 csoler Wed, 16 May 2018 13:37:02 +0200 Merge pull request #1251 from PhenomRetroShare/Fix_Cppcheck(duplInheritedMember)InRsItem
d11f88c csoler Wed, 16 May 2018 13:33:25 +0200 Merge pull request #1252 from PhenomRetroShare/Fix_Cppcheck(duplInheritedMember)InbdNode
2145911 csoler Wed, 16 May 2018 13:30:56 +0200 Merge pull request #1262 from PhenomRetroShare/Fix_PartialDirCheck
e232000 csoler Wed, 16 May 2018 13:28:23 +0200 Merge pull request #1266 from csoler/v0.6-FT
3f88e3e csoler Wed, 16 May 2018 13:24:52 +0200 added check to avoid hashing files that are currently being modified
8451550 csoler Wed, 16 May 2018 11:40:39 +0200 added missing licence to file_tree.h
291c86e csoler Wed, 16 May 2018 11:17:22 +0200 Merge pull request #1265 from csoler/v0.6-GxsFix
4661329 csoler Wed, 16 May 2018 11:15:18 +0200 fixed bug causing new forums and identities to not show up immediately
9f37b63 G10h4c Wed, 16 May 2018 10:49:28 +0200 Merge pull request #1264 from G10h4ck/channel_json_api_v2
181d99e Gioacc Wed, 16 May 2018 10:38:47 +0200 Give proper error message if Qt version is too old
f12cd57 Phenom Sat, 12 May 2018 14:31:17 +0200 Fix Partial Dir Check
57cff61 csoler Fri, 11 May 2018 20:28:53 +0200 fixed merge
ecbd115 csoler Fri, 11 May 2018 20:24:24 +0200 added missing include path for libretroshare/src in libresapi
fe5ea9e csoler Fri, 11 May 2018 17:37:15 +0200 additional fixes to debian packaging files
2173aab csoler Fri, 11 May 2018 17:02:58 +0200 fixed rules file again
84a02cb csoler Fri, 11 May 2018 16:39:49 +0200 added missing targets in rules file
4b6304e csoler Fri, 11 May 2018 16:33:19 +0200 few fixes according to lintian complaints
c2492fe csoler Thu, 10 May 2018 23:10:16 +0200 fixed a few lintian errors in debian/control
9f5409b csoler Thu, 10 May 2018 22:04:11 +0200 fixed email to match mentors login
45fdbb4 csoler Thu, 10 May 2018 22:03:39 +0200 fixed email to match mentors login
b4ada80 csoler Wed, 9 May 2018 13:54:40 +0200 removed > 3.4.1 in debian/control, because pbuilder would not build
e81c82e csoler Wed, 9 May 2018 13:37:25 +0200 added notes file for debian release
4d287d6 csoler Wed, 9 May 2018 13:27:16 +0200 fixed weird mistake in grouter which causes an issue only in gcc > 8
889c277 csoler Wed, 9 May 2018 10:15:32 +0200 fixed packaging script for debian release
f406d9a csoler Wed, 9 May 2018 10:15:02 +0200 updated debian/control to be the control file for stretch. Updated copyright notice
186ff0f csoler Wed, 9 May 2018 10:12:34 +0200 created proper debian changelog using dch and updated project url
6d67936 csoler Tue, 8 May 2018 15:34:44 +0200 Merge pull request #1253 from PhenomRetroShare/Add_LastPostColInGroupTreeWidget
2ebacf3 Phenom Tue, 8 May 2018 12:08:08 +0200 Add Last Post Column in GroupTreeWidget.
4d748bd Phenom Mon, 7 May 2018 18:05:07 +0200 Fix CppCheck duplInheritedMember warning in bdNode
f39fd06 Phenom Mon, 7 May 2018 17:29:11 +0200 Fix CppCheck duplInheritedMember warning in RsItem
1352631 thunde Mon, 7 May 2018 06:42:52 +0200 Updated Windows build environment
38ac234 thunde Mon, 7 May 2018 07:30:29 +0200 Fixed Windows compile with pre-compiled libraries Added new variable EXTERNAL_LIB_DIR to specify path of external libraries
d9a75a9 thunde Sun, 29 Apr 2018 20:40:05 +0200 Added RapidJSON to Windows build environment
5b607ad csoler Sun, 6 May 2018 23:53:45 +0200 Merge pull request #1245 from PhenomRetroShare/AddContextMenuForGxsIdInTextChatBrowser
a6821f4 csoler Sun, 6 May 2018 23:02:18 +0200 Merge pull request #1249 from sehraf/pr_libsecret
c20436e csoler Sun, 6 May 2018 22:59:20 +0200 Merge pull request #1250 from PhenomRetroShare/Fix_CppCheckerWarningInFtController
d8dc2a8 csoler Sun, 6 May 2018 22:57:57 +0200 Merge pull request #1246 from PhenomRetroShare/Add_GxsIdInRestoredChatMsg
dca33da Phenom Sun, 6 May 2018 18:53:29 +0200 Fix CppCheck in ftcontroller.cc
c89e36a sehraf Fri, 4 May 2018 20:52:31 +0200 add auto selection of libsecret with fallback to libgnome-keyring
1129bcb sehraf Fri, 4 May 2018 20:47:41 +0200 Add support for libsecret
10badf5 sehraf Fri, 4 May 2018 20:43:40 +0200 fix retroshare-nogui.pro autologin
676c070 csoler Thu, 3 May 2018 15:55:21 +0200 extended the rapid_json trick to plugins
5f12b60 csoler Thu, 3 May 2018 15:22:39 +0200 added -lgnome-keyring to unix LIBS when rs_autologin is set
bfe8e40 csoler Thu, 3 May 2018 15:22:03 +0200 updated ubuntu changelog
98f0052 Phenom Thu, 3 May 2018 15:04:22 +0200 Add GxsId in Restored Chat Message.
ecba4c2 Phenom Wed, 2 May 2018 20:31:52 +0200 Add Context Menu for GxsId in lobby textBrowser.
91ed367 csoler Thu, 3 May 2018 13:45:44 +0200 added packaging for ubuntu bionic
56e8134 cyril soler Thu, 3 May 2018 11:32:24 +0200 removed sqlite3 lib from ld when using sqlcipher.
1366f61 csoler Wed, 2 May 2018 23:51:46 +0200 Merge pull request #1241 from RetroPooh/chatimgattprev1
8e111c2 csoler Wed, 2 May 2018 22:46:27 +0200 added rapidjson-1.1.0 code hard-coded in the source directory to allow everyone to compile without the need to tweak too much. When v1.1.0 is mainstream (espcially on ubuntu) we can revert back to an external dependency
48c4b4c G10h4c Sat, 28 Apr 2018 09:34:14 +0200 Merge pull request #1242 from beardog108/master
ccede9d G10h4c Sat, 28 Apr 2018 09:33:14 +0200 Merge pull request #1243 from sehraf/pr_fix-make-install
10daf3b sehraf Sat, 28 Apr 2018 09:06:10 +0200 Fix 'make install'
82a00c2 KevinF Fri, 27 Apr 2018 15:34:43 -0500 added rapidjson to package installation command on Debian/OpenSUSE/Arch
be75e89 Gioacc Fri, 27 Apr 2018 20:55:38 +0200 Fix compialtion after merge
f3ae61b Gioacc Fri, 27 Apr 2018 18:17:09 +0200 Merge branch 'json_experiments'
-- Retroshare Dev Team <contact@retroshare.net> Thu, 03 May 2018 12:00:00 +0100
retroshare (0.6.4-1.20180503.676c0701~xenial) xenial; urgency=low
2dc69cb RetroP Fri, 27 Apr 2018 16:50:00 +0300 embed preview for images on file attach in chat
c199199 Gioacc Sun, 8 Apr 2018 12:37:41 +0200 pqissl silence extra debug message
8245d74 csoler Sat, 7 Apr 2018 14:33:58 +0200 Merge pull request #1230 from csoler/master
2782494 csoler Sat, 7 Apr 2018 14:29:23 +0200 removed debug info
e2b0e27 csoler Sat, 7 Apr 2018 00:56:07 +0200 fixed costly polling in RsGenExchange
cc091cc Gioacc Sat, 7 Apr 2018 12:48:01 +0200 Fixed hidden nodes listening failure
73c6dee csoler Tue, 27 Mar 2018 20:54:31 +0200 Merge pull request #1191 from G10h4ck/IPv6-v3
4be73b7 csoler Sat, 24 Mar 2018 10:18:37 +0100 Merge pull request #1216 from beardog108/security
599c3d4 Kevin Fri, 23 Mar 2018 23:00:27 -0500 fixed clickjacking attack with x-frame-options
24d1f5d csoler Sat, 17 Mar 2018 18:40:32 +0100 Merge pull request #1190 from PhenomRetroShare/Add_ShowEmptySubMenuRemoteTree
09de680 csoler Sat, 17 Mar 2018 18:30:21 +0100 Merge pull request #1210 from PhenomRetroShare/Add_BackgroundInProgressBarText
1432104 csoler Sat, 17 Mar 2018 18:25:47 +0100 Merge pull request #1214 from csoler/v0.6-FT
e1482dd Phenom Sat, 17 Mar 2018 00:00:05 +0100 Add Rounded and Gradient Background to xprogressbar text.
7da73b3 Phenom Mon, 5 Mar 2018 20:31:39 +0100 Add differents views depends ProgressBar width
311b190 Phenom Sun, 4 Mar 2018 20:06:33 +0100 Add Background to xprogressbar text for more readability.
e1ad21c csoler Thu, 15 Mar 2018 13:11:19 +0100 fixed wrong file count in RsCollectionDialog when downloading files
b3653d1 csoler Thu, 15 Mar 2018 11:32:55 +0100 enabled aggressive re-request of pending slices at end of transfer, thus fixing the long delay to finish files with mixed fast/slow sources
6e8305a csoler Wed, 14 Mar 2018 20:56:30 +0100 Merge pull request #1211 from PhenomRetroShare/Fix_AvatarStatusOverlay
c7549a2 csoler Wed, 14 Mar 2018 20:49:42 +0100 Merge pull request #1208 from PhenomRetroShare/Fix_ChangeChatTextColorWhenChangeStyle
11cfa7b csoler Wed, 14 Mar 2018 20:34:52 +0100 Merge pull request #1209 from PhenomRetroShare/Add_DescriptionGxsGroupToolTip
3fc6314 csoler Wed, 14 Mar 2018 20:33:34 +0100 Merge pull request #1206 from PhenomRetroShare/Fix_AboutIcon
0e6d27a csoler Tue, 13 Mar 2018 20:25:38 +0100 fixed bug in FT causing transfer lines to only update when the mouse moves over the widget
91634ba thunde Thu, 8 Mar 2018 17:45:24 +0100 Added build of Retrotor to Windows build environment
e9b49e1 Gioacc Mon, 12 Mar 2018 17:06:01 +0100 Update Android quirks documentation
ce56a20 Gioacc Mon, 12 Mar 2018 16:22:42 +0100 Added sources verification in android toolchain
e7078b5 Gioacc Mon, 12 Mar 2018 14:27:59 +0100 Update Android documentation
514b31e Gioacc Sun, 11 Mar 2018 20:46:07 +0100 Add Qt installation in android preparation script
6f30aa2 Gioacc Sun, 11 Mar 2018 20:45:40 +0100 Merge branch 'master' of git://github.com/RetroShare/RetroShare
13b18e3 csoler Sat, 10 Mar 2018 16:05:52 +0100 added missing decoration icon on transfer sources
4dd2776 Gioacc Sat, 10 Mar 2018 13:15:53 +0100 Remove android JNI .class from source
2b300eb Gioacc Sat, 10 Mar 2018 00:44:24 +0100 Update version in Android Manifest
f5a3b26 Gioacc Fri, 9 Mar 2018 20:26:29 +0100 More omogeneous variable naming in android build tools
c92b860 thunde Sun, 4 Mar 2018 20:08:15 +0100 Windows build environment: - Updated external libraries - Added compile of plugins to build.bat - Added copy of Qt style DLL to pack.bat and Windows Installer - Removed "CONFIG=console" for release build
8b42873 Phenom Sun, 4 Mar 2018 22:45:11 +0100 Fix Friend Avatar status overlay no depends size scale.
6877589 Phenom Sun, 4 Mar 2018 18:19:18 +0100 Add description in GroupTreeWidget tooltip.
51cc94b Phenom Sun, 4 Mar 2018 17:31:40 +0100 Fix ChatWidget current text edit color when changing appearance style.
4e6f2ae Phenom Sun, 4 Mar 2018 14:31:16 +0100 Fix Icon for About page.
a89ab8f Phenom Sat, 24 Feb 2018 14:07:32 +0100 Add ShowEmpty sub menu in Tree Remote SharedFilesDialog.
-- Retroshare Dev Team <contact@retroshare.net> Thu, 03 May 2018 12:00:00 +0100
retroshare (0.6.4-1.20180313.0e6d27ad~xenial) xenial; urgency=low
919417a csoler Sat, 3 Mar 2018 19:04:54 +0100 make sure tor executable from config path can be reached
b587ac8 csoler Sat, 3 Mar 2018 16:06:49 +0100 Merge pull request #1192 from PhenomRetroShare/Add_WarningMaxFlatViewFile
9bcff07 csoler Sat, 3 Mar 2018 15:58:11 +0100 Merge pull request #1203 from PhenomRetroShare/Fix_SharedFileDialogShowColumn

View File

@ -0,0 +1,46 @@
Source: retroshare
Section: devel
Priority: standard
Maintainer: Cyril Soler <csoler@users.sourceforge.net>
Build-Depends: debhelper (>= 7), libglib2.0-dev, libupnp-dev, libssl-dev, libxss-dev, libgnome-keyring-dev, libbz2-dev, libspeex-dev, libspeexdsp-dev, libxslt1-dev, cmake, libcurl4-openssl-dev, libopencv-dev, tcl8.6, libsqlcipher-dev, libmicrohttpd-dev, libavcodec-dev, qtmultimedia5-dev, qttools5-dev, libqt5x11extras5-dev, qt5-default
Standards-Version: 3.9.6
Homepage: http://retroshare.sourceforge.net
Package: retroshare-voip-plugin
Architecture: any
Conflicts: retroshare06-voip-plugin
Depends: ${shlibs:Depends}, ${misc:Depends}, retroshare, libspeex1, libspeexdsp1, libqt5multimedia5
Description: RetroShare VOIP plugin
This package provides a plugin for RetroShare, a secured Friend-to-Friend communication
plateform. The plugin adds voice-over-IP functionality to the private chat window. Both
friends chatting together need the plugin installed to be able to talk together.
Package: retroshare-feedreader-plugin
Architecture: any
Conflicts: retroshare06-feedreader-plugin
Depends: ${shlibs:Depends}, ${misc:Depends}, retroshare
Description: RetroShare FeedReader plugin
This package provides a plugin for RetroShare, a secured Friend-to-Friend communication
plateform. The plugin adds a RSS feed reader tab to retroshare.
Package: retroshare-nogui
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, gnome-keyring
Conflicts: retroshare,retroshare06-nogui
Description: Secure communication with friends
This is the command-line client for RetroShare network. This client
can be contacted and talked-to using SSL. Clients exist for portable
devices running e.g. Android.
Package: retroshare
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, gnome-keyring
Conflicts: retroshare-nogui,retroshare06
Description: Secure communication with friends
RetroShare is a Open Source cross-platform, private and secure decentralised
commmunication platform. It lets you to securely chat and share files with your
friends and family, using a web-of-trust to authenticate peers and OpenSSL to
encrypt all communication. RetroShare provides filesharing, chat, messages,
forums and channels.

View File

@ -0,0 +1,5 @@
retroshare (0.6.4) UNRELEASED; urgency=medium
* Initial release for Debian. (Closes: #659069)
-- Cyril Soler <csoler@users.sourceforge.net> Wed, 09 May 2018 10:11:31 +0200

View File

@ -1 +1 @@
7
10

View File

@ -2,45 +2,40 @@ Source: retroshare
Section: devel
Priority: standard
Maintainer: Cyril Soler <csoler@users.sourceforge.net>
Build-Depends: debhelper (>= 7), libglib2.0-dev, libupnp-dev, qt4-dev-tools, libqt4-dev, libssl-dev, libxss-dev, libgnome-keyring-dev, libbz2-dev, libqt4-opengl-dev, libqtmultimediakit1, qtmobility-dev, libspeex-dev, libspeexdsp-dev, libxslt1-dev, cmake, libcurl4-openssl-dev, libopencv-dev, tcl8.5, libsqlcipher-dev, libmicrohttpd-dev, libavcodec-dev
Standards-Version: 3.9.3
Build-Depends: debhelper (>= 9), libglib2.0-dev, libupnp-dev, libssl-dev, libxss-dev, libgnome-keyring-dev, libbz2-dev, libspeex-dev, libspeexdsp-dev, libxslt1-dev, cmake, libcurl4-openssl-dev, libopencv-dev, tcl8.6, libsqlcipher-dev, libmicrohttpd-dev, libavcodec-dev, qtmultimedia5-dev, qttools5-dev, libqt5x11extras5-dev, qtbase5-dev, qt5-qmake, qtbase5-dev-tools
Standards-Version: 4.1.4
Homepage: http://retroshare.sourceforge.net
Package: retroshare-voip-plugin
Architecture: any
Conflicts: retroshare06-voip-plugin
Depends: ${shlibs:Depends}, ${misc:Depends}, retroshare, libspeex1, libspeexdsp1, libqtmultimediakit1
Conflicts:
Depends: ${shlibs:Depends}, ${misc:Depends}, retroshare, libspeex1, libspeexdsp1, libqt5multimedia5
Description: RetroShare VOIP plugin
This package provides a plugin for RetroShare, a secured Friend-to-Friend communication
This package provides a plugin for RetroShare, a secured Friend-to-Friend communication
plateform. The plugin adds voice-over-IP functionality to the private chat window. Both
friends chatting together need the plugin installed to be able to talk together.
Package: retroshare-feedreader-plugin
Architecture: any
Conflicts: retroshare06-feedreader-plugin
Conflicts:
Depends: ${shlibs:Depends}, ${misc:Depends}, retroshare
Description: RetroShare FeedReader plugin
This package provides a plugin for RetroShare, a secured Friend-to-Friend communication
plateform. The plugin adds a RSS feed reader tab to retroshare.
Plugin for Retroshare, adding a RSS feed reader tab to retroshare.
Package: retroshare-nogui
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, gnome-keyring
Conflicts: retroshare,retroshare06-nogui
Description: Secure communication with friends
This is the command-line client for RetroShare network. This client
can be contacted and talked-to using SSL. Clients exist for portable
devices running e.g. Android.
Conflicts: retroshare
Description: headless version of Retroshare
Headless version of the Retroshare platform.
Package: retroshare
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, gnome-keyring
Conflicts: retroshare-nogui,retroshare06
Conflicts: retroshare-nogui
Description: Secure communication with friends
RetroShare is a Open Source cross-platform, private and secure decentralised
commmunication platform. It lets you to securely chat and share files with your
friends and family, using a web-of-trust to authenticate peers and OpenSSL to
encrypt all communication. RetroShare provides filesharing, chat, messages,
forums and channels.
RetroShare is a Open Source, private and secure decentralised
commmunication platform. It creates mesh of computers linked with TLS connections,
on top of which it provides file transfer, asynchronous email, forums, channels and chat.

View File

@ -7,11 +7,12 @@ configure-stamp:
touch $@
build: build-stamp
build: build-arch build-indep
build-stamp: configure-stamp
dh_testdir
# Add here commands to compile the package.
# cd libssh-0.6.4 && mkdir -p build && cd build && cmake -DWITH_STATIC_LIB=ON .. && make
# cd libssh-0.6.4 && mkdir -p build && cd build && cmake -DWITH_STATIC_LIB=ON .. && make
# cd sqlcipher && ./configure --disable-shared --enable-static --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto" && make
# mkdir lib
# cp -r libssh-0.6.4 lib/
@ -20,18 +21,24 @@ build-stamp: configure-stamp
cd src && $(MAKE)
touch $@
build-indep: build-stamp
build-arch: build-stamp
clean:
dh_testdir
dh_testroot
rm -f configure-stamp build-stamp
# Add here commands to clean up after the build process.
[ ! -f src/Makefile ] || (cd src && $(MAKE) distclean)
dh_prep
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_prep
dh_clean
#dh_installdirs
cd src && $(MAKE) INSTALL_ROOT=$(CURDIR)/debian/tmp install

View File

@ -0,0 +1 @@
1.0

View File

@ -0,0 +1,32 @@
Creation of a new Debian changelog:
dch --create --package retroshare --newversion 0.6.4-1
Note: dch reads email in $DEBMAIL or $USER@$HOSTNAME, so it should be made correct in debian/changlog
If the email does not match the email in mentors, the package will be rejected.
dget command to retrieve source package:
dget -u https://launchpad.net/~retroshare/+archive/ubuntu/stable/+files/retroshare_0.6.4-1.20180313.0e6d27ad~xenial.dsc
(-u means don't check PGP signature)
When ready:
* updload the package in a place that can be used to dget the package on mentors.debian.net.
dput mentors retroshare_0.6.4-1_source.changes
Checkign with lintian:
lintian --pedantic --profile debian retroshare_0.6.4-1_source.changes
Todo
* make a sid binary package.
* test in sid using pbuilder chroot system (pbuilder login)
* upload to mentors
* request for sponsorship
Getting help:
https://webchat.oftc.net/
Bug creation/report
reportbug -B debian

View File

@ -3,8 +3,8 @@
###################### PARAMETERS ####################
gitpath="https://github.com/RetroShare/RetroShare.git"
branch="master"
#branch="v0.6.3-official_release"
#bubba3="Y" # comment out to compile for bubba3
#branch="v0.6.4-official_release"
#bubba3="Y" # comment out to compile for bubba3
######################################################
RS_MAJOR_VERSION=`fgrep RS_MAJOR_VERSION ../../libretroshare/src/retroshare/rsversion.h | cut -d\\ -f3- | sed -e s\/\ \/\/g | cut -c1`
@ -33,7 +33,7 @@ gpgkey="0932399B"
date=`git log --pretty=format:"%ai" | head -1 | cut -d\ -f1 | sed -e s/-//g`
time=`git log --pretty=format:"%aD" | head -1 | cut -d\ -f5 | sed -e s/://g`
hhsh=`git log --pretty=format:"%H" | head -1 | cut -c1-8`
hhsh=`git log --pretty=format:"%H" | head -1 | cut -c1-8`
rev=${date}.${hhsh}
useretrotor="false"
@ -45,7 +45,7 @@ while [ ${#} -gt 0 ]; do
shift
;;
"-retrotor") shift
useretrotor="true"
useretrotor="true"
;;
"-distribution") shift
dist=${1}
@ -68,16 +68,16 @@ while [ ${#} -gt 0 ]; do
done
if test "${useretrotor}" = "true"; then
if ! test "${dist}" = "trusty"; then
echo ERROR: retro-tor can only be packaged for trusty for now.
exit 1;
fi
#gitpath="https://github.com/csoler/RetroShare.git"
#branch="v0.6-TorOnly"
if ! test "${dist}" = "trusty"; then
echo ERROR: retro-tor can only be packaged for trusty for now.
exit 1;
fi
#gitpath="https://github.com/csoler/RetroShare.git"
#branch="v0.6-TorOnly"
fi
if test "${dist}" = "" ; then
dist="trusty xenial artful"
dist="trusty xenial artful bionic"
fi
echo Attempting to get revision number...
@ -96,7 +96,7 @@ echo " Using distributions:"${dist}
echo " Using PGP key id :"${gpgkey}
if test ${useretrotor} = "true"; then
echo " "Specific flags : retrotor
echo " "Specific flags : retrotor
fi
echo Done.
@ -115,15 +115,15 @@ cd ${workdir}/src
git clone --depth 1 ${gitpath} --single-branch --branch $branch .
# if ! test "$hhsh" = "" ; then
# echo Checking out revision $hhsh
# git checkout $hhsh
# echo Checking out revision $hhsh
# git checkout $hhsh
# fi
cd -
if ! test -d ${workdir}/src/libretroshare/; then
echo Git clone failed.
exit
echo Git clone failed.
exit
fi
cp -r debian ${workdir}/debian
@ -131,6 +131,12 @@ cp -r debian ${workdir}/debian
# VOIP tweak
cp ${workdir}/src/retroshare-gui/src/gui/chat/PopupChatDialog.ui ${workdir}/src/plugins/VOIP/gui/PopupChatDialog.ui
# remove unised qml code, only needed on Android
rm -rf ${workdir}/src/retroshare-qml-app/
rm -rf ${workdir}/src/build_scripts/
rm ${workdir}/debian/*~
# Cloning sqlcipher
# git clone https://github.com/sqlcipher/sqlcipher.git
@ -147,21 +153,26 @@ echo Cleaning...
echo Calling debuild...
for i in ${dist}; do
echo copying changelog for ${i}
sed -e s/XXXXXX/"${rev}"/g -e s/YYYYYY/"${i}"/g -e s/ZZZZZZ/"${version_number}"/g ../changelog > debian/changelog
if test ${useretrotor} = "true"; then
cp ../rules.retrotor debian/rules
cp ../control.trusty_retrotor debian/control
elif test -f ../control."${i}" ; then
echo \/\!\\ Using specific control file for distribution "${i}"
cp ../control."${i}" debian/control
if ! test "${i}" = "debian"; then
echo copying changelog for ${i}
sed -e s/XXXXXX/"${rev}"/g -e s/YYYYYY/"${i}"/g -e s/ZZZZZZ/"${version_number}"/g ../changelog > debian/changelog
if test ${useretrotor} = "true"; then
cp ../rules.retrotor debian/rules
cp ../control.trusty_retrotor debian/control
elif test -f ../control."${i}" ; then
echo \/\!\\ Using specific control file for distribution "${i}"
cp ../control."${i}" debian/control
else
echo Using standard control file control."${i}" for distribution "${i}"
cp ../debian/control debian/control
fi
else
echo Using standard control file control."${i}" for distribution "${i}"
cp ../debian/control debian/control
fi
echo creating official debian release. Using built-in changelog and control files
fi
debuild -S -k${gpgkey}
debuild -S -k${gpgkey} --lintian-opts +pedantic -EviIL
done
cd -

View File

@ -12,14 +12,13 @@ TCL_VERSION=8.6.2
SQLCIPHER_VERSION=2.2.1
LIBMICROHTTPD_VERSION=0.9.59
FFMPEG_VERSION=3.4
MAKEFILE_PATH=$(dir $(MAKEFILE_LIST))
LIBS_PATH?=$(MAKEFILE_PATH)../../../../libs
RAPIDJSON_VERSION=1.1.0
DOWNLOAD_PATH?=download
COPY_ANSWER?=
BUILD_PATH=build
LIBS_PATH?=libs
all: dirs zlib bzip2 miniupnpc openssl speex speexdsp opencv libxml2 libxslt curl sqlcipher libmicrohttpd ffmpeg copylibs
all: dirs zlib bzip2 miniupnpc openssl speex speexdsp opencv libxml2 libxslt curl sqlcipher libmicrohttpd ffmpeg rapidjson copylibs
download: \
$(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz \
@ -35,234 +34,246 @@ download: \
$(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz \
$(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz \
$(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz \
$(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz
$(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz \
$(DOWNLOAD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tar.gz
clean:
rm -r -f libs
rm -r -f $(BUILD_PATH)
rm -r -f $(LIBS_PATH)
dirs:
mkdir -p $(DOWNLOAD_PATH)
mkdir -p libs
gcc --version | head --lines 1 | tr ' ' '\n' | tail -1 >libs/gcc-version
mkdir -p $(BUILD_PATH)
gcc --version | head --lines 1 | tr ' ' '\n' | tail -1 >$(BUILD_PATH)/gcc-version
$(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz:
wget --no-check-certificate http://sourceforge.net/projects/libpng/files/zlib/$(ZLIB_VERSION)/zlib-$(ZLIB_VERSION).tar.gz/download -O $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz
zlib: libs/zlib-$(ZLIB_VERSION)
zlib: $(BUILD_PATH)/zlib-$(ZLIB_VERSION)
libs/zlib-$(ZLIB_VERSION): $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz
$(BUILD_PATH)/zlib-$(ZLIB_VERSION): $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz
# prepare
rm -r -f libs/zlib-*
rm -r -f $(BUILD_PATH)/zlib-*
tar xvf $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz
# build
cd zlib-$(ZLIB_VERSION) && ./configure
#cd zlib-$(ZLIB_VERSION) && make install prefix="`pwd`/../libs"
#cd zlib-$(ZLIB_VERSION) && make install prefix="`pwd`/../$(BUILD_PATH)"
cd zlib-$(ZLIB_VERSION) && make
# copy files
mkdir -p libs/zlib-$(ZLIB_VERSION).tmp/include
cp zlib-$(ZLIB_VERSION)/zlib.h libs/zlib-$(ZLIB_VERSION).tmp/include/
cp zlib-$(ZLIB_VERSION)/zconf.h libs/zlib-$(ZLIB_VERSION).tmp/include/
mkdir -p libs/zlib-$(ZLIB_VERSION).tmp/lib
cp zlib-$(ZLIB_VERSION)/libz.a libs/zlib-$(ZLIB_VERSION).tmp/lib/
mkdir -p $(BUILD_PATH)/zlib-$(ZLIB_VERSION).tmp/include
cp zlib-$(ZLIB_VERSION)/zlib.h $(BUILD_PATH)/zlib-$(ZLIB_VERSION).tmp/include/
cp zlib-$(ZLIB_VERSION)/zconf.h $(BUILD_PATH)/zlib-$(ZLIB_VERSION).tmp/include/
mkdir -p $(BUILD_PATH)/zlib-$(ZLIB_VERSION).tmp/lib
cp zlib-$(ZLIB_VERSION)/libz.a $(BUILD_PATH)/zlib-$(ZLIB_VERSION).tmp/lib/
# cleanup
rm -r -f zlib-$(ZLIB_VERSION)
mv libs/zlib-$(ZLIB_VERSION).tmp libs/zlib-$(ZLIB_VERSION)
mv $(BUILD_PATH)/zlib-$(ZLIB_VERSION).tmp $(BUILD_PATH)/zlib-$(ZLIB_VERSION)
bzip2: libs/bzip2-$(BZIP2_VERSION)
bzip2: $(BUILD_PATH)/bzip2-$(BZIP2_VERSION)
$(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz:
wget http://bzip.org/$(BZIP2_VERSION)/bzip2-$(BZIP2_VERSION).tar.gz -O $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz
libs/bzip2-$(BZIP2_VERSION): $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz
$(BUILD_PATH)/bzip2-$(BZIP2_VERSION): $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz
# prepare
rm -r -f libs/bzip2-*
rm -r -f $(BUILD_PATH)/bzip2-*
tar xvf $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz
# build
#cd bzip2-$(BZIP2_VERSION) && make install PREFIX="`pwd`/../libs"
#cd bzip2-$(BZIP2_VERSION) && make install PREFIX="`pwd`/../$(BUILD_PATH)"
cd bzip2-$(BZIP2_VERSION) && make
# copy files
mkdir -p libs/bzip2-$(BZIP2_VERSION).tmp/include
cp bzip2-$(BZIP2_VERSION)/bzlib.h libs/bzip2-$(BZIP2_VERSION).tmp/include/
mkdir -p libs/bzip2-$(BZIP2_VERSION).tmp/lib
cp bzip2-$(BZIP2_VERSION)/libbz2.a libs/bzip2-$(BZIP2_VERSION).tmp/lib/
mkdir -p $(BUILD_PATH)/bzip2-$(BZIP2_VERSION).tmp/include
cp bzip2-$(BZIP2_VERSION)/bzlib.h $(BUILD_PATH)/bzip2-$(BZIP2_VERSION).tmp/include/
mkdir -p $(BUILD_PATH)/bzip2-$(BZIP2_VERSION).tmp/lib
cp bzip2-$(BZIP2_VERSION)/libbz2.a $(BUILD_PATH)/bzip2-$(BZIP2_VERSION).tmp/lib/
# cleanup
rm -r -f bzip2-$(BZIP2_VERSION)
mv libs/bzip2-$(BZIP2_VERSION).tmp libs/bzip2-$(BZIP2_VERSION)
mv $(BUILD_PATH)/bzip2-$(BZIP2_VERSION).tmp $(BUILD_PATH)/bzip2-$(BZIP2_VERSION)
miniupnpc: libs/miniupnpc-$(MINIUPNPC_VERSION)
miniupnpc: $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION)
$(DOWNLOAD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tar.gz:
wget http://miniupnp.free.fr/files/download.php?file=miniupnpc-$(MINIUPNPC_VERSION).tar.gz -O $(DOWNLOAD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tar.gz
libs/miniupnpc-$(MINIUPNPC_VERSION): $(DOWNLOAD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tar.gz
$(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION): $(DOWNLOAD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tar.gz
# prepare
rm -r -f libs/miniupnpc-*
rm -r -f $(BUILD_PATH)/miniupnpc-*
tar xvf $(DOWNLOAD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tar.gz
# build
cd miniupnpc-$(MINIUPNPC_VERSION) && export CC=gcc && make -f Makefile.mingw init libminiupnpc.a miniupnpc.dll
# copy files
mkdir -p libs/miniupnpc-$(MINIUPNPC_VERSION).tmp/include/miniupnpc
cp miniupnpc-$(MINIUPNPC_VERSION)/*.h libs/miniupnpc-$(MINIUPNPC_VERSION).tmp/include/miniupnpc/
mkdir -p libs/miniupnpc-$(MINIUPNPC_VERSION).tmp/lib
cp miniupnpc-$(MINIUPNPC_VERSION)/miniupnpc.lib libs/miniupnpc-$(MINIUPNPC_VERSION).tmp/lib/
mkdir -p libs/miniupnpc-$(MINIUPNPC_VERSION).tmp/bin
cp miniupnpc-$(MINIUPNPC_VERSION)/miniupnpc.dll libs/miniupnpc-$(MINIUPNPC_VERSION).tmp/bin/
mkdir -p $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/include/miniupnpc
cp miniupnpc-$(MINIUPNPC_VERSION)/*.h $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/include/miniupnpc/
mkdir -p $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/lib
cp miniupnpc-$(MINIUPNPC_VERSION)/miniupnpc.lib $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/lib/
mkdir -p $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/bin
cp miniupnpc-$(MINIUPNPC_VERSION)/miniupnpc.dll $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/bin/
# cleanup
rm -r -f miniupnpc-$(MINIUPNPC_VERSION)
mv libs/miniupnpc-$(MINIUPNPC_VERSION).tmp libs/miniupnpc-$(MINIUPNPC_VERSION)
mv $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION)
openssl: libs/openssl-$(OPENSSL_VERSION)
openssl: $(BUILD_PATH)/openssl-$(OPENSSL_VERSION)
$(DOWNLOAD_PATH)/openssl-$(OPENSSL_VERSION).tar.gz:
wget --no-check-certificate https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz -O $(DOWNLOAD_PATH)/openssl-$(OPENSSL_VERSION).tar.gz
libs/openssl-$(OPENSSL_VERSION): $(DOWNLOAD_PATH)/openssl-$(OPENSSL_VERSION).tar.gz
$(BUILD_PATH)/openssl-$(OPENSSL_VERSION): $(DOWNLOAD_PATH)/openssl-$(OPENSSL_VERSION).tar.gz
# prepare
rm -r -f libs/openssl-*
rm -r -f $(BUILD_PATH)/openssl-*
tar xvf $(DOWNLOAD_PATH)/openssl-$(OPENSSL_VERSION).tar.gz
# build
#cd openssl-$(OPENSSL_VERSION) && ./config --prefix="`pwd`/../libs"
#cd openssl-$(OPENSSL_VERSION) && ./config --prefix="`pwd`/../$(BUILD_PATH)"
#cd openssl-$(OPENSSL_VERSION) && make install
cd openssl-$(OPENSSL_VERSION) && ./config shared
cd openssl-$(OPENSSL_VERSION) && make
# copy files
mkdir -p libs/openssl-$(OPENSSL_VERSION).tmp/include/openssl
cp openssl-$(OPENSSL_VERSION)/include/openssl/*.h libs/openssl-$(OPENSSL_VERSION).tmp/include/openssl/
mkdir -p libs/openssl-$(OPENSSL_VERSION).tmp/bin
cp openssl-$(OPENSSL_VERSION)/libeay32.dll libs/openssl-$(OPENSSL_VERSION).tmp/bin/
cp openssl-$(OPENSSL_VERSION)/ssleay32.dll libs/openssl-$(OPENSSL_VERSION).tmp/bin/
mkdir -p libs/openssl-$(OPENSSL_VERSION).tmp/lib
cp openssl-$(OPENSSL_VERSION)/libcrypto.dll.a libs/openssl-$(OPENSSL_VERSION).tmp/lib/
cp openssl-$(OPENSSL_VERSION)/libssl.dll.a libs/openssl-$(OPENSSL_VERSION).tmp/lib/
mkdir -p $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/include/openssl
cp openssl-$(OPENSSL_VERSION)/include/openssl/*.h $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/include/openssl/
mkdir -p $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/bin
cp openssl-$(OPENSSL_VERSION)/libeay32.dll $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/bin/
cp openssl-$(OPENSSL_VERSION)/ssleay32.dll $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/bin/
mkdir -p $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/lib
cp openssl-$(OPENSSL_VERSION)/libcrypto.dll.a $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/lib/
cp openssl-$(OPENSSL_VERSION)/libssl.dll.a $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/lib/
# cleanup
rm -r -f openssl-$(OPENSSL_VERSION)
mv libs/openssl-$(OPENSSL_VERSION).tmp libs/openssl-$(OPENSSL_VERSION)
mv $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp $(BUILD_PATH)/openssl-$(OPENSSL_VERSION)
speex: libs/speex-$(SPEEX_VERSION)
speex: $(BUILD_PATH)/speex-$(SPEEX_VERSION)
$(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).tar.gz:
wget --no-check-certificate http://downloads.xiph.org/releases/speex/speex-$(SPEEX_VERSION).tar.gz -O $(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).tar.gz
libs/speex-$(SPEEX_VERSION): $(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).tar.gz
$(BUILD_PATH)/speex-$(SPEEX_VERSION): $(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).tar.gz
# prepare
rm -r -f libs/speex-*
rm -r -f $(BUILD_PATH)/speex-*
tar xvf $(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).tar.gz
# build
cd speex-$(SPEEX_VERSION) && ./configure
#cd speex-$(SPEEX_VERSION) && make install exec_prefix="`pwd`/../libs"
#cd speex-$(SPEEX_VERSION) && make install exec_prefix="`pwd`/../$(BUILD_PATH)"
cd speex-$(SPEEX_VERSION) && make
# copy files
mkdir -p libs/speex-$(SPEEX_VERSION).tmp/include/speex
cp speex-$(SPEEX_VERSION)/include/speex/*.h libs/speex-$(SPEEX_VERSION).tmp/include/speex/
mkdir -p libs/speex-$(SPEEX_VERSION).tmp/lib
cp speex-$(SPEEX_VERSION)/libspeex/.libs/libspeex.a libs/speex-$(SPEEX_VERSION).tmp/lib
mkdir -p $(BUILD_PATH)/speex-$(SPEEX_VERSION).tmp/include/speex
cp speex-$(SPEEX_VERSION)/include/speex/*.h $(BUILD_PATH)/speex-$(SPEEX_VERSION).tmp/include/speex/
mkdir -p $(BUILD_PATH)/speex-$(SPEEX_VERSION).tmp/lib
cp speex-$(SPEEX_VERSION)/libspeex/.libs/libspeex.a $(BUILD_PATH)/speex-$(SPEEX_VERSION).tmp/lib
# cleanup
rm -r -f speex-$(SPEEX_VERSION)
mv libs/speex-$(SPEEX_VERSION).tmp libs/speex-$(SPEEX_VERSION)
mv $(BUILD_PATH)/speex-$(SPEEX_VERSION).tmp $(BUILD_PATH)/speex-$(SPEEX_VERSION)
speexdsp: libs/speexdsp-$(SPEEXDSP_VERSION)
speexdsp: $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION)
$(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz:
wget --no-check-certificate http://downloads.xiph.org/releases/speex/speexdsp-$(SPEEXDSP_VERSION).tar.gz -O $(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz
libs/speexdsp-$(SPEEXDSP_VERSION): $(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz
$(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION): $(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz
# prepare
rm -r -f libs/speexdsp-*
rm -r -f $(BUILD_PATH)/speexdsp-*
tar xvf $(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz
# build
cd speexdsp-$(SPEEXDSP_VERSION) && ./configure
cd speexdsp-$(SPEEXDSP_VERSION) && make
# copy files
mkdir -p libs/speexdsp-$(SPEEXDSP_VERSION).tmp/include/speex
cp speexdsp-$(SPEEXDSP_VERSION)/include/speex/*.h libs/speexdsp-$(SPEEXDSP_VERSION).tmp/include/speex/
mkdir -p libs/speexdsp-$(SPEEXDSP_VERSION).tmp/lib
cp speexdsp-$(SPEEXDSP_VERSION)/libspeexdsp/.libs/libspeexdsp.a libs/speexdsp-$(SPEEXDSP_VERSION).tmp/lib
mkdir -p $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tmp/include/speex
cp speexdsp-$(SPEEXDSP_VERSION)/include/speex/*.h $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tmp/include/speex/
mkdir -p $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tmp/lib
cp speexdsp-$(SPEEXDSP_VERSION)/libspeexdsp/.libs/libspeexdsp.a $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tmp/lib
# cleanup
rm -r -f speexdsp-$(SPEEXDSP_VERSION)
mv libs/speexdsp-$(SPEEXDSP_VERSION).tmp libs/speexdsp-$(SPEEXDSP_VERSION)
mv $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tmp $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION)
opencv: libs/opencv-$(OPENCV_VERSION)
opencv: $(BUILD_PATH)/opencv-$(OPENCV_VERSION)
$(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz:
wget --no-check-certificate https://github.com/opencv/opencv/archive/$(OPENCV_VERSION).tar.gz -O $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz
libs/opencv-$(OPENCV_VERSION): $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz
$(BUILD_PATH)/opencv-$(OPENCV_VERSION): $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz
# prepare
rm -r -f libs/opencv-*
rm -r -f $(BUILD_PATH)/opencv-*
tar xvf $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz
# build
mkdir -p opencv-$(OPENCV_VERSION)/build
#cd opencv-$(OPENCV_VERSION)/build && cmake .. -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="`pwd`/../../libs"
#cd opencv-$(OPENCV_VERSION)/build && cmake .. -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="`pwd`/../../build"
cd opencv-$(OPENCV_VERSION)/build && cmake .. -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DENABLE_CXX11=ON -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -DSTRSAFE_NO_DEPRECATE" -DCMAKE_INSTALL_PREFIX="`pwd`/install"
cd opencv-$(OPENCV_VERSION)/build && make install
# copy files
mkdir -p libs/opencv-$(OPENCV_VERSION).tmp/include
cp -r opencv-$(OPENCV_VERSION)/build/install/include/* libs/opencv-$(OPENCV_VERSION).tmp/include/
mkdir -p libs/opencv-$(OPENCV_VERSION).tmp/lib/opencv
cp -r opencv-$(OPENCV_VERSION)/build/install/x86/mingw/staticlib/* libs/opencv-$(OPENCV_VERSION).tmp/lib/opencv/
mkdir -p $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp/include
cp -r opencv-$(OPENCV_VERSION)/build/install/include/* $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp/include/
mkdir -p $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp/lib/opencv
cp -r opencv-$(OPENCV_VERSION)/build/install/x86/mingw/staticlib/* $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp/lib/opencv/
# cleanup
rm -r -f opencv-$(OPENCV_VERSION)
mv libs/opencv-$(OPENCV_VERSION).tmp libs/opencv-$(OPENCV_VERSION)
mv $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp $(BUILD_PATH)/opencv-$(OPENCV_VERSION)
libxml2: libs/libxml2-$(LIBXML2_VERSION)
libxml2: $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION)
$(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz:
wget ftp://xmlsoft.org/libxml2/libxml2-$(LIBXML2_VERSION).tar.gz -O $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz
libs/libxml2-$(LIBXML2_VERSION): $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz
$(BUILD_PATH)/libxml2-$(LIBXML2_VERSION): $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz
# prepare
rm -r -f libs/libxml2-*
rm -r -f $(BUILD_PATH)/libxml2-*
tar xvf $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz
# build
cd libxml2-$(LIBXML2_VERSION) && ./configure --without-iconv -enable-shared=no
#cd libxml2-$(LIBXML2_VERSION) && make install exec_prefix="`pwd`/../libs"
#cd libxml2-$(LIBXML2_VERSION) && make install exec_prefix="`pwd`/../$(BUILD_PATH)"
cd libxml2-$(LIBXML2_VERSION) && make
# copy files
mkdir -p libs/libxml2-$(LIBXML2_VERSION).tmp/include/libxml
cp libxml2-$(LIBXML2_VERSION)/include/libxml/*.h libs/libxml2-$(LIBXML2_VERSION).tmp/include/libxml/
mkdir -p libs/libxml2-$(LIBXML2_VERSION).tmp/lib
cp libxml2-$(LIBXML2_VERSION)/.libs/libxml2.a libs/libxml2-$(LIBXML2_VERSION).tmp/lib/
mkdir -p $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION).tmp/include/libxml
cp libxml2-$(LIBXML2_VERSION)/include/libxml/*.h $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION).tmp/include/libxml/
mkdir -p $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION).tmp/lib
cp libxml2-$(LIBXML2_VERSION)/.libs/libxml2.a $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION).tmp/lib/
# cleanup
#rm -r -f libxml2-$(LIBXML2_VERSION) # see libxslt
mv libs/libxml2-$(LIBXML2_VERSION).tmp libs/libxml2-$(LIBXML2_VERSION)
mv $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION).tmp $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION)
libxslt: libs/libxslt-$(LIBXSLT_VERSION)
libxslt: $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION)
$(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz:
wget ftp://xmlsoft.org/libxml2/libxslt-$(LIBXSLT_VERSION).tar.gz -O $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz
libs/libxslt-$(LIBXSLT_VERSION): $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz
$(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION): $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz
# prepare
rm -r -f libs/libxslt-*
rm -r -f $(BUILD_PATH)/libxslt-*
tar xvf $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz
tar xvf $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz
# build
cd libxslt-$(LIBXSLT_VERSION) && ./configure --with-libxml-src=../libxml2-$(LIBXML2_VERSION) -enable-shared=no CFLAGS=-DLIBXML_STATIC
cd libxslt-$(LIBXSLT_VERSION) && make
# copy files
mkdir -p libs/libxslt-$(LIBXSLT_VERSION).tmp/include/libxslt
cp libxslt-$(LIBXSLT_VERSION)/libxslt/*.h libs/libxslt-$(LIBXSLT_VERSION).tmp/include/libxslt/
mkdir -p libs/libxslt-$(LIBXSLT_VERSION).tmp/lib
cp libxslt-$(LIBXSLT_VERSION)/libxslt/.libs/libxslt.a libs/libxslt-$(LIBXSLT_VERSION).tmp/lib/
cp libxslt-$(LIBXSLT_VERSION)/libexslt/.libs/libexslt.a libs/libxslt-$(LIBXSLT_VERSION).tmp/lib/
mkdir -p $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION).tmp/include/libxslt
cp libxslt-$(LIBXSLT_VERSION)/libxslt/*.h $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION).tmp/include/libxslt/
mkdir -p $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION).tmp/lib
cp libxslt-$(LIBXSLT_VERSION)/libxslt/.libs/libxslt.a $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION).tmp/lib/
cp libxslt-$(LIBXSLT_VERSION)/libexslt/.libs/libexslt.a $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION).tmp/lib/
# cleanup
rm -r -f libxml2-$(LIBXML2_VERSION)
rm -r -f libxslt-$(LIBXSLT_VERSION)
mv libs/libxslt-$(LIBXSLT_VERSION).tmp libs/libxslt-$(LIBXSLT_VERSION)
mv $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION).tmp $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION)
curl: libs/curl-$(CURL_VERSION)
curl: $(BUILD_PATH)/curl-$(CURL_VERSION)
$(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz:
wget --no-check-certificate http://curl.haxx.se/download/curl-$(CURL_VERSION).tar.gz -O $(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz
libs/curl-$(CURL_VERSION): $(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz
$(BUILD_PATH)/curl-$(CURL_VERSION): $(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz
# prepare
rm -r -f libs/curl-*
rm -r -f $(BUILD_PATH)/curl-*
tar xvf $(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz
# build
cd curl-$(CURL_VERSION) && ./configure --disable-shared --with-ssl="`pwd`/../libs/openssl-$(OPENSSL_VERSION)"
#cd curl-$(CURL_VERSION) && make install exec_prefix="`pwd`/../libs"
cd curl-$(CURL_VERSION) && ./configure --disable-shared --with-ssl="`pwd`/../$(BUILD_PATH)/openssl-$(OPENSSL_VERSION)"
#cd curl-$(CURL_VERSION) && make install exec_prefix="`pwd`/../$(BUILD_PATH)"
cd curl-$(CURL_VERSION) && make
# copy files
mkdir -p libs/curl-$(CURL_VERSION).tmp/include/curl
cp curl-$(CURL_VERSION)/include/curl/*.h libs/curl-$(CURL_VERSION).tmp/include/curl/
mkdir -p libs/curl-$(CURL_VERSION).tmp/lib
cp curl-$(CURL_VERSION)/lib/.libs/libcurl.a libs/curl-$(CURL_VERSION).tmp/lib/
mkdir -p $(BUILD_PATH)/curl-$(CURL_VERSION).tmp/include/curl
cp curl-$(CURL_VERSION)/include/curl/*.h $(BUILD_PATH)/curl-$(CURL_VERSION).tmp/include/curl/
mkdir -p $(BUILD_PATH)/curl-$(CURL_VERSION).tmp/lib
cp curl-$(CURL_VERSION)/lib/.libs/libcurl.a $(BUILD_PATH)/curl-$(CURL_VERSION).tmp/lib/
# cleanup
rm -r -f curl-$(CURL_VERSION)
mv libs/curl-$(CURL_VERSION).tmp libs/curl-$(CURL_VERSION)
mv $(BUILD_PATH)/curl-$(CURL_VERSION).tmp $(BUILD_PATH)/curl-$(CURL_VERSION)
sqlcipher: libs/sqlcipher-$(SQLCIPHER_VERSION)
sqlcipher: $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION)
$(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz:
wget --no-check-certificate http://downloads.sourceforge.net/project/tcl/Tcl/$(TCL_VERSION)/tcl$(TCL_VERSION)-src.tar.gz -O $(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz
@ -270,9 +281,9 @@ $(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz:
$(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz:
wget --no-check-certificate https://github.com/sqlcipher/sqlcipher/archive/v$(SQLCIPHER_VERSION).tar.gz -O $(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz
libs/sqlcipher-$(SQLCIPHER_VERSION): $(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz $(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz
$(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION): $(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz $(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz
# prepare
rm -r -f libs/sqlcipher-*
rm -r -f $(BUILD_PATH)/sqlcipher-*
# tcl
tar xvf $(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz
mkdir -p tcl$(TCL_VERSION)/build
@ -284,59 +295,73 @@ libs/sqlcipher-$(SQLCIPHER_VERSION): $(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.
mkdir -p tcl$(TCL_VERSION)/lib
ln -s `pwd`/tcl$(TCL_VERSION)/library `pwd`/tcl$(TCL_VERSION)/lib/tcl8.6
# build
cd sqlcipher-$(SQLCIPHER_VERSION) && PATH=.:$$PATH:`pwd`/../tcl$(TCL_VERSION)/build && export LIBS="-L`pwd`/../libs/openssl-$(OPENSSL_VERSION)/lib -lgdi32 $$LIBS" && ./configure --disable-shared --enable-static --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -I`pwd`/../libs/openssl-$(OPENSSL_VERSION)/include -I`pwd`/../tcl$(TCL_VERSION)/generic" LDFLAGS="-L`pwd`/../libs/openssl-$(OPENSSL_VERSION)/lib -lcrypto -lgdi32" --with-tcl="`pwd`/../tcl$(TCL_VERSION)/build" && make install prefix="`pwd`/install"
cd sqlcipher-$(SQLCIPHER_VERSION) && PATH=.:$$PATH:`pwd`/../tcl$(TCL_VERSION)/build && export LIBS="-L`pwd`/../$(BUILD_PATH)/openssl-$(OPENSSL_VERSION)/lib -lgdi32 $$LIBS" && ./configure --disable-shared --enable-static --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -I`pwd`/../$(BUILD_PATH)/openssl-$(OPENSSL_VERSION)/include -I`pwd`/../tcl$(TCL_VERSION)/generic" LDFLAGS="-L`pwd`/../$(BUILD_PATH)/openssl-$(OPENSSL_VERSION)/lib -lcrypto -lgdi32" --with-tcl="`pwd`/../tcl$(TCL_VERSION)/build" && make install prefix="`pwd`/install"
# copy files
mkdir -p libs/sqlcipher-$(SQLCIPHER_VERSION).tmp/include
cp -r sqlcipher-$(SQLCIPHER_VERSION)/install/include/* libs/sqlcipher-$(SQLCIPHER_VERSION).tmp/include/
mkdir -p libs/sqlcipher-$(SQLCIPHER_VERSION).tmp/lib
cp sqlcipher-$(SQLCIPHER_VERSION)/install/lib/libsqlcipher.a libs/sqlcipher-$(SQLCIPHER_VERSION).tmp/lib/
mkdir -p libs/sqlcipher-$(SQLCIPHER_VERSION).tmp/bin
cp sqlcipher-$(SQLCIPHER_VERSION)/install/bin/sqlcipher.exe libs/sqlcipher-$(SQLCIPHER_VERSION).tmp/bin/
mkdir -p $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tmp/include
cp -r sqlcipher-$(SQLCIPHER_VERSION)/install/include/* $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tmp/include/
mkdir -p $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tmp/lib
cp sqlcipher-$(SQLCIPHER_VERSION)/install/lib/libsqlcipher.a $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tmp/lib/
mkdir -p $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tmp/bin
cp sqlcipher-$(SQLCIPHER_VERSION)/install/bin/sqlcipher.exe $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tmp/bin/
# cleanup
rm -r -f sqlcipher-$(SQLCIPHER_VERSION)
rm -r -f tcl$(TCL_VERSION)
mv libs/sqlcipher-$(SQLCIPHER_VERSION).tmp libs/sqlcipher-$(SQLCIPHER_VERSION)
mv $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tmp $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION)
libmicrohttpd: libs/libmicrohttpd-$(LIBMICROHTTPD_VERSION)
libmicrohttpd: $(BUILD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION)
$(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz:
wget --no-check-certificate http://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz -O $(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz
libs/libmicrohttpd-$(LIBMICROHTTPD_VERSION): $(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz
$(BUILD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION): $(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz
# prepare
rm -r -f libs/libmicrohttpd-*
rm -r -f $(BUILD_PATH)/libmicrohttpd-*
tar xvf $(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz
# build
cd libmicrohttpd-$(LIBMICROHTTPD_VERSION) && ./configure --disable-shared --enable-static --prefix="`pwd`/../libs/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tmp"
cd libmicrohttpd-$(LIBMICROHTTPD_VERSION) && ./configure --disable-shared --enable-static --prefix="`pwd`/../$(BUILD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tmp"
cd libmicrohttpd-$(LIBMICROHTTPD_VERSION) && make install
# copy files
# cleanup
rm -r -f libmicrohttpd-$(LIBMICROHTTPD_VERSION)
mv libs/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tmp libs/libmicrohttpd-$(LIBMICROHTTPD_VERSION)
mv $(BUILD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tmp $(BUILD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION)
ffmpeg: libs/ffmpeg-$(FFMPEG_VERSION)
ffmpeg: $(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION)
$(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz:
wget --no-check-certificate https://ffmpeg.org/releases/ffmpeg-$(FFMPEG_VERSION).tar.gz -O $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz
libs/ffmpeg-$(FFMPEG_VERSION): $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz
$(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION): $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz
# prepare
rm -r -f libs/ffmpeg-*
rm -r -f $(BUILD_PATH)/ffmpeg-*
tar xvf $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz
# build
cd ffmpeg-$(FFMPEG_VERSION) && ./configure --disable-shared --enable-static --disable-programs --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-yasm --disable-everything --enable-encoder=mpeg4 --enable-decoder=mpeg4 --prefix="`pwd`/../libs/ffmpeg-$(FFMPEG_VERSION).tmp"
cd ffmpeg-$(FFMPEG_VERSION) && ./configure --disable-shared --enable-static --disable-programs --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-yasm --disable-everything --enable-encoder=mpeg4 --enable-decoder=mpeg4 --prefix="`pwd`/../$(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION).tmp"
cd ffmpeg-$(FFMPEG_VERSION) && make install
# copy files
# cleanup
rm -r -f ffmpeg-$(FFMPEG_VERSION)
mv libs/ffmpeg-$(FFMPEG_VERSION).tmp libs/ffmpeg-$(FFMPEG_VERSION)
mv $(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION).tmp $(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION)
rapidjson: $(BUILD_PATH)/rapidjson-$(RAPIDJSON_VERSION)
$(DOWNLOAD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tar.gz:
wget --no-check-certificate https://github.com/Tencent/rapidjson/archive/v$(RAPIDJSON_VERSION).tar.gz -O $(DOWNLOAD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tar.gz
$(BUILD_PATH)/rapidjson-$(RAPIDJSON_VERSION): $(DOWNLOAD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tar.gz
# prepare
rm -r -f $(BUILD_PATH)/rapidjson-*
tar xvf $(DOWNLOAD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tar.gz
# build
#mkdir -p rapidjson-$(RAPIDJSON_VERSION)/build
#cd rapidjson-$(RAPIDJSON_VERSION)/build && cmake .. -G"MSYS Makefiles"
#cd rapidjson-$(RAPIDJSON_VERSION)/build && make
# copy files
mkdir -p $(BUILD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tmp/include
cp -r rapidjson-$(RAPIDJSON_VERSION)/include/* $(BUILD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tmp/include/
# cleanup
rm -r -f rapidjson-$(RAPIDJSON_VERSION)
mv $(BUILD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tmp $(BUILD_PATH)/rapidjson-$(RAPIDJSON_VERSION)
copylibs:
if [ "$(COPY_ANSWER)" = "" ] ; then \
read -p "Do you want to copy libs to retroshare? (y|n)" answer; \
else \
answer=$(COPY_ANSWER) ; \
fi ; \
if [ "$$answer" = "y" ] ; then \
rm -r -f $(LIBS_PATH) ; \
mkdir -p $(LIBS_PATH) ; \
cp ./libs/gcc-version $(LIBS_PATH) ; \
find ./libs -mindepth 1 -maxdepth 1 -type d -not -name "*.tmp" -print -exec cp -r {}/. $(LIBS_PATH) \; ; \
fi
rm -r -f $(LIBS_PATH) ; \
mkdir -p $(LIBS_PATH) ; \
cp $(BUILD_PATH)/gcc-version $(LIBS_PATH) ; \
find $(BUILD_PATH) -mindepth 1 -maxdepth 1 -type d -not -name "*.tmp" -print -exec cp -r {}/. $(LIBS_PATH) \; ; \

View File

@ -1,5 +1,5 @@
:: Usage:
:: call build-libs.bat [auto-copy] [make tasks]
:: call build-libs.bat [make tasks]
@echo off
@ -7,7 +7,6 @@ setlocal
:: Parameter
set MakeParam="DOWNLOAD_PATH=../download"
if "%~1"=="auto-copy" set MakeParam=%MakeParam% "COPY_ANSWER=y"& shift /1
set MakeTask=
:param_loop
@ -30,6 +29,9 @@ if not exist "%EnvMSYSSH%" %cecho% error "Please install MSYS first." & exit /B
call "%~dp0env.bat"
if errorlevel 1 goto error_env
:: Add tools path to PATH environment
set PATH=%EnvToolsPath%;%PATH%
call "%ToolsPath%\msys-path.bat" "%~dp0" MSYSCurPath
call "%ToolsPath%\msys-path.bat" "%BuildLibsPath%" MSYSBuildLibsPath

View File

@ -9,7 +9,7 @@ call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
%cecho% info "Build libraries"
call "%~dp0build-libs\build-libs.bat" auto-copy
call "%~dp0build-libs\build-libs.bat"
if errorlevel 1 %cecho% error "Failed to build libraries." & exit /B %ERRORLEVEL%
%cecho% info "Build %SourceName%"

View File

@ -9,7 +9,7 @@ call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
%cecho% info "Build libraries"
call "%~dp0build-libs\build-libs.bat" auto-copy
call "%~dp0build-libs\build-libs.bat"
if errorlevel 1 %cecho% error "Failed to build libraries." & exit /B %ERRORLEVEL%
%cecho% info "Build %SourceName%"

View File

@ -8,22 +8,19 @@ if errorlevel 1 goto error_env
call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
:: Get gcc versions
call "%ToolsPath%\get-gcc-version.bat" GCCVersion
if "%GCCVersion%"=="" echo Cannot get gcc version.& exit /B 1
:: Check external libraries
if not exist "%RootPath%\libs" echo Please build external libraries first.& exit /B 1
:: Check gcc version of external libraries
if not exist "%RootPath%\libs\gcc-version" echo Cannot get gcc version of external libraries.& exit /B 1
set /P LibsGCCVersion=<"%RootPath%\libs\gcc-version"
if "%LibsGCCVersion%" NEQ "%GCCVersion%" echo Please use correct version of external libraries. (gcc %GCCVersion% ^<^> libs %LibsGCCVersion%).& exit /B 1
:: Initialize environment
call "%~dp0env.bat" standard
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env
:: Check external libraries
if not exist "%BuildLibsPath%\libs" %cecho% error "Please build external libraries first." & exit /B 1
:: Check gcc version of external libraries
if not exist "%BuildLibsPath%\libs\gcc-version" %cecho% error "Cannot get gcc version of external libraries." & exit /B 1
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
:: Build defines for script
set NSIS_PARAM=

View File

@ -8,22 +8,19 @@ if errorlevel 1 goto error_env
call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
:: Get gcc versions
call "%ToolsPath%\get-gcc-version.bat" GCCVersion
if "%GCCVersion%"=="" echo Cannot get gcc version.& exit /B 1
:: Check external libraries
if not exist "%RootPath%\libs" echo Please build external libraries first.& exit /B 1
:: Check gcc version of external libraries
if not exist "%RootPath%\libs\gcc-version" echo Cannot get gcc version of external libraries.& exit /B 1
set /P LibsGCCVersion=<"%RootPath%\libs\gcc-version"
if "%LibsGCCVersion%" NEQ "%GCCVersion%" echo Please use correct version of external libraries. (gcc %GCCVersion% ^<^> libs %LibsGCCVersion%).& exit /B 1
:: Initialize environment
call "%~dp0env.bat" %*
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env
:: Check external libraries
if not exist "%BuildLibsPath%\libs" %cecho% error "Please build external libraries first." & exit /B 1
:: Check gcc version of external libraries
if not exist "%BuildLibsPath%\libs\gcc-version" %cecho% error "Cannot get gcc version of external libraries." & exit /B 1
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
set GitPath=
call "%ToolsPath%\find-in-path.bat" GitPath git.exe
@ -55,7 +52,7 @@ title Build - %SourceName%%RsType%-%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
qmake "%SourcePath%\RetroShare.pro" -r "CONFIG+=%RS_QMAKE_CONFIG%"
qmake "%SourcePath%\RetroShare.pro" -r -spec win32-g++ "CONFIG+=%RS_QMAKE_CONFIG%" "EXTERNAL_LIB_DIR=%BuildLibsPath%\libs"
if errorlevel 1 goto error
echo.

View File

@ -9,7 +9,7 @@ if "%~1"=="standard" (
echo.
echo Usage: standard^|retrotor
echo.
exit /B 1
exit /B 2
)
)
@ -22,16 +22,22 @@ if not exist "%DeployPath%" mkdir "%DeployPath%"
:: Check Qt environment
set QtPath=
call "%ToolsPath%\find-in-path.bat" QtPath qmake.exe
if "%QtPath%"=="" echo Please run command in the Qt Command Prompt.& exit /B 1
if "%QtPath%"=="" %cecho% error "Please run command in the Qt Command Prompt." & exit /B 1
:: Check MinGW environment
set MinGWPath=
call "%ToolsPath%\find-in-path.bat" MinGWPath gcc.exe
if "%MinGWPath%"=="" echo Please run command in the Qt Command Prompt.& exit /B 1
if "%MinGWPath%"=="" %cecho% error "Please run command in the Qt Command Prompt." & exit /B 1
:: Get Qt version
call "%ToolsPath%\get-qt-version.bat" QtVersion
if "%QtVersion%"=="" echo Cannot get Qt version.& exit /B 1
if "%QtVersion%"=="" %cecho% error "Cannot get Qt version." & exit /B 1
:: Get gcc versions
call "%ToolsPath%\get-gcc-version.bat" GCCVersion
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%

View File

@ -10,22 +10,19 @@ if errorlevel 1 goto error_env
call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
:: Get gcc versions
call "%ToolsPath%\get-gcc-version.bat" GCCVersion
if "%GCCVersion%"=="" echo Cannot get gcc version.& exit /B 1
:: Check external libraries
if not exist "%RootPath%\libs" echo Please build external libraries first.& exit /B 1
:: Check gcc version of external libraries
if not exist "%RootPath%\libs\gcc-version" echo Cannot get gcc version of external libraries.& exit /B 1
set /P LibsGCCVersion=<"%RootPath%\libs\gcc-version"
if "%LibsGCCVersion%" NEQ "%GCCVersion%" echo Please use correct version of external libraries. (gcc %GCCVersion% ^<^> libs %LibsGCCVersion%).& exit /B 1
:: Initialize environment
call "%~dp0env.bat" %*
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env
:: Check external libraries
if not exist "%BuildLibsPath%\libs" %cecho% error "Please build external libraries first." & exit /B 1
:: Check gcc version of external libraries
if not exist "%BuildLibsPath%\libs\gcc-version" %cecho% error "Cannot get gcc version of external libraries." & exit /B 1
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
:: Remove deploy path
if exist "%RsDeployPath%" rmdir /S /Q "%RsDeployPath%"

View File

@ -52,7 +52,8 @@ mingw-get.exe install msys-autoconf
mingw-get.exe install msys-automake
mingw-get.exe install msys-autogen
mingw-get.exe install msys-mktemp
mingw-get.exe install msys-wget
rem Use own wget binary, because MSYS version of wget is to old
rem mingw-get.exe install msys-wget
popd
%cecho% info "Unpack CMake"

View File

@ -4,8 +4,8 @@ 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=http://7-zip.org/a/7z1602.msi
set SevenZipInstall=7z1602.msi
set SevenZipUrl=https://sourceforge.net/projects/sevenzip/files/7-Zip/18.05/7z1805.msi/download
set SevenZipInstall=7z1805.msi
::set CurlUrl=https://bintray.com/artifact/download/vszakats/generic/curl-7.50.1-win32-mingw.7z
::set CurlInstall=curl-7.50.1-win32-mingw.7z
set WgetUrl=https://eternallybored.org/misc/wget/1.19.4/32/wget.exe
@ -20,13 +20,23 @@ set NSISUrl=http://prdownloads.sourceforge.net/nsis/nsis-3.0-setup.exe?download
set NSISInstall=nsis-3.0-setup.exe
set NSISInstallPath=%EnvToolsPath%\NSIS
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%\winhttpjs.bat" %SevenZipUrl% -saveTo "%EnvDownloadPath%\%SevenZipInstall%"
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
@ -69,16 +79,6 @@ if not exist "%EnvToolsPath%\cecho.exe" (
:: call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
::)
if not exist "%EnvToolsPath%\wget.exe" (
%cecho% info "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
%cecho% info "Copy Wget"
copy "%EnvDownloadPath%\wget.exe" "%EnvToolsPath%"
)
if not exist "%EnvToolsPath%\jom.exe" (
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
mkdir "%EnvTempPath%"

View File

@ -8,6 +8,6 @@ if "%~2"=="" (
)
::"%EnvCurlExe%" -L -k "%~1" -o "%~2"
"%EnvWgetExe%" --continue "%~1" --output-document="%~2"
"%EnvWgetExe%" --no-check-certificate --continue "%~1" --output-document="%~2"
exit /B %ERRORLEVEL%

View File

@ -72,7 +72,7 @@ bdNodeManager::bdNodeManager(bdNodeId *id, std::string dhtVersion, std::string b
:bdNode(id, dhtVersion, bootfile, filterfile, fns, this)
{
mMode = BITDHT_MGR_STATE_OFF;
mFns = fns;
mDhtFns = fns;
mModeTS = 0 ;
mStartTS = 0;
mSearchingDone = false;
@ -87,7 +87,7 @@ bdNodeManager::bdNodeManager(bdNodeId *id, std::string dhtVersion, std::string b
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::bdNodeManager() ID: ";
mFns->bdPrintNodeId(std::cerr, id);
mDhtFns->bdPrintNodeId(std::cerr, id);
std::cerr << std::endl;
#endif
@ -188,7 +188,7 @@ void bdNodeManager::addFindNode(bdNodeId *id, uint32_t qflags)
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::addFindNode() ";
mFns->bdPrintNodeId(std::cerr, id);
mDhtFns->bdPrintNodeId(std::cerr, id);
std::cerr << std::endl;
#endif
/* check if exists already */
@ -257,7 +257,7 @@ void bdNodeManager::removeFindNode(bdNodeId *id)
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::removeFindNode() ";
mFns->bdPrintNodeId(std::cerr, id);
mDhtFns->bdPrintNodeId(std::cerr, id);
std::cerr << std::endl;
#endif
std::map<bdNodeId, bdQueryPeer>::iterator it;
@ -525,7 +525,7 @@ int bdNodeManager::QueryRandomLocalNet()
else
{
/* calculate mid point */
mFns->bdRandomMidId(&mOwnId, &(id.id), &targetNodeId);
mDhtFns->bdRandomMidId(&mOwnId, &(id.id), &targetNodeId);
}
/* do standard find_peer message */
@ -534,13 +534,13 @@ int bdNodeManager::QueryRandomLocalNet()
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::QueryRandomLocalNet() Querying : ";
mFns->bdPrintId(std::cerr, &id);
mDhtFns->bdPrintId(std::cerr, &id);
std::cerr << " searching for : ";
mFns->bdPrintNodeId(std::cerr, &targetNodeId);
mDhtFns->bdPrintNodeId(std::cerr, &targetNodeId);
bdMetric dist;
mFns->bdDistance(&targetNodeId, &(mOwnId), &dist);
int bucket = mFns->bdBucketDistance(&dist);
mDhtFns->bdDistance(&targetNodeId, &(mOwnId), &dist);
int bucket = mDhtFns->bdBucketDistance(&dist);
std::cerr << " in Bucket: " << bucket;
std::cerr << std::endl;
#endif
@ -593,7 +593,7 @@ void bdNodeManager::SearchForLocalNet()
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::SearchForLocalNet() Existing Internal Search: ";
mFns->bdPrintNodeId(std::cerr, &(it->first));
mDhtFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << std::endl;
#endif
@ -630,7 +630,7 @@ void bdNodeManager::SearchForLocalNet()
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::SearchForLocalNet() " << i << " Attempts to find OkNode: ";
mFns->bdPrintNodeId(std::cerr, &targetNodeId);
mDhtFns->bdPrintNodeId(std::cerr, &targetNodeId);
std::cerr << std::endl;
#endif
}
@ -638,7 +638,7 @@ void bdNodeManager::SearchForLocalNet()
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::SearchForLocalNet() Failed to Find FilterOk this time: ";
mFns->bdPrintNodeId(std::cerr, &targetNodeId);
mDhtFns->bdPrintNodeId(std::cerr, &targetNodeId);
std::cerr << std::endl;
#endif
}
@ -649,7 +649,7 @@ void bdNodeManager::SearchForLocalNet()
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::SearchForLocalNet() Adding New Internal Search: ";
mFns->bdPrintNodeId(std::cerr, &(targetNodeId));
mDhtFns->bdPrintNodeId(std::cerr, &(targetNodeId));
std::cerr << std::endl;
#endif
}
@ -709,7 +709,7 @@ int bdNodeManager::checkStatus()
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() Query in Progress id: ";
mFns->bdPrintNodeId(std::cerr, &(it->first));
mDhtFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << std::endl;
#endif
}
@ -719,7 +719,7 @@ int bdNodeManager::checkStatus()
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() Query Failed: id: ";
mFns->bdPrintNodeId(std::cerr, &(it->first));
mDhtFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << std::endl;
#endif
// BAD.
@ -733,7 +733,7 @@ int bdNodeManager::checkStatus()
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() Found Closest: id: ";
mFns->bdPrintNodeId(std::cerr, &(it->first));
mDhtFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << std::endl;
#endif
@ -747,7 +747,7 @@ int bdNodeManager::checkStatus()
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() the Peer Online but Unreachable: id: ";
mFns->bdPrintNodeId(std::cerr, &(it->first));
mDhtFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << std::endl;
#endif
@ -761,7 +761,7 @@ int bdNodeManager::checkStatus()
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() Found Query: id: ";
mFns->bdPrintNodeId(std::cerr, &(it->first));
mDhtFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << std::endl;
#endif
//foundId =
@ -803,7 +803,7 @@ int bdNodeManager::checkStatus()
doCallback = false;
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() Internal: no cb for id: ";
mFns->bdPrintNodeId(std::cerr, &(it->first));
mDhtFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << std::endl;
#endif
}
@ -1024,7 +1024,7 @@ int bdNodeManager::getDhtPeerAddress(const bdNodeId *id, struct sockaddr_in &fro
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::getDhtPeerAddress() Id: ";
mFns->bdPrintNodeId(std::cerr, id);
mDhtFns->bdPrintNodeId(std::cerr, id);
std::cerr << " ... ? TODO" << std::endl;
#else
(void) id;
@ -1034,7 +1034,7 @@ int bdNodeManager::getDhtPeerAddress(const bdNodeId *id, struct sockaddr_in &fro
pit = mActivePeers.find(*id);
std::cerr << "bdNodeManager::getDhtPeerAddress() Id: ";
mFns->bdPrintNodeId(std::cerr, id);
mDhtFns->bdPrintNodeId(std::cerr, id);
std::cerr << std::endl;
if (pit != mActivePeers.end())
@ -1061,7 +1061,7 @@ int bdNodeManager::getDhtValue(const bdNodeId *id, std::string key, std::string
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::getDhtValue() Id: ";
mFns->bdPrintNodeId(std::cerr, id);
mDhtFns->bdPrintNodeId(std::cerr, id);
std::cerr << " key: " << key;
std::cerr << " ... ? TODO" << std::endl;
#else
@ -1144,7 +1144,7 @@ void bdNodeManager::doNodeCallback(const bdId *id, uint32_t peerflags)
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::doNodeCallback() ";
mFns->bdPrintId(std::cerr, id);
mDhtFns->bdPrintId(std::cerr, id);
std::cerr << "peerflags: " << peerflags;
std::cerr << std::endl;
#endif
@ -1163,7 +1163,7 @@ void bdNodeManager::doPeerCallback(const bdId *id, uint32_t status)
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::doPeerCallback()";
mFns->bdPrintId(std::cerr, id);
mDhtFns->bdPrintId(std::cerr, id);
std::cerr << "status: " << status;
std::cerr << std::endl;
#endif

View File

@ -184,7 +184,7 @@ void SearchForLocalNet();
time_t mSearchTS;
bool mSearchingDone;
bdDhtFunctions *mFns;
bdDhtFunctions *mDhtFns;
uint32_t mNetworkSize;
uint32_t mBdNetworkSize;

View File

@ -518,7 +518,7 @@ void bdNode::checkPotentialPeer(bdId *id, bdId *src)
#ifndef DISABLE_BAD_PEER_FILTER
std::cerr << "bdNode::checkPotentialPeer(";
mFns->bdPrintId(std::cerr, id);
std::cerr << ") MASQARADING AS KNOWN PEER - FLAGGING AS BAD";
std::cerr << ") MASQUERADING AS KNOWN PEER - FLAGGING AS BAD";
std::cerr << std::endl;
// Stores in queue for later callback and desemination around the network.
@ -603,7 +603,7 @@ void bdNode::addPeer(const bdId *id, uint32_t peerflags)
std::cerr << "bdNode::addPeer(";
mFns->bdPrintId(std::cerr, id);
std::cerr << ", " << std::hex << peerflags << std::dec;
std::cerr << ") MASQARADING AS KNOWN PEER - FLAGGING AS BAD";
std::cerr << ") MASQUERADING AS KNOWN PEER - FLAGGING AS BAD";
std::cerr << std::endl;

View File

@ -6,23 +6,10 @@ CONFIG -= qt
TARGET = bitdht
DESTDIR = lib
!include("use_libbitdht.pri"):error("Including")
QMAKE_CXXFLAGS *= -Wall -DBE_DEBUG
profiling {
QMAKE_CXXFLAGS -= -fomit-frame-pointer
QMAKE_CXXFLAGS *= -pg -g -fno-omit-frame-pointer
}
release {
# not much here yet.
}
#CONFIG += debug
debug {
QMAKE_CXXFLAGS -= -O2 -fomit-frame-pointer
QMAKE_CXXFLAGS *= -g -fno-omit-frame-pointer
}
# treat warnings as error for better removing
#QMAKE_CFLAGS += -Werror
#QMAKE_CXXFLAGS += -Werror

View File

@ -0,0 +1,5 @@
DEPENDPATH *= $$system_path($$clean_path($${PWD}/../../libbitdht/src))
INCLUDEPATH *= $$system_path($$clean_path($${PWD}/../../libbitdht/src))
LIBS *= -L$$system_path($$clean_path($${OUT_PWD}/../../libbitdht/src/lib/)) -lbitdht
!equals(TARGET, bitdht):PRE_TARGETDEPS *= $$system_path($$clean_path($${OUT_PWD}/../../libbitdht/src/lib/libbitdht.a))

View File

@ -17,7 +17,7 @@
#include "ChannelsHandler.h"
#include "StatsHandler.h"
#ifdef LIBRESAPI_QT
#ifdef LIBRESAPI_SETTINGS
#include "SettingsHandler.h"
#endif
@ -240,9 +240,9 @@ public:
mTransfersHandler(sts, ifaces.mFiles, ifaces.mPeers, *ifaces.mNotify),
mChatHandler(sts, ifaces.mNotify, ifaces.mMsgs, ifaces.mPeers, ifaces.mIdentity, &mPeersHandler),
mApiPluginHandler(sts, ifaces),
mChannelsHandler(ifaces.mGxsChannels),
mChannelsHandler(*ifaces.mGxsChannels),
mStatsHandler()
#ifdef LIBRESAPI_QT
#ifdef LIBRESAPI_SETTINGS
,mSettingsHandler(sts)
#endif
{
@ -272,7 +272,7 @@ public:
&ChannelsHandler::handleRequest);
router.addResourceHandler("stats", dynamic_cast<ResourceRouter*>(&mStatsHandler),
&StatsHandler::handleRequest);
#ifdef LIBRESAPI_QT
#ifdef LIBRESAPI_SETTINGS
router.addResourceHandler("settings", dynamic_cast<ResourceRouter*>(&mSettingsHandler),
&SettingsHandler::handleRequest);
#endif
@ -290,7 +290,7 @@ public:
ChannelsHandler mChannelsHandler;
StatsHandler mStatsHandler;
#ifdef LIBRESAPI_QT
#ifdef LIBRESAPI_SETTINGS
SettingsHandler mSettingsHandler;
#endif
};

View File

@ -369,6 +369,9 @@ static void secure_queue_response(MHD_Connection *connection, unsigned int statu
// tell Internet Explorer to not do content sniffing
MHD_add_response_header(response, "X-Content-Type-Options", "nosniff");
// Prevent clickjacking attacks (also prevented by CSP, but not in all browsers, including FireFox)
MHD_add_response_header(response, "X-Frame-Options", "SAMEORIGIN");
// Content security policy header, its a new technology and not implemented everywhere
// get own host name as the browser sees it

View File

@ -1,8 +1,29 @@
/*
* RetroShare JSON API
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ChannelsHandler.h"
#include <retroshare/rsgxschannels.h>
#include <util/radix64.h>
#include <util/rstime.h>
#include <algorithm>
#include <time.h>
#include "Operators.h"
namespace resource_api
@ -21,22 +42,414 @@ StreamBase& operator << (StreamBase& left, RsGxsFile& file)
{
double size = 0;
left << makeKeyValueReference("size", size);
file.mSize = size;
file.mSize = size;
}
return left;
}
ChannelsHandler::ChannelsHandler(RsGxsChannels *channels):
mChannels(channels)
ChannelsHandler::ChannelsHandler(RsGxsChannels& channels): mChannels(channels)
{
addResourceHandler("create_post", this, &ChannelsHandler::handleCreatePost);
addResourceHandler("list_channels", this,
&ChannelsHandler::handleListChannels);
addResourceHandler("get_channel_info", this, &ChannelsHandler::handleGetChannelInfo);
addResourceHandler("get_channel_content", this, &ChannelsHandler::handleGetChannelContent);
addResourceHandler("toggle_subscribe", this, &ChannelsHandler::handleToggleSubscription);
addResourceHandler("toggle_auto_download", this, &ChannelsHandler::handleToggleAutoDownload);
addResourceHandler("toggle_read", this, &ChannelsHandler::handleTogglePostRead);
addResourceHandler("create_channel", this, &ChannelsHandler::handleCreateChannel);
addResourceHandler("create_post", this, &ChannelsHandler::handleCreatePost);
}
ResponseTask* ChannelsHandler::handleCreatePost(Request &req, Response &resp)
void ChannelsHandler::handleListChannels(Request& /*req*/, Response& resp)
{
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
uint32_t token;
RsTokenService& tChannels = *mChannels.getTokenService();
tChannels.requestGroupInfo(token, RS_DEPRECATED_TOKREQ_ANSTYPE, opts);
time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
&&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
std::list<RsGroupMetaData> grps;
if( tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE
&& mChannels.getGroupSummary(token, grps) )
{
for( RsGroupMetaData& grp : grps )
{
KeyValueReference<RsGxsGroupId> id("channel_id", grp.mGroupId);
KeyValueReference<uint32_t> vis_msg("visible_msg_count", grp.mVisibleMsgCount);
bool own = (grp.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
bool subscribed = IS_GROUP_SUBSCRIBED(grp.mSubscribeFlags);
std::string lastPostTsStr = std::to_string(grp.mLastPost);
std::string publishTsStr = std::to_string(grp.mPublishTs);
resp.mDataStream.getStreamToMember()
<< id
<< makeKeyValueReference("name", grp.mGroupName)
<< makeKeyValueReference("last_post_ts", lastPostTsStr)
<< makeKeyValueReference("popularity", grp.mPop)
<< makeKeyValueReference("publish_ts", publishTsStr)
<< vis_msg
<< makeKeyValueReference("group_status", grp.mGroupStatus)
<< makeKeyValueReference("author_id", grp.mAuthorId)
<< makeKeyValueReference("parent_grp_id", grp.mParentGrpId)
<< makeKeyValueReference("own", own)
<< makeKeyValueReference("subscribed", subscribed);
}
resp.setOk();
}
else resp.setFail("Cant get data from GXS!");
}
void ChannelsHandler::handleGetChannelInfo(Request& req, Response& resp)
{
std::string chanIdStr;
req.mStream << makeKeyValueReference("channel_id", chanIdStr);
if(chanIdStr.empty())
{
resp.setFail("channel_id required!");
return;
}
RsGxsGroupId chanId(chanIdStr);
if(chanId.isNull())
{
resp.setFail("Invalid channel_id:" + chanIdStr);
return;
}
bool wantThumbnail = true;
req.mStream << makeKeyValueReference("want_thumbnail", wantThumbnail);
std::list<RsGxsGroupId> groupIds; groupIds.push_back(chanId);
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
uint32_t token;
RsTokenService& tChannels = *mChannels.getTokenService();
tChannels.requestGroupInfo( token, RS_DEPRECATED_TOKREQ_ANSTYPE,
opts, groupIds );
time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
&&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
std::vector<RsGxsChannelGroup> grps;
if( tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE
&& mChannels.getGroupData(token, grps) )
{
for( RsGxsChannelGroup& grp : grps )
{
KeyValueReference<RsGxsGroupId> id("channel_id", grp.mMeta.mGroupId);
KeyValueReference<uint32_t> vis_msg("visible_msg_count", grp.mMeta.mVisibleMsgCount);
bool own = (grp.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
bool subscribed = IS_GROUP_SUBSCRIBED(grp.mMeta.mSubscribeFlags);
std::string lastPostTsStr = std::to_string(grp.mMeta.mLastPost);
std::string publishTsStr = std::to_string(grp.mMeta.mPublishTs);
StreamBase& rgrp(resp.mDataStream.getStreamToMember());
rgrp << id
<< makeKeyValueReference("name", grp.mMeta.mGroupName)
<< makeKeyValueReference("last_post_ts", lastPostTsStr)
<< makeKeyValueReference("popularity", grp.mMeta.mPop)
<< makeKeyValueReference("publish_ts", publishTsStr)
<< vis_msg
<< makeKeyValueReference("group_status", grp.mMeta.mGroupStatus)
<< makeKeyValueReference("author_id", grp.mMeta.mAuthorId)
<< makeKeyValueReference("parent_grp_id", grp.mMeta.mParentGrpId)
<< makeKeyValueReference("description", grp.mDescription)
<< makeKeyValueReference("own", own)
<< makeKeyValueReference("subscribed", subscribed)
<< makeKeyValueReference("auto_download", grp.mAutoDownload);
if(wantThumbnail)
{
std::string thumbnail_base64;
Radix64::encode(grp.mImage.mData, grp.mImage.mSize, thumbnail_base64);
rgrp << makeKeyValueReference("thumbnail_base64_png", thumbnail_base64);
}
}
resp.setOk();
}
else resp.setFail("Cant get data from GXS!");
}
void ChannelsHandler::handleGetChannelContent(Request& req, Response& resp)
{
std::string chanIdStr;
req.mStream << makeKeyValueReference("channel_id", chanIdStr);
if(chanIdStr.empty())
{
resp.setFail("channel_id required!");
return;
}
RsGxsGroupId chanId(chanIdStr);
if(chanId.isNull())
{
resp.setFail("Invalid channel_id:" + chanIdStr);
return;
}
std::list<RsGxsGroupId> groupIds; groupIds.push_back(chanId);
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
if(! mChannels.getTokenService()->
requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds) )
{
resp.setFail("Unknown GXS error!");
return;
}
time_t start = time(NULL);
while((mChannels.getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
&&(mChannels.getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
std::vector<RsGxsChannelPost> posts;
std::vector<RsGxsComment> comments;
if( mChannels.getTokenService()->requestStatus(token) ==
RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE &&
mChannels.getPostData(token, posts, comments) )
{
for( std::vector<RsGxsChannelPost>::iterator vit = posts.begin();
vit != posts.end(); ++vit )
{
RsGxsChannelPost& post = *vit;
RsMsgMetaData& pMeta = post.mMeta;
resp.mDataStream.getStreamToMember()
<< makeKeyValueReference("channel_id", pMeta.mGroupId)
<< makeKeyValueReference("name", pMeta.mMsgName)
<< makeKeyValueReference("post_id", pMeta.mMsgId)
<< makeKeyValueReference("parent_id", pMeta.mParentId)
<< makeKeyValueReference("author_id", pMeta.mAuthorId)
<< makeKeyValueReference("orig_msg_id", pMeta.mOrigMsgId)
<< makeKeyValueReference("thread_id", pMeta.mThreadId)
<< makeKeyValueReference("message", post.mMsg);
}
for( std::vector<RsGxsComment>::iterator vit = comments.begin();
vit != comments.end(); ++vit )
{
RsGxsComment& comment = *vit;
RsMsgMetaData& cMeta = comment.mMeta;
std::string scoreStr = std::to_string(comment.mScore);
resp.mDataStream.getStreamToMember()
<< makeKeyValueReference("channel_id", cMeta.mGroupId)
<< makeKeyValueReference("name", cMeta.mMsgName)
<< makeKeyValueReference("comment_id", cMeta.mMsgId)
<< makeKeyValueReference("parent_id", cMeta.mParentId)
<< makeKeyValueReference("author_id", cMeta.mAuthorId)
<< makeKeyValueReference("orig_msg_id", cMeta.mOrigMsgId)
<< makeKeyValueReference("thread_id", cMeta.mThreadId)
<< makeKeyValueReference("score", scoreStr)
<< makeKeyValueReference("message", comment.mComment);
}
resp.setOk();
}
else resp.setFail("Cant get data from GXS!");
}
void ChannelsHandler::handleToggleSubscription(Request& req, Response& resp)
{
std::string chanIdStr;
bool subscribe = true;
req.mStream << makeKeyValueReference("channel_id", chanIdStr)
<< makeKeyValueReference("subscribe", subscribe);
if(chanIdStr.empty())
{
resp.setFail("channel_id required!");
return;
}
RsGxsGroupId chanId(chanIdStr);
if(chanId.isNull())
{
resp.setFail("Invalid channel_id:" + chanIdStr);
return;
}
uint32_t token;
if(mChannels.subscribeToGroup(token, chanId, subscribe))
{
RsTokenService& tChannels = *mChannels.getTokenService();
time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
&&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
if(tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
resp.setOk();
else resp.setFail("Unknown GXS error!");
}
else resp.setFail("Unknown GXS error!");
}
void ChannelsHandler::handleCreateChannel(Request& req, Response& resp)
{
RsGxsChannelGroup chan;
RsGroupMetaData& cMeta = chan.mMeta;
std::string authorIdStr;
std::string thumbnail_base64;
req.mStream << makeKeyValueReference("author_id", authorIdStr)
<< makeKeyValueReference("name", cMeta.mGroupName)
<< makeKeyValueReference("description", chan.mDescription)
<< makeKeyValueReference("thumbnail_base64_png", thumbnail_base64);
if(cMeta.mGroupName.empty())
{
resp.setFail("Channel name required!");
return;
}
if(thumbnail_base64.empty()) chan.mImage.clear();
else
{
std::vector<uint8_t> png_data = Radix64::decode(thumbnail_base64);
if(!png_data.empty())
{
if(png_data.size() < 8)
{
resp.setFail("Decoded thumbnail_base64_png is smaller than 8 byte. This can't be a valid png file!");
return;
}
uint8_t png_magic_number[] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a};
if(!std::equal(&png_magic_number[0],&png_magic_number[8],png_data.begin()))
{
resp.setFail("Decoded thumbnail_base64_png does not seem to be a png file. (Header is missing magic number)");
return;
}
chan.mImage.copy(png_data.data(), png_data.size());
}
}
if(!authorIdStr.empty()) cMeta.mAuthorId = RsGxsId(authorIdStr);
// ATM supports creating only public channels
cMeta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
// I am not sure about those flags I have reversed them with the debugger
// that gives 520 as value of this member when a channel with default
// options is created from Qt Gui
cMeta.mSignFlags = GXS_SERV::MSG_AUTHEN_CHILD_AUTHOR_SIGN |
GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_REQUIRED;
uint32_t token;
if(mChannels.createGroup(token, chan))
{
RsTokenService& tChannels = *mChannels.getTokenService();
time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
&&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
if(tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
resp.setOk();
else resp.setFail("Unknown GXS error!");
}
else resp.setFail("Unkown GXS error!");
}
void ChannelsHandler::handleToggleAutoDownload(Request& req, Response& resp)
{
std::string chanIdStr;
bool autoDownload = true;
req.mStream << makeKeyValueReference("channel_id", chanIdStr)
<< makeKeyValueReference("auto_download", autoDownload);
if(chanIdStr.empty())
{
resp.setFail("channel_id required!");
return;
}
RsGxsGroupId chanId(chanIdStr);
if(chanId.isNull())
{
resp.setFail("Invalid channel_id:" + chanIdStr);
return;
}
if(mChannels.setChannelAutoDownload(chanId, autoDownload))
resp.setOk();
else resp.setFail();
}
void ChannelsHandler::handleTogglePostRead(Request& req, Response& resp)
{
std::string chanIdStr;
std::string postIdStr;
bool read = true;
req.mStream << makeKeyValueReference("channel_id", chanIdStr)
<< makeKeyValueReference("post_id", postIdStr)
<< makeKeyValueReference("read", read);
if(chanIdStr.empty())
{
resp.setFail("channel_id required!");
return;
}
RsGxsGroupId chanId(chanIdStr);
if(chanId.isNull())
{
resp.setFail("Invalid channel_id:" + chanIdStr);
return;
}
if(postIdStr.empty())
{
resp.setFail("post_id required!");
return;
}
RsGxsMessageId postId(postIdStr);
if(postId.isNull())
{
resp.setFail("Invalid post_id:" + postIdStr);
return;
}
std::cerr << __PRETTY_FUNCTION__ << " " << chanIdStr << " " << postIdStr
<< " " << read << std::endl;
uint32_t token;
mChannels.setMessageReadStatus(token, std::make_pair(chanId,postId), read);
RsTokenService& tChannels = *mChannels.getTokenService();
time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
&&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
if(tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
resp.setOk();
else resp.setFail("Unknown GXS error!");
}
void ChannelsHandler::handleCreatePost(Request &req, Response &resp)
{
RsGxsChannelPost post;
req.mStream << makeKeyValueReference("group_id", post.mMeta.mGroupId);
req.mStream << makeKeyValueReference("channel_id", post.mMeta.mGroupId);
req.mStream << makeKeyValueReference("subject", post.mMeta.mMsgName);
req.mStream << makeKeyValueReference("message", post.mMsg);
@ -53,36 +466,36 @@ ResponseTask* ChannelsHandler::handleCreatePost(Request &req, Response &resp)
if(post.mMeta.mGroupId.isNull())
{
resp.setFail("groupd_id is null");
return 0;
resp.setFail("groupd_id is null");
return;
}
if(post.mMeta.mMsgName.empty())
{
resp.setFail("subject is empty");
return 0;
resp.setFail("subject is empty");
return;
}
if(post.mMsg.empty())
{
resp.setFail("msg text is empty");
return 0;
resp.setFail("msg text is empty");
return;
}
// empty file list is ok, but files have to be valid
for(std::list<RsGxsFile>::iterator lit = post.mFiles.begin(); lit != post.mFiles.end(); ++lit)
{
if(lit->mHash.isNull())
{
resp.setFail("at least one file hash is empty");
return 0;
resp.setFail("at least one file hash is empty");
return;
}
if(lit->mName.empty())
{
resp.setFail("at leats one file name is empty");
return 0;
resp.setFail("at leats one file name is empty");
return;
}
if(lit->mSize == 0)
{
resp.setFail("at least one file size is empty");
return 0;
resp.setFail("at least one file size is empty");
return;
}
}
@ -91,22 +504,33 @@ ResponseTask* ChannelsHandler::handleCreatePost(Request &req, Response &resp)
{
if(png_data.size() < 8)
{
resp.setFail("Decoded thumbnail_base64_png is smaller than 8 byte. This can't be a valid png file!");
return 0;
resp.setFail("Decoded thumbnail_base64_png is smaller than 8 byte. This can't be a valid png file!");
return;
}
uint8_t png_magic_number[] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a};
if(!std::equal(&png_magic_number[0],&png_magic_number[8],png_data.begin()))
{
resp.setFail("Decoded thumbnail_base64_png does not seem to be a png file. (Header is missing magic number)");
return 0;
resp.setFail("Decoded thumbnail_base64_png does not seem to be a png file. (Header is missing magic number)");
return;
}
post.mThumbnail.copy(png_data.data(), png_data.size());
}
uint32_t token;
mChannels->createPost(token, post);
// TODO: grp creation acknowledge
return 0;
if(mChannels.createPost(token, post))
{
RsTokenService& tChannels = *mChannels.getTokenService();
time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
&&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
if(tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
resp.setOk();
else resp.setFail("Unknown GXS error!");
}
else resp.setFail("Unknown GXS error!");
}
} // namespace resource_api

View File

@ -1,4 +1,21 @@
#pragma once
/*
* RetroShare JSON API
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ResourceRouter.h"
@ -7,15 +24,21 @@ class RsGxsChannels;
namespace resource_api
{
class ChannelsHandler : public ResourceRouter
struct ChannelsHandler : ResourceRouter
{
public:
ChannelsHandler(RsGxsChannels* channels);
ChannelsHandler(RsGxsChannels& channels);
private:
ResponseTask* handleCreatePost(Request& req, Response& resp);
void handleListChannels(Request& req, Response& resp);
void handleGetChannelInfo(Request& req, Response& resp);
void handleGetChannelContent(Request& req, Response& resp);
void handleToggleSubscription(Request& req, Response& resp);
void handleCreateChannel(Request& req, Response& resp);
void handleToggleAutoDownload(Request& req, Response& resp);
void handleTogglePostRead(Request& req, Response& resp);
void handleCreatePost(Request& req, Response& resp);
RsGxsChannels* mChannels;
RsGxsChannels& mChannels;
};
} // namespace resource_api

View File

@ -37,6 +37,16 @@ FileSharingHandler::FileSharingHandler(StateTokenServer *sts, RsFiles *files,
addResourceHandler("get_dir_parent", this, &FileSharingHandler::handleGetDirectoryParent);
addResourceHandler("get_dir_childs", this, &FileSharingHandler::handleGetDirectoryChilds);
addResourceHandler( "get_download_directory", this,
&FileSharingHandler::handleGetDownloadDirectory );
addResourceHandler( "set_download_directory", this,
&FileSharingHandler::handleSetDownloadDirectory );
addResourceHandler( "get_partials_directory", this,
&FileSharingHandler::handleGetPartialsDirectory );
addResourceHandler( "set_partials_directory", this,
&FileSharingHandler::handleSetPartialsDirectory );
addResourceHandler("is_dl_dir_shared", this, &FileSharingHandler::handleIsDownloadDirShared);
addResourceHandler("share_dl_dir", this, &FileSharingHandler::handleShareDownloadDirectory);
@ -513,4 +523,48 @@ void FileSharingHandler::handleDownload(Request& req, Response& resp)
resp.setFail("Couldn't download file");
}
void FileSharingHandler::handleGetDownloadDirectory( Request& /*req*/,
Response& resp )
{
std::string dlDir = mRsFiles->getDownloadDirectory();
resp.mDataStream << makeKeyValueReference("download_directory", dlDir);
resp.setOk();
}
void FileSharingHandler::handleSetDownloadDirectory( Request& req,
Response& resp )
{
std::string dlDir;
req.mStream << makeKeyValueReference("download_directory", dlDir);
if(dlDir.empty()) resp.setFail("missing download_directory");
else
{
mRsFiles->setDownloadDirectory(dlDir);
resp.setOk();
}
}
void FileSharingHandler::handleGetPartialsDirectory( Request& /*req*/,
Response& resp )
{
std::string partialsDir = mRsFiles->getPartialsDirectory();
resp.mDataStream << makeKeyValueReference("partials_directory", partialsDir);
resp.setOk();
}
void FileSharingHandler::handleSetPartialsDirectory( Request& req,
Response& resp )
{
std::string partialsDir;
req.mStream << makeKeyValueReference("partials_directory", partialsDir);
if(partialsDir.empty()) resp.setFail("missing partials_directory");
else
{
mRsFiles->setPartialsDirectory(partialsDir);
resp.setOk();
}
}
} // namespace resource_api

View File

@ -57,6 +57,12 @@ private:
void handleDownload(Request& req, Response& resp);
void handleGetDownloadDirectory(Request& req, Response& resp);
void handleSetDownloadDirectory(Request& req, Response& resp);
void handleGetPartialsDirectory(Request& req, Response& resp);
void handleSetPartialsDirectory(Request& req, Response& resp);
/// Token indicating change in local shared files
StateToken mLocalDirStateToken;

View File

@ -15,6 +15,14 @@ TransfersHandler::TransfersHandler(StateTokenServer *sts, RsFiles *files, RsPeer
addResourceHandler("downloads", this, &TransfersHandler::handleDownloads);
addResourceHandler("uploads", this, &TransfersHandler::handleUploads);
addResourceHandler("control_download", this, &TransfersHandler::handleControlDownload);
addResourceHandler( "set_file_destination_directory", this,
&TransfersHandler::handleSetFileDestinationDirectory );
addResourceHandler( "set_file_destination_name", this,
&TransfersHandler::handleSetFileDestinationName );
addResourceHandler( "set_file_chunk_strategy", this,
&TransfersHandler::handleSetFileChunkStrategy );
mStateToken = mStateTokenServer->getNewToken();
mStateTokenServer->registerTickClient(this);
mNotify.registerNotifyClient(this);
@ -288,4 +296,58 @@ void TransfersHandler::handleUploads(Request & /* req */, Response &resp)
resp.setOk();
}
void TransfersHandler::handleSetFileDestinationDirectory( Request& req,
Response& resp )
{
mStateTokenServer->replaceToken(mStateToken);
std::string hashString;
std::string newPath;
req.mStream << makeKeyValueReference("path", newPath);
req.mStream << makeKeyValueReference("hash", hashString);
RsFileHash hash(hashString);
if (mFiles->setDestinationDirectory(hash, newPath)) resp.setOk();
else resp.setFail();
}
void TransfersHandler::handleSetFileDestinationName( Request& req,
Response& resp )
{
mStateTokenServer->replaceToken(mStateToken);
std::string hashString;
std::string newName;
req.mStream << makeKeyValueReference("name", newName);
req.mStream << makeKeyValueReference("hash", hashString);
RsFileHash hash(hashString);
if (mFiles->setDestinationName(hash, newName)) resp.setOk();
else resp.setFail();
}
void TransfersHandler::handleSetFileChunkStrategy(Request& req, Response& resp)
{
mStateTokenServer->replaceToken(mStateToken);
std::string hashString;
std::string newChunkStrategyStr;
req.mStream << makeKeyValueReference("chuck_stategy", newChunkStrategyStr);
req.mStream << makeKeyValueReference("hash", hashString);
RsFileHash hash(hashString);
FileChunksInfo::ChunkStrategy newStrategy =
FileChunksInfo::CHUNK_STRATEGY_PROGRESSIVE;
if ( newChunkStrategyStr == "streaming" )
newStrategy = FileChunksInfo::CHUNK_STRATEGY_STREAMING;
else if ( newChunkStrategyStr == "random" )
newStrategy = FileChunksInfo::CHUNK_STRATEGY_RANDOM;
else if ( newChunkStrategyStr == "progressive" )
newStrategy = FileChunksInfo::CHUNK_STRATEGY_PROGRESSIVE;
if (mFiles->setChunkStrategy(hash, newStrategy)) resp.setOk();
else resp.setFail();
}
} // namespace resource_api

View File

@ -30,6 +30,9 @@ private:
void handleControlDownload(Request& req, Response& resp);
void handleDownloads(Request& req, Response& resp);
void handleUploads(Request& req, Response& resp);
void handleSetFileDestinationDirectory(Request& req, Response& resp);
void handleSetFileDestinationName(Request& req, Response& resp);
void handleSetFileChunkStrategy(Request& req, Response& resp);
StateTokenServer* mStateTokenServer;
RsFiles* mFiles;

View File

@ -2,50 +2,30 @@
TEMPLATE = lib
CONFIG += staticlib
CONFIG += create_prl
CONFIG -= qt
TARGET = resapi
TARGET_PRL = libresapi
DESTDIR = lib
DEPENDPATH += ../../libretroshare/src/
!include(use_libresapi.pri):error("Including")
# when rapidjson is mainstream on all distribs, we will not need the sources anymore
# in the meantime, they are part of the RS directory so that it is always possible to find them
INCLUDEPATH += ../../rapidjson-1.1.0
INCLUDEPATH += ../../libretroshare/src
libresapilocalserver {
SOURCES *= api/ApiServerLocal.cpp
HEADERS *= api/ApiServerLocal.h
}
retroshare_android_service {
win32 {
OBJECTS_DIR = temp/obj
LIBS_DIR = $$PWD/../../libs/lib
LIBS += $$OUT_PWD/../../libretroshare/src/lib/libretroshare.a
LIBS += $$OUT_PWD/../../openpgpsdk/src/lib/libops.a
for(lib, LIB_DIR):LIBS += -L"$$lib"
for(bin, BIN_DIR):LIBS += -L"$$bin"
LIBS += -lssl -lcrypto -lpthread -lminiupnpc -lz -lws2_32
LIBS += -luuid -lole32 -liphlpapi -lcrypt32 -lgdi32
LIBS += -lwinmm
DEFINES *= WINDOWS_SYS WIN32_LEAN_AND_MEAN _USE_32BIT_TIME_T
DEPENDPATH += . $$INC_DIR
INCLUDEPATH += . $$INC_DIR
greaterThan(QT_MAJOR_VERSION, 4) {
# Qt 5
RC_INCLUDEPATH += $$_PRO_FILE_PWD_/../../libretroshare/src
} else {
# Qt 4
QMAKE_RC += --include-dir=$$_PRO_FILE_PWD_/../../libretroshare/src
}
}
libresapi_settings {
SOURCES += api/SettingsHandler.cpp
HEADERS += api/SettingsHandler.h
}
libresapihttpserver {
CONFIG += libmicrohttpd
unix {
webui_files.path = "$${DATA_DIR}/webui"
@ -121,20 +101,13 @@ libresapihttpserver {
DEFINES *= WINDOWS_SYS
INCLUDEPATH += . $$INC_DIR
greaterThan(QT_MAJOR_VERSION, 4) {
# Qt 5
PRO_PATH=$$shell_path($$_PRO_FILE_PWD_)
MAKE_SRC=$$shell_path($$PRO_PATH/webui-src/make-src)
} else {
# Qt 4
PRO_PATH=$$replace(_PRO_FILE_PWD_, /, \\)
MAKE_SRC=$$PRO_PATH\\webui-src\\make-src
}
PRO_PATH=$$shell_path($$_PRO_FILE_PWD_)
MAKE_SRC=$$shell_path($$PRO_PATH/webui-src/make-src)
#create_webfiles.commands = $$MAKE_SRC\\build.bat $$PRO_PATH
#QMAKE_EXTRA_TARGETS += create_webfiles
#PRE_TARGETDEPS += create_webfiles
QMAKE_POST_LINK=$$MAKE_SRC\\build.bat $$PRO_PATH
#create_webfiles.commands = $$MAKE_SRC\\build.bat $$PRO_PATH
#QMAKE_EXTRA_TARGETS += create_webfiles
#PRE_TARGETDEPS += create_webfiles
QMAKE_POST_LINK=$$MAKE_SRC\\build.bat $$PRO_PATH
# create dummy files
system($$MAKE_SRC\\init.bat .)
@ -211,18 +184,3 @@ HEADERS += \
api/ChannelsHandler.h \
api/StatsHandler.h \
api/FileSharingHandler.h
libresapilocalserver {
CONFIG *= qt
QT *= network
SOURCES *= api/ApiServerLocal.cpp
HEADERS *= api/ApiServerLocal.h
}
qt_dependencies {
CONFIG *= qt
QT *= core
SOURCES += api/SettingsHandler.cpp
HEADERS += api/SettingsHandler.h
}

View File

@ -0,0 +1,37 @@
DEPENDPATH *= $$system_path($$clean_path($$PWD/../../libresapi/src))
INCLUDEPATH *= $$system_path($$clean_path($${PWD}/../../libresapi/src))
LIBS *= -L$$system_path($$clean_path($${OUT_PWD}/../../libresapi/src/lib/)) -lresapi
!equals(TARGET, resapi):PRE_TARGETDEPS *= $$system_path($$clean_path($${OUT_PWD}/../../libresapi/src/lib/libresapi.a))
!include("../../libretroshare/src/use_libretroshare.pri"):error("Including")
sLibs =
mLibs =
dLibs =
libresapilocalserver {
CONFIG *= qt
QT *= network
}
libresapi_settings {
CONFIG *= qt
QT *= core
}
libresapihttpserver {
mLibs *= microhttpd
}
static {
sLibs *= $$mLibs
} else {
dLibs *= $$mLibs
}
LIBS += $$linkStaticLibs(sLibs)
PRE_TARGETDEPS += $$pretargetStaticLibs(sLibs)
LIBS += $$linkDynamicLibs(dLibs)

View File

@ -30,7 +30,7 @@
typedef RsPeerId ChatLobbyVirtualPeerId ;
class RsItem ;
struct RsItem;
class p3HistoryMgr ;
class p3IdService ;
class p3ServiceControl;

View File

@ -205,11 +205,8 @@ void RsPrivateChatMsgConfigItem::get(RsChatMsgItem *ci)
ci->recvTime = recvTime;
}
/* Necessary to serialize `store` that is an STL container with RsChatMsgItem
* inside which is a subtype of RsItem */
RS_REGISTER_ITEM_TYPE(RsChatMsgItem)
void PrivateOugoingMapItem::serial_process(
RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx )
{ RS_REGISTER_SERIAL_MEMBER(store); }
{ RS_SERIAL_PROCESS(store); }

View File

@ -4,6 +4,7 @@
* BitDht interface for RetroShare.
*
* Copyright 2009-2010 by Robert Fernie.
* Copyright (C) 2015-2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -184,18 +185,24 @@ bool p3BitDht::dropPeer(const RsPeerId& pid)
********************************* Basic Peer Details *************************************
******************************************************************************************/
int p3BitDht::addBadPeer(const struct sockaddr_storage &addr, uint32_t /*reason*/, uint32_t /*flags*/, uint32_t /*age*/)
int p3BitDht::addBadPeer( const sockaddr_storage &addr, uint32_t /*reason*/,
uint32_t /*flags*/, uint32_t /*age*/ )
{
//mUdpBitDht->updateKnownPeer(&id, 0, bdflags);
struct sockaddr_in addrv4;
if (addr.ss_family != AF_INET)
sockaddr_in addrv4;
sockaddr_storage tmpaddr;
sockaddr_storage_copy(addr, tmpaddr);
if(!sockaddr_storage_ipv6_to_ipv4(tmpaddr))
{
std::cerr << "p3BitDht::addBadPeer() cannot handle IPV6 Yet, aborting";
std::cerr << std::endl;
abort();
std::cerr << __PRETTY_FUNCTION__ << " Error: got non IPv4 address!"
<< std::endl;
sockaddr_storage_dump(addr);
print_stacktrace();
return -EINVAL;
}
struct sockaddr_in *ap = (struct sockaddr_in *) &addr;
struct sockaddr_in *ap = (struct sockaddr_in *) &tmpaddr;
// convert.
addrv4.sin_family = ap->sin_family;
@ -216,39 +223,30 @@ int p3BitDht::addBadPeer(const struct sockaddr_storage &addr, uint32_t /*reason*
}
int p3BitDht::addKnownPeer(const RsPeerId &pid, const struct sockaddr_storage &addr, uint32_t flags)
int p3BitDht::addKnownPeer( const RsPeerId &pid,
const sockaddr_storage &addr, uint32_t flags )
{
struct sockaddr_in addrv4;
sockaddr_clear(&addrv4);
sockaddr_in addrv4;
sockaddr_clear(&addrv4);
if (addr.ss_family != AF_INET)
{
if(addr.ss_family != AF_UNSPEC)
{
std::cerr << "p3BitDht::addKnownPeer() Warning! Non IPv4 Address - Cannot handle IPV6 Yet. addr.ss_family=" << addr.ss_family;
std::cerr << std::endl;
}
if (flags & NETASSIST_KNOWN_PEER_ONLINE)
{
std::cerr << "p3BitDht::addKnownPeer() Non IPv4 Address & ONLINE. Abort()ing.";
std::cerr << std::endl;
abort();
}
}
else
sockaddr_storage tmpaddr;
sockaddr_storage_copy(addr, tmpaddr);
if( !sockaddr_storage_isnull(addr) &&
!sockaddr_storage_ipv6_to_ipv4(tmpaddr) )
{
// convert.
struct sockaddr_in *ap = (struct sockaddr_in *) &addr;
addrv4.sin_family = ap->sin_family;
addrv4.sin_addr = ap->sin_addr;
addrv4.sin_port = ap->sin_port;
std::cerr << __PRETTY_FUNCTION__ << " Error: got non IPv4 address!"
<< std::endl;
sockaddr_storage_dump(addr);
print_stacktrace();
return -EINVAL;
}
// convert.
struct sockaddr_in *ap = (struct sockaddr_in *) &tmpaddr;
addrv4.sin_family = ap->sin_family;
addrv4.sin_addr = ap->sin_addr;
addrv4.sin_port = ap->sin_port;
int p3type = 0;
int bdflags = 0;
bdId id;
@ -295,7 +293,7 @@ int p3BitDht::addKnownPeer(const RsPeerId &pid, const struct sockaddr_storage &a
if (!isOwnId)
{
RsStackMutex stack(dhtMtx); /********* LOCKED *********/
RS_STACK_MUTEX(dhtMtx);
DhtPeerDetails *dpd = addInternalPeer_locked(pid, p3type);

View File

@ -623,7 +623,7 @@ bool LocalDirectoryStorage::locked_getFileSharingPermissions(const EntryIndex& i
if(it == mLocalDirs.end())
{
std::cerr << "(EE) very weird bug: base directory \"" << base_dir << "\" not found in shared dir list." << std::endl;
std::cerr << "(II) base directory \"" << base_dir << "\" not found in shared dir list." << std::endl;
return false ;
}

View File

@ -73,10 +73,23 @@ void LocalDirectoryUpdater::data_tick()
{
if(now > mDelayBetweenDirectoryUpdates + mLastSweepTime)
{
if(sweepSharedDirectories())
bool some_files_not_ready = false ;
if(sweepSharedDirectories(some_files_not_ready))
{
mNeedsFullRecheck = false;
mLastSweepTime = now ;
if(some_files_not_ready)
{
mNeedsFullRecheck = true ;
mLastSweepTime = now - mDelayBetweenDirectoryUpdates + 60 ; // retry 20 secs from now
std::cerr << "(II) some files being modified. Will re-scan in 60 secs." << std::endl;
}
else
{
mNeedsFullRecheck = false ;
mLastSweepTime = now ;
}
mSharedDirectories->notifyTSChanged();
mForceUpdate = false ;
}
@ -111,7 +124,7 @@ void LocalDirectoryUpdater::forceUpdate()
mHashCache->togglePauseHashingProcess();
}
bool LocalDirectoryUpdater::sweepSharedDirectories()
bool LocalDirectoryUpdater::sweepSharedDirectories(bool& some_files_not_ready)
{
if(mHashSalt.isNull())
{
@ -158,8 +171,8 @@ bool LocalDirectoryUpdater::sweepSharedDirectories()
#endif
existing_dirs.insert(RsDirUtil::removeSymLinks(stored_dir_it.name()));
recursUpdateSharedDir(stored_dir_it.name(), *stored_dir_it,existing_dirs,1) ; // here we need to use the list that was stored, instead of the shared dir list, because the two
// are not necessarily in the same order.
recursUpdateSharedDir(stored_dir_it.name(), *stored_dir_it,existing_dirs,1,some_files_not_ready) ; // here we need to use the list that was stored, instead of the shared dir list, because the two
// are not necessarily in the same order.
}
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
@ -168,7 +181,7 @@ bool LocalDirectoryUpdater::sweepSharedDirectories()
return true ;
}
void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_path, DirectoryStorage::EntryIndex indx,std::set<std::string>& existing_directories,uint32_t current_depth)
void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_path, DirectoryStorage::EntryIndex indx,std::set<std::string>& existing_directories,uint32_t current_depth,bool& some_files_not_ready)
{
#ifdef DEBUG_LOCAL_DIR_UPDATER
std::cerr << "[directory storage] parsing directory " << cumulated_path << ", index=" << indx << std::endl;
@ -187,6 +200,8 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
return;
}
time_t now = time(NULL) ;
if(mNeedsFullRecheck || dirIt.dir_modtime() > dir_local_mod_time) // the > is because we may have changed the virtual name, and therefore the TS wont match.
// we only want to detect when the directory has changed on the disk
{
@ -200,11 +215,23 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
{
switch(dirIt.file_type())
{
case librs::util::FolderIterator::TYPE_FILE: subfiles[dirIt.file_name()].modtime = dirIt.file_modtime() ;
subfiles[dirIt.file_name()].size = dirIt.file_size();
case librs::util::FolderIterator::TYPE_FILE:
if(dirIt.file_modtime() + MIN_TIME_AFTER_LAST_MODIFICATION < now)
{
subfiles[dirIt.file_name()].modtime = dirIt.file_modtime() ;
subfiles[dirIt.file_name()].size = dirIt.file_size();
#ifdef DEBUG_LOCAL_DIR_UPDATER
std::cerr << " adding sub-file \"" << dirIt.file_name() << "\"" << std::endl;
std::cerr << " adding sub-file \"" << dirIt.file_name() << "\"" << std::endl;
#endif
}
else
{
some_files_not_ready = true ;
std::cerr << "(WW) file " << dirIt.file_fullpath() << " is probably being modified. Keeping it for later." << std::endl;
}
break;
case librs::util::FolderIterator::TYPE_DIR:
@ -276,7 +303,7 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
#ifdef DEBUG_LOCAL_DIR_UPDATER
std::cerr << " recursing into " << stored_dir_it.name() << std::endl;
#endif
recursUpdateSharedDir(cumulated_path + "/" + stored_dir_it.name(), *stored_dir_it,existing_directories,current_depth+1) ;
recursUpdateSharedDir(cumulated_path + "/" + stored_dir_it.name(), *stored_dir_it,existing_directories,current_depth+1,some_files_not_ready) ;
}
}

View File

@ -70,8 +70,8 @@ protected:
virtual void hash_callback(uint32_t client_param, const std::string& name, const RsFileHash& hash, uint64_t size);
virtual bool hash_confirm(uint32_t client_param) ;
void recursUpdateSharedDir(const std::string& cumulated_path, DirectoryStorage::EntryIndex indx, std::set<std::string>& existing_directories, uint32_t current_depth);
bool sweepSharedDirectories();
void recursUpdateSharedDir(const std::string& cumulated_path, DirectoryStorage::EntryIndex indx, std::set<std::string>& existing_directories, uint32_t current_depth,bool& files_not_ready);
bool sweepSharedDirectories(bool &some_files_not_ready);
private:
bool filterFile(const std::string& fname) const ; // reponds true if the file passes the ignore lists test.

View File

@ -34,16 +34,16 @@ static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORIES_SWEEP = 60 ; // 60 se
static const uint32_t DELAY_BEFORE_DELETE_NON_EMPTY_REMOTE_DIR = 60*24*86400 ; // delete non empty remoe directories after 60 days of inactivity
static const uint32_t DELAY_BEFORE_DELETE_EMPTY_REMOTE_DIR = 5*24*86400 ; // delete empty remote directories after 5 days of inactivity
static const std::string HASH_CACHE_DURATION_SS = "HASH_CACHE_DURATION" ; // key string to store hash remembering time
static const std::string WATCH_FILE_DURATION_SS = "WATCH_FILES_DELAY" ; // key to store delay before re-checking for new files
static const std::string WATCH_FILE_ENABLED_SS = "WATCH_FILES_ENABLED"; // key to store ON/OFF flags for file whatch
static const std::string FOLLOW_SYMLINKS_SS = "FOLLOW_SYMLINKS"; // dereference symbolic links, or just ignore them.
static const std::string IGNORE_DUPLICATES = "IGNORE_DUPLICATES"; // do not index files that are referenced multiple times because of links
static const std::string WATCH_HASH_SALT_SS = "WATCH_HASH_SALT"; // Salt that is used to hash directory names
static const std::string IGNORED_PREFIXES_SS = "IGNORED_PREFIXES"; // ignore file prefixes
static const std::string IGNORED_SUFFIXES_SS = "IGNORED_SUFFIXES"; // ignore file suffixes
static const std::string IGNORE_LIST_FLAGS_SS = "IGNORED_FLAGS"; // ignore file flags
static const std::string MAX_SHARE_DEPTH = "MAX_SHARE_DEPTH"; // maximum depth of shared directories
static const std::string HASH_CACHE_DURATION_SS = "HASH_CACHE_DURATION" ; // key string to store hash remembering time
static const std::string WATCH_FILE_DURATION_SS = "WATCH_FILES_DELAY" ; // key to store delay before re-checking for new files
static const std::string WATCH_FILE_ENABLED_SS = "WATCH_FILES_ENABLED"; // key to store ON/OFF flags for file whatch
static const std::string FOLLOW_SYMLINKS_SS = "FOLLOW_SYMLINKS"; // dereference symbolic links, or just ignore them.
static const std::string IGNORE_DUPLICATES = "IGNORE_DUPLICATES"; // do not index files that are referenced multiple times because of links
static const std::string WATCH_HASH_SALT_SS = "WATCH_HASH_SALT"; // Salt that is used to hash directory names
static const std::string IGNORED_PREFIXES_SS = "IGNORED_PREFIXES"; // ignore file prefixes
static const std::string IGNORED_SUFFIXES_SS = "IGNORED_SUFFIXES"; // ignore file suffixes
static const std::string IGNORE_LIST_FLAGS_SS = "IGNORED_FLAGS"; // ignore file flags
static const std::string MAX_SHARE_DEPTH = "MAX_SHARE_DEPTH"; // maximum depth of shared directories
static const std::string FILE_SHARING_DIR_NAME = "file_sharing" ; // hard-coded directory name to store friend file lists, hash cache, etc.
static const std::string HASH_CACHE_FILE_NAME = "hash_cache.bin" ; // hard-coded directory name to store encrypted hash cache.
@ -51,6 +51,7 @@ static const std::string LOCAL_SHARED_DIRS_FILE_NAME = "local_dir_hierarchy.bin"
static const uint32_t MIN_INTERVAL_BETWEEN_HASH_CACHE_SAVE = 20 ; // never save hash cache more often than every 20 secs.
static const uint32_t MIN_INTERVAL_BETWEEN_REMOTE_DIRECTORY_SAVE = 23 ; // never save remote directories more often than this
static const uint32_t MIN_TIME_AFTER_LAST_MODIFICATION = 20 ; // never hash a file that is just being modified, otherwise we end up with a corrupted hash
static const uint32_t MAX_DIR_SYNC_RESPONSE_DATA_SIZE = 20000 ; // Maximum RsItem data size in bytes for serialised directory transmission
static const uint32_t DEFAULT_HASH_STORAGE_DURATION_DAYS = 30 ; // remember deleted/inaccessible files for 30 days

View File

@ -1,3 +1,28 @@
/*
* RetroShare C++ File lists IO methods.
*
* file_sharing/file_tree.h
*
* Copyright 2017 by csoler
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare.project@gmail.com".
*
*/
#include "retroshare/rsfiles.h"
class FileTreeImpl: public FileTree

View File

@ -39,6 +39,7 @@
static const uint32_t SOURCE_CHUNK_MAP_UPDATE_PERIOD = 60 ; //! TTL for chunkmap info
static const uint32_t INACTIVE_CHUNK_TIME_LAPSE = 3600 ; //! TTL for an inactive chunk
static const uint32_t FT_CHUNKMAP_MAX_CHUNK_JUMP = 50 ; //! Maximum chunk jump in progressive DL mode
static const uint32_t FT_CHUNKMAP_MAX_SLICE_REASK_DELAY = 10 ; //! Maximum time to re-ask a slice to another peer at end of transfer
std::ostream& operator<<(std::ostream& o,const ftChunk& c)
{
@ -120,7 +121,7 @@ void ChunkMap::setAvailabilityMap(const CompressedChunkMap& map)
}
}
void ChunkMap::dataReceived(const ftChunk::ChunkId& cid)
void ChunkMap::dataReceived(const ftChunk::OffsetInFile& cid)
{
// 1 - find which chunk contains the received data.
//
@ -139,7 +140,7 @@ void ChunkMap::dataReceived(const ftChunk::ChunkId& cid)
return ;
}
std::map<ftChunk::ChunkId,uint32_t>::iterator it(itc->second._slices.find(cid)) ;
std::map<ftChunk::OffsetInFile,ChunkDownloadInfo::SliceRequestInfo>::iterator it(itc->second._slices.find(cid)) ;
if(it == itc->second._slices.end())
{
@ -150,8 +151,8 @@ void ChunkMap::dataReceived(const ftChunk::ChunkId& cid)
return ;
}
_total_downloaded += it->second ;
itc->second._remains -= it->second ;
_total_downloaded += it->second.size ;
itc->second._remains -= it->second.size ;
itc->second._slices.erase(it) ;
itc->second._last_data_received = time(NULL) ; // update time stamp
@ -256,6 +257,38 @@ void ChunkMap::setChunkCheckingResult(uint32_t chunk_number,bool check_succeeded
}
}
bool ChunkMap::reAskPendingChunk( const RsPeerId& peer_id,
uint32_t /*size_hint*/,
uint64_t& offset, uint32_t& size)
{
// make sure that we're at the end of the file. No need to be too greedy in the middle of it.
for(uint32_t i=0;i<_map.size();++i)
if(_map[i] == FileChunksInfo::CHUNK_OUTSTANDING)
return false ;
time_t now = time(NULL);
for(std::map<uint32_t,ChunkDownloadInfo>::iterator it(_slices_to_download.begin());it!=_slices_to_download.end();++it)
for(std::map<ftChunk::OffsetInFile,ChunkDownloadInfo::SliceRequestInfo >::iterator it2(it->second._slices.begin());it2!=it->second._slices.end();++it2)
if(it2->second.request_time + FT_CHUNKMAP_MAX_SLICE_REASK_DELAY < now && it2->second.peers.end()==it2->second.peers.find(peer_id))
{
offset = it2->first;
size = it2->second.size ;
#ifdef DEBUG_FTCHUNK
std::cerr << "*** ChunkMap::reAskPendingChunk: re-asking slice (" << offset << ", " << size << ") to peer " << peer_id << std::endl;
#endif
it2->second.request_time = now ;
it2->second.peers.insert(peer_id) ;
return true ;
}
return false ;
}
// Warning: a chunk may be empty, but still being downloaded, so asking new slices from it
// will produce slices of size 0. This happens at the end of each chunk.
// --> I need to get slices from the next chunk, in such a case.
@ -295,7 +328,7 @@ bool ChunkMap::getDataChunk(const RsPeerId& peer_id,uint32_t size_hint,ftChunk&
ChunkDownloadInfo& cdi(_slices_to_download[c]) ;
falsafe_it = pit ; // let's keep this one just in case.
if(cdi._slices.rbegin() != cdi._slices.rend() && cdi._slices.rbegin()->second*0.7 <= (float)size_hint)
if(cdi._slices.rbegin() != cdi._slices.rend() && cdi._slices.rbegin()->second.size*0.7 <= (float)size_hint)
{
it = pit ;
#ifdef DEBUG_FTCHUNK
@ -348,9 +381,14 @@ bool ChunkMap::getDataChunk(const RsPeerId& peer_id,uint32_t size_hint,ftChunk&
// Get the first slice of the chunk, that is at most of length size
//
it->second.getSlice(size_hint,chunk) ;
_slices_to_download[chunk.offset/_chunk_size]._slices[chunk.id] = chunk.size ;
_slices_to_download[chunk.offset/_chunk_size]._last_data_received = time(NULL) ;
ChunkDownloadInfo::SliceRequestInfo& r(_slices_to_download[chunk.offset/_chunk_size]._slices[chunk.id]);
r.size = chunk.size ;
r.request_time = time(NULL);
r.peers.insert(peer_id);
chunk.peer_id = peer_id ;
#ifdef DEBUG_FTCHUNK
@ -362,7 +400,7 @@ bool ChunkMap::getDataChunk(const RsPeerId& peer_id,uint32_t size_hint,ftChunk&
return true ;
}
void ChunkMap::removeInactiveChunks(std::vector<ftChunk::ChunkId>& to_remove)
void ChunkMap::removeInactiveChunks(std::vector<ftChunk::OffsetInFile>& to_remove)
{
to_remove.clear() ;
time_t now = time(NULL) ;
@ -377,7 +415,7 @@ void ChunkMap::removeInactiveChunks(std::vector<ftChunk::ChunkId>& to_remove)
//
std::map<ChunkNumber,ChunkDownloadInfo>::iterator tmp(it) ;
for(std::map<ftChunk::ChunkId,uint32_t>::const_iterator it2(it->second._slices.begin());it2!=it->second._slices.end();++it2)
for(std::map<ftChunk::OffsetInFile,ChunkDownloadInfo::SliceRequestInfo>::const_iterator it2(it->second._slices.begin());it2!=it->second._slices.end();++it2)
to_remove.push_back(it2->first) ;
_map[it->first] = FileChunksInfo::CHUNK_OUTSTANDING ; // reset the chunk

View File

@ -32,7 +32,7 @@ class ftController ;
class ftChunk
{
public:
typedef uint64_t ChunkId ;
typedef uint64_t OffsetInFile ;
ftChunk():offset(0), size(0), id(0), ts(0),ref_cnt(NULL) {}
@ -40,7 +40,7 @@ class ftChunk
uint64_t offset; // current offset of the slice
uint64_t size; // size remaining to download
ChunkId id ; // id of the chunk. Equal to the starting offset of the chunk
OffsetInFile id ; // id of the chunk. Equal to the starting offset of the chunk
time_t ts; // time of last data received
int *ref_cnt; // shared counter of number of sub-blocks. Used when a slice gets split.
RsPeerId peer_id ;
@ -70,10 +70,17 @@ class Chunk
uint64_t _end ; // const
};
class ChunkDownloadInfo
struct ChunkDownloadInfo
{
public:
std::map<ftChunk::ChunkId,uint32_t> _slices ;
struct SliceRequestInfo
{
uint32_t size ; // size of the slice
time_t request_time ; // last request time
std::set<RsPeerId> peers ; // peers the slice was requested to. Normally only one, except at the end of the file.
};
std::map<ftChunk::OffsetInFile,SliceRequestInfo> _slices ;
uint32_t _remains ;
time_t _last_data_received ;
};
@ -109,24 +116,29 @@ class ChunkMap
/// destructor
virtual ~ChunkMap() {}
/// Returns an slice of data to be asked to the peer within a chunk.
/// Returns an slice of data to be asked to the peer within a chunk.
/// If a chunk is already been downloaded by this peer, take a slice at
/// the beginning of this chunk, or at least where it starts.
/// If not, randomly/streamly select a new chunk depending on the strategy.
/// adds an entry in the chunk_ids map, and sets up 1 interval for it.
/// the chunk should be available from the designated peer.
/// If not, randomly/streamly select a new chunk depending on the strategy.
/// adds an entry in the chunk_ids map, and sets up 1 interval for it.
/// the chunk should be available from the designated peer.
/// On return:
/// - source_chunk_map_needed = true if the source map should be asked
virtual bool getDataChunk(const RsPeerId& peer_id,uint32_t size_hint,ftChunk& chunk,bool& source_chunk_map_needed) ;
/// Notify received a slice of data. This needs to
/// - carve in the map of chunks what is received, what is not.
/// - tell which chunks are finished. For this, each interval must know what chunk number it has been attributed
/// when the interval is split in the middle, the number of intervals for the chunk is increased. If the interval is
/// completely covered by the data, the interval number is decreased.
/// Returns an already pending slice that was being downloaded but hasn't arrived yet. This is mostly used at the end of the file
/// in order to re-ask pendign slices to active peers while slow peers take a lot of time to send their remaining slices.
///
bool reAskPendingChunk(const RsPeerId& peer_id,uint32_t size_hint,uint64_t& offset,uint32_t& size);
virtual void dataReceived(const ftChunk::ChunkId& c_id) ;
/// Notify received a slice of data. This needs to
/// - carve in the map of chunks what is received, what is not.
/// - tell which chunks are finished. For this, each interval must know what chunk number it has been attributed
/// when the interval is split in the middle, the number of intervals for the chunk is increased. If the interval is
/// completely covered by the data, the interval number is decreased.
virtual void dataReceived(const ftChunk::OffsetInFile& c_id) ;
/// Decides how chunks are selected.
/// STREAMING: the 1st chunk is always returned
@ -163,7 +175,7 @@ class ChunkMap
/// Remove active chunks that have not received any data for the last 60 seconds, and return
/// the list of slice numbers that should be canceled.
void removeInactiveChunks(std::vector<ftChunk::ChunkId>& to_remove) ;
void removeInactiveChunks(std::vector<ftChunk::OffsetInFile>& to_remove) ;
/// Updates the peer's availablility map
//
@ -214,7 +226,7 @@ class ChunkMap
uint32_t _chunk_size ; //! Size of chunks. Common to all chunks.
FileChunksInfo::ChunkStrategy _strategy ; //! how do we allocate new chunks
std::map<RsPeerId,Chunk> _active_chunks_feed ; //! vector of chunks being downloaded. Exactly 1 chunk per peer.
std::map<ChunkNumber,ChunkDownloadInfo> _slices_to_download ; //! list of (slice id,slice size)
std::map<ChunkNumber,ChunkDownloadInfo> _slices_to_download ; //! list of (slice offset,slice size) currently being downloaded
std::vector<FileChunksInfo::ChunkState> _map ; //! vector of chunk state over the whole file
std::map<RsPeerId,SourceChunksInfo> _peers_chunks_availability ; //! what does each source peer have
uint64_t _total_downloaded ; //! completion for the file

View File

@ -88,16 +88,13 @@ ftFileControl::ftFileControl()
return;
}
ftFileControl::ftFileControl(std::string fname,
std::string tmppath, std::string dest,
uint64_t size, const RsFileHash &hash, TransferRequestFlags flags,
ftFileCreator *fc, ftTransferModule *tm)
:mName(fname), mCurrentPath(tmppath), mDestination(dest),
mTransfer(tm), mCreator(fc), mState(DOWNLOADING), mHash(hash),
mSize(size), mFlags(flags), mCreateTime(0), mQueuePriority(0), mQueuePosition(0)
{
return;
}
ftFileControl::ftFileControl(const std::string& fname, const std::string& tmppath, const std::string& dest
, uint64_t size, const RsFileHash &hash, TransferRequestFlags flags
, ftFileCreator *fc, ftTransferModule *tm)
: mName(fname), mCurrentPath(tmppath), mDestination(dest)
, mTransfer(tm), mCreator(fc), mState(DOWNLOADING), mHash(hash)
, mSize(size), mFlags(flags), mCreateTime(0), mQueuePriority(0), mQueuePosition(0)
{}
ftController::ftController(ftDataMultiplex *dm, p3ServiceControl *sc, uint32_t ftServiceId)
: p3Config(),
@ -1475,24 +1472,24 @@ bool ftController::setPartialsDirectory(std::string path)
/* check it is not a subdir of download / shared directories (BAD) - TODO */
{
RsStackMutex stack(ctrlMutex);
RsStackMutex stack(ctrlMutex);
path = RsDirUtil::convertPathToUnix(path);
path = RsDirUtil::convertPathToUnix(path);
if (!path.find(mDownloadPath)) {
return false;
}
if (path.find(mDownloadPath) != std::string::npos) {
return false;
}
if (rsFiles) {
std::list<SharedDirInfo>::iterator it;
std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs);
for (it = dirs.begin(); it != dirs.end(); ++it) {
if (!path.find((*it).filename)) {
return false;
}
}
}
if (rsFiles) {
std::list<SharedDirInfo>::iterator it;
std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs);
for (it = dirs.begin(); it != dirs.end(); ++it) {
if (path.find((*it).filename) != std::string::npos) {
return false;
}
}
}
}
/* check if it exists */

View File

@ -73,9 +73,9 @@ class ftFileControl
};
ftFileControl();
ftFileControl(std::string fname, std::string tmppath, std::string dest,
uint64_t size, const RsFileHash& hash, TransferRequestFlags flags,
ftFileCreator *fc, ftTransferModule *tm);
ftFileControl( const std::string& fname, const std::string& tmppath, const std::string& dest
, uint64_t size, const RsFileHash& hash, TransferRequestFlags flags
, ftFileCreator *fc, ftTransferModule *tm);
std::string mName;
std::string mCurrentPath; /* current full path (including name) */
@ -175,8 +175,8 @@ class ftController: public RsTickingThread, public pqiServiceMonitor, public p3C
void FileDownloads(std::list<RsFileHash> &hashs);
/* Directory Handling */
bool setDownloadDirectory(std::string path);
bool setPartialsDirectory(std::string path);
bool setDownloadDirectory(std::string path);
bool setPartialsDirectory(std::string path);
std::string getDownloadDirectory();
std::string getPartialsDirectory();
bool FileDetails(const RsFileHash &hash, FileInfo &info);

View File

@ -240,7 +240,7 @@ void ftFileCreator::removeInactiveChunks()
#ifdef FILE_DEBUG
std::cerr << "ftFileCreator::removeInactiveChunks(): looking for old chunks." << std::endl ;
#endif
std::vector<ftChunk::ChunkId> to_remove ;
std::vector<ftChunk::OffsetInFile> to_remove ;
chunkMap.removeInactiveChunks(to_remove) ;
@ -421,7 +421,9 @@ int ftFileCreator::locked_notifyReceived(uint64_t offset, uint32_t chunk_size)
if(!found)
{
#ifdef FILE_DEBUG
std::cerr << "ftFileCreator::locked_notifyReceived(): failed to find an active slice for " << offset << "+" << chunk_size << ", hash = " << hash << ": dropping data." << std::endl;
#endif
return 0; /* ignoring */
}
}
@ -531,7 +533,14 @@ bool ftFileCreator::getMissingChunk(const RsPeerId& peer_id,uint32_t size_hint,u
ftChunk chunk ;
if(!chunkMap.getDataChunk(peer_id,size_hint,chunk,source_chunk_map_needed))
{
// No chunks are available. We brutally re-ask an ongoing chunk to another peer.
if(chunkMap.reAskPendingChunk(peer_id,size_hint,offset,size))
return true ;
return false ;
}
#ifdef FILE_DEBUG
std::cerr << "ffc::getMissingChunk() Retrieved new chunk: " << chunk << std::endl ;

View File

@ -23,35 +23,40 @@
*
*/
#include <iostream>
#include <time.h>
#include "util/rsdebug.h"
#include "util/rsdir.h"
#include "util/rsprint.h"
#include "crypto/chacha20.h"
#include "retroshare/rstypes.h"
#include "retroshare/rspeers.h"
//const int ftserverzone = 29539;
#include "file_sharing/p3filelists.h"
#include "ft/ftturtlefiletransferitem.h"
#include "ft/ftserver.h"
#include "ft/ftextralist.h"
#include "ft/ftfilesearch.h"
#include "ft/ftcontroller.h"
#include "ft/ftfileprovider.h"
#include "ft/ftdatamultiplex.h"
//#include "ft/ftdwlqueue.h"
#include "turtle/p3turtle.h"
#include "pqi/p3notify.h"
#include "rsserver/p3face.h"
#include "ft/ftextralist.h"
#include "ft/ftfileprovider.h"
#include "ft/ftfilesearch.h"
#include "ft/ftserver.h"
#include "ft/ftturtlefiletransferitem.h"
#include "pqi/pqi.h"
#include "pqi/p3linkmgr.h"
#include "pqi/p3notify.h"
#include "pqi/pqi.h"
#include "retroshare/rstypes.h"
#include "retroshare/rspeers.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"
#include "util/rsdir.h"
#include "util/rsprint.h"
#include <iostream>
#include <time.h>
/***
* #define SERVER_DEBUG 1
* #define SERVER_DEBUG_CACHE 1
@ -145,9 +150,19 @@ void ftServer::SetupFtServer()
/* make Controller */
mFtController = new ftController(mFtDataplex, mServiceCtrl, getServiceInfo().mServiceType);
mFtController -> setFtSearchNExtra(mFtSearch, mFtExtra);
std::string tmppath = ".";
mFtController->setPartialsDirectory(tmppath);
mFtController->setDownloadDirectory(tmppath);
std::string emergencySaveDir = rsAccounts->PathAccountDirectory();
std::string emergencyPartialsDir = rsAccounts->PathAccountDirectory();
if (emergencySaveDir != "")
{
emergencySaveDir += "/";
emergencyPartialsDir += "/";
}
emergencySaveDir += "Downloads";
emergencyPartialsDir += "Partials";
mFtController->setDownloadDirectory(emergencySaveDir);
mFtController->setPartialsDirectory(emergencyPartialsDir);
/* complete search setup */
mFtSearch->addSearchMode(mFtExtra, RS_FILE_HINTS_EXTRA);
@ -412,9 +427,9 @@ void ftServer::requestDirUpdate(void *ref)
}
/* Directory Handling */
void ftServer::setDownloadDirectory(std::string path)
bool ftServer::setDownloadDirectory(std::string path)
{
mFtController->setDownloadDirectory(path);
return mFtController->setDownloadDirectory(path);
}
std::string ftServer::getDownloadDirectory()
@ -422,9 +437,9 @@ std::string ftServer::getDownloadDirectory()
return mFtController->getDownloadDirectory();
}
void ftServer::setPartialsDirectory(std::string path)
bool ftServer::setPartialsDirectory(std::string path)
{
mFtController->setPartialsDirectory(path);
return mFtController->setPartialsDirectory(path);
}
std::string ftServer::getPartialsDirectory()

View File

@ -208,8 +208,8 @@ public:
* Directory Handling
***/
virtual void requestDirUpdate(void *ref) ; // triggers the update of the given reference. Used when browsing.
virtual void setDownloadDirectory(std::string path);
virtual void setPartialsDirectory(std::string path);
virtual bool setDownloadDirectory(std::string path);
virtual bool setPartialsDirectory(std::string path);
virtual std::string getDownloadDirectory();
virtual std::string getPartialsDirectory();

View File

@ -34,7 +34,7 @@
#include <stdlib.h>
#include <grouter/grouteritems.h>
class RsItem ;
struct RsItem;
static const uint32_t GROUTER_CLIENT_SERVICE_DATA_STATUS_UNKNOWN = 0x0000 ; // unused.
static const uint32_t GROUTER_CLIENT_SERVICE_DATA_STATUS_RECEIVED = 0x0001 ; // sent when data has been received and a receipt is available.

View File

@ -31,7 +31,7 @@
#include "retroshare/rsgrouter.h"
#include "groutertypes.h"
class RsItem ;
struct RsItem;
// The routing matrix records the event clues received from each friend
//

View File

@ -541,7 +541,7 @@ if(itm == NULL)
void GRouterTunnelInfo::removeVirtualPeer(const TurtleVirtualPeerId& vpid)
{
std::set<TurtleVirtualPeerId,RsGRouterTransactionChunkItem*>::iterator it = virtual_peers.find(vpid) ;
std::set<TurtleVirtualPeerId>::iterator it = virtual_peers.find(vpid) ;
if(it == virtual_peers.end())
{

View File

@ -952,6 +952,8 @@ void RsDataService::locked_updateGrpMetaCache(const RsGxsGrpMetaData& meta)
if(it != mGrpMetaDataCache.end())
*(it->second) = meta ;
else
mGrpMetaDataCache[meta.mGroupId] = new RsGxsGrpMetaData(meta) ;
}
void RsDataService::locked_clearGrpMetaCache(const RsGxsGroupId& gid)
@ -1215,7 +1217,7 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
const RsGxsGroupId& grpId = mit->first;
// if vector empty then request all messages
const std::vector<RsGxsMessageId>& msgIdV = mit->second;
const std::set<RsGxsMessageId>& msgIdV = mit->second;
std::vector<RsNxsMsg*> msgSet;
if(msgIdV.empty()){
@ -1233,7 +1235,7 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
}else{
// request each grp
std::vector<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
std::set<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
for(; sit!=msgIdV.end();++sit){
const RsGxsMessageId& msgId = *sit;
@ -1303,7 +1305,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
const RsGxsGroupId& grpId = mit->first;
// if vector empty then request all messages
const std::vector<RsGxsMessageId>& msgIdV = mit->second;
const std::set<RsGxsMessageId>& msgIdV = mit->second;
std::vector<RsGxsMsgMetaData*> metaSet;
if(msgIdV.empty()){
@ -1319,7 +1321,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
}else{
// request each grp
std::vector<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
std::set<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
for(; sit!=msgIdV.end(); ++sit){
const RsGxsMessageId& msgId = *sit;
@ -1559,7 +1561,7 @@ int RsDataService::removeMsgs(const GxsMsgReq& msgIds)
for(; mit != msgIds.end(); ++mit)
{
const std::vector<RsGxsMessageId>& msgIdV = mit->second;
const std::set<RsGxsMessageId>& msgIdV = mit->second;
const RsGxsGroupId& grpId = mit->first;
// delete messages
@ -1620,7 +1622,7 @@ int RsDataService::retrieveGroupIds(std::vector<RsGxsGroupId> &grpIds)
return 1;
}
int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgIds)
int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgIds)
{
#ifdef RS_DATA_SERVICE_DEBUG_TIME
rstime::RsScopeTimer timer("");
@ -1641,7 +1643,7 @@ int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std
if(c->columnCount() != 1)
std::cerr << "(EE) ********* not retrieving all columns!!" << std::endl;
msgIds.push_back(RsGxsMessageId(msgId));
msgIds.insert(RsGxsMessageId(msgId));
valid = c->moveToNext();
#ifdef RS_DATA_SERVICE_DEBUG_TIME
@ -1672,8 +1674,8 @@ bool RsDataService::locked_removeMessageEntries(const GxsMsgReq& msgIds)
for(; mit != msgIds.end(); ++mit)
{
const RsGxsGroupId& grpId = mit->first;
const std::vector<RsGxsMessageId>& msgsV = mit->second;
std::vector<RsGxsMessageId>::const_iterator vit = msgsV.begin();
const std::set<RsGxsMessageId>& msgsV = mit->second;
std::set<RsGxsMessageId>::const_iterator vit = msgsV.begin();
for(; vit != msgsV.end(); ++vit)
{

View File

@ -110,7 +110,7 @@ public:
* @param msgId msgsids retrieved
* @return error code
*/
int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgId);
int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgId);
/*!
* @return the cache size set for this RsGeneralDataService in bytes

View File

@ -208,7 +208,7 @@ public:
* @param msgId msgsids retrieved
* @return error code
*/
virtual int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgId) = 0;
virtual int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgId) = 0;
/*!
* @return the cache size set for this RsGeneralDataService in bytes

View File

@ -217,7 +217,7 @@ void RsGenExchange::tick()
RS_STACK_MUTEX(mGenMtx) ;
std::list<RsGxsGroupId> grpIds;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgIds;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgIds;
mIntegrityCheck->getDeletedIds(grpIds, msgIds);
if (!grpIds.empty())
@ -1078,23 +1078,19 @@ bool RsGenExchange::checkAuthenFlag(const PrivacyBitPos& pos, const uint8_t& fla
}
}
static void addMessageChanged(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgs, const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChanged)
static void addMessageChanged(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgs, const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChanged)
{
if (msgs.empty()) {
msgs = msgChanged;
} else {
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mapIt;
for (mapIt = msgChanged.begin(); mapIt != msgChanged.end(); ++mapIt) {
for (auto mapIt = msgChanged.begin(); mapIt != msgChanged.end(); ++mapIt)
{
const RsGxsGroupId &grpId = mapIt->first;
const std::vector<RsGxsMessageId> &srcMsgIds = mapIt->second;
std::vector<RsGxsMessageId> &destMsgIds = msgs[grpId];
const std::set<RsGxsMessageId> &srcMsgIds = mapIt->second;
std::set<RsGxsMessageId> &destMsgIds = msgs[grpId];
std::vector<RsGxsMessageId>::const_iterator msgIt;
for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) {
if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) {
destMsgIds.push_back(*msgIt);
}
}
for (auto msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt)
destMsgIds.insert(*msgIt) ;
}
}
}
@ -1796,8 +1792,8 @@ void RsGenExchange::deleteMsgs(uint32_t& token, const GxsMsgReq& msgs)
if(mNetService != NULL)
for(GxsMsgReq::const_iterator it(msgs.begin());it!=msgs.end();++it)
for(uint32_t i=0;i<it->second.size();++i)
mNetService->rejectMessage(it->second[i]) ;
for(auto it2(it->second.begin());it2!=it->second.end();++it2)
mNetService->rejectMessage(*it2);
}
void RsGenExchange::publishMsg(uint32_t& token, RsGxsMsgItem *msgItem)
@ -1977,8 +1973,8 @@ void RsGenExchange::processMsgMetaChanges()
if(m.val.getAsInt32(RsGeneralDataService::MSG_META_STATUS+GXS_MASK, mask))
{
GxsMsgReq req;
std::vector<RsGxsMessageId> msgIdV;
msgIdV.push_back(m.msgId.second);
std::set<RsGxsMessageId> msgIdV;
msgIdV.insert(m.msgId.second);
req.insert(std::make_pair(m.msgId.first, msgIdV));
GxsMsgMetaResult result;
mDataStore->retrieveGxsMsgMetaData(req, result);
@ -2010,7 +2006,7 @@ void RsGenExchange::processMsgMetaChanges()
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE);
if (changed)
{
msgIds[m.msgId.first].push_back(m.msgId.second);
msgIds[m.msgId.first].insert(m.msgId.second);
}
}
else
@ -2026,7 +2022,7 @@ void RsGenExchange::processMsgMetaChanges()
if (!msgIds.empty()) {
RS_STACK_MUTEX(mGenMtx);
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, true);
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
c->msgChangeMap = msgIds;
mNotifications.push_back(c);
}
@ -2161,7 +2157,7 @@ void RsGenExchange::publishMsgs()
mMsgsToPublish.insert(std::make_pair(sign_it->first, item.mItem));
}
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgChangeMap;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgChangeMap;
std::map<uint32_t, RsGxsMsgItem*>::iterator mit = mMsgsToPublish.begin();
for(; mit != mMsgsToPublish.end(); ++mit)
@ -2289,7 +2285,7 @@ void RsGenExchange::publishMsgs()
mDataAccess->addMsgData(msg);
delete msg ;
msgChangeMap[grpId].push_back(msgId);
msgChangeMap[grpId].insert(msgId);
delete[] metaDataBuff;
@ -2988,10 +2984,10 @@ void RsGenExchange::processRecvdMessages()
msg->metaData->mMsgStatus = GXS_SERV::GXS_MSG_STATUS_UNPROCESSED | GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD;
msgs_to_store.push_back(msg);
std::vector<RsGxsMessageId> &msgv = msgIds[msg->grpId];
if (std::find(msgv.begin(), msgv.end(), msg->msgId) == msgv.end())
msgv.push_back(msg->msgId);
msgIds[msg->grpId].insert(msg->msgId);
// std::vector<RsGxsMessageId> &msgv = msgIds[msg->grpId];
// if (std::find(msgv.begin(), msgv.end(), msg->msgId) == msgv.end())
// msgv.push_back(msg->msgId);
computeHash(msg->msg, msg->metaData->mHash);
msg->metaData->recvTS = time(NULL);
@ -3346,7 +3342,7 @@ void RsGenExchange::removeDeleteExistingMessages( std::list<RsNxsMsg*>& msgs, Gx
//RsGxsGroupId::std_list grpIds(mGrpIdsUnique.begin(), mGrpIdsUnique.end());
//RsGxsGroupId::std_list::const_iterator it = grpIds.begin();
typedef std::map<RsGxsGroupId, RsGxsMessageId::std_vector> MsgIdReq;
typedef std::map<RsGxsGroupId, RsGxsMessageId::std_set> MsgIdReq;
MsgIdReq msgIdReq;
// now get a list of all msgs ids for each group
@ -3355,18 +3351,18 @@ void RsGenExchange::removeDeleteExistingMessages( std::list<RsNxsMsg*>& msgs, Gx
mDataStore->retrieveMsgIds(*it, msgIdReq[*it]);
#ifdef GEN_EXCH_DEBUG
const std::vector<RsGxsMessageId>& vec(msgIdReq[*it]) ;
const std::set<RsGxsMessageId>& vec(msgIdReq[*it]) ;
std::cerr << " retrieved " << vec.size() << " message ids for group " << *it << std::endl;
for(uint32_t i=0;i<vec.size();++i)
std::cerr << " " << vec[i] << std::endl;
for(auto it2(vec.begin());it2!=vec.end();++it2)
std::cerr << " " << *it2 << std::endl;
#endif
}
// now for each msg to be stored that exist in the retrieved msg/grp "index" delete and erase from map
for(std::list<RsNxsMsg*>::iterator cit2 = msgs.begin(); cit2 != msgs.end();)
{
const RsGxsMessageId::std_vector& msgIds = msgIdReq[(*cit2)->metaData->mGroupId];
const RsGxsMessageId::std_set& msgIds = msgIdReq[(*cit2)->metaData->mGroupId];
#ifdef GEN_EXCH_DEBUG
std::cerr << " grpid=" << (*cit2)->grpId << ", msgid=" << (*cit2)->msgId ;
@ -3374,12 +3370,13 @@ void RsGenExchange::removeDeleteExistingMessages( std::list<RsNxsMsg*>& msgs, Gx
// Avoid storing messages that are already in the database, as well as messages that are too old (or generally do not pass the database storage test)
//
if(std::find(msgIds.begin(), msgIds.end(), (*cit2)->metaData->mMsgId) != msgIds.end() || !messagePublicationTest( *(*cit2)->metaData))
if(msgIds.find((*cit2)->metaData->mMsgId) != msgIds.end() || !messagePublicationTest( *(*cit2)->metaData))
{
// msg exist in retrieved index. We should use a std::set here instead of a vector.
RsGxsMessageId::std_vector& notifyIds = msgIdsNotify[ (*cit2)->metaData->mGroupId];
RsGxsMessageId::std_vector::iterator it2 = std::find(notifyIds.begin(), notifyIds.end(), (*cit2)->metaData->mMsgId);
RsGxsMessageId::std_set& notifyIds = msgIdsNotify[ (*cit2)->metaData->mGroupId];
RsGxsMessageId::std_set::iterator it2 = notifyIds.find((*cit2)->metaData->mMsgId);
if(it2 != notifyIds.end())
{
notifyIds.erase(it2);

View File

@ -225,7 +225,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
MsgMetaReq* mmr = new MsgMetaReq();
for(; lit != grpIds.end(); ++lit)
mmr->mMsgIds[*lit] = std::vector<RsGxsMessageId>();
mmr->mMsgIds[*lit] = std::set<RsGxsMessageId>();
req = mmr;
}else if(reqType & GXS_REQUEST_TYPE_MSG_DATA)
@ -233,7 +233,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
MsgDataReq* mdr = new MsgDataReq();
for(; lit != grpIds.end(); ++lit)
mdr->mMsgIds[*lit] = std::vector<RsGxsMessageId>();
mdr->mMsgIds[*lit] = std::set<RsGxsMessageId>();
req = mdr;
}else if(reqType & GXS_REQUEST_TYPE_MSG_IDS)
@ -241,7 +241,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
MsgIdReq* mir = new MsgIdReq();
for(; lit != grpIds.end(); ++lit)
mir->mMsgIds[*lit] = std::vector<RsGxsMessageId>();
mir->mMsgIds[*lit] = std::set<RsGxsMessageId>();
req = mir;
}
@ -1191,7 +1191,7 @@ bool RsGxsDataAccess::getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions&
// Add the discovered Latest Msgs.
for(oit = origMsgTs.begin(); oit != origMsgTs.end(); ++oit)
{
msgIdsOut[grpId].push_back(oit->second.first);
msgIdsOut[grpId].insert(oit->second.first);
}
}
@ -1228,7 +1228,7 @@ bool RsGxsDataAccess::getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions&
if (add)
{
msgIdsOut[grpId].push_back(msgMeta->mMsgId);
msgIdsOut[grpId].insert(msgMeta->mMsgId);
metaFilter[grpId].insert(std::make_pair(msgMeta->mMsgId, msgMeta));
}
@ -1373,7 +1373,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
// get meta data for all in group
GxsMsgMetaResult result;
GxsMsgReq msgIds;
msgIds.insert(std::make_pair(grpMsgIdPair.first, std::vector<RsGxsMessageId>()));
msgIds.insert(std::make_pair(grpMsgIdPair.first, std::set<RsGxsMessageId>()));
mDataStore->retrieveGxsMsgMetaData(msgIds, result);
std::vector<RsGxsMsgMetaData*>& metaV = result[grpMsgIdPair.first];
std::vector<RsGxsMsgMetaData*>::iterator vit_meta;
@ -1382,7 +1382,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
const RsGxsMessageId& msgId = grpMsgIdPair.second;
const RsGxsGroupId& grpId = grpMsgIdPair.first;
std::vector<RsGxsMessageId> outMsgIds;
std::set<RsGxsMessageId> outMsgIds;
RsGxsMsgMetaData* origMeta = NULL;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
@ -1477,7 +1477,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
// Add the discovered Latest Msgs.
for(oit = origMsgTs.begin(); oit != origMsgTs.end(); ++oit)
{
outMsgIds.push_back(oit->second.first);
outMsgIds.insert(oit->second.first);
}
}
else
@ -1502,7 +1502,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
}
}
}
outMsgIds.push_back(latestMsgId);
outMsgIds.insert(latestMsgId);
metaMap.insert(std::make_pair(latestMsgId, latestMeta));
}
}
@ -1514,7 +1514,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
if (meta->mOrigMsgId == origMsgId)
{
outMsgIds.push_back(meta->mMsgId);
outMsgIds.insert(meta->mMsgId);
metaMap.insert(std::make_pair(meta->mMsgId, meta));
}
}
@ -1556,7 +1556,7 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
{
// filter based on options
GxsMsgIdResult metaReq;
metaReq[req->mGrpId] = std::vector<RsGxsMessageId>();
metaReq[req->mGrpId] = std::set<RsGxsMessageId>();
GxsMsgMetaResult metaResult;
mDataStore->retrieveGxsMsgMetaData(metaReq, metaResult);
@ -1672,7 +1672,7 @@ bool RsGxsDataAccess::getMsgList(MsgIdReq* req)
for(; vit != vit_end; ++vit)
{
RsGxsMsgMetaData* meta = *vit;
req->mMsgIdResult[grpId].push_back(meta->mMsgId);
req->mMsgIdResult[grpId].insert(meta->mMsgId);
delete meta; // discard meta data mem
}
}
@ -1718,8 +1718,8 @@ void RsGxsDataAccess::filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOption
if(cit == msgMetas.end())
continue;
std::vector<RsGxsMessageId>& msgs = mit->second;
std::vector<RsGxsMessageId>::iterator vit = msgs.begin();
std::set<RsGxsMessageId>& msgs = mit->second;
std::set<RsGxsMessageId>::iterator vit = msgs.begin();
const std::map<RsGxsMessageId, RsGxsMsgMetaData*>& meta = cit->second;
std::map<RsGxsMessageId, RsGxsMsgMetaData*>::const_iterator cit2;

View File

@ -940,7 +940,7 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs)
// now count available messages
GxsMsgReq reqIds;
reqIds[grs->grpId] = std::vector<RsGxsMessageId>();
reqIds[grs->grpId] = std::set<RsGxsMessageId>();
GxsMsgMetaResult result;
#ifdef NXS_NET_DEBUG_6
@ -2945,7 +2945,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
#endif
GxsMsgReq reqIds;
reqIds[grpId] = std::vector<RsGxsMessageId>();
reqIds[grpId] = std::set<RsGxsMessageId>();
GxsMsgMetaResult result;
mDataStore->retrieveGxsMsgMetaData(reqIds, result);
std::vector<RsGxsMsgMetaData*> &msgMetaV = result[grpId];
@ -3497,7 +3497,7 @@ void RsGxsNetService::locked_genSendMsgsTransaction(NxsTransaction* tr)
RsNxsSyncMsgItem* item = dynamic_cast<RsNxsSyncMsgItem*>(*lit);
if (item)
{
msgIds[item->grpId].push_back(item->msgId);
msgIds[item->grpId].insert(item->msgId);
if(grpId.isNull())
grpId = item->grpId;
@ -4351,7 +4351,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
}
GxsMsgReq req;
req[item->grpId] = std::vector<RsGxsMessageId>();
req[item->grpId] = std::set<RsGxsMessageId>();
GxsMsgMetaResult metaResult;
mDataStore->retrieveGxsMsgMetaData(req, metaResult);

View File

@ -67,7 +67,7 @@ bool RsGxsMessageCleanUp::clean()
GxsMsgReq req;
GxsMsgMetaResult result;
req[grpId] = std::vector<RsGxsMessageId>();
req[grpId] = std::set<RsGxsMessageId>();
mDs->retrieveGxsMsgMetaData(req, result);
GxsMsgMetaResult::iterator mit = result.begin();
@ -117,7 +117,7 @@ bool RsGxsMessageCleanUp::clean()
if( remove )
{
req[grpId].push_back(meta->mMsgId);
req[grpId].insert(meta->mMsgId);
#ifdef DEBUG_GXSUTIL
std::cerr << " Scheduling for removal." << std::endl;
@ -241,9 +241,9 @@ bool RsGxsIntegrityCheck::check()
for (msgIdsIt = msgIds.begin(); msgIdsIt != msgIds.end(); ++msgIdsIt)
{
const RsGxsGroupId& grpId = msgIdsIt->first;
std::vector<RsGxsMessageId> &msgIdV = msgIdsIt->second;
std::set<RsGxsMessageId> &msgIdV = msgIdsIt->second;
std::vector<RsGxsMessageId>::iterator msgIdIt;
std::set<RsGxsMessageId>::iterator msgIdIt;
for (msgIdIt = msgIdV.begin(); msgIdIt != msgIdV.end(); ++msgIdIt)
{
const RsGxsMessageId& msgId = *msgIdIt;
@ -261,7 +261,7 @@ bool RsGxsIntegrityCheck::check()
if (nxsMsgIt == nxsMsgV.end())
{
msgsToDel[grpId].push_back(msgId);
msgsToDel[grpId].insert(msgId);
}
}
}
@ -284,7 +284,7 @@ bool RsGxsIntegrityCheck::check()
if(msg->metaData == NULL || currHash != msg->metaData->mHash)
{
std::cerr << "(EE) deleting message data with wrong hash or null meta data. meta=" << (void*)msg->metaData << std::endl;
msgsToDel[msg->grpId].push_back(msg->msgId);
msgsToDel[msg->grpId].insert(msg->msgId);
}
else if(!msg->metaData->mAuthorId.isNull() && subscribed_groups.find(msg->metaData->mGroupId)!=subscribed_groups.end())
{
@ -377,7 +377,7 @@ bool RsGxsIntegrityCheck::isDone()
return mDone;
}
void RsGxsIntegrityCheck::getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds)
void RsGxsIntegrityCheck::getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIds)
{
RsStackMutex stack(mIntegrityMutex);

View File

@ -208,7 +208,7 @@ public:
void run();
void getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds);
void getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds);
private:
@ -217,7 +217,7 @@ private:
bool mDone;
RsMutex mIntegrityMutex;
std::list<RsGxsGroupId> mDeletedGrps;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mDeletedMsgs;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mDeletedMsgs;
RsGixs *mGixs ;
};

View File

@ -455,7 +455,7 @@ void p3GxsTrans::GxsTransIntegrityCleanupThread::run()
if(stored_msgs.end() != it2)
{
msgsToDel[it2->second.first].push_back(it2->second.second);
msgsToDel[it2->second.first].insert(it2->second.second);
#ifdef DEBUG_GXSTRANS
std::cerr << " scheduling msg " << std::hex << it2->second.first << "," << it2->second.second << " for deletion." << std::endl;

View File

@ -1,6 +1,6 @@
/*
* GXS Mailing Service
* Copyright (C) 2016-2017 Gioacchino Mazzurco <gio@eigenlab.org>
* Copyright (C) 2016-2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@ -38,30 +38,28 @@ OutgoingRecord::OutgoingRecord( RsGxsId rec, GxsTransSubServices cs,
memcpy(&mailData[0], data, size);
}
RS_REGISTER_ITEM_TYPE(RsGxsTransMailItem) // for mailItem
RS_REGISTER_ITEM_TYPE(RsNxsTransPresignedReceipt) // for presignedReceipt
void OutgoingRecord_deprecated::serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx)
void OutgoingRecord_deprecated::serial_process(
RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx )
{
RS_REGISTER_SERIAL_MEMBER_TYPED(status, uint8_t);
RS_REGISTER_SERIAL_MEMBER(recipient);
RS_REGISTER_SERIAL_MEMBER(mailItem);
RS_REGISTER_SERIAL_MEMBER(mailData);
RS_REGISTER_SERIAL_MEMBER_TYPED(clientService, uint16_t);
RS_REGISTER_SERIAL_MEMBER(presignedReceipt);
RS_SERIAL_PROCESS(status);
RS_SERIAL_PROCESS(recipient);
RS_SERIAL_PROCESS(mailItem);
RS_SERIAL_PROCESS(mailData);
RS_SERIAL_PROCESS(clientService);
RS_SERIAL_PROCESS(presignedReceipt);
}
void OutgoingRecord::serial_process(RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx)
{
RS_REGISTER_SERIAL_MEMBER_TYPED(status, uint8_t);
RS_REGISTER_SERIAL_MEMBER(recipient);
RS_REGISTER_SERIAL_MEMBER(author);
RS_REGISTER_SERIAL_MEMBER(group_id);
RS_REGISTER_SERIAL_MEMBER(sent_ts);
RS_REGISTER_SERIAL_MEMBER(mailItem);
RS_REGISTER_SERIAL_MEMBER(mailData);
RS_REGISTER_SERIAL_MEMBER_TYPED(clientService, uint16_t);
RS_REGISTER_SERIAL_MEMBER(presignedReceipt);
RS_SERIAL_PROCESS(status);
RS_SERIAL_PROCESS(recipient);
RS_SERIAL_PROCESS(author);
RS_SERIAL_PROCESS(group_id);
RS_SERIAL_PROCESS(sent_ts);
RS_SERIAL_PROCESS(mailItem);
RS_SERIAL_PROCESS(mailData);
RS_SERIAL_PROCESS(clientService);
RS_SERIAL_PROCESS(presignedReceipt);
}

View File

@ -55,7 +55,7 @@ public:
void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx )
{ RS_REGISTER_SERIAL_MEMBER_TYPED(mailId, uint64_t); }
{ RS_SERIAL_PROCESS(mailId); }
};
class RsGxsTransPresignedReceipt : public RsGxsTransBaseMsgItem
@ -140,9 +140,9 @@ public:
RsGenericSerializer::SerializeContext& ctx )
{
RsGxsTransBaseMsgItem::serial_process(j, ctx);
RS_REGISTER_SERIAL_MEMBER_TYPED(cryptoType, uint8_t);
RS_REGISTER_SERIAL_MEMBER(recipientHint);
RS_REGISTER_SERIAL_MEMBER(payload);
RS_SERIAL_PROCESS(cryptoType);
RS_SERIAL_PROCESS(recipientHint);
RS_SERIAL_PROCESS(payload);
}
void clear()

View File

@ -102,6 +102,9 @@ template<> void RsTypeSerializer::print_data(const std::string& name,BIGNUM
std::cerr << "[BIGNUM] : " << name << std::endl;
}
RS_TYPE_SERIALIZER_TO_JSON_NOT_IMPLEMENTED_DEF(BIGNUM*)
RS_TYPE_SERIALIZER_FROM_JSON_NOT_IMPLEMENTED_DEF(BIGNUM*)
void RsGxsTunnelStatusItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process<uint32_t>(j,ctx,status,"status") ;

View File

@ -2,34 +2,26 @@
TEMPLATE = lib
CONFIG += staticlib
CONFIG += create_prl
CONFIG -= qt
TARGET = retroshare
TARGET_PRL = libretroshare
DESTDIR = lib
#CONFIG += dsdv
retrotor {
DEFINES *= RETROTOR
CONFIG -= bitdht
} else {
CONFIG += bitdht
}
!include("use_libretroshare.pri"):error("Including")
# the dht stunner is used to obtain RS external ip addr. when it is natted
# this system is unreliable and rs supports a newer and better one (asking connected peers)
# CONFIG += useDhtStunner
profiling {
QMAKE_CXXFLAGS -= -fomit-frame-pointer
QMAKE_CXXFLAGS *= -pg -g -fno-omit-frame-pointer
}
# treat warnings as error for better removing
#QMAKE_CFLAGS += -Werror
#QMAKE_CXXFLAGS += -Werror
# when rapidjson is mainstream on all distribs, we will not need the sources anymore
# in the meantime, they are part of the RS directory so that it is always possible to find them
INCLUDEPATH += ../../rapidjson-1.1.0
debug {
# DEFINES *= DEBUG
# DEFINES *= OPENDHT_DEBUG DHT_DEBUG CONN_DEBUG DEBUG_UDP_SORTER P3DISC_DEBUG DEBUG_UDP_LAYER FT_DEBUG EXTADDRSEARCH_DEBUG
@ -203,21 +195,11 @@ linux-* {
PKGCONFIG *= libssl libupnp
PKGCONFIG *= libcrypto zlib
LIBS *= -lpthread -ldl
}
no_sqlcipher:PKGCONFIG *= sqlite3
LIBS *= -ldl
linux-* {
DEFINES *= PLUGIN_DIR=\"\\\"$${PLUGIN_DIR}\\\"\"
DEFINES *= DATA_DIR=\"\\\"$${DATA_DIR}\\\"\"
## where to put the librarys interface
#include_rsiface.path = "$${INC_DIR}"
#include_rsiface.files = $$PUBLIC_HEADERS
#INSTALLS += include_rsiface
## where to put the shared library itself
#target.path = "$$LIB_DIR"
#INSTALLS *= target
}
linux-g++ {
@ -234,7 +216,7 @@ version_detail_bash_script {
PRE_TARGETDEPS = write_version_detail
write_version_detail.commands = $$PWD/version_detail.sh
}
win32 {
win32-* {
QMAKE_EXTRA_TARGETS += write_version_detail
PRE_TARGETDEPS = write_version_detail
write_version_detail.commands = $$PWD/version_detail.bat
@ -263,13 +245,11 @@ win32-x-g++ {
}
################################# Windows ##########################################
win32 {
win32-g++ {
QMAKE_CC = $${QMAKE_CXX}
OBJECTS_DIR = temp/obj
MOC_DIR = temp/moc
DEFINES *= WINDOWS_SYS WIN32 STATICLIB MINGW WIN32_LEAN_AND_MEAN _USE_32BIT_TIME_T
# This defines the platform to be WinXP or later and is needed for getaddrinfo (_WIN32_WINNT_WINXP)
DEFINES *= WINVER=0x0501
DEFINES *= STATICLIB
# Switch on extra warnings
QMAKE_CFLAGS += -Wextra
@ -287,17 +267,8 @@ win32 {
DEFINES += USE_CMD_ARGS
CONFIG += upnp_miniupnpc
no_sqlcipher {
PKGCONFIG *= sqlite3
LIBS += -lsqlite3
} else {
LIBS += -lsqlcipher
}
DEPENDPATH += . $$INC_DIR
INCLUDEPATH += . $$INC_DIR
wLibs = ws2_32 gdi32 uuid iphlpapi crypt32 ole32 winmm
LIBS += $$linkDynamicLibs(wLibs)
}
################################# MacOSX ##########################################
@ -306,22 +277,10 @@ mac {
QMAKE_CC = $${QMAKE_CXX}
OBJECTS_DIR = temp/obj
MOC_DIR = temp/moc
#DEFINES = WINDOWS_SYS WIN32 STATICLIB MINGW
#DEFINES *= MINIUPNPC_VERSION=13
CONFIG += upnp_miniupnpc
CONFIG += c++11
# zeroconf disabled at the end of libretroshare.pro (but need the code)
#CONFIG += zeroconf
#CONFIG += zcnatassist
# Beautiful Hack to fix 64bit file access.
QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dfopen64=fopen -Dvstatfs64=vstatfs
#GPG_ERROR_DIR = ../../../../libgpg-error-1.7
#GPGME_DIR = ../../../../gpgme-1.1.8
for(lib, LIB_DIR):LIBS += -L"$$lib"
for(bin, BIN_DIR):LIBS += -L"$$bin"
@ -561,7 +520,7 @@ SOURCES += ft/ftchunkmap.cc \
ft/ftfilesearch.cc \
ft/ftserver.cc \
ft/fttransfermodule.cc \
ft/ftturtlefiletransferitem.cc
ft/ftturtlefiletransferitem.cc
SOURCES += crypto/chacha20.cpp \
crypto/hashstream.cc
@ -655,6 +614,7 @@ SOURCES += serialiser/rsbaseserial.cc \
rsitems/rsgxsupdateitems.cc \
rsitems/rsserviceinfoitems.cc \
SOURCES += services/autoproxy/rsautoproxymonitor.cc \
services/autoproxy/p3i2pbob.cc \
services/p3msgservice.cc \
@ -697,13 +657,16 @@ SOURCES += util/folderiterator.cc \
util/rsrecogn.cc \
util/rstime.cc
upnp_miniupnpc {
HEADERS += upnp/upnputil.h upnp/upnphandler_miniupnp.h
SOURCES += upnp/upnputil.c upnp/upnphandler_miniupnp.cc
## Added for retrocompatibility remove ASAP
isEmpty(RS_UPNP_LIB) {
upnp_miniupnpc:RS_UPNP_LIB=miniupnpc
upnp_libupnp:RS_UPNP_LIB="upnp ixml threadutil"
}
upnp_libupnp {
equals(RS_UPNP_LIB, miniupnpc) {
HEADERS += upnp/upnputil.h upnp/upnphandler_miniupnp.h
SOURCES += upnp/upnputil.c upnp/upnphandler_miniupnp.cc
} else {
HEADERS += upnp/UPnPBase.h upnp/upnphandler_linux.h
SOURCES += upnp/UPnPBase.cpp upnp/upnphandler_linux.cc
DEFINES *= RS_USE_LIBUPNP
@ -795,7 +758,8 @@ SOURCES += gxstunnel/p3gxstunnel.cc \
gxstunnel/rsgxstunnelitems.cc
# new serialization code
HEADERS += serialiser/rsserializer.h \
HEADERS += serialiser/rsserializable.h \
serialiser/rsserializer.h \
serialiser/rstypeserializer.h
SOURCES += serialiser/rsserializer.cc \
@ -936,19 +900,13 @@ android-* {
DEFINES *= "fopen64=fopen"
DEFINES *= "fseeko64=fseeko"
DEFINES *= "ftello64=ftello"
LIBS *= -lbz2 -lupnp -lixml -lthreadutil -lsqlite3
## Static library are verysensible to order in command line, has to be in the
## end of file for this reason
## Static library are very susceptible to order in command line
sLibs = bz2 $$RS_UPNP_LIB $$RS_SQL_LIB ssl crypto
LIBS += -L$$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/ -lsqlcipher
PRE_TARGETDEPS += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/libsqlcipher.a
LIBS += -L$$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/ -lssl
PRE_TARGETDEPS += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/libssl.a
LIBS += -L$$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/ -lcrypto
PRE_TARGETDEPS += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/libcrypto.a
LIBS += $$linkStaticLibs(sLibs)
PRE_TARGETDEPS += $$pretargetStaticLibs(sLibs)
HEADERS += util/androiddebug.h
}

View File

@ -174,24 +174,24 @@ RsCertificate::RsCertificate(const RsPeerDetails& Detail, const unsigned char *b
try
{
scan_ip(Detail.localAddr,Detail.localPort,ipv4_internal_ip_and_port) ;
scan_ip(Detail.localAddr,Detail.localPort,ipv4_internal_ip_and_port);
}
catch(...)
{
std::cerr << "RsCertificate::Invalid LocalAddress";
std::cerr << std::endl;
memset(ipv4_internal_ip_and_port,0,6) ;
std::cerr << "RsCertificate::Invalid LocalAddress: "
<< Detail.localAddr << std::endl;
memset(ipv4_internal_ip_and_port,0,6);
}
try
{
scan_ip(Detail.extAddr,Detail.extPort,ipv4_external_ip_and_port) ;
scan_ip(Detail.extAddr,Detail.extPort,ipv4_external_ip_and_port);
}
catch(...)
{
std::cerr << "RsCertificate::Invalid ExternalAddress";
std::cerr << std::endl;
std::cerr << "RsCertificate::Invalid ExternalAddress: "
<< Detail.extAddr << std::endl;
memset(ipv4_external_ip_and_port,0,6) ;
}

View File

@ -67,7 +67,7 @@ p3HistoryMgr::~p3HistoryMgr()
/***** p3HistoryMgr *****/
//void p3HistoryMgr::addMessage(bool incoming, const RsPeerId &chatPeerId, const RsPeerId &peerId, const RsChatMsgItem *chatItem)
//void p3HistoryMgr::addMessage(bool incoming, const RsPeerId &chatPeerId, const RsPeerId &msgPeerId, const RsChatMsgItem *chatItem)
void p3HistoryMgr::addMessage(const ChatMessage& cm)
{
uint32_t addMsgId = 0;
@ -84,48 +84,48 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
RsPeerId peerId; // id of sending peer
RsPeerId chatPeerId; // id of chat endpoint
std::string peerName; //name of sending peer
RsPeerId msgPeerId; // id of sending peer
RsPeerId chatPeerId; // id of chat endpoint
std::string peerName; //name of sending peer
bool enabled = false;
if (cm.chat_id.isBroadcast() && mPublicEnable == true) {
peerName = rsPeers->getPeerName(cm.broadcast_peer_id);
enabled = true;
bool enabled = false;
if (cm.chat_id.isBroadcast() && mPublicEnable == true) {
peerName = rsPeers->getPeerName(cm.broadcast_peer_id);
enabled = true;
}
if (cm.chat_id.isPeerId() && mPrivateEnable == true) {
msgPeerId = cm.incoming ? cm.chat_id.toPeerId() : rsPeers->getOwnId();
peerName = rsPeers->getPeerName(msgPeerId);
enabled = true;
}
if (cm.chat_id.isLobbyId() && mLobbyEnable == true) {
peerName = cm.lobby_peer_gxs_id.toStdString();
enabled = true;
}
if (cm.chat_id.isPeerId() && mPrivateEnable == true) {
peerId = cm.incoming ? cm.chat_id.toPeerId() : rsPeers->getOwnId();
peerName = rsPeers->getPeerName(peerId);
enabled = true;
}
if (cm.chat_id.isLobbyId() && mLobbyEnable == true) {
peerName = cm.lobby_peer_gxs_id.toStdString();
enabled = true;
}
if(cm.chat_id.isDistantChatId())
{
DistantChatPeerInfo dcpinfo;
if (rsMsgs->getDistantChatStatus(cm.chat_id.toDistantChatId(), dcpinfo))
peerName = cm.chat_id.toPeerId().toStdString();
enabled = true;
}
if(cm.chat_id.isDistantChatId())
{
DistantChatPeerInfo dcpinfo;
if (rsMsgs->getDistantChatStatus(cm.chat_id.toDistantChatId(), dcpinfo))
peerName = cm.chat_id.toPeerId().toStdString();
enabled = true;
}
if(enabled == false)
return;
if(enabled == false)
return;
if(!chatIdToVirtualPeerId(cm.chat_id, chatPeerId))
return;
if(!chatIdToVirtualPeerId(cm.chat_id, chatPeerId))
return;
RsHistoryMsgItem* item = new RsHistoryMsgItem;
item->chatPeerId = chatPeerId;
item->incoming = cm.incoming;
item->peerId = peerId;
item->peerName = peerName;
item->sendTime = cm.sendTime;
item->recvTime = cm.recvTime;
item->incoming = cm.incoming;
item->msgPeerId = msgPeerId;
item->peerName = peerName;
item->sendTime = cm.sendTime;
item->recvTime = cm.recvTime;
item->message = cm.msg ;
item->message = cm.msg ;
//librs::util::ConvertUtf16ToUtf8(chatItem->message, item->message);
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(item->chatPeerId);
@ -138,7 +138,7 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
uint32_t limit;
if (chatPeerId.isNull())
limit = mPublicSaveCount;
else if (cm.chat_id.isLobbyId())
else if (cm.chat_id.isLobbyId())
limit = mLobbySaveCount;
else
limit = mPrivateSaveCount;
@ -424,7 +424,7 @@ static void convertMsg(const RsHistoryMsgItem* item, HistoryMsg &msg)
msg.msgId = item->msgId;
msg.chatPeerId = item->chatPeerId;
msg.incoming = item->incoming;
msg.peerId = item->peerId;
msg.peerId = item->msgPeerId;
msg.peerName = item->peerName;
msg.sendTime = item->sendTime;
msg.recvTime = item->recvTime;

View File

@ -3,7 +3,8 @@
*
* 3P/PQI network interface for RetroShare.
*
* Copyright 2007-2011 by Robert Fernie.
* Copyright (C) 2007-2011 Robert Fernie.
* Copyright (C) 2015-2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -56,6 +57,7 @@ static struct RsLog::logInfo p3connectzoneInfo = {RsLog::Default, "p3connect"};
/****
* #define LINKMGR_DEBUG 1
* #define LINKMGR_DEBUG_LOG 1
* #define LINKMGR_DEBUG_CONNFAIL 1
* #define LINKMGR_DEBUG_ACTIONS 1
* #define LINKMGR_DEBUG_LINKTYPE 1
@ -620,7 +622,9 @@ bool p3LinkMgrIMPL::connectAttempt(const RsPeerId &id, struct sockaddr_storage &
}
#ifdef LINKMGR_DEBUG_LOG
rslog(RSL_WARNING, p3connectzone, "p3LinkMgrIMPL::connectAttempt() called id: " + id.toStdString());
#endif
it->second.lastattempt = time(NULL);
it->second.inConnAttempt = true;
@ -823,7 +827,9 @@ bool p3LinkMgrIMPL::connectResult(const RsPeerId &id, bool success, bool isIncom
out += " FAILED ATTEMPT (Not Connected)";
}
}
#ifdef LINKMGR_DEBUG_LOG
rslog(RSL_WARNING, p3connectzone, out);
#endif
}
@ -1344,8 +1350,10 @@ void p3LinkMgrIMPL::peerStatus(const RsPeerId& id, const pqiIpAddrSet &addrs,
}
/* This has become very unwieldy - as extra arguments are required for UDP connections */
void p3LinkMgrIMPL::peerConnectRequest(const RsPeerId& id, const struct sockaddr_storage &raddr, const struct sockaddr_storage &proxyaddr, const struct sockaddr_storage &srcaddr,
uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth)
void p3LinkMgrIMPL::peerConnectRequest(
const RsPeerId& id, const sockaddr_storage &raddr,
const sockaddr_storage &proxyaddr, const sockaddr_storage &srcaddr,
uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth )
{
#ifdef LINKMGR_DEBUG
std::cerr << "p3LinkMgrIMPL::peerConnectRequest() id: " << id;
@ -2057,8 +2065,9 @@ bool p3LinkMgrIMPL::locked_ConnectAttempt_Complete(peerConnectState *peer)
int p3LinkMgrIMPL::addFriend(const RsPeerId &id, bool isVisible)
{
#ifdef LINKMGR_DEBUG_LOG
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::addFriend() id: " + id.toStdString());
#endif
{
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/

View File

@ -692,11 +692,11 @@ void p3NetMgrIMPL::netExtCheck()
bool netSetupDone = false;
{
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
RS_STACK_MUTEX(mNetMtx);
bool isStable = false;
struct sockaddr_storage tmpip ;
sockaddr_storage tmpip;
std::map<sockaddr_storage,ZeroInt> address_votes ;
std::map<sockaddr_storage,ZeroInt> address_votes;
/* check for External Address */
/* in order of importance */
@ -705,38 +705,30 @@ void p3NetMgrIMPL::netExtCheck()
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext Not Ok" << std::endl;
#endif
/* net Assist */
if (netAssistExtAddress(tmpip))
if ( netAssistExtAddress(tmpip) &&
sockaddr_storage_isValidNet(tmpip) &&
sockaddr_storage_ipv6_to_ipv4(tmpip) )
{
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext supplied from netAssistExternalAddress()" << std::endl;
#endif
if(sockaddr_storage_isValidNet(tmpip))
if( !rsBanList ||
rsBanList->isAddressAccepted(
tmpip, RSBANLIST_CHECKING_FLAGS_BLACKLIST ) )
{
if( (rsBanList==NULL) || rsBanList->isAddressAccepted(tmpip,RSBANLIST_CHECKING_FLAGS_BLACKLIST))
{
// must be stable???
isStable = true;
//mNetFlags.mExtAddr = tmpip;
mNetFlags.mExtAddrOk = true;
mNetFlags.mExtAddrStableOk = isStable;
address_votes[tmpip].n++ ;
std::cerr << "NetAssistAddress reported external address " << sockaddr_storage_iptostring(tmpip) << std::endl;
}
else
std::cerr << "(SS) netAssisExternalAddress returned banned own IP " << sockaddr_storage_iptostring(tmpip) << " (banned). Rejecting." << std::endl;
// must be stable???
isStable = true;
mNetFlags.mExtAddrOk = true;
mNetFlags.mExtAddrStableOk = isStable;
address_votes[tmpip].n++ ;
std::cerr << __PRETTY_FUNCTION__ << " NetAssistAddress "
<< " reported external address "
<< sockaddr_storage_iptostring(tmpip)
<< std::endl;
}
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
else
{
std::cerr << "p3NetMgrIMPL::netExtCheck() Bad Address supplied from netAssistExternalAddress()" << std::endl;
}
#endif
std::cerr << "(SS) netAssisExternalAddress returned banned "
<< "own IP " << sockaddr_storage_iptostring(tmpip)
<< " (banned). Rejecting." << std::endl;
}
}
#ifdef ALLOW_DHT_STUNNER
@ -780,7 +772,7 @@ void p3NetMgrIMPL::netExtCheck()
}
#endif
/* otherwise ask ExtAddrFinder */
/* ask ExtAddrFinder */
{
/* ExtAddrFinder */
if (mUseExtAddrFinder)
@ -789,7 +781,7 @@ void p3NetMgrIMPL::netExtCheck()
std::cerr << "p3NetMgrIMPL::netExtCheck() checking ExtAddrFinder" << std::endl;
#endif
bool extFinderOk = mExtAddrFinder->hasValidIP(tmpip);
if (extFinderOk)
if (extFinderOk && sockaddr_storage_ipv6_to_ipv4(tmpip))
{
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext supplied by ExtAddrFinder" << std::endl;
@ -803,38 +795,41 @@ void p3NetMgrIMPL::netExtCheck()
std::cerr << std::endl;
#endif
//mNetFlags.mExtAddr = tmpip;
mNetFlags.mExtAddrOk = true;
address_votes[tmpip].n++ ;
/* XXX HACK TO FIX */
#warning drbob: ALLOWING ExtAddrFinder -> ExtAddrStableOk = true (which it is not normally)
/* XXX HACK TO FIX drbob: ALLOWING
* ExtAddrFinder -> ExtAddrStableOk = true
* (which it is not normally) */
mNetFlags.mExtAddrStableOk = true;
std::cerr << "ExtAddrFinder reported external address " << sockaddr_storage_iptostring(tmpip) << std::endl;
std::cerr << __PRETTY_FUNCTION__ << " ExtAddrFinder "
<< " reported external address "
<< sockaddr_storage_iptostring(tmpip)
<< std::endl;
}
}
}
/* also ask peer mgr. */
/* also ask peer mgr. */
if (mPeerMgr)
{
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
std::cerr << "p3NetMgrIMPL::netExtCheck() checking mPeerMgr" << std::endl;
#endif
uint8_t isstable ; // unused
sockaddr_storage tmpaddr ;
uint8_t isstable; // unused
sockaddr_storage tmpaddr;
if (mPeerMgr->getExtAddressReportedByFriends(tmpaddr, isstable))
if ( mPeerMgr->getExtAddressReportedByFriends(tmpaddr, isstable) &&
sockaddr_storage_ipv6_to_ipv4(tmpaddr) )
{
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext supplied by ExtAddrFinder" << std::endl;
#endif
/* best guess at port */
sockaddr_storage_setport(tmpaddr, sockaddr_storage_port(mLocalAddr));
sockaddr_storage_setport( tmpaddr,
sockaddr_storage_port(mLocalAddr) );
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
std::cerr << "p3NetMgrIMPL::netExtCheck() ";
@ -842,20 +837,21 @@ void p3NetMgrIMPL::netExtCheck()
std::cerr << std::endl;
#endif
//mNetFlags.mExtAddr = tmpaddr;
mNetFlags.mExtAddrOk = true;
mNetFlags.mExtAddrStableOk = isstable;
address_votes[tmpaddr].n++ ;
std::cerr << "PeerMgr reported external address " << sockaddr_storage_iptostring(tmpaddr) << std::endl;
address_votes[tmpaddr].n++;
std::cerr << __PRETTY_FUNCTION__ << " PeerMgr reported external"
<< " address "
<< sockaddr_storage_iptostring(tmpaddr) << std::endl;
}
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
else
std::cerr << " No reliable address returned." << std::endl;
else
std::cerr << " No reliable address returned." << std::endl;
#endif
}
/* any other sources ??? */
/* finalise address */
@ -950,14 +946,6 @@ void p3NetMgrIMPL::netExtCheck()
#endif
netAssistSetAddress(mNetFlags.mLocalAddr, mNetFlags.mExtAddr, mNetMode);
}
#if 0
else
{
std::cerr << "p3NetMgrIMPL::netExtCheck() setting ERR netAssistSetAddress(0)" << std::endl;
/* mode = 0 for error */
netAssistSetAddress(mNetFlags.mLocalAddr, mNetFlags.mExtAddr, mNetMode);
}
#endif
/* flag unreachables! */
if ((mNetFlags.mExtAddrOk) && (!mNetFlags.mExtAddrStableOk))
@ -966,9 +954,6 @@ void p3NetMgrIMPL::netExtCheck()
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext Unstable - Unreachable Check" << std::endl;
#endif
}
}
if (netSetupDone)
@ -988,9 +973,9 @@ void p3NetMgrIMPL::netExtCheck()
RsPeerId fakeId;
netAssistKnownPeer(fakeId, mExtAddr, NETASSIST_KNOWN_PEER_SELF | NETASSIST_KNOWN_PEER_ONLINE);
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::netExtCheck() Network Setup Complete");
std::cerr << __PRETTY_FUNCTION__ << " Network Setup Complete"
<< std::endl;
}
}
/**********************************************************************************************
@ -1002,8 +987,8 @@ bool p3NetMgrIMPL::checkNetAddress()
bool addrChanged = false;
bool validAddr = false;
struct sockaddr_storage prefAddr;
struct sockaddr_storage oldAddr;
sockaddr_storage prefAddr;
sockaddr_storage oldAddr;
if (mNetMode & RS_NET_MODE_TRY_LOOPBACK)
{
@ -1011,7 +996,7 @@ bool p3NetMgrIMPL::checkNetAddress()
std::cerr << "p3NetMgrIMPL::checkNetAddress() LOOPBACK ... forcing to 127.0.0.1";
std::cerr << std::endl;
#endif
sockaddr_storage_ipv4_aton(prefAddr, "127.0.0.1");
sockaddr_storage_ipv4_aton(prefAddr, "127.0.0.1");
validAddr = true;
}
else
@ -1021,15 +1006,19 @@ bool p3NetMgrIMPL::checkNetAddress()
* possible. It will require complete reenginering of the network layer
* code. */
/* For retro-compatibility strictly accept only IPv4 addresses here,
* IPv6 addresses are handled in a retro-compatible manner in
* p3PeerMgrIMPL::UpdateOwnAddress */
std::vector<sockaddr_storage> addrs;
if (getLocalAddresses(addrs))
{
for (auto it = addrs.begin(); it!=addrs.end(); ++it)
for (auto it = addrs.begin(); it != addrs.end(); ++it)
{
sockaddr_storage& addr(*it);
if( sockaddr_storage_isValidNet(addr) &&
!sockaddr_storage_isLoopbackNet(addr) &&
!sockaddr_storage_isLinkLocalNet(addr))
!sockaddr_storage_isLinkLocalNet(addr) &&
sockaddr_storage_ipv6_to_ipv4(addr) )
{
prefAddr = addr;
validAddr = true;
@ -1043,7 +1032,8 @@ bool p3NetMgrIMPL::checkNetAddress()
{
sockaddr_storage& addr(*it);
if( sockaddr_storage_isValidNet(addr) &&
!sockaddr_storage_isLoopbackNet(addr) )
!sockaddr_storage_isLoopbackNet(addr) &&
sockaddr_storage_ipv6_to_ipv4(addr) )
{
prefAddr = addr;
validAddr = true;
@ -1069,9 +1059,9 @@ bool p3NetMgrIMPL::checkNetAddress()
/* check addresses */
{
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
oldAddr = mLocalAddr;
RS_STACK_MUTEX(mNetMtx);
sockaddr_storage_copy(mLocalAddr, oldAddr);
addrChanged = !sockaddr_storage_sameip(prefAddr, mLocalAddr);
#ifdef NETMGR_DEBUG_TICK
@ -1097,7 +1087,7 @@ bool p3NetMgrIMPL::checkNetAddress()
// update address.
sockaddr_storage_copyip(mLocalAddr, prefAddr);
mNetFlags.mLocalAddr = mLocalAddr;
sockaddr_storage_copy(mLocalAddr, mNetFlags.mLocalAddr);
if(sockaddr_storage_isLoopbackNet(mLocalAddr))
{
@ -1144,9 +1134,13 @@ bool p3NetMgrIMPL::checkNetAddress()
* are the same (modify server)... this mismatch can
* occur when the local port is changed....
*/
if (sockaddr_storage_sameip(mLocalAddr, mExtAddr))
if (sockaddr_storage_sameip(mLocalAddr, mExtAddr) && sockaddr_storage_port(mLocalAddr) != sockaddr_storage_port(mExtAddr))
{
#ifdef NETMGR_DEBUG_RESET
std::cerr << "p3NetMgrIMPL::checkNetAddress() local and external ports are not the same. Setting external port to " << sockaddr_storage_port(mLocalAddr) << std::endl;
#endif
sockaddr_storage_setport(mExtAddr, sockaddr_storage_port(mLocalAddr));
addrChanged = true;
}
// ensure that address family is set, otherwise windows Barfs.
@ -1171,8 +1165,10 @@ bool p3NetMgrIMPL::checkNetAddress()
{
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
}
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::checkNetAddress() local address changed, resetting network");
std::cerr << __PRETTY_FUNCTION__
<< " local address changed, resetting network" << std::endl;
netReset();
}

View File

@ -4,6 +4,7 @@
* 3P/PQI network interface for RetroShare.
*
* Copyright 2007-2011 by Robert Fernie.
* Copyright (C) 2015-2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -23,6 +24,9 @@
*
*/
#include <vector> // for std::vector
#include <algorithm> // for std::random_shuffle
#include "rsserver/p3face.h"
#include "util/rsnet.h"
#include "pqi/authgpg.h"
@ -32,6 +36,7 @@
#include "pqi/p3linkmgr.h"
#include "pqi/p3netmgr.h"
#include "pqi/p3historymgr.h"
#include "pqi/pqinetwork.h" // for getLocalAddresses
//#include "pqi/p3dhtmgr.h" // Only need it for constants.
//#include "tcponudp/tou.h"
@ -69,6 +74,7 @@ static struct RsLog::logInfo p3peermgrzoneInfo = {RsLog::Default, "p3peermgr"};
/****
* #define PEER_DEBUG 1
* #define PEER_DEBUG_LOG 1
***/
#define MAX_AVAIL_PERIOD 230 //times a peer stay in available state when not connected
@ -326,8 +332,8 @@ const RsPeerId& p3PeerMgrIMPL::getOwnId()
bool p3PeerMgrIMPL::getOwnNetStatus(peerState &state)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
state = mOwnState;
RS_STACK_MUTEX(mPeerMtx);
state = mOwnState;
return true;
}
@ -812,15 +818,12 @@ int p3PeerMgrIMPL::getFriendCount(bool ssl, bool online)
bool p3PeerMgrIMPL::getFriendNetStatus(const RsPeerId &id, peerState &state)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RS_STACK_MUTEX(mPeerMtx);
/* check for existing */
std::map<RsPeerId, peerState>::iterator it;
it = mFriendList.find(id);
if (it == mFriendList.end())
{
return false;
}
if (it == mFriendList.end()) return false;
state = it->second;
return true;
@ -829,27 +832,24 @@ bool p3PeerMgrIMPL::getFriendNetStatus(const RsPeerId &id, peerState &state)
bool p3PeerMgrIMPL::getOthersNetStatus(const RsPeerId &id, peerState &state)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RS_STACK_MUTEX(mPeerMtx);
/* check for existing */
std::map<RsPeerId, peerState>::iterator it;
it = mOthersList.find(id);
if (it == mOthersList.end())
{
return false;
}
if (it == mOthersList.end()) return false;
state = it->second;
return true;
}
int p3PeerMgrIMPL::getConnectAddresses(const RsPeerId &id,
struct sockaddr_storage &lAddr, struct sockaddr_storage &eAddr,
pqiIpAddrSet &histAddrs, std::string &dyndns)
int p3PeerMgrIMPL::getConnectAddresses(
const RsPeerId &id, sockaddr_storage &lAddr, sockaddr_storage &eAddr,
pqiIpAddrSet &histAddrs, std::string &dyndns )
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RS_STACK_MUTEX(mPeerMtx);
/* check for existing */
std::map<RsPeerId, peerState>::iterator it;
it = mFriendList.find(id);
@ -860,7 +860,7 @@ int p3PeerMgrIMPL::getConnectAddresses(const RsPeerId &id,
std::cerr << std::endl;
return 0;
}
lAddr = it->second.localaddr;
eAddr = it->second.serveraddr;
histAddrs = it->second.ipAddrs;
@ -910,8 +910,9 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg
RsPeerId id = input_id ;
RsPgpId gpg_id = input_gpg_id ;
#ifdef PEER_DEBUG_LOG
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::addFriend() id: " + id.toStdString());
#endif
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
@ -1227,45 +1228,101 @@ void p3PeerMgrIMPL::printPeerLists(std::ostream &out)
* as it doesn't call back to there.
*/
bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_storage &localAddr, const struct sockaddr_storage &extAddr)
bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& pLocalAddr,
const sockaddr_storage& pExtAddr )
{
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress(";
std::cerr << sockaddr_storage_tostring(localAddr);
std::cerr << ", ";
std::cerr << sockaddr_storage_tostring(extAddr);
std::cerr << ")" << std::endl;
#endif
sockaddr_storage localAddr;
sockaddr_storage_copy(pLocalAddr, localAddr);
sockaddr_storage_ipv6_to_ipv4(localAddr);
if((rsBanList != NULL) && !rsBanList->isAddressAccepted(localAddr, RSBANLIST_CHECKING_FLAGS_BLACKLIST))
{
std::cerr << "(SS) Trying to set own IP to a banned IP " << sockaddr_storage_iptostring(localAddr) << ". This probably means that a friend in under traffic re-routing attack." << std::endl;
return false ;
}
sockaddr_storage extAddr;
sockaddr_storage_copy(pExtAddr, extAddr);
sockaddr_storage_ipv6_to_ipv4(extAddr);
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
//#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress("
<< sockaddr_storage_tostring(localAddr) << ", "
<< sockaddr_storage_tostring(extAddr) << ")" << std::endl;
//#endif
//update ip address list
pqiIpAddress ipAddressTimed;
ipAddressTimed.mAddr = localAddr;
ipAddressTimed.mSeenTime = time(NULL);
ipAddressTimed.mSrc = 0 ;
mOwnState.ipAddrs.updateLocalAddrs(ipAddressTimed);
if( rsBanList &&
!rsBanList->isAddressAccepted(localAddr,
RSBANLIST_CHECKING_FLAGS_BLACKLIST) )
{
std::cerr << "(SS) Trying to set own IP to a banned IP "
<< sockaddr_storage_iptostring(localAddr) << ". This probably"
<< "means that a friend in under traffic re-routing attack."
<< std::endl;
return false;
}
mOwnState.localaddr = localAddr;
}
{
RS_STACK_MUTEX(mPeerMtx);
//update ip address list
pqiIpAddress ipAddressTimed;
sockaddr_storage_copy(localAddr, ipAddressTimed.mAddr);
ipAddressTimed.mSeenTime = time(NULL);
ipAddressTimed.mSrc = 0;
mOwnState.ipAddrs.updateLocalAddrs(ipAddressTimed);
if(!mOwnState.hiddenNode)
{
/* Workaround to spread multiple local ip addresses when presents.
* This is needed because RS wrongly assumes that there is just one
* active local ip address at time. */
std::vector<sockaddr_storage> addrs;
if(getLocalAddresses(addrs))
{
/* To work around MAX_ADDRESS_LIST_SIZE addresses limitation,
* let's shuffle the list of local addresses in the hope that
* with enough time every local address is advertised to
* trusted nodes so they may try to connect to all of them
* including the most convenient if a local connection exists.
*/
std::random_shuffle(addrs.begin(), addrs.end());
for (auto it = addrs.begin(); it!=addrs.end(); ++it)
{
sockaddr_storage& addr(*it);
if( sockaddr_storage_isValidNet(addr) &&
!sockaddr_storage_isLoopbackNet(addr) &&
/* Avoid IPv6 link local addresses as we don't have
* implemented the logic needed to handle sin6_scope_id.
* To properly handle sin6_scope_id it would probably
* require deep reenginering of the RetroShare
* networking stack */
!sockaddr_storage_ipv6_isLinkLocalNet(addr) )
{
sockaddr_storage_ipv6_to_ipv4(addr);
pqiIpAddress pqiIp;
sockaddr_storage_clear(pqiIp.mAddr);
pqiIp.mAddr.ss_family = addr.ss_family;
sockaddr_storage_copyip(pqiIp.mAddr, addr);
sockaddr_storage_setport(
pqiIp.mAddr,
sockaddr_storage_port(localAddr) );
pqiIp.mSeenTime = time(nullptr);
pqiIp.mSrc = 0;
mOwnState.ipAddrs.updateLocalAddrs(pqiIp);
}
}
}
}
sockaddr_storage_copy(localAddr, mOwnState.localaddr);
}
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
{
RS_STACK_MUTEX(mPeerMtx);
//update ip address list
pqiIpAddress ipAddressTimed;
ipAddressTimed.mAddr = extAddr;
ipAddressTimed.mSeenTime = time(NULL);
ipAddressTimed.mSrc = 0 ;
mOwnState.ipAddrs.updateExtAddrs(ipAddressTimed);
//update ip address list
pqiIpAddress ipAddressTimed;
sockaddr_storage_copy(extAddr, ipAddressTimed.mAddr);
ipAddressTimed.mSeenTime = time(NULL);
ipAddressTimed.mSrc = 0;
mOwnState.ipAddrs.updateExtAddrs(ipAddressTimed);
/* Attempted Fix to MANUAL FORWARD Mode....
* don't update the server address - if we are in this mode
@ -1285,8 +1342,8 @@ bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_storage &localAddr,
std::cerr << std::endl;
}
else if (mOwnState.netMode & RS_NET_MODE_EXT)
{
sockaddr_storage_copyip(mOwnState.serveraddr,extAddr);
{
sockaddr_storage_copyip(mOwnState.serveraddr, extAddr);
std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress() Disabling Update of Server Port ";
std::cerr << " as MANUAL FORWARD Mode";
@ -1296,8 +1353,8 @@ bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_storage &localAddr,
std::cerr << std::endl;
}
else
{
mOwnState.serveraddr = extAddr;
{
sockaddr_storage_copy(extAddr, mOwnState.serveraddr);
}
}
@ -1371,21 +1428,25 @@ bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr
return changed;
}
bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr)
bool p3PeerMgrIMPL::setExtAddress( const RsPeerId &id,
const sockaddr_storage &addr )
{
bool changed = false;
uint32_t check_res = 0 ;
bool changed = false;
uint32_t check_res = 0;
if(rsBanList!=NULL && !rsBanList->isAddressAccepted(addr,RSBANLIST_CHECKING_FLAGS_BLACKLIST,&check_res))
{
std::cerr << "(SS) trying to set external contact address for peer " << id << " to a banned address " << sockaddr_storage_iptostring(addr )<< std::endl;
return false ;
}
if( rsBanList!=NULL && !rsBanList->isAddressAccepted(
addr, RSBANLIST_CHECKING_FLAGS_BLACKLIST, &check_res) )
{
std::cerr << "(SS) trying to set external contact address for peer "
<< id << " to a banned address "
<< sockaddr_storage_iptostring(addr) << std::endl;
return false;
}
if (id == AuthSSL::getAuthSSL()->OwnId())
{
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RS_STACK_MUTEX(mPeerMtx);
if (!sockaddr_storage_same(mOwnState.serveraddr, addr))
{
mOwnState.serveraddr = addr;
@ -1398,7 +1459,7 @@ bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_s
return changed;
}
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RS_STACK_MUTEX(mPeerMtx);
/* check if it is a friend */
std::map<RsPeerId, peerState>::iterator it;
if (mFriendList.end() == (it = mFriendList.find(id)))
@ -1406,7 +1467,9 @@ bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_s
if (mOthersList.end() == (it = mOthersList.find(id)))
{
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl;
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres "
<< "info : peer id not found in friend list id: " << id
<< std::endl;
#endif
return false;
}
@ -1957,7 +2020,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
RsPeerNetItem *item = new RsPeerNetItem();
item->clear();
item->peerId = getOwnId();
item->nodePeerId = getOwnId();
item->pgpId = mOwnState.gpg_id;
item->location = mOwnState.location;
@ -2008,7 +2071,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
item = new RsPeerNetItem();
item->clear();
item->peerId = it->first;
item->nodePeerId = it->first;
item->pgpId = (it->second).gpg_id;
item->location = (it->second).location;
item->netMode = (it->second).netMode;
@ -2208,7 +2271,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
RsPeerNetItem *pitem = dynamic_cast<RsPeerNetItem *>(*it);
if (pitem)
{
RsPeerId peer_id = pitem->peerId ;
RsPeerId peer_id = pitem->nodePeerId ;
RsPgpId peer_pgp_id = pitem->pgpId ;
if (peer_id == ownId)
@ -2235,7 +2298,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
/* ************* */
// permission flags is used as a mask for the existing perms, so we set it to 0xffff
addFriend(peer_id, peer_pgp_id, pitem->netMode, pitem->vs_disc, pitem->vs_dht, pitem->lastContact, RS_NODE_PERM_ALL);
setLocation(pitem->peerId, pitem->location);
setLocation(pitem->nodePeerId, pitem->location);
}
if (pitem->netMode == RS_NET_MODE_HIDDEN)

View File

@ -119,17 +119,20 @@ class p3NetMgrIMPL;
class p3PeerMgr
{
public:
public:
p3PeerMgr() { return; }
virtual ~p3PeerMgr() { return; }
p3PeerMgr() {}
virtual ~p3PeerMgr() {}
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT)) = 0;
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId) = 0;
virtual bool addFriend( const RsPeerId &ssl_id, const RsPgpId &gpg_id,
uint32_t netMode = RS_NET_MODE_UDP,
uint16_t vsDisc = RS_VS_DISC_FULL,
uint16_t vsDht = RS_VS_DHT_FULL,
time_t lastContact = 0,
ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT) ) = 0;
virtual bool isFriend(const RsPeerId& ssl_id) = 0;
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId) = 0;
virtual bool isFriend(const RsPeerId& ssl_id) = 0;
virtual bool getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId> &ids) = 0;
virtual bool removeAllFriendLocations(const RsPgpId &gpgid) = 0;
@ -146,7 +149,7 @@ virtual bool getGroupInfoByName(const std::string& groupName, RsGroupInfo &gr
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
virtual bool assignPeersToGroup(const RsNodeGroupId &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0;
virtual bool resetOwnExternalAddressList() = 0 ;
virtual bool resetOwnExternalAddressList() = 0 ;
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) =0;
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) =0;
@ -354,9 +357,9 @@ public:
bool setOwnNetworkMode(uint32_t netMode);
bool setOwnVisState(uint16_t vs_disc, uint16_t vs_dht);
int getConnectAddresses(const RsPeerId &id,
struct sockaddr_storage &lAddr, struct sockaddr_storage &eAddr,
pqiIpAddrSet &histAddrs, std::string &dyndns);
int getConnectAddresses( const RsPeerId &id, sockaddr_storage &lAddr,
sockaddr_storage &eAddr, pqiIpAddrSet &histAddrs,
std::string &dyndns );
protected:

View File

@ -38,7 +38,7 @@
class PQInterface;
class RSTrafficClue;
class RsBwRates;
class RsItem;
struct RsItem;
class RsRawItem;
class SearchModule

View File

@ -27,7 +27,7 @@
#include <stddef.h> // for NULL
class RsItem;
struct RsItem;
/***
#define LOOPBACK_DEBUG 1

View File

@ -31,7 +31,7 @@
#include "pqi/pqi_base.h" // for NetInterface (ptr only), PQInterface
#include "retroshare/rstypes.h" // for RsPeerId
class RsItem;
struct RsItem;
class pqiloopback: public PQInterface
{

View File

@ -41,6 +41,7 @@
#include "util/rsdebug.h"
#include "util/rsstring.h"
#include "util/rsnet.h"
#include "util/stacktrace.h"
static struct RsLog::logInfo pqinetzoneInfo = {RsLog::Default, "pqinet"};
#define pqinetzone &pqinetzoneInfo
@ -335,15 +336,17 @@ bool getLocalAddresses(std::vector<sockaddr_storage>& addrs)
struct ifaddrs *ifsaddrs, *ifa;
if(getifaddrs(&ifsaddrs) != 0)
{
std::cerr << "FATAL ERROR: getLocalAddresses failed!" << std::endl;
return false ;
std::cerr << __PRETTY_FUNCTION__ << " FATAL ERROR: " << errno << " "
<< strerror(errno) << std::endl;
print_stacktrace();
return false;
}
for ( ifa = ifsaddrs; ifa; ifa = ifa->ifa_next )
if ( ifa->ifa_addr && (ifa->ifa_flags & IFF_UP) )
{
sockaddr_storage tmp;
sockaddr_storage_clear(tmp);
if (sockaddr_storage_copyip(tmp, * reinterpret_cast<sockaddr_storage*>(ifa->ifa_addr)))
if (sockaddr_storage_copyip(tmp, *reinterpret_cast<sockaddr_storage*>(ifa->ifa_addr)))
addrs.push_back(tmp);
}
freeifaddrs(ifsaddrs);
@ -438,43 +441,17 @@ int unix_fcntl_nonblock(int fd)
}
int unix_connect(int fd, const struct sockaddr *serv_addr, socklen_t socklen)
int unix_connect(int fd, const sockaddr_storage &serv_addr)
{
#ifdef NET_DEBUG
std::cerr << "unix_connect()";
std::cerr << std::endl;
std::cerr << __PRETTY_FUNCTION__ << std::endl;
#endif
const struct sockaddr_storage *ss_addr = (struct sockaddr_storage *) serv_addr;
socklen_t len = socklen;
switch (ss_addr->ss_family)
{
case AF_INET:
len = sizeof(struct sockaddr_in);
break;
case AF_INET6:
len = sizeof(struct sockaddr_in6);
break;
}
if (len > socklen)
{
std::cerr << "unix_connect() ERROR len > socklen";
std::cerr << std::endl;
len = socklen;
//return EINVAL;
}
int ret = connect(fd, serv_addr, len);
int ret = connect( fd, (const struct sockaddr *) &serv_addr,
sizeof(struct sockaddr_in6) );
/******************* WINDOWS SPECIFIC PART ******************/
#ifdef WINDOWS_SYS // WINDOWS
#ifdef NET_DEBUG
std::cerr << "unix_connect()" << std::endl;
#endif
if (ret != 0)
{
errno = WinToUnixError(WSAGetLastError());

View File

@ -103,7 +103,7 @@ bool getLocalAddresses(std::vector<sockaddr_storage> & addrs);
int unix_close(int sockfd);
int unix_socket(int domain, int type, int protocol);
int unix_fcntl_nonblock(int sockfd);
int unix_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen);
int unix_connect(int sockfd, const sockaddr_storage& serv_addr);
int unix_getsockopt_error(int sockfd, int *err);
#ifdef WINDOWS_SYS // WINDOWS

View File

@ -45,6 +45,7 @@ static std::list<RsPeerId> waitingIds;
/****
*#define PGRP_DEBUG 1
*#define PGRP_DEBUG_LOG 1
****/
#define DEFAULT_DOWNLOAD_KB_RATE (200.0)
@ -420,7 +421,9 @@ int pqipersongrp::addPeer(const RsPeerId& id)
sm -> pqi = pqip;
// reset it to start it working.
#ifdef PGRP_DEBUG_LOG
pqioutput(PQL_WARNING, pqipersongrpzone, "pqipersongrp::addPeer() => reset() called to initialise new person");
#endif
pqip -> reset();
pqip -> listen();

View File

@ -4,6 +4,7 @@
* 3P/PQI network interface for RetroShare.
*
* Copyright 2004-2006 by Robert Fernie.
* Copyright (C) 2015-2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -59,14 +60,15 @@ static struct RsLog::logInfo pqisslzoneInfo = {RsLog::Default, "pqisslzone"};
#define PQISSL_PASSIVE 0x00
#define PQISSL_ACTIVE 0x01
#define PQISSL_DEBUG 1
#define PQISSL_LOG_DEBUG 1
const int PQISSL_LOCAL_FLAG = 0x01;
const int PQISSL_REMOTE_FLAG = 0x02;
const int PQISSL_UDP_FLAG = 0x02;
***********/
//#define PQISSL_DEBUG 1
//#define PQISSL_LOG_DEBUG 1
//#define PQISSL_LOG_DEBUG2 1
static const int PQISSL_MAX_READ_ZERO_COUNT = 20;
static const time_t PQISSL_MAX_READ_ZERO_TIME = 15; // 15 seconds of no data => reset. (atm HeartBeat pkt sent 5 secs)
@ -96,44 +98,14 @@ static const int PQISSL_SSL_CONNECT_TIMEOUT = 30;
*
*/
pqissl::pqissl(pqissllistener *l, PQInterface *parent, p3LinkMgr *lm)
:NetBinInterface(parent, parent->PeerId()),
mLinkMgr(lm), pqil(l),
mSslMtx("pqissl"),
active(false), certvalid(false), waiting(WAITING_NOT),
sslmode(PQISSL_ACTIVE), ssl_connection(NULL), sockfd(-1),
readpkt(NULL), pktlen(0), total_len(0),
attempt_ts(0),
n_read_zero(0), mReadZeroTS(0), ssl_connect_timeout(0),
mConnectDelay(0), mConnectTS(0),
mConnectTimeout(0), mTimeoutTS(0)
{
RsStackMutex stack(mSslMtx); /**** LOCKED MUTEX ****/
/* set address to zero */
sockaddr_storage_clear(remote_addr);
#ifdef PQISSL_LOG_DEBUG
rslog(RSL_DEBUG_BASIC, pqisslzone, "pqissl for PeerId: " + PeerId());
#endif
#if 0
if (!(AuthSSL::getAuthSSL()->isAuthenticated(PeerId())))
{
rslog(RSL_ALERT, pqisslzone,
"pqissl::Warning Certificate Not Approved!");
rslog(RSL_ALERT, pqisslzone,
"\t pqissl will not initialise....");
}
#else
rslog(RSL_DEBUG_BASIC, pqisslzone,
"pqissl::Warning SSL Certificate Approval Not CHECKED??");
#endif
return;
}
pqissl::pqissl(pqissllistener *l, PQInterface *parent, p3LinkMgr *lm) :
NetBinInterface(parent, parent->PeerId()),
mLinkMgr(lm), pqil(l), mSslMtx("pqissl"), active(false), certvalid(false),
waiting(WAITING_NOT), sslmode(PQISSL_ACTIVE), ssl_connection(NULL),
sockfd(-1), readpkt(NULL), pktlen(0), total_len(0), attempt_ts(0),
n_read_zero(0), mReadZeroTS(0), ssl_connect_timeout(0), mConnectDelay(0),
mConnectTS(0), mConnectTimeout(0), mTimeoutTS(0)
{ sockaddr_storage_clear(remote_addr); }
pqissl::~pqissl()
{
@ -151,11 +123,9 @@ pqissl::pqissl(pqissllistener *l, PQInterface *parent, p3LinkMgr *lm)
int pqissl::connect(const struct sockaddr_storage &raddr)
{
RsStackMutex stack(mSslMtx); /**** LOCKED MUTEX ****/
RS_STACK_MUTEX(mSslMtx);
// reset failures
remote_addr = raddr;
return ConnectAttempt();
}
@ -203,12 +173,11 @@ int pqissl::close()
// put back on the listening queue.
int pqissl::reset()
{
RsStackMutex stack(mSslMtx); /**** LOCKED MUTEX ****/
RS_STACK_MUTEX(mSslMtx);
return reset_locked();
}
int pqissl::reset_locked()
int pqissl::reset_locked()
{
std::string outLog;
bool neededReset = false;
@ -269,7 +238,9 @@ int pqissl::reset_locked()
#endif
}
#ifdef PQISSL_LOG_DEBUG2
rslog(RSL_ALERT, pqisslzone, outLog);
#endif
// notify people of problem!
// but only if we really shut something down.
@ -387,7 +358,7 @@ int pqissl::status()
out += " active: \n";
// print out connection.
out += "Connected TO : " + PeerId() + "\n";
out += "Connected TO : " + PeerId().toStdString() + "\n";
// print out cipher.
rs_sprintf_append(out, "\t\tSSL Cipher:%s", SSL_get_cipher(ssl_connection));
rs_sprintf_append(out, " (%d:%d)", SSL_get_cipher_bits(ssl_connection, &alg), alg);
@ -583,7 +554,7 @@ int pqissl::Delay_Connection()
#ifdef PQISSL_LOG_DEBUG
{
std::string out;
rs_sprintf(out, "pqissl::Delay_Connection() Delaying Connection to %s for %lu seconds", PeerId().c_str(), mConnectDelay);
rs_sprintf(out, "pqissl::Delay_Connection() Delaying Connection to %s for %lu seconds", PeerId().toStdString(), mConnectDelay);
rslog(RSL_DEBUG_BASIC, pqisslzone, out);
}
#endif
@ -596,7 +567,7 @@ int pqissl::Delay_Connection()
#ifdef PQISSL_LOG_DEBUG
{
std::string out;
rs_sprintf(out, "pqissl::Delay_Connection() Connection to %s starting in %ld seconds", PeerId().c_str(), mConnectTS - time(NULL));
rs_sprintf(out, "pqissl::Delay_Connection() Connection to %s starting in %ld seconds", PeerId().toStdString(), mConnectTS - time(NULL));
rslog(RSL_DEBUG_BASIC, pqisslzone, out);
}
#endif
@ -608,35 +579,30 @@ int pqissl::Delay_Connection()
}
rslog(RSL_WARNING, pqisslzone,
"pqissl::Initiate_Connection() Already Attempt in Progress!");
"pqissl::Delay_Connection() Already Attempt in Progress!");
return -1;
}
int pqissl::Initiate_Connection()
int pqissl::Initiate_Connection()
{
int err;
struct sockaddr_storage addr = remote_addr;
#ifdef PQISSL_LOG_DEBUG
rslog(RSL_DEBUG_BASIC, pqisslzone,
"pqissl::Initiate_Connection() Attempting Outgoing Connection....");
#ifdef PQISSL_DEBUG
std::cerr << __PRETTY_FUNCTION__ << " "
<< sockaddr_storage_tostring(remote_addr) << std::endl;
#endif
if (waiting != WAITING_DELAY)
int err;
sockaddr_storage addr; sockaddr_storage_copy(remote_addr, addr);
if(waiting != WAITING_DELAY)
{
rslog(RSL_WARNING, pqisslzone,
"pqissl::Initiate_Connection() Already Attempt in Progress!");
std::cerr << __PRETTY_FUNCTION__ << " Already Attempt in Progress!"
<< std::endl;
return -1;
}
#ifdef PQISSL_LOG_DEBUG
rslog(RSL_DEBUG_BASIC, pqisslzone,
"pqissl::Initiate_Connection() Opening Socket");
#endif
// open socket connection to addr.
int osock = unix_socket(PF_INET, SOCK_STREAM, 0);
int osock = unix_socket(PF_INET6, SOCK_STREAM, 0);
#ifdef PQISSL_LOG_DEBUG
{
@ -662,7 +628,7 @@ int pqissl::Initiate_Connection()
"pqissl::Initiate_Connection() Making Non-Blocking");
#endif
err = unix_fcntl_nonblock(osock);
err = unix_fcntl_nonblock(osock);
if (err < 0)
{
std::string out;
@ -674,13 +640,6 @@ int pqissl::Initiate_Connection()
return -1;
}
{
std::string out;
rs_sprintf(out, "pqissl::Initiate_Connection() Connecting To: %s via: ", PeerId().toStdString().c_str());
out += sockaddr_storage_tostring(addr);
rslog(RSL_WARNING, pqisslzone, out);
}
if (sockaddr_storage_isnull(addr))
{
rslog(RSL_WARNING, pqisslzone, "pqissl::Initiate_Connection() Invalid (0.0.0.0) Remote Address, Aborting Connect.");
@ -736,66 +695,55 @@ int pqissl::Initiate_Connection()
#endif
#endif // WINDOWS_SYS
/* Systems that supports dual stack sockets defines IPV6_V6ONLY and some set
* it to 1 by default. This enable dual stack socket on such systems.
* Systems which don't support dual stack (only Windows older then XP SP3)
* will support IPv6 only and not IPv4 */
#ifdef IPV6_V6ONLY
int no = 0;
err = rs_setsockopt( osock, IPPROTO_IPV6, IPV6_V6ONLY,
reinterpret_cast<uint8_t*>(&no), sizeof(no) );
#ifdef PQISSL_DEBUG
if (err) std::cerr << __PRETTY_FUNCTION__
<< " Error setting IPv6 socket dual stack: "
<< errno << " " << strerror(errno) << std::endl;
else std::cerr << __PRETTY_FUNCTION__
<< " Setting IPv6 socket dual stack" << std::endl;
#endif // PQISSL_DEBUG
#endif // IPV6_V6ONLY
mTimeoutTS = time(NULL) + mConnectTimeout;
//std::cerr << "Setting Connect Timeout " << mConnectTimeout << " Seconds into Future " << std::endl;
if (0 != (err = unix_connect(osock, (struct sockaddr *) &addr, sizeof(addr))))
sockaddr_storage_ipv4_to_ipv6(addr);
#ifdef PQISSL_DEBUG
std::cerr << __PRETTY_FUNCTION__ << " Connecting To: "
<< PeerId().toStdString() <<" via: "
<< sockaddr_storage_tostring(addr) << std::endl;
#endif
if (0 != (err = unix_connect(osock, addr)))
{
std::string out;
rs_sprintf(out, "pqissl::Initiate_Connection() connect returns:%d -> errno: %d error: %s\n", err, errno, socket_errorType(errno).c_str());
if (errno == EINPROGRESS)
switch (errno)
{
// set state to waiting.....
case EINPROGRESS:
waiting = WAITING_SOCK_CONNECT;
sockfd = osock;
#ifdef PQISSL_LOG_DEBUG
out += " EINPROGRESS Waiting for Socket Connection";
rslog(RSL_DEBUG_BASIC, pqisslzone, out);
#endif
return 0;
}
else if ((errno == ENETUNREACH) || (errno == ETIMEDOUT))
{
out += "ENETUNREACHABLE: cert: " + PeerId().toStdString();
rslog(RSL_WARNING, pqisslzone, out);
default:
#ifdef PQISSL_DEBUG
std::cerr << __PRETTY_FUNCTION__ << " Failure connect "
<< sockaddr_storage_tostring(addr)
<< " returns: "
<< err << " -> errno: " << errno << " "
<< socket_errorType(errno) << std::endl;
#endif
// Then send unreachable message.
net_internal_close(osock);
osock=-1;
//reset();
osock = -1;
waiting = WAITING_FAIL_INTERFACE;
return -1;
}
/* IF we get here ---- we Failed for some other reason.
* Should abandon this interface
* Known reasons to get here: EINVAL (bad address)
*/
rs_sprintf_append(out, "Error: Connection Failed: %d - %s", errno, socket_errorType(errno).c_str());
net_internal_close(osock);
osock=-1;
waiting = WAITING_FAIL_INTERFACE;
rslog(RSL_WARNING, pqisslzone, out);
// extra output for the moment.
std::cerr << out;
return -1;
}
else
{
#ifdef PQISSL_LOG_DEBUG
rslog(RSL_DEBUG_BASIC, pqisslzone,
"pqissl::Init_Connection() connect returned 0");
#endif
}
waiting = WAITING_SOCK_CONNECT;
@ -832,10 +780,14 @@ bool pqissl::CheckConnectionTimeout()
std::string out;
rs_sprintf(out, "pqissl::Basic_Connection_Complete() Connection Timed Out. Peer: %s Period: %lu", PeerId().toStdString().c_str(), mConnectTimeout);
#ifdef PQISSL_LOG_DEBUG2
rslog(RSL_WARNING, pqisslzone, out);
#endif
/* as sockfd is valid, this should close it all up */
#ifdef PQISSL_LOG_DEBUG2
rslog(RSL_ALERT, pqisslzone, "pqissl::Basic_Connection_Complete() -> calling reset()");
#endif
reset_locked();
return true;
}
@ -974,7 +926,9 @@ int pqissl::Basic_Connection_Complete()
{
std::string out;
rs_sprintf(out, "pqissl::Basic_Connection_Complete() TCP Connection Complete: cert: %s on osock: ", PeerId().toStdString().c_str(), sockfd);
#ifdef PQISSL_LOG_DEBUG2
rslog(RSL_WARNING, pqisslzone, out);
#endif
}
return 1;
}
@ -1105,7 +1059,7 @@ int pqissl::Initiate_SSL_Connection()
return 1;
}
int pqissl::SSL_Connection_Complete()
int pqissl::SSL_Connection_Complete()
{
#ifdef PQISSL_LOG_DEBUG
rslog(RSL_DEBUG_BASIC, pqisslzone,
@ -1247,27 +1201,21 @@ int pqissl::Extract_Failed_SSL_Certificate()
int pqissl::Authorise_SSL_Connection()
int pqissl::Authorise_SSL_Connection()
{
#ifdef PQISSL_LOG_DEBUG
rslog(RSL_DEBUG_BASIC, pqisslzone,
"pqissl::Authorise_SSL_Connection()");
#ifdef PQISSL_DEBUG
std::cerr << __PRETTY_FUNCTION__ << std::endl;
#endif
if (time(NULL) > ssl_connect_timeout)
{
rslog(RSL_WARNING, pqisslzone,
"pqissl::Authorise_SSL_Connection() Connection Timed Out!");
/* as sockfd is valid, this should close it all up */
rslog(RSL_ALERT, pqisslzone, "pqissl::Authorise_Connection_Complete() -> calling reset()");
reset_locked();
if (time(NULL) > ssl_connect_timeout)
{
std::cerr << __PRETTY_FUNCTION__ << " Connection timed out reset!"
<< std::endl;
reset_locked();
}
int err;
if (0 >= (err = SSL_Connection_Complete()))
{
return err;
}
if (0 >= (err = SSL_Connection_Complete())) return err;
#ifdef PQISSL_LOG_DEBUG
rslog(RSL_DEBUG_BASIC, pqisslzone,
@ -1352,36 +1300,54 @@ int pqissl::Authorise_SSL_Connection()
/* This function is public, and callable from pqilistener - so must be mutex protected */
int pqissl::accept(SSL *ssl, int fd, const struct sockaddr_storage &foreign_addr) // initiate incoming connection.
int pqissl::accept( SSL *ssl, int fd,
const sockaddr_storage &foreign_addr)
{
#ifdef PQISSL_DEBUG
std::cerr << "pqissl::accept()";
std::cerr << std::endl;
std::cerr << __PRETTY_FUNCTION__ << std::endl;
#endif
RsStackMutex stack(mSslMtx); /**** LOCKED MUTEX ****/
RS_STACK_MUTEX(mSslMtx);
return accept_locked(ssl, fd, foreign_addr);
}
int pqissl::accept_locked(SSL *ssl, int fd, const struct sockaddr_storage &foreign_addr) // initiate incoming connection.
int pqissl::accept_locked( SSL *ssl, int fd,
const sockaddr_storage &foreign_addr )
{
uint32_t check_result;
uint32_t checking_flags = RSBANLIST_CHECKING_FLAGS_BLACKLIST;
if (rsPeers->servicePermissionFlags(PeerId()) & RS_NODE_PERM_REQUIRE_WL)
checking_flags |= RSBANLIST_CHECKING_FLAGS_WHITELIST;
#ifdef PQISSL_DEBUG
std::cerr << __PRETTY_FUNCTION__ << std::endl;
#endif
if(rsBanList!=NULL && !rsBanList->isAddressAccepted(foreign_addr,checking_flags,&check_result))
{
std::cerr << "(SS) refusing incoming SSL connection from blacklisted foreign address " << sockaddr_storage_iptostring(foreign_addr)
<< ". Reason: " << check_result << "." << std::endl;
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_IP_BLACKLISTED, PeerId().toStdString(), sockaddr_storage_iptostring(foreign_addr), "", "", check_result);
uint32_t check_result;
uint32_t checking_flags = RSBANLIST_CHECKING_FLAGS_BLACKLIST;
if (rsPeers->servicePermissionFlags(PeerId()) & RS_NODE_PERM_REQUIRE_WL)
checking_flags |= RSBANLIST_CHECKING_FLAGS_WHITELIST;
if( rsBanList && !rsBanList->isAddressAccepted( foreign_addr,
checking_flags,
&check_result ) )
{
std::cerr << __PRETTY_FUNCTION__
<< " (SS) refusing incoming SSL connection from blacklisted "
<< "foreign address "
<< sockaddr_storage_iptostring(foreign_addr)
<< ". Reason: " << check_result << "." << std::endl;
RsServer::notify()->AddFeedItem(
RS_FEED_ITEM_SEC_IP_BLACKLISTED,
PeerId().toStdString(),
sockaddr_storage_iptostring(foreign_addr), "", "",
check_result);
reset_locked();
return -1;
}
return -1;
}
if (waiting != WAITING_NOT)
{
rslog(RSL_WARNING, pqisslzone, "pqissl::accept() Peer: " + PeerId().toStdString() + " - Two connections in progress - Shut 1 down!");
std::cerr << __PRETTY_FUNCTION__ << " Peer: " << PeerId().toStdString()
<< " - Two connections in progress - Shut 1 down!"
<< std::endl;
// outgoing connection in progress.
// shut this baby down.
@ -1392,70 +1358,51 @@ int pqissl::accept_locked(SSL *ssl, int fd, const struct sockaddr_storage &forei
switch(waiting)
{
case WAITING_SOCK_CONNECT:
#ifdef PQISSL_LOG_DEBUG
rslog(RSL_DEBUG_BASIC, pqisslzone,
"pqissl::accept() STATE = Waiting Sock Connect - close the socket");
#ifdef PQISSL_DEBUG
std::cerr << __PRETTY_FUNCTION__ << " STATE = Waiting Sock Connect "
<< "- close the socket" << std::endl;
#endif
break;
case WAITING_SSL_CONNECTION:
#ifdef PQISSL_LOG_DEBUG
rslog(RSL_DEBUG_BASIC, pqisslzone,
"pqissl::accept() STATE = Waiting SSL Connection - close sockfd + ssl_conn");
#ifdef PQISSL_DEBUG
std::cerr << __PRETTY_FUNCTION__ << " STATE = Waiting SSL "
<< "Connection - close sockfd + ssl_conn" << std::endl;
#endif
break;
case WAITING_SSL_AUTHORISE:
#ifdef PQISSL_LOG_DEBUG
rslog(RSL_DEBUG_BASIC, pqisslzone,
"pqissl::accept() STATE = Waiting SSL Authorise - close sockfd + ssl_conn");
#ifdef PQISSL_DEBUG
std::cerr << __PRETTY_FUNCTION__ << " STATE = Waiting SSL Authorise"
<< " - close sockfd + ssl_conn" << std::endl;
#endif
break;
case WAITING_FAIL_INTERFACE:
#ifdef PQISSL_LOG_DEBUG
rslog(RSL_DEBUG_BASIC, pqisslzone,
"pqissl::accept() STATE = Failed, ignore?");
#ifdef PQISSL_DEBUG
std::cerr << __PRETTY_FUNCTION__ << " STATE = Failed, ignore?"
<< std::endl;
#endif
break;
default:
rslog(RSL_ALERT, pqisslzone,
"pqissl::accept() STATE = Unknown - ignore?");
rslog(RSL_ALERT, pqisslzone, "pqissl::accept() -> calling reset()");
std::cerr << __PRETTY_FUNCTION__ << " STATE = Unknown - resetting!"
<< std::endl;
reset_locked();
break;
}
//waiting = WAITING_FAIL_INTERFACE;
//return -1;
}
/* shutdown existing - in all cases use the new one */
if ((ssl_connection) && (ssl_connection != ssl))
{
rslog(RSL_ALERT, pqisslzone,
"pqissl::accept() closing Previous/Existing ssl_connection");
std::cerr << __PRETTY_FUNCTION__
<< " closing Previous/Existing ssl_connection" << std::endl;
SSL_shutdown(ssl_connection);
SSL_free (ssl_connection);
}
if ((sockfd > -1) && (sockfd != fd))
{
rslog(RSL_ALERT, pqisslzone,
"pqissl::accept() closing Previous/Existing sockfd");
std::cerr << __PRETTY_FUNCTION__ << " closing Previous/Existing sockfd"
<< std::endl;
net_internal_close(sockfd);
}
@ -1468,54 +1415,39 @@ int pqissl::accept_locked(SSL *ssl, int fd, const struct sockaddr_storage &forei
/* if we connected - then just writing the same over,
* but if from ssllistener then we need to save the address.
*/
remote_addr = foreign_addr;
sockaddr_storage_copy(foreign_addr, remote_addr);
/* check whether it is on the same LAN */
struct sockaddr_storage localaddr;
mLinkMgr->getLocalAddress(localaddr);
std::cerr << __PRETTY_FUNCTION__ << " SUCCESSFUL connection to: "
<< PeerId().toStdString() << " remoteaddr: "
<< sockaddr_storage_iptostring(remote_addr) << std::endl;
#ifdef PQISSL_DEBUG
{
std::string out = "pqissl::accept() SUCCESSFUL connection to: " + PeerId().toStdString();
out += " localaddr: " + sockaddr_storage_iptostring(localaddr);
out += " remoteaddr: " + sockaddr_storage_iptostring(remote_addr);
rslog(RSL_WARNING, pqisslzone, out);
}
// establish the ssl details.
// cipher name.
int err;
#ifdef PQISSL_LOG_DEBUG
{
int alg;
std::string out;
rs_sprintf(out, "SSL Cipher:%s\n", SSL_get_cipher(ssl));
rs_sprintf_append(out, "SSL Cipher Bits:%d - %d\n", SSL_get_cipher_bits(ssl, &alg), alg);
rs_sprintf_append(out, "SSL Cipher Version:%s\n", SSL_get_cipher_version(ssl));
rslog(RSL_DEBUG_BASIC, pqisslzone, out);
int alg;
std::cerr << __PRETTY_FUNCTION__ << "SSL Cipher: "
<< SSL_get_cipher(ssl) << std::endl << "SSL Cipher Bits: "
<< SSL_get_cipher_bits(ssl, &alg) << " - " << alg
<< std::endl;
}
#endif
// make non-blocking / or check.....
if ((err = net_internal_fcntl_nonblock(sockfd)) < 0)
int err;
if ((err = net_internal_fcntl_nonblock(sockfd)) < 0)
{
rslog(RSL_ALERT, pqisslzone, "Error: Cannot make socket NON-Blocking: ");
std::cerr << __PRETTY_FUNCTION__ << "Cannot make socket NON-Blocking "
<< "reset!" << std::endl;
active = false;
waiting = WAITING_FAIL_INTERFACE;
// failed completely.
rslog(RSL_ALERT, pqisslzone, "pqissl::accept() -> calling reset()");
waiting = WAITING_FAIL_INTERFACE; // failed completely.
reset_locked();
return -1;
}
else
{
#ifdef PQISSL_LOG_DEBUG
rslog(RSL_DEBUG_BASIC, pqisslzone, "pqissl::accept() Socket Made Non-Blocking!");
#ifdef PQISSL_DEBUG
else std::cerr << __PRETTY_FUNCTION__ << " Socket made non-nlocking!"
<< std::endl;
#endif
}
// we want to continue listening - incase this socket is crap, and they try again.
//stoplistening();
@ -1524,15 +1456,16 @@ int pqissl::accept_locked(SSL *ssl, int fd, const struct sockaddr_storage &forei
waiting = WAITING_NOT;
#ifdef PQISSL_DEBUG
std::cerr << "pqissl::accept_locked() connection complete - notifying parent";
std::cerr << std::endl;
std::cerr << __PRETTY_FUNCTION__ << "connection complete - notifying parent"
<< std::endl;
#endif
// Notify the pqiperson.... (Both Connect/Receive)
if (parent())
{
struct sockaddr_storage addr = remote_addr;
parent() -> notifyEvent(this, NET_CONNECT_SUCCESS, addr);
// Is the copy necessary?
sockaddr_storage addr; sockaddr_storage_copy(remote_addr, addr);
parent()->notifyEvent(this, NET_CONNECT_SUCCESS, addr);
}
return 1;
}
@ -1626,31 +1559,35 @@ int pqissl::senddata(void *data, int len)
return tmppktlen;
}
int pqissl::readdata(void *data, int len)
int pqissl::readdata(void *data, int len)
{
RsStackMutex stack(mSslMtx); /**** LOCKED MUTEX ****/
RS_STACK_MUTEX(mSslMtx);
#ifdef PQISSL_DEBUG
std::cout << "Reading data thread=" << pthread_self() << ", ssl=" << (void*)this << std::endl ;
std::cout << "Reading data thread=" << pthread_self() << ", ssl="
<< (void*)this << std::endl;
#endif
// Safety check. Apparently this avoids some SIGSEGV.
//
if (ssl_connection == NULL)
return -1 ;
if (ssl_connection == NULL) return -1;
// There is a do, because packets can be splitted into multiple ssl buffers
// when they are larger than 16384 bytes. Such packets have to be read in
// multiple slices.
do
{
int tmppktlen ;
int tmppktlen;
#ifdef PQISSL_DEBUG
std::cerr << "calling SSL_read. len=" << len << ", total_len=" << total_len << std::endl ;
std::cerr << "calling SSL_read. len=" << len << ", total_len="
<< total_len << std::endl;
#endif
ERR_clear_error() ;
tmppktlen = SSL_read(ssl_connection, (void*)( &(((uint8_t*)data)[total_len])), len-total_len) ;
ERR_clear_error();
tmppktlen = SSL_read(ssl_connection,
(void*)( &(((uint8_t*)data)[total_len])),
len-total_len);
#ifdef PQISSL_DEBUG
std::cerr << "have read " << tmppktlen << " bytes" << std::endl ;
std::cerr << "data[0] = "
@ -1665,7 +1602,6 @@ int pqissl::readdata(void *data, int len)
#endif
// Need to catch errors.....
//
if (tmppktlen <= 0) // probably needs a reset.
{
std::string out;

View File

@ -4,6 +4,7 @@
* 3P/PQI network interface for RetroShare.
*
* Copyright 2004-2006 by Robert Fernie.
* Copyright (C) 2015-2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -114,16 +115,13 @@ virtual bool cansend(uint32_t usec);
virtual int close(); /* BinInterface version of reset() */
virtual RsFileHash gethash(); /* not used here */
virtual bool bandwidthLimited() { return true ; } // replace by !sameLAN to avoid bandwidth limiting on LAN
virtual bool bandwidthLimited() { return true ; }
public:
/* Completion of the SSL connection,
* this is public, so it can be called by
* the listener (should make friends??)
*/
/// initiate incoming connection.
int accept(SSL *ssl, int fd, const struct sockaddr_storage &foreign_addr);
int accept(SSL *ssl, int fd, const struct sockaddr_storage &foreign_addr);
void getCryptoParams(RsPeerCryptoParams& params) ;
bool actAsServer();
@ -139,7 +137,10 @@ protected:
RsMutex mSslMtx; /**** MUTEX protects data and fn below ****/
virtual int reset_locked();
int accept_locked(SSL *ssl, int fd, const struct sockaddr_storage &foreign_addr);
/// initiate incoming connection.
int accept_locked( SSL *ssl, int fd,
const sockaddr_storage& foreign_addr );
// A little bit of information to describe
// the SSL state, this is needed

View File

@ -4,6 +4,7 @@
* 3P/PQI network interface for RetroShare.
*
* Copyright 2004-2006 by Robert Fernie.
* Copyright (C) 2015-2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -59,8 +60,10 @@ static struct RsLog::logInfo pqissllistenzoneInfo = {RsLog::Default, "p3peermgr"
pqissllistenbase::pqissllistenbase(const sockaddr_storage &addr, p3PeerMgr *pm)
: laddr(addr), mPeerMgr(pm), active(false)
: mPeerMgr(pm), active(false)
{
sockaddr_storage_copy(addr, laddr);
if (!(AuthSSL::getAuthSSL()-> active()))
{
pqioutput(PQL_ALERT, pqissllistenzone,
@ -103,17 +106,29 @@ int pqissllistenbase::status()
return 1;
}
int pqissllistenbase::setuplisten()
int pqissllistenbase::setuplisten()
{
int err;
if (active)
return -1;
int err;
if (active) return -1;
lsock = socket(PF_INET6, SOCK_STREAM, 0);
#ifdef IPV6_V6ONLY
int no = 0;
err = rs_setsockopt(lsock, IPPROTO_IPV6, IPV6_V6ONLY,
reinterpret_cast<uint8_t*>(&no), sizeof(no));
if (err) std::cerr << __PRETTY_FUNCTION__
<< ": Error setting IPv6 socket dual stack" << std::endl;
#ifdef DEBUG_LISTENNER
else std::cerr << __PRETTY_FUNCTION__
<< ": Success setting IPv6 socket dual stack" << std::endl;
#endif
#endif // IPV6_V6ONLY
lsock = socket(PF_INET, SOCK_STREAM, 0);
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS // ie UNIX
if (lsock < 0)
{
if (lsock < 0)
{
pqioutput(PQL_ALERT, pqissllistenzone,
"pqissllistenbase::setuplisten() Cannot Open Socket!");
@ -197,22 +212,20 @@ int pqissllistenbase::setuplisten()
}
}
#ifdef OPEN_UNIVERSAL_PORT
struct sockaddr_storage tmpaddr = laddr;
struct sockaddr_storage tmpaddr;
sockaddr_storage_copy(laddr, tmpaddr);
sockaddr_storage_ipv4_to_ipv6(tmpaddr);
if (!mPeerMgr->isHidden()) sockaddr_storage_zeroip(tmpaddr);
if (0 != (err = universal_bind(lsock, (struct sockaddr *) &tmpaddr, sizeof(tmpaddr))))
#else
if (0 != (err = universal_bind(lsock, (struct sockaddr *) &laddr, sizeof(laddr))))
#endif
if (0 != (err = rs_bind(lsock, tmpaddr)))
{
std::string out = "pqissllistenbase::setuplisten() Cannot Bind to Local Address!\n";
showSocketError(out);
pqioutput(PQL_ALERT, pqissllistenzone, out);
std::cerr << out << std::endl;
std::cerr << "laddr: " << sockaddr_storage_tostring(laddr) << std::endl;
#ifdef OPEN_UNIVERSAL_PORT
if (!mPeerMgr->isHidden()) std::cerr << "Zeroed tmpaddr: " << sockaddr_storage_tostring(tmpaddr) << std::endl;
#endif
std::cerr << out << std::endl
<< "tmpaddr: " << sockaddr_storage_tostring(tmpaddr)
<< std::endl;
print_stacktrace();
return -1;
}

View File

@ -42,6 +42,7 @@ static struct RsLog::logInfo pqisslproxyzoneInfo = {RsLog::Default, "pqisslproxy
#define pqisslproxyzone &pqisslproxyzoneInfo
// #define PROXY_DEBUG 1
// #define PROXY_DEBUG_LOG 1
#define PROXY_STATE_FAILED 0
#define PROXY_STATE_INIT 1
@ -593,8 +594,9 @@ bool pqisslproxy::connect_parameter(uint32_t type, const std::string &value)
{
std::string out;
rs_sprintf(out, "pqisslproxy::connect_parameter() Peer: %s DOMAIN_ADDRESS: %s", PeerId().toStdString().c_str(), value.c_str());
#ifdef PROXY_DEBUG_LOG
rslog(RSL_WARNING, pqisslproxyzone, out);
#endif
mDomainAddress = value;
#ifdef PROXY_DEBUG
std::cerr << out << std::endl;
@ -615,8 +617,9 @@ bool pqisslproxy::connect_parameter(uint32_t type, uint32_t value)
{
std::string out;
rs_sprintf(out, "pqisslproxy::connect_parameter() Peer: %s REMOTE_PORT: %lu", PeerId().toStdString().c_str(), value);
#ifdef PROXY_DEBUG_LOG
rslog(RSL_WARNING, pqisslproxyzone, out);
#endif
mRemotePort = value;
#ifdef PROXY_DEBUG
std::cerr << out << std::endl;

View File

@ -227,6 +227,15 @@ int pqissludp::Initiate_Connection()
return -1;
}
if(!sockaddr_storage_ipv6_to_ipv4(remote_addr))
{
std::cerr << __PRETTY_FUNCTION__ << "Error: remote_addr is not "
<< "valid IPv4!" << std::endl;
sockaddr_storage_dump(remote_addr);
print_stacktrace();
return -EINVAL;
}
mTimeoutTS = time(NULL) + mConnectTimeout;
//std::cerr << "Setting Connect Timeout " << mConnectTimeout << " Seconds into Future " << std::endl;
//std::cerr << " Connect Period is:" << mConnectPeriod << std::endl;
@ -250,22 +259,28 @@ int pqissludp::Initiate_Connection()
{
std::cerr << "CONVERTING ALL ADDRESSES TO IPV4: TODO make IPV6";
std::cerr << std::endl;
struct sockaddr_in srcaddr;
struct sockaddr_in proxyaddr;
struct sockaddr_in remoteaddr;
if ((mConnectSrcAddr.ss_family != AF_INET) ||
(mConnectProxyAddr.ss_family != AF_INET) ||
(remote_addr.ss_family != AF_INET))
if(!sockaddr_storage_ipv6_to_ipv4(mConnectSrcAddr))
{
std::cerr << "Error One Address is not IPv4. aborting";
std::cerr << std::endl;
abort();
std::cerr << __PRETTY_FUNCTION__ << "Error: mConnectSrcAddr is "
<< "not valid IPv4!" << std::endl;
sockaddr_storage_dump(mConnectSrcAddr);
print_stacktrace();
return -EINVAL;
}
if(!sockaddr_storage_ipv6_to_ipv4(mConnectProxyAddr))
{
std::cerr << __PRETTY_FUNCTION__ << "Error: mConnectProxyAddr "
<< "is not valid IPv4!" << std::endl;
sockaddr_storage_dump(mConnectProxyAddr);
print_stacktrace();
return -EINVAL;
}
struct sockaddr_in *rap = (struct sockaddr_in *) &remote_addr;
struct sockaddr_in *pap = (struct sockaddr_in *) &mConnectProxyAddr;
struct sockaddr_in *sap = (struct sockaddr_in *) &mConnectSrcAddr;
@ -285,7 +300,6 @@ int pqissludp::Initiate_Connection()
err = tou_connect_via_relay(sockfd, &srcaddr, &proxyaddr, &remoteaddr);
}
/*** It seems that the UDP Layer sees x 1.2 the traffic of the SSL layer.
* We need to compensate somewhere... we drop the maximum traffic to 75% of limit

View File

@ -38,7 +38,7 @@
#include "retroshare/rstypes.h" // for RsPeerId
#include "util/rsthreads.h" // for RsMutex
class RsItem;
struct RsItem;
class RsSerialiser;
struct PartialPacketRecord

View File

@ -182,7 +182,7 @@ private:
class StringExpression: public Expression
{
public:
StringExpression(enum StringOperator op, std::list<std::string> &t, bool ic): Op(op),terms(t), IgnoreCase(ic){}
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;
@ -275,7 +275,7 @@ Some implementations of StringExpressions.
class NameExpression: public StringExpression
{
public:
NameExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
NameExpression(enum StringOperator op, const std::list<std::string> &t, bool ic):
StringExpression(op,t,ic) {}
bool eval(const ExpFileEntry& file);
@ -290,7 +290,7 @@ public:
class PathExpression: public StringExpression {
public:
PathExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
PathExpression(enum StringOperator op, const std::list<std::string> &t, bool ic):
StringExpression(op,t,ic) {}
bool eval(const ExpFileEntry& file);
@ -305,7 +305,7 @@ public:
class ExtExpression: public StringExpression {
public:
ExtExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
ExtExpression(enum StringOperator op, const std::list<std::string> &t, bool ic):
StringExpression(op,t,ic) {}
bool eval(const ExpFileEntry& file);
@ -320,7 +320,7 @@ public:
class HashExpression: public StringExpression {
public:
HashExpression(enum StringOperator op, std::list<std::string> &t):
HashExpression(enum StringOperator op, const std::list<std::string> &t):
StringExpression(op,t, true) {}
bool eval(const ExpFileEntry& file);

View File

@ -169,10 +169,9 @@ public:
class RsFiles
{
public:
RsFiles() { return; }
virtual ~RsFiles() { return; }
public:
RsFiles() {}
virtual ~RsFiles() {}
/**
* Provides file data for the gui: media streaming or rpc clients.
@ -281,8 +280,8 @@ class RsFiles
***/
virtual void requestDirUpdate(void *ref) =0 ; // triggers the update of the given reference. Used when browsing.
virtual void setDownloadDirectory(std::string path) = 0;
virtual void setPartialsDirectory(std::string path) = 0;
virtual bool setDownloadDirectory(std::string path) = 0;
virtual bool setPartialsDirectory(std::string path) = 0;
virtual std::string getDownloadDirectory() = 0;
virtual std::string getPartialsDirectory() = 0;

View File

@ -124,24 +124,27 @@ class RsGxsComment
};
class RsGxsCommentService
struct RsGxsCommentService
{
public:
RsGxsCommentService() {}
virtual ~RsGxsCommentService() {}
RsGxsCommentService() { return; }
virtual ~RsGxsCommentService() { return; }
/** Get previously requested comment data with token */
virtual bool getCommentData( uint32_t token,
std::vector<RsGxsComment> &comments ) = 0;
virtual bool getRelatedComments( uint32_t token,
std::vector<RsGxsComment> &comments ) = 0;
virtual bool getCommentData(const uint32_t &token, std::vector<RsGxsComment> &comments) = 0;
virtual bool getRelatedComments(const uint32_t &token, std::vector<RsGxsComment> &comments) = 0;
virtual bool createComment(uint32_t &token, RsGxsComment &comment) = 0;
virtual bool createVote(uint32_t &token, RsGxsVote &vote) = 0;
//virtual bool getDetailedCommentData(const uint32_t &token, std::vector<RsGxsComment> &comments);
virtual bool createComment(uint32_t &token, RsGxsComment &comment) = 0;
virtual bool createVote(uint32_t &token, RsGxsVote &vote) = 0;
virtual bool acknowledgeComment(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId) = 0;
virtual bool acknowledgeVote(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId) = 0;
virtual bool acknowledgeComment(
uint32_t token,
std::pair<RsGxsGroupId, RsGxsMessageId>& msgId ) = 0;
virtual bool acknowledgeVote(
uint32_t token,
std::pair<RsGxsGroupId, RsGxsMessageId>& msgId ) = 0;
};

View File

@ -40,8 +40,8 @@ class RsGxsChanges
public:
RsGxsChanges(): mService(0){}
RsTokenService *mService;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgs;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgsMeta;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgs;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgsMeta;
std::list<RsGxsGroupId> mGrps;
std::list<RsGxsGroupId> mGrpsMeta;
};

View File

@ -1,3 +1,23 @@
/*
* rsgxsifacetypes.h
*
* Copyright (C) 2013 crispy
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* rsgxsifacetypes.h
*
@ -13,18 +33,20 @@
#include <string>
#include <inttypes.h>
#include <retroshare/rstypes.h>
#include <retroshare/rsids.h>
#include "retroshare/rstypes.h"
#include "retroshare/rsids.h"
#include "serialiser/rsserializable.h"
#include "serialiser/rstypeserializer.h"
typedef GXSGroupId RsGxsGroupId;
typedef Sha1CheckSum RsGxsMessageId;
typedef GXSId RsGxsId;
typedef GXSCircleId RsGxsCircleId;
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgIdResult;
typedef std::map<RsGxsGroupId, std::set<RsGxsMessageId> > GxsMsgIdResult;
typedef std::pair<RsGxsGroupId, RsGxsMessageId> RsGxsGrpMsgIdPair;
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMessageId> > MsgRelatedIdResult;
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq;
typedef std::map<RsGxsGrpMsgIdPair, std::set<RsGxsMessageId> > MsgRelatedIdResult;
typedef std::map<RsGxsGroupId, std::set<RsGxsMessageId> > GxsMsgReq;
struct RsMsgMetaData;
@ -34,7 +56,7 @@ typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > MsgMetaResult;
class RsGxsGrpMetaData;
class RsGxsMsgMetaData;
struct RsGroupMetaData
struct RsGroupMetaData : RsSerializable
{
// (csoler) The correct default value to be used in mCircleType is GXS_CIRCLE_TYPE_PUBLIC, which is defined in rsgxscircles.h,
// but because of a loop in the includes, I cannot include it here. So I replaced with its current value 0x0001.
@ -73,6 +95,30 @@ struct RsGroupMetaData
std::string mServiceString; // Service Specific Free-Form extra storage.
RsPeerId mOriginator;
RsGxsCircleId mInternalCircle;
/// @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx )
{
RS_SERIAL_PROCESS(mGroupId);
RS_SERIAL_PROCESS(mGroupName);
RS_SERIAL_PROCESS(mGroupFlags);
RS_SERIAL_PROCESS(mSignFlags);
RS_SERIAL_PROCESS(mPublishTs);
RS_SERIAL_PROCESS(mAuthorId);
RS_SERIAL_PROCESS(mCircleId);
RS_SERIAL_PROCESS(mCircleType);
RS_SERIAL_PROCESS(mAuthenFlags);
RS_SERIAL_PROCESS(mParentGrpId);
RS_SERIAL_PROCESS(mSubscribeFlags);
RS_SERIAL_PROCESS(mPop);
RS_SERIAL_PROCESS(mVisibleMsgCount);
RS_SERIAL_PROCESS(mLastPost);
RS_SERIAL_PROCESS(mGroupStatus);
RS_SERIAL_PROCESS(mServiceString);
RS_SERIAL_PROCESS(mOriginator);
RS_SERIAL_PROCESS(mInternalCircle);
}
};

View File

@ -58,7 +58,7 @@ class RsGxsMsgChange : public RsGxsNotify
{
public:
RsGxsMsgChange(NotifyType type, bool metaChange) : NOTIFY_TYPE(type), mMetaChange(metaChange) {}
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgChangeMap;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgChangeMap;
NotifyType getType(){ return NOTIFY_TYPE;}
bool metaChange() { return mMetaChange; }
private:

View File

@ -6,7 +6,8 @@
*
* RetroShare C++ Interface.
*
* Copyright 2012-2012 by Robert Fernie.
* Copyright (C) 2012 Robert Fernie.
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -36,9 +37,12 @@
#include "retroshare/rsids.h"
#include "serialiser/rstlvimage.h"
#include "retroshare/rsgxscommon.h"
#include "serialiser/rsserializable.h"
#include "serialiser/rstypeserializer.h"
#include "util/rsdeprecate.h"
/* The Main Interface Class - for information about your Peers */
class RsIdentity;
struct RsIdentity;
extern RsIdentity *rsIdentity;
@ -63,6 +67,7 @@ extern RsIdentity *rsIdentity;
#define RSID_RELATION_OTHER 0x0008
#define RSID_RELATION_UNKNOWN 0x0010
/// @deprecated remove toghether with RsGxsIdGroup::mRecognTags
#define RSRECOGN_MAX_TAGINFO 5
// Unicode symbols. NOT utf-8 bytes, because of multi byte characters
@ -77,27 +82,36 @@ static const uint32_t RS_IDENTITY_FLAGS_PGP_KNOWN = 0x0004;
static const uint32_t RS_IDENTITY_FLAGS_IS_OWN_ID = 0x0008;
static const uint32_t RS_IDENTITY_FLAGS_IS_DEPRECATED= 0x0010; // used to denote keys with deprecated fingerprint format.
class GxsReputation
struct GxsReputation : RsSerializable
{
public:
GxsReputation();
GxsReputation();
bool updateIdScore(bool pgpLinked, bool pgpKnown);
bool update(); // checks ranges and calculates overall score.
int mOverallScore;
int mIdScore; // PGP, Known, etc.
int mOwnOpinion;
int mPeerOpinion;
bool updateIdScore(bool pgpLinked, bool pgpKnown);
bool update(); /// checks ranges and calculates overall score.
int32_t mOverallScore;
int32_t mIdScore; /// PGP, Known, etc.
int32_t mOwnOpinion;
int32_t mPeerOpinion;
/// @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx )
{
RS_SERIAL_PROCESS(mOverallScore);
RS_SERIAL_PROCESS(mIdScore);
RS_SERIAL_PROCESS(mOwnOpinion);
RS_SERIAL_PROCESS(mPeerOpinion);
}
};
struct RsGxsIdGroup
struct RsGxsIdGroup : RsSerializable
{
RsGxsIdGroup() :
mLastUsageTS(0), mPgpKnown(false), mIsAContact(false) {}
~RsGxsIdGroup() {}
RsGroupMetaData mMeta;
// In GroupMetaData.
@ -120,7 +134,7 @@ struct RsGxsIdGroup
std::string mPgpIdSign;
// Recognition Strings. MAX# defined above.
std::list<std::string> mRecognTags;
RS_DEPRECATED std::list<std::string> mRecognTags;
// Avatar
RsGxsImage mImage ;
@ -131,8 +145,11 @@ struct RsGxsIdGroup
bool mIsAContact; // change that into flags one day
RsPgpId mPgpId;
GxsReputation mReputation;
};
/// @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx );
};
std::ostream &operator<<(std::ostream &out, const RsGxsIdGroup &group);
@ -149,12 +166,11 @@ class RsRecognTag
};
class RsRecognTagDetails
struct RsRecognTagDetails
{
public:
RsRecognTagDetails()
:valid_from(0), valid_to(0), tag_class(0), tag_type(0),
is_valid(false), is_pending(false) { return; }
RsRecognTagDetails() :
valid_from(0), valid_to(0), tag_class(0), tag_type(0), is_valid(false),
is_pending(false) {}
time_t valid_from;
time_t valid_to;
@ -167,105 +183,166 @@ class RsRecognTagDetails
bool is_pending;
};
class RsIdOpinion
{
public:
RsGxsId id;
int rating;
};
class RsIdentityParameters
struct RsIdentityParameters
{
public:
RsIdentityParameters(): isPgpLinked(false) { return; }
RsIdentityParameters() :
isPgpLinked(false) {}
bool isPgpLinked;
std::string nickname;
RsGxsImage mImage ;
std::string nickname;
RsGxsImage mImage;
};
class RsIdentityUsage
struct RsIdentityUsage : RsSerializable
{
public:
enum UsageCode { UNKNOWN_USAGE = 0x00,
GROUP_ADMIN_SIGNATURE_CREATION = 0x01, // These 2 are normally not normal GXS identities, but nothing prevents it to happen either.
GROUP_ADMIN_SIGNATURE_VALIDATION = 0x02,
GROUP_AUTHOR_SIGNATURE_CREATION = 0x03, // not typically used, since most services do not require group author signatures
GROUP_AUTHOR_SIGNATURE_VALIDATION = 0x04,
MESSAGE_AUTHOR_SIGNATURE_CREATION = 0x05, // most common use case. Messages are signed by authors in e.g. forums.
MESSAGE_AUTHOR_SIGNATURE_VALIDATION = 0x06,
GROUP_AUTHOR_KEEP_ALIVE = 0x07, // Identities are stamped regularly by crawlign the set of messages for all groups. That helps keepign the useful identities in hand.
MESSAGE_AUTHOR_KEEP_ALIVE = 0x08, // Identities are stamped regularly by crawlign the set of messages for all groups. That helps keepign the useful identities in hand.
CHAT_LOBBY_MSG_VALIDATION = 0x09, // Chat lobby msgs are signed, so each time one comes, or a chat lobby event comes, a signature verificaiton happens.
GLOBAL_ROUTER_SIGNATURE_CHECK = 0x0a, // Global router message validation
GLOBAL_ROUTER_SIGNATURE_CREATION = 0x0b, // Global router message signature
GXS_TUNNEL_DH_SIGNATURE_CHECK = 0x0c, //
GXS_TUNNEL_DH_SIGNATURE_CREATION = 0x0d, //
IDENTITY_DATA_UPDATE = 0x0e, // Group update on that identity data. Can be avatar, name, etc.
IDENTITY_GENERIC_SIGNATURE_CHECK = 0x0f, // Any signature verified for that identity
IDENTITY_GENERIC_SIGNATURE_CREATION = 0x10, // Any signature made by that identity
IDENTITY_GENERIC_ENCRYPTION = 0x11,
IDENTITY_GENERIC_DECRYPTION = 0x12,
CIRCLE_MEMBERSHIP_CHECK = 0x13
} ;
enum UsageCode : uint8_t
{
UNKNOWN_USAGE = 0x00,
explicit RsIdentityUsage(uint16_t service,const RsIdentityUsage::UsageCode& code,const RsGxsGroupId& gid=RsGxsGroupId(),const RsGxsMessageId& mid=RsGxsMessageId(),uint64_t additional_id=0,const std::string& comment = std::string());
/** These 2 are normally not normal GXS identities, but nothing prevents
* it to happen either. */
GROUP_ADMIN_SIGNATURE_CREATION = 0x01,
GROUP_ADMIN_SIGNATURE_VALIDATION = 0x02,
uint16_t mServiceId; // Id of the service using that identity, as understood by rsServiceControl
UsageCode mUsageCode; // Specific code to use. Will allow forming the correct translated message in the GUI if necessary.
RsGxsGroupId mGrpId; // Group ID using the identity
/** Not typically used, since most services do not require group author
* signatures */
GROUP_AUTHOR_SIGNATURE_CREATION = 0x03,
GROUP_AUTHOR_SIGNATURE_VALIDATION = 0x04,
RsGxsMessageId mMsgId; // Message ID using the identity
uint64_t mAdditionalId; // Some additional ID. Can be used for e.g. chat lobbies.
std::string mComment ; // additional comment to be used mainly for debugging, but not GUI display
/// most common use case. Messages are signed by authors in e.g. forums.
MESSAGE_AUTHOR_SIGNATURE_CREATION = 0x05,
MESSAGE_AUTHOR_SIGNATURE_VALIDATION = 0x06,
bool operator<(const RsIdentityUsage& u) const
{
return mHash < u.mHash ;
}
RsFileHash mHash ;
/** Identities are stamped regularly by crawlign the set of messages for
* all groups. That helps keepign the useful identities in hand. */
GROUP_AUTHOR_KEEP_ALIVE = 0x07,
MESSAGE_AUTHOR_KEEP_ALIVE = 0x08,
/** Chat lobby msgs are signed, so each time one comes, or a chat lobby
* event comes, a signature verificaiton happens. */
CHAT_LOBBY_MSG_VALIDATION = 0x09,
/// Global router message validation
GLOBAL_ROUTER_SIGNATURE_CHECK = 0x0a,
/// Global router message signature
GLOBAL_ROUTER_SIGNATURE_CREATION = 0x0b,
GXS_TUNNEL_DH_SIGNATURE_CHECK = 0x0c,
GXS_TUNNEL_DH_SIGNATURE_CREATION = 0x0d,
/// Group update on that identity data. Can be avatar, name, etc.
IDENTITY_DATA_UPDATE = 0x0e,
/// Any signature verified for that identity
IDENTITY_GENERIC_SIGNATURE_CHECK = 0x0f,
/// Any signature made by that identity
IDENTITY_GENERIC_SIGNATURE_CREATION = 0x10,
IDENTITY_GENERIC_ENCRYPTION = 0x11,
IDENTITY_GENERIC_DECRYPTION = 0x12,
CIRCLE_MEMBERSHIP_CHECK = 0x13
} ;
RsIdentityUsage( uint16_t service, const RsIdentityUsage::UsageCode& code,
const RsGxsGroupId& gid = RsGxsGroupId(),
const RsGxsMessageId& mid = RsGxsMessageId(),
uint64_t additional_id=0,
const std::string& comment = std::string() );
/// Id of the service using that identity, as understood by rsServiceControl
uint16_t mServiceId;
/** Specific code to use. Will allow forming the correct translated message
* in the GUI if necessary. */
UsageCode mUsageCode;
/// Group ID using the identity
RsGxsGroupId mGrpId;
/// Message ID using the identity
RsGxsMessageId mMsgId;
/// Some additional ID. Can be used for e.g. chat lobbies.
uint64_t mAdditionalId;
/// additional comment to be used mainly for debugging, but not GUI display
std::string mComment;
bool operator<(const RsIdentityUsage& u) const { return mHash < u.mHash; }
RsFileHash mHash ;
/// @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx )
{
RS_SERIAL_PROCESS(mServiceId);
RS_SERIAL_PROCESS(mUsageCode);
RS_SERIAL_PROCESS(mGrpId);
RS_SERIAL_PROCESS(mMsgId);
RS_SERIAL_PROCESS(mAdditionalId);
RS_SERIAL_PROCESS(mComment);
RS_SERIAL_PROCESS(mHash);
}
friend struct RsTypeSerializer;
private:
/** Accessible only to friend class RsTypeSerializer needed for
* deserialization */
RsIdentityUsage();
};
class RsIdentityDetails
struct RsIdentityDetails : RsSerializable
{
public:
RsIdentityDetails()
: mFlags(0), mLastUsageTS(0) { return; }
RsIdentityDetails() : mFlags(0), mLastUsageTS(0) {}
RsGxsId mId;
// identity details.
std::string mNickname;
uint32_t mFlags ;
uint32_t mFlags;
// PGP Stuff.
RsPgpId mPgpId;
RsPgpId mPgpId;
// Recogn details.
std::list<RsRecognTag> mRecognTags;
/// @deprecated Recogn details.
RS_DEPRECATED std::list<RsRecognTag> mRecognTags;
// Cyril: Reputation details. At some point we might want to merge information
// between the two into a single global score. Since the old reputation system
// is not finished yet, I leave this in place. We should decide what to do with it.
RsReputations::ReputationInfo mReputation;
/** Cyril: Reputation details. At some point we might want to merge
* information between the two into a single global score. Since the old
* reputation system is not finished yet, I leave this in place. We should
* decide what to do with it.
*/
RsReputations::ReputationInfo mReputation;
// avatar
RsGxsImage mAvatar ;
RsGxsImage mAvatar;
// last usage
time_t mLastUsageTS ;
std::map<RsIdentityUsage,time_t> mUseCases ;
time_t mLastUsageTS;
std::map<RsIdentityUsage,time_t> mUseCases;
/// @see RsSerializable
virtual void serial_process(RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx)
{
RS_SERIAL_PROCESS(mId);
RS_SERIAL_PROCESS(mNickname);
RS_SERIAL_PROCESS(mFlags);
RS_SERIAL_PROCESS(mPgpId);
//RS_SERIAL_PROCESS(mReputation);
//RS_SERIAL_PROCESS(mAvatar);
RS_SERIAL_PROCESS(mLastUsageTS);
RS_SERIAL_PROCESS(mUseCases);
}
};
class RsIdentity: public RsGxsIfaceHelper
struct RsIdentity : RsGxsIfaceHelper
{
public:
explicit RsIdentity(RsGxsIface *gxs): RsGxsIfaceHelper(gxs) {}
virtual ~RsIdentity() {}

View File

@ -61,14 +61,17 @@
/* TODO CLEANUP: RS_TOKREQ_ANSTYPE_* values are meaningless and not used by
* RsTokenService or its implementation, and may be arbitrarly defined by each
* GXS client as they are of no usage, their use is deprecated */
* GXS client as they are of no usage, their use is deprecated, up until the
* definitive cleanup is done new code must use RS_DEPRECATED_TOKREQ_ANSTYPE for
* easier cleanup. */
#ifndef RS_NO_WARN_DEPRECATED
# warning RS_TOKREQ_ANSTYPE_* macros are deprecated!
#endif
#define RS_TOKREQ_ANSTYPE_LIST 0x0001
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
#define RS_TOKREQ_ANSTYPE_ACK 0x0004
#define RS_DEPRECATED_TOKREQ_ANSTYPE 0x0000
#define RS_TOKREQ_ANSTYPE_LIST 0x0001
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
#define RS_TOKREQ_ANSTYPE_ACK 0x0004
/*!

View File

@ -36,6 +36,8 @@
#include <retroshare/rsids.h>
#include <retroshare/rsflags.h>
#include <serialiser/rsserializable.h>
#include <serialiser/rstypeserializer.h>
#define USE_NEW_CHUNK_CHECKING_CODE
@ -118,13 +120,21 @@ class Condition
std::string name;
};
class PeerBandwidthLimits
struct PeerBandwidthLimits : RsSerializable
{
public:
PeerBandwidthLimits() : max_up_rate_kbs(0), max_dl_rate_kbs(0) {}
uint32_t max_up_rate_kbs ;
uint32_t max_dl_rate_kbs ;
PeerBandwidthLimits() : max_up_rate_kbs(0), max_dl_rate_kbs(0) {}
uint32_t max_up_rate_kbs;
uint32_t max_dl_rate_kbs;
/// @see RsSerializable
void serial_process(RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx)
{
RS_SERIAL_PROCESS(max_up_rate_kbs);
RS_SERIAL_PROCESS(max_dl_rate_kbs);
}
};
//class SearchRequest // unused stuff.
@ -295,7 +305,7 @@ class FileChunksInfo
std::map<uint32_t, std::vector<SliceInfo> > pending_slices ;
};
class CompressedChunkMap
class CompressedChunkMap : public RsSerializable
{
public:
CompressedChunkMap() {}
@ -345,10 +355,16 @@ class CompressedChunkMap
inline void set(uint32_t j) { _map[j >> 5] |= (1 << (j & 31)) ; }
inline void reset(uint32_t j) { _map[j >> 5] &= ~(1 << (j & 31)) ; }
/// compressed map, one bit per chunk
std::vector<uint32_t> _map ;
/// compressed map, one bit per chunk
std::vector<uint32_t> _map;
/// @see RsSerializable
void serial_process(RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx)
{ RS_SERIAL_PROCESS(_map); }
};
template<class CRCTYPE> class t_CRCMap
{
public:

View File

@ -48,8 +48,8 @@ void RsBanListItem::serial_process(RsGenericSerializer::SerializeJob j,RsGeneric
void RsBanListConfigItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process<uint32_t>(j,ctx,type,"type") ;
RsTypeSerializer::serial_process (j,ctx,peerId,"peerId") ;
RsTypeSerializer::serial_process<uint32_t>(j,ctx,banListType,"type") ;
RsTypeSerializer::serial_process (j,ctx,banListPeerId,"peerId") ;
RsTypeSerializer::serial_process<time_t> (j,ctx,update_time,"update_time") ;
RsTypeSerializer::serial_process (j,ctx,banned_peers,"banned_peers") ;
}

View File

@ -60,18 +60,20 @@ class RsBanListItem: public RsItem
class RsBanListConfigItem: public RsItem
{
public:
RsBanListConfigItem()
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_BANLIST, RS_PKT_SUBTYPE_BANLIST_CONFIG_ITEM) {}
RsBanListConfigItem()
: RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_BANLIST, RS_PKT_SUBTYPE_BANLIST_CONFIG_ITEM)
, banListType(0), update_time(0)
{}
virtual ~RsBanListConfigItem(){}
virtual void clear() { banned_peers.TlvClear() ; }
virtual ~RsBanListConfigItem(){}
virtual void clear() { banned_peers.TlvClear() ; }
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
uint32_t type ;
RsPeerId peerId ;
time_t update_time ;
RsTlvBanList banned_peers;
uint32_t banListType ;
RsPeerId banListPeerId ;
time_t update_time ;
RsTlvBanList banned_peers;
};
class RsBanListSerialiser: public RsServiceSerializer

Some files were not shown because too many files have changed in this diff Show More