merged with upstream/master

This commit is contained in:
mr-alice 2016-09-01 19:52:31 +02:00
commit ade6017f74
469 changed files with 88476 additions and 59565 deletions

3
.gitignore vendored
View File

@ -1,5 +1,8 @@
/RetroShare.pro.user
*.o
*.sw?
*.so
*.so.*
moc_*.cpp
qrc_*.cpp
ui_*.h

View File

@ -8,7 +8,7 @@ Build Status
| Platform | Build Status |
| :------------- | :------------- |
| GNU/Linux, MacOS, (via travis-ci) | [![Build Status](https://travis-ci.org/RetroShare/RetroShare.svg?branch=master)](https://travis-ci.org/RetroShare/RetroShare) |
| Windows, `MSys2` (via appveyor) | [![Build status](https://ci.appveyor.com/api/projects/status/axkopdqj9fc48kwe?svg=true)](https://ci.appveyor.com/project/PhenomRetroShare/retroshare) |
| Windows, `MSys2` (via appveyor) | [![Build status](https://ci.appveyor.com/api/projects/status/fu7q0ye6pge53579?svg=true)](https://ci.appveyor.com/project/PhenomRetroShare/retroshare-59qxh) |
Compilation on Windows
----------------------------

View File

@ -1,49 +1,51 @@
!include("retroshare.pri"): error("Could not include file retroshare.pri")
TEMPLATE = subdirs
SUBDIRS += \
openpgpsdk \
libbitdht \
libretroshare \
libresapi \
retroshare_gui \
retroshare_nogui \
plugins
openpgpsdk.file = openpgpsdk/src/openpgpsdk.pro
libbitdht.file = libbitdht/src/libbitdht.pro
libretroshare.file = libretroshare/src/libretroshare.pro
libretroshare.depends = openpgpsdk libbitdht
libresapi.file = libresapi/src/libresapi.pro
libresapi.depends = libretroshare
retroshare_gui.file = retroshare-gui/src/retroshare-gui.pro
retroshare_gui.depends = libretroshare libresapi
retroshare_gui.target = retroshare-gui
retroshare_nogui.file = retroshare-nogui/src/retroshare-nogui.pro
retroshare_nogui.depends = libretroshare libresapi
retroshare_nogui.target = retroshare-nogui
plugins.file = plugins/plugins.pro
plugins.depends = retroshare_gui
plugins.target = plugins
wikipoos {
SUBDIRS += pegmarkdown
pegmarkdown.file = supportlibs/pegmarkdown/pegmarkdown.pro
retroshare_gui.depends += pegmarkdown
}
tests {
SUBDIRS += librssimulator
librssimulator.file = tests/librssimulator/librssimulator.pro
SUBDIRS += unittests
unittests.file = tests/unittests/unittests.pro
unittests.depends = libretroshare librssimulator
}
!include("retroshare.pri"): error("Could not include file retroshare.pri")
TEMPLATE = subdirs
#CONFIG += tests
SUBDIRS += \
openpgpsdk \
libbitdht \
libretroshare \
libresapi \
retroshare_gui \
retroshare_nogui \
plugins
openpgpsdk.file = openpgpsdk/src/openpgpsdk.pro
libbitdht.file = libbitdht/src/libbitdht.pro
libretroshare.file = libretroshare/src/libretroshare.pro
libretroshare.depends = openpgpsdk libbitdht
libresapi.file = libresapi/src/libresapi.pro
libresapi.depends = libretroshare
retroshare_gui.file = retroshare-gui/src/retroshare-gui.pro
retroshare_gui.depends = libretroshare libresapi
retroshare_gui.target = retroshare-gui
retroshare_nogui.file = retroshare-nogui/src/retroshare-nogui.pro
retroshare_nogui.depends = libretroshare libresapi
retroshare_nogui.target = retroshare-nogui
plugins.file = plugins/plugins.pro
plugins.depends = retroshare_gui
plugins.target = plugins
wikipoos {
SUBDIRS += pegmarkdown
pegmarkdown.file = supportlibs/pegmarkdown/pegmarkdown.pro
retroshare_gui.depends += pegmarkdown
}
tests {
SUBDIRS += librssimulator
librssimulator.file = tests/librssimulator/librssimulator.pro
SUBDIRS += unittests
unittests.file = tests/unittests/unittests.pro
unittests.depends = libretroshare librssimulator
unittests.target = unittests
}

View File

@ -12,7 +12,7 @@
#---------------------------------#
# version format
version: RetroShare 6.0.{build}-{branch}
version: RetroShare 0.6.0.{build}-{branch}
# you can use {branch} name in version format too
# version: 1.0.{build}-{branch}

View File

@ -1,4 +1,300 @@
retroshare06 (0.6.0-1.XXXXXX~YYYYYY) YYYYYY; urgency=low
retroshare06 (0.6.1-1.XXXXXX~YYYYYY) YYYYYY; urgency=low
Release of version 0.6.1.
* See detailed logs: https://github.com/RetroShare/RetroShare/blob/master/build_scripts/Debian%2BUbuntu/changelog
* Release blog post: https://retroshareteam.wordpress.com
* Website: https://github.com/Retroshare/Retroshare/releases
-- Cyril Soler <csoler@users.sourceforge.net> Wed, 31 Aug 2016 12:00:00 +0100
retroshare06 (0.6.0-1.20160818.b9ac4f87) xenial; urgency=low
9780f1f Phenom Mon, 15 Aug 2016 12:00:44 +0200 Add AutoHide to RSImageBlockWidget
368a429 csoler Wed, 17 Aug 2016 09:40:16 +0200 fixed read_125Size and write_125Size according to RFC4880
4b11fb1 defnax Tue, 16 Aug 2016 22:26:48 +0200 update FeedReader icons
6682a7a defnax Tue, 16 Aug 2016 22:02:30 +0200 added new mainwindow icons for RetroShare.
4d5be7f csoler Tue, 16 Aug 2016 10:29:21 +0200 Merge pull request #476 from PhenomRetroShare/Add_FilterBannedInIdDialog
4572dc6 csoler Tue, 16 Aug 2016 10:22:00 +0200 Merge pull request #475 from PhenomRetroShare/Fix_RSTextBrowser_loadRessource_OnWindows
26cbb27 csoler Tue, 16 Aug 2016 10:20:30 +0200 Merge pull request #472 from PhenomRetroShare/Fix_ChangeImageBlockedIconOnRSTextBrowser
bb9f158 csoler Tue, 16 Aug 2016 10:05:38 +0200 Merge pull request #473 from PhenomRetroShare/Fix_RsCertificate_toStdString
81cd2e9 thunder2 Tue, 16 Aug 2016 09:09:19 +0200 Fixed MSYS2 compile (use correct bracket in pro file)
accd3ca Phenom Mon, 15 Aug 2016 19:05:00 +0200 Fix RsTextBrowser::loadRessource on Windows.
dd2e4c3 Phenom Mon, 15 Aug 2016 12:11:56 +0200 Change Image Blocked Icon On RSTextBrowser
38a9e10 Phenom Mon, 15 Aug 2016 14:19:29 +0200 Fix RsCertificate::toStdString by fixing PGPKeyParser::read_125Size.
df44f50 Phenom Mon, 15 Aug 2016 19:53:43 +0200 Add Banned Filter in IdDialog.
b8158a4 Thunder Mon, 15 Aug 2016 19:54:52 +0200 Merge pull request #474 from PhenomRetroShare/Fix_MSys2WindowsCompilation
3200ea5 Phenom Mon, 15 Aug 2016 16:16:46 +0200 Fix MSys2 Windows Compilation after #f1847a9 commit.
3640e32 thunder2 Mon, 15 Aug 2016 11:49:36 +0200 Updated build of external libraries for Windows compile
f1847a9 thunder2 Sun, 14 Aug 2016 14:11:01 +0200 Changed check for MSYS2 environment for Windows compile
b0b4320 defnax Sat, 13 Aug 2016 16:20:58 +0200 decrease chat bar widget icon size
c01f5a3 defnax Sat, 13 Aug 2016 13:16:35 +0200 Merge pull request #468 from PhenomRetroShare/Add_ChatLoadEmbeddedImagesOption
fcad9d9 Phenom Sat, 13 Aug 2016 10:42:42 +0200 Fix RSTextBrowser::loadResource if image comes from stylesheet.
f71aad4 Phenom Tue, 9 Aug 2016 23:32:25 +0200 Add Chat Load Embedded Images Option like forum and message.
0e1c0c2 defnax Fri, 12 Aug 2016 22:19:44 +0200 Added search filter for participants list.
ab82c4a csoler Fri, 12 Aug 2016 15:24:40 +0200 added missing return in PGPKeyUtil, causing corruption of keys in some--possible rare--situations
81d42f0 thunder2 Fri, 12 Aug 2016 14:14:09 +0200 Fixed MSYS2AUTOMAKE path in msys2_build_libs/Makefile
f3b8843 thunder2 Fri, 12 Aug 2016 10:03:47 +0200 Fixed QMAKE_PRE_LINK for Windows compile without MSYS2
1fe7dce defnax Wed, 10 Aug 2016 00:22:23 +0200 Set icons for the voting combo box
d1645e9 defnax Tue, 9 Aug 2016 19:38:56 +0200 moved auto-ban checkbox to a better position
aaf13eb csoler Tue, 9 Aug 2016 10:47:08 +0200 Merge pull request #466 from PhenomRetroShare/Fix_RsCollEditorCountUpdateWhenRemove
32db280 csoler Tue, 9 Aug 2016 10:35:01 +0200 Merge pull request #459 from PhenomRetroShare/Add_CreateNewGXSIDInGenCertDialog
275c47e Phenom Tue, 9 Aug 2016 01:22:14 +0200 Add Title when ask for password.
6edd7bb Phenom Sat, 6 Aug 2016 17:15:56 +0200 Add possibility to create GXSId directly on GenCertDialog.
6db747a csoler Mon, 8 Aug 2016 22:19:38 +0200 Merge pull request #467 from PhenomRetroShare/Fix_NATStatusLED
c2c8893 csoler Mon, 8 Aug 2016 22:18:32 +0200 Merge pull request #462 from PhenomRetroShare/Add_CaseSensitiveOptionForLobbyNotify
0b1f08a csoler Mon, 8 Aug 2016 22:12:55 +0200 Merge pull request #461 from PhenomRetroShare/Add_CommentNumberOnButton
723d96b csoler Mon, 8 Aug 2016 22:11:10 +0200 Merge pull request #460 from PhenomRetroShare/Fix_LobbyNotifyIcon
9c601dc csoler Mon, 8 Aug 2016 22:10:01 +0200 Merge pull request #463 from PhenomRetroShare/Fix_ImageBlockOnRsTextBrowser
d59f7a0 Phenom Mon, 8 Aug 2016 21:59:12 +0200 Fix NAT Status LED
ee368ef Phenom Mon, 8 Aug 2016 20:45:35 +0200 Fix RsCollection Editor Count Update When Removing items.
c0c7ede csoler Mon, 8 Aug 2016 20:14:05 +0200 Merge pull request #464 from G10h4ck/libresapilocal
600e2d6 csoler Mon, 8 Aug 2016 20:11:21 +0200 Merge pull request #465 from PhenomRetroShare/Fix_RsGxsNetService_handleRecvPublishKeys_grpMeta_NULL
72d7435 Phenom Mon, 8 Aug 2016 19:05:42 +0200 Fix RsGxsNetService::handleRecvPublishKeys when grpMeta is NULL
183ac22 Gio Mon, 8 Aug 2016 14:02:01 +0200 ApiServerLocal run on it's own thread to avoid stopping UI ApiLocalConnectionHandler can now handle both buffered (QLocalSocket based) and unbuffered (like ncat or simple scripts) clients
88407e6 Phenom Sun, 7 Aug 2016 19:41:44 +0200 Fix Image Block on RSTextBrowser.
d048270 Phenom Sun, 7 Aug 2016 19:00:23 +0200 Add Case Sensitive option for Lobby Notify.
ea6bbac Phenom Sun, 7 Aug 2016 14:40:04 +0200 Add Comment Number On Button.
dea776a defnax Sat, 6 Aug 2016 18:35:07 +0200 Moved font menu to Settings menu
776e404 Phenom Sat, 6 Aug 2016 17:52:12 +0200 Fix Lobby Notify Icon.
9f14103 csoler Sat, 6 Aug 2016 15:47:23 +0200 Merge pull request #458 from PhenomRetroShare/Fix_QMessageBoxAddWidget
329a7e7 csoler Sat, 6 Aug 2016 15:46:01 +0200 Merge pull request #456 from PhenomRetroShare/Fix_ForumItemSortOnLastView
21bd8cd Phenom Sat, 6 Aug 2016 13:49:39 +0200 Fix QMessageBox layout addWidget.
beab81e Phenom Sat, 6 Aug 2016 11:57:20 +0200 Fix Forum Item sort on LastPost View.
f3d1a6c defnax Fri, 5 Aug 2016 19:13:59 +0200 Added missed notify icon
ac73fd9 defnax Fri, 5 Aug 2016 01:01:56 +0200 Merge branch 'master' of https://github.com/RetroShare/RetroShare
e2bb477 defnax Fri, 5 Aug 2016 01:00:53 +0200 Added new blue icon set for Chat Widget (icons by Beluga) svg ad png Format
96e73b3 csoler Thu, 4 Aug 2016 22:38:59 +0200 Merge pull request #454 from csoler/v0.6-ContactList
cd433e8 csoler Thu, 4 Aug 2016 22:33:45 +0200 fixed bug causing uninitialised memory read in reputation changing
5a55de5 csoler Thu, 4 Aug 2016 22:01:11 +0200 added missing DontUseNativeDialog flag in misc.cpp
46d4863 defnax Thu, 4 Aug 2016 19:50:00 +0200 Merge branch 'master' of https://github.com/RetroShare/RetroShare
e2d29f6 defnax Thu, 4 Aug 2016 19:46:20 +0200 update icons
3993fbf csoler Thu, 4 Aug 2016 16:10:00 +0200 fixed auto-positive opinions for contacts
c757630 csoler Thu, 4 Aug 2016 13:12:55 +0200 added callback in RsGenExchange subclasses to autorise new groups, to be used by p3GxsIdentity
7545ad4 csoler Thu, 4 Aug 2016 11:43:35 +0200 simplied/improved reputation system. Now ids can be banned based on their owner node using a single checkbox in the Person tab, with immediate effect
70228ee csoler Thu, 4 Aug 2016 11:02:12 +0200 fixed missign return, probably causing crashes
48b2e05 csoler Wed, 3 Aug 2016 19:56:49 +0200 Merge pull request #453 from G10h4ck/libresapilocal
c4ef4d7 csoler Tue, 2 Aug 2016 23:57:11 +0200 saved owner node ID in GXS reputation item
353308e Gio Wed, 3 Aug 2016 14:35:45 +0200 ApiLocalConnectionHandler class quit() at the end outside if
60cf299 csoler Wed, 3 Aug 2016 08:46:15 +0200 Merge pull request #436 from G10h4ck/libresapilocal
e4e29c5 Gio Wed, 3 Aug 2 016 00:50:49 +0200 quit ApiLocalConnectionHandler after replying API query
17003f1 csoler Tue, 2 Aug 2016 16:25:00 +0200 modified wrong comment in why mLastPost should not be used in rsgxsnetservice.cc, and added a call to clearing GrpMeta cache when new msg in that group are received
3cd90ae csoler Mon, 1 Aug 2016 16:35:19 +0200 re-disabled the code to update the server TS to last post as it can severely perturbate the distribution of posts. Added a call to update msgServerUpdateMap when new messages received
d6be440 csoler Mon, 1 Aug 2016 15:38:51 +0200 re-enabled some code previously disabled in last commit
b1288bc csoler Mon, 1 Aug 2016 14:43:17 +0200 added missing time stamp of msgServerUpdateMap when posting a new message
5fac5a8 csoler Sun, 31 Jul 2016 22:14:23 +0200 moved all getOpenFilename to use misc::getOpenFilename
c643d1e csoler Sun, 31 Jul 2016 22:07:43 +0200 Merge pull request #451 from PhenomRetroShare/Fix_ImportExportCertASC
d000d75 Phenom Sun, 31 Jul 2016 21:03:45 +0200 Fix Import and Export Cert file *.asc.
edce1e9 csoler Sun, 31 Jul 2016 17:47:50 +0200 Merge pull request #449 from PhenomRetroShare/Add_RemoveDuplicateCBInRSCollEditor
6e25a30 csoler Sun, 31 Jul 2016 17:21:12 +0200 Merge pull request #450 from PhenomRetroShare/Fix_QFileDialogDontUseNativeDialog
6935441 Phenom Sun, 31 Jul 2016 16:23:41 +0200 Fix other QFileDialog call in misc adding DontUseNativeDialog option.
0317904 Phenom Sun, 31 Jul 2016 16:08:15 +0200 Add Remove Duplicate checkbox in RsCollection editor.
64b5609 csoler Sun, 31 Jul 2016 11:52:23 +0200 Merge pull request #448 from PhenomRetroShare/Fix_IdDialogContextMenuShownAtStartUp
998fede Phenom Sun, 31 Jul 2016 11:15:47 +0200 Fix IdDialog ContextMenu shown at startup.
3721055 csoler Sat, 30 Jul 2016 21:15:08 +0200 Merge pull request #447 from PhenomRetroShare/Fix_IdChooserInSignedLobby
bef7db4 Phenom Sat, 30 Jul 2016 19:14:59 +0200 Fix IdChooser in Signed Lobby.
2921d9e csoler Sat, 30 Jul 2016 15:26:27 +0200 Merge pull request #445 from PhenomRetroShare/Add_MergeDisplayMenuToHeaderContextMenu
2126234 csoler Sat, 30 Jul 2016 15:25:30 +0200 Merge pull request #446 from PhenomRetroShare/Fix_FriendListSortGPGItem
46e4b3b Phenom Sat, 30 Jul 2016 13:58:02 +0200 Fix FriendList sorting when expand PGPItem sorted by LastContact or IP
ae9ab64 Phenom Sat, 30 Jul 2016 13:27:23 +0200 Move Display button's menu to Header context menu on FriendList.
d62f8a4 defnax Fri, 29 Jul 2016 23:21:46 +0200 Fixed stylesheet
032bcf7 defnax Fri, 29 Jul 2016 23:14:46 +0200 Fixed Stylesheets
b1dcd2f csoler Fri, 29 Jul 2016 22:02:57 +0200 Merge pull request #444 from PhenomRetroShare/Add_MergeFilterIdFilterToHeaderContextMenu
1707c07 csoler Fri, 29 Jul 2016 21:58:31 +0200 added DontUseNativeDialog as default flag in file dialog in order to avoid some crashed when not using it
d3beccf Phenom Fri, 29 Jul 2016 20:54:26 +0200 Merge Filter ComboBox to Header Context Menu in IdDialog.
431dd68 defnax Fri, 29 Jul 2016 17:29:54 +0200 Temporary solution for the Filter Combobox it takes to much space, no space more for search filter,moved under the ToolBar.
7c2e2bd Gio Thu, 28 Jul 2016 17:24:17 +0200 take in account that QLocalSocket is of type STREAM so it doesn't emit readyRead event for each write() on the other side
fe7de83 Gio Thu, 28 Jul 2016 14:08:49 +0200 WebUI is now optional but enabled by default at compile time
c73be93 csoler Tue, 26 Jul 2016 16:06:03 +0200 removed anti-spam message that has become irrelevant
da8a520 csoler Mon, 25 Jul 2016 16:07:53 -0400 Merge pull request #442 from csoler/v0.6-ContactList
ed05ec7 csoler Mon, 25 Jul 2016 16:06:28 -0400 fixed text in People tab
f5e55e8 csoler Mon, 25 Jul 2016 16:04:30 -0400 fixed a few bugs in the People tab
2189771 csoler Mon, 25 Jul 2016 15:45:49 -0400 added two new options to people page for handlign reputations: change the ban limit from friend opinions, and allow to auto-set positive opinions to contacts
efd503e csoler Mon, 25 Jul 2016 14:56:55 -0400 removed the possibility of GXS groups to keep track of post origin before release, as it is too intrusive as compared to the benefits
35c01e5 csoler Fri, 22 Jul 2016 21:10:54 -0400 updated translation files
1a4d400 csoler Fri, 22 Jul 2016 20:40:42 -0400 updated changlog
e5d9bd5 csoler Fri, 22 Jul 2016 20:39:55 -0400 Merge pull request #441 from PhenomRetroShare/Fix_PostedFeedItemWithComments
7c7da7e Phenom Sat, 23 Jul 2016 01:48:23 +0200 Fix Posted Feed Item when received comment.
-- Cyril Soler <csoler@users.sourceforge.net> Wed, 18 Aug 2016 16:00:00 +0100
retroshare06 (0.6.0-1.20160722~daf54dff) precise; urgency=low
daf54df csoler Fri, 22 Jul 2016 17:49:07 -0400 fixed missing RsGxsGrpMeta cache update when updating grp meta, which caused unstable group flags/name/perms update
95edc5b csoler Fri, 22 Jul 2016 10:06:24 -0400 fixed variable name problem in ServerPage (with no consequences)
713deac csoler Sat, 16 Jul 2016 18:39:36 -0400 time-stamping newly received GXS ids
95202d6 csoler Sat, 16 Jul 2016 18:26:04 -0400 removed possible double free() of buf in parse_headers (suggestion by GuessWho)
71168c7 csoler Fri, 15 Jul 2016 22:47:35 -0400 drop net ID request when peer list is empty
8fdd255 csoler Fri, 15 Jul 2016 22:28:36 -0400 improved strategy for merging pending ID load requests, fixing bug in previous commit
59d0859 csoler Fri, 15 Jul 2016 22:25:15 -0400 fixed compilation in tests
9fd44a5 csoler Fri, 15 Jul 2016 19:28:54 -0400 Merge pull request #437 from PhenomRetroShare/Fix_UnitTests
9126076 csoler Fri, 15 Jul 2016 17:09:22 -0400 removed debug info in p3IdService and RsGxsNetService
90dfc6e csoler Fri, 15 Jul 2016 16:59:57 -0400 improved explicit requests of missing GXS ids, also fixing situations where empty peers lists would wipe out pe
3152eca Phenom Fri, 15 Jul 2016 15:03:41 +0200 Fix UnitTests and run it in windows too.
8ccfee2 csoler Tue, 12 Jul 2016 22:49:21 -0400 Merge pull request #434 from csoler/v0.6-LocalCircles
c555300 csoler Tue, 12 Jul 2016 22:45:23 -0400 fixed merging with upstream
c7e60d0 csoler Tue, 12 Jul 2016 22:42:19 -0400 removed debug info in rsgxsnetservice
ed523e8 csoler Mon, 11 Jul 2016 22:44:15 -0400 fixed backend for locl circles
931c3df csoler Mon, 11 Jul 2016 21:33:09 -0400 fixed display of group node restriction in GxsGroupDialog and info
a7d82cf csoler Mon, 11 Jul 2016 18:44:52 -0400 delete GXS IDs with no TS
45b189c csoler Mon, 11 Jul 2016 18:30:12 -0400 removed EXTERNAL/PERSONNAL options from GxsCircleChooser
951f29f csoler Sun, 10 Jul 2016 23:00:47 -0400 removed debug info in rsDataService
95915fa csoler Sun, 10 Jul 2016 22:46:37 -0400 removed cross deadlock between p3GxsReputation and p3IdService
d089e2e csoler Sat, 9 Jul 2016 18:06:59 -0400 added a GroupChooser class to choose groups of friend nodes
0125f91 csoler Wed, 6 Jul 2016 22:36:59 -0400 fixed deserialise bug in FileItem
a69629c csoler Wed, 6 Jul 2016 22:16:05 -0400 added missing own id from group list, and removed possible duplicates in random group ids
269f945 csoler Wed, 6 Jul 2016 22:02:56 -0400 fixed load/save of new group ids and backward compatibility with FriendList
01c0d2f csoler Tue, 5 Jul 2016 23:49:43 -0400 finished conversion to RsNodeGroupId for file transfer and GUI
1c277ab csoler Tue, 5 Jul 2016 23:47:55 -0400 Merge pull request #433 from csoler/v0.6-SqlCache
4ee9eff csoler Mon, 4 Jul 2016 23:55:48 -0400 changed internal storage of groups of friend nodes so as to use an abstract ID instead of a string (phase 1 of l
42f2210 csoler Sun, 3 Jul 2016 23:15:05 -0400 removed debug info in IdDialog
218ca45 csoler Sun, 3 Jul 2016 23:12:56 -0400 removed some debug info in rsdataservice
09ad539 csoler Sun, 3 Jul 2016 22:02:23 -0400 fixed red color in IdDialog
9f9f021 csoler Sun, 3 Jul 2016 22:02:04 -0400 remved debug output in udlstck
c98416d csoler Sun, 3 Jul 2016 18:59:30 -0400 added auto-cleaning of reputation info for outdated/removed identities
bf28ea7 csoler Sun, 3 Jul 2016 18:49:02 -0400 removed debug info in udpstack.cc
692293e csoler Sun, 3 Jul 2016 18:12:50 -0400 added red color to banned identities in IdDialog
e611b2b csoler Sun, 3 Jul 2016 18:06:01 -0400 moved isIdentitybanned from p3GxsReputations to p3IdService, so as to avoid calling back p3IdService from p3GxsR
720c6fd csoler Sat, 2 Jul 2016 22:41:12 -0400 fixed bug causing TS update of some unused identities
86d8f01 csoler Fri, 1 Jul 2016 23:38:10 -0400 added a local cache in rsdataservice to avoid calling sqlcipher on GrpMetaData
cdd2c1f csoler Thu, 30 Jun 2016 16:50:35 -0400 Merge pull request #432 from G10h4ck/master
da4c563 Gio Thu, 30 Jun 2016 22:03:22 +0200 Fix typo in libresapi documentation
0206c65 csoler Thu, 30 Jun 2016 15:06:41 -0400 added missing else in display of forum anti-spam message
2dfe116 csoler Thu, 30 Jun 2016 14:21:54 -0400 added compilation flag for profiling in GUI
ef95451 csoler Tue, 28 Jun 2016 21:16:31 -0400 updated changelog
440390e csoler Thu, 30 Jun 2016 14:21:11 -0400 Merge pull request #431 from csoler/v0.6-SignedForums3
ba50028 csoler Thu, 30 Jun 2016 14:16:45 -0400 added GXS distribution flag to defavor posts signed by key form unknown RS nodes, and updated UI in forums to u
-- Cyril Soler <csoler@users.sourceforge.net> Mon, 18 Jul 2016 22:00:00 -0500
retroshare06 (0.6.0-1.20160628~18eb34b8) trusty; urgency=low
9f7ef8b csoler Tue, 28 Jun 2016 20:59:56 -0400 fixed possible cross deadlocks between RsGxsGenExchange and RsGxsNetService
00bdc50 csoler Tue, 28 Jun 2016 17:56:37 -0400 updated changelog
bb82b6e csoler Tue, 28 Jun 2016 14:35:59 -0400 Merge pull request #429 from PhenomRetroShare/Fix_StandardQSS
456751a Phenom Tue, 28 Jun 2016 20:23:32 +0200 Fix ProgressBar Chunk with Standard.qss
019ed12 csoler Tue, 28 Jun 2016 12:37:04 -0400 Merge pull request #428 from sehraf/pr-fix-udp
ea07a13 sehraf Tue, 28 Jun 2016 17:37:22 +0200 fix TcpPacket::readPacket
c15c979 csoler Mon, 27 Jun 2016 17:17:28 +0100 Merge pull request #426 from sehraf/pr-disable-dht-stunner
ff86678 csoler Sun, 26 Jun 2016 23:14:01 -0400 clear error queue before calling SSL_read()/SSL_write(), to avoid remaining errors to corrupt the next connection attempts and cause disconnections
31089d7 csoler Sat, 25 Jun 2016 19:12:35 +0100 added auto-clean of pending data in pqistreamer after connection is closed, to avoid confusing the peer after re-connecting (probably not the cause of the SSL error)
043c5b1 csoler Sat, 25 Jun 2016 13:01:36 -0400 Merge pull request #427 from PhenomRetroShare/Fix_TheRetroSharesDeskTopFileIsMissing
e6347d7 Phenom Sat, 25 Jun 2016 11:09:28 +0200 Fix "!!!The RetroShare's desktop file is missing or wrong!!!" message for Linux.
5d96268 sehraf Tue, 21 Jun 2016 14:02:52 +0200 removed unused variable warnings
4d2d825 sehraf Tue, 21 Jun 2016 13:55:23 +0200 add new option to qmake to enable dht stunner removed dht stunner code when option is not set
37ae8bc csoler Tue, 21 Jun 2016 07:22:13 -0400 Merge pull request #424 from sehraf/pr-dht-banlist
3bb03ff sehraf Mon, 20 Jun 2016 22:30:51 +0200 Added new (optional) callback to libbitdht to ask upper layer if an IP is banned. In case this callback is implemented it will be used in favour of the built-in...
ddce43b csoler Sat, 18 Jun 2016 20:43:42 -0400 Merge pull request #422 from PhenomRetroShare/Fix_ReadMe.md
24eb88a csoler Sat, 18 Jun 2016 20:38:48 -0400 added explicit comparisons for tests on RsGxsGrpMetaData and RsGxsMsgMetaData
0388162 Phenom Sun, 19 Jun 2016 01:37:50 +0200 Change Build AppVeyor State to RetroShare/RetroShare.
bc04f3c csoler Sat, 18 Jun 2016 17:43:50 -0400 Merge pull request #421 from PhenomRetroShare/Fix_UnitTestCompilation
43f618f Phenom Sat, 18 Jun 2016 23:10:12 +0200 Fix UnitTest Compilation
07bda26 csoler Sat, 18 Jun 2016 16:27:15 -0400 fixed permission matrix widget crash
35da9cb csoler Sat, 18 Jun 2016 15:36:03 -0400 Merge pull request #419 from PhenomRetroShare/Fix_ChannelNewsFeedWhenComment
90a27f4 csoler Sat, 18 Jun 2016 15:33:10 -0400 Merge pull request #418 from sehraf/pr-improve-debug
d84fdff Phenom Sat, 18 Jun 2016 20:03:55 +0200 Fix GxsChannelPostItem when received comment.
3cf1968 sehraf Sat, 18 Jun 2016 18:04:18 +0200 fixed p3msgservice.cc
d8235c6 sehraf Sat, 18 Jun 2016 13:08:14 +0200 removed dead code and cleanup
09afbbe sehraf Sat, 18 Jun 2016 13:00:15 +0200 switched to new rslog method
7627bd9 csoler Fri, 17 Jun 2016 22:53:05 -0400 Merge pull request #417 from csoler/v0.6-SecurityKeys
f57f620 csoler Fri, 17 Jun 2016 22:27:00 -0400 reduced database testing/cleaning frequency to 31/59 mins.
eb05922 csoler Fri, 17 Jun 2016 22:21:06 -0400 added a tooltip and read color for unsecure GXS identities. These are still supported for a few weeks at most. So get rid of them
4df4bb6 csoler Fri, 17 Jun 2016 20:46:58 -0400 fixed removal of messages in unsubscribed groups
886d896 csoler Fri, 17 Jun 2016 20:46:24 -0400 fixed warning about old fingerprint for own keys.
f6c5a05 sehraf Fri, 17 Jun 2016 11:09:59 +0200 switched to caller providing all needed information instead of saving those on callee side
cc6ae74 csoler Thu, 16 Jun 2016 23:17:40 -0400 fixed color of admin circles (we cannot use a bullet, since bullets are kept for Membership property)
4d452bf csoler Thu, 16 Jun 2016 18:34:33 -0400 removed annoying warning in avatar widget
c25b650 csoler Thu, 16 Jun 2016 23:10:13 -0400 removed check key debug info
25c0c9d csoler Thu, 16 Jun 2016 23:06:07 -0400 added systematic consistency checking of public/private RSA keys at deserialisation time
b9ba51f csoler Thu, 16 Jun 2016 22:23:27 -0400 improved naming of publish/admin rights in GroupTreeWidget
8d54603 csoler Thu, 16 Jun 2016 21:27:28 -0400 fixed bug in private key extraction
dbd78d2 csoler Thu, 16 Jun 2016 20:19:03 -0400 merged with upstream/master
e28e972 sehraf Thu, 16 Jun 2016 21:26:02 +0200 removed dead code
70662cf defnax Thu, 16 Jun 2016 18:41:56 +0200 Fixed some layout spacing
656e7eb csoler Wed, 15 Jun 2016 23:27:30 -0400 Merge pull request #415 from PhenomRetroShare/Add_BuildStatusInReadme.md
c7da734 csoler Wed, 15 Jun 2016 21:38:14 -0400 Merge pull request #416 from csoler/v0.6-ContactList
e63f936 csoler Wed, 15 Jun 2016 21:33:27 -0400 improved strategy for removal of unused GXS ids with proper constants for unknown/signed/known ids. Forbid the stamping of banned keys.
da11995 defnax Wed, 15 Jun 2016 23:32:01 +0200 Clean up the Chat Toolbar Buttons Fixed display of Info Text on PGg details
631a29c Phenom Wed, 15 Jun 2016 20:53:56 +0200 Add Build Status in ReadMe.md file. And add AppVeyor File.
6b74a8a csoler Tue, 14 Jun 2016 21:54:09 -0400 added missing call to ssl_pendign in pqissludp.
c3eba4a csoler Tue, 14 Jun 2016 21:53:48 -0400 added missing serialisation call for peer bandwidth limits
8c44e69 csoler Tue, 14 Jun 2016 21:53:06 -0400 added output of items which doesnot serialise correctly in pqisslstore
ceecdb2 csoler Tue, 14 Jun 2016 20:31:38 -0400 Merge pull request #414 from PhenomRetroShare/Add_MessageWhenSendingArgToOtherInstance
cedce2e csoler Tue, 14 Jun 2016 20:30:06 -0400 Merge pull request #260 from PhenomRetroShare/Add_SendAsPlainText_And_NoEmoteIcon_Button
69e98b8 defnax Wed, 15 Jun 2016 00:08:45 +0200 Added count Invited Members to Create Circles Dialog. Changed some context menu icons for People list and Circles tree. Added icon when im Cir
ddbcd21 Phenom Wed, 27 Jan 2016 20:27:44 +0100 Add buttons to send message in plain text and without EmoteIcon.
9b09187 Phenom Tue, 14 Jun 2016 15:10:15 +0200 Add message, when sending arguments to other instance, to disable this option.
56e0797 csoler Mon, 13 Jun 2016 23:06:10 -0400 Merge pull request #413 from csoler/v0.6-Circles
e03c5df csoler Mon, 13 Jun 2016 22:38:51 -0400 improved GUI layout in circle creation box. Added tooltips
600607d csoler Mon, 13 Jun 2016 22:14:09 -0400 added warning for old peers in circles
8b954a2 csoler Mon, 13 Jun 2016 18:08:05 -0400 added names to upnp redirects to avoid router confusion (patch from ET)
fa29dd7 csoler Sun, 12 Jun 2016 21:41:09 -0400 changed the way RsGxsSyncMsgReqItem are sent for circle-restricted groups, using a hash of the group ID instead of encrypting the whole item,
972de42 csoler Sat, 11 Jun 2016 18:07:57 -0400 converted static variable to class member in pqihandler
34f49d4 csoler Sat, 11 Jun 2016 18:07:07 -0400 removed compilation warning
248d0c4 csoler Sat, 11 Jun 2016 17:58:08 -0400 Merge pull request #412 from csoler/v0.6-MaxUpRate
ef4455a csoler Sat, 11 Jun 2016 17:54:11 -0400 cleaned the MaxUpRate branch from unused code
8e75185 csoler Sat, 11 Jun 2016 17:21:04 -0400 made avgReadCount and avgSendCound to be uint32_t instead of floats, since they count bytes. Changes kb to 1024 instead of 1000
eb9025d csoler Sat, 11 Jun 2016 17:20:22 -0400 removed annoying warning when a circle is empty
373d41b csoler Sat, 11 Jun 2016 14:11:21 -0400 added missing variable def after previous commit
23e8e93 csoler Sat, 11 Jun 2016 09:50:22 -0400 added mutex proteciton around mAvgLastUpdate to avoid it being changed by the constructor
0d1d31a csoler Sat, 11 Jun 2016 09:33:11 -0400 added mutex protection around pqistreamer::getRates, since float r/w are not necessarily atomic
eba90a8 csoler Sat, 11 Jun 2016 09:24:33 -0400 Merge pull request #411 from PhenomRetroShare/Add_SIGFPE_Debug_DEFINES
afe23e7 csoler Sat, 11 Jun 2016 09:22:53 -0400 Merge pull request #410 from PhenomRetroShare/Fix_SIGFPE_InQProgressBar_PrintEvent
d649659 Phenom Sat, 11 Jun 2016 14:38:31 +0200 Add SIGFPE debug DEFINES.
08258ca Phenom Sat, 11 Jun 2016 14:23:26 +0200 Fix SIGFPE in QProgressBar::paintEvent
d1be3f3 defnax Fri, 10 Jun 2016 13:40:24 +0200 Set a minimum column width
83a1434 csoler Thu, 9 Jun 2016 23:23:51 -0400 fixed bug in setting MaxRate values
f5ad8b4 csoler Thu, 9 Jun 2016 23:13:07 -0400 moved node-wide options to node details
a4931ed csoler Thu, 9 Jun 2016 20:51:09 -0400 fixed setting/getting maxrates using pgp id
a07805b csoler Thu, 9 Jun 2016 20:41:27 -0400 moved bandwidth limits to the pgp level
38b86c3 csoler Thu, 9 Jun 2016 18:12:04 -0400 improved debug output for early address rejection
6b78275 csoler Wed, 8 Jun 2016 22:54:40 -0400 fixed bug in loading config file to set max rates
5a0fa66 csoler Wed, 8 Jun 2016 22:44:28 -0400 added proper talking between pqihandler and GUI for maxrates fixing
226e85c csoler Wed, 8 Jun 2016 21:00:26 -0400 added dropmenu entry in circles to allow admin to grant/deny membership
509266a csoler Tue, 7 Jun 2016 22:38:24 -0400 removed some dead code
a1bbcd8 csoler Tue, 7 Jun 2016 22:06:32 -0400 fixed a few small issues in new peer rates
20b6745 csoler Tue, 7 Jun 2016 21:48:22 -0400 added GUI and storage for max up/dn rates per peer
0e85709 csoler Tue, 7 Jun 2016 11:00:34 -0400 Merge pull request #409 from sehraf/pr-upnp-version
2d5883c sehraf Tue, 7 Jun 2016 16:30:39 +0200 add UPnP lib version
1c1b7ac csoler Mon, 6 Jun 2016 22:55:23 -0400 attempt at fixing the crash when quitting RS (due to operator new not being able to allocate memory from deleted allocator
54a0ca4 csoler Sun, 5 Jun 2016 15:49:33 -0400 added line in circle tooltip for visibility. Re-worked tooltip text a little bit
ee25596 csoler Sun, 5 Jun 2016 15:20:48 -0400 updated tooltip and names for self-restricted circles to "private"
195ad4e csoler Sun, 5 Jun 2016 15:15:40 -0400 use grey bullet as a placeholder for circles without pending operations
456b57b csoler Sun, 5 Jun 2016 13:17:30 -0400 Merge pull request #205 from pztrn/master
9f2d6bd csoler Sun, 5 Jun 2016 13:02:13 -0400 Merge pull request #259 from heini/rhel_fedora_qt5
e2e9ede csoler Sun, 5 Jun 2016 11:51:47 -0400 fixed initialization of memebrs in peerDetails
f1d69ad csoler Sun, 5 Jun 2016 11:26:29 -0400 Merge pull request #351 from PhenomRetroShare/Add_WebUI_ClearButtonOnBradCast
f55b283 csoler Sun, 5 Jun 2016 11:05:52 -0400 second pass over compilation warnings
927f782 csoler Sun, 5 Jun 2016 10:43:57 -0400 pass over compiler warnings
c2ae4fc csoler Sun, 5 Jun 2016 10:06:11 -0400 merged upstream/master
2567feb csoler Sun, 5 Jun 2016 09:54:26 -0400 fixed compilation broken by using deprecated Qt method
a2ca038 csoler Sat, 4 Jun 2016 21:39:40 -0400 fixed compilation and several problems following separation of public/private keys
0eb4e9e defnax Sat, 4 Jun 2016 21:27:20 +0200 - renamed label "restricted to group" to "restricted to circle" - changed icon
b2497cc csoler Sat, 4 Jun 2016 09:45:17 -0400 Merge pull request #406 from sehraf/pr-fixes-#2
24f619d csoler Sat, 4 Jun 2016 03:20:45 +0200 added missing include for debian squeeze
d8189d0 csoler Fri, 3 Jun 2016 21:11:12 -0400 moved placeholder text from .ui to .cpp to allow compilation with old Qt
99f54a2 defnax Fri, 3 Jun 2016 19:16:59 +0200 Merge branch 'master' of https://github.com/RetroShare/RetroShare
4300d87 defnax Fri, 3 Jun 2016 19:15:24 +0200 Set default Header Stylesheet for Circles
814db7e csoler Fri, 3 Jun 2016 19:15:16 +0200 fixed possible uninitialised memory read
4c986cd csoler Fri, 3 Jun 2016 19:03:10 +0200 attempt to fix the pthread_setname_np symbol issue. To be tested
0d10603 sehraf Fri, 3 Jun 2016 09:02:19 +0200 fix build errors (return typ is a pointer and not boolean)
590be09 csoler Thu, 2 Jun 2016 23:47:57 -0400 separated RsTlvSecurityKey into two incompatible classes to enforce the correct usage of private vs. public keys
53eb4df csoler Thu, 2 Jun 2016 21:21:18 -0400 fixed compilation errors due to last merge operation
e2b5785 csoler Thu, 2 Jun 2016 21:15:51 -0400 merged PR403 with trunk
10e0254 csoler Thu, 2 Jun 2016 20:23:22 -0400 fixed a few things to correct PR403
699b3cf csoler Thu, 2 Jun 2016 20:38:28 -0400 Merge pull request #402 from PhenomRetroShare/Fix_WindowsCompilationWithMksTemp
5362fd3 csoler Thu, 2 Jun 2016 20:36:51 -0400 Merge pull request #401 from PhenomRetroShare/Fix_WindowsCompilationWithThreadName
6f5693d csoler Thu, 2 Jun 2016 18:26:43 -0400 Merge pull request #405 from PhenomRetroShare/Fix_UnitTestsCompilation
2c8d047 Phenom Thu, 2 Jun 2016 19:34:58 +0200 Fix UnitTests Compilation
2f4f44e csoler Thu, 2 Jun 2016 09:36:50 -0400 added early discarding of incoming connection attempt (before SSL handshake) for blacklisted IPs
6e38554 sehraf Thu, 2 Jun 2016 13:22:24 +0200 rename define UBUNTU to HAS_GNOME_KEYRING The name UBUNTU is misleading since it is only used to select the keyring backend (which is gnome key
4f60c8c sehraf Thu, 2 Jun 2016 14:53:15 +0200 libretroshare: fix comparison between signed and unsigned integer
8b788b2 sehraf Thu, 2 Jun 2016 14:44:33 +0200 libretroshare: fix member initialisation order
cfc0e70 sehraf Thu, 2 Jun 2016 14:42:32 +0200 libretroshare: remove unused variables
005af47 Phenom Wed, 1 Jun 2016 22:37:05 +0200 Fix Compilation when mkstemp is not defined.
-- Cyril Soler <csoler@users.sourceforge.net> Mon, 20 Jun 2016 14:00:00 -0500
retroshare06 (0.6.0-1.20160601.1f8a6ee2~trusty) trusty; urgency=low
cbef014 csoler Sun, 29 May 2016 16:09:56 -0400 added regular test of circle auto-subscribe from cache, and auto-subscribe w
2bde81f csoler Sat, 28 May 2016 21:09:44 -0400 removed more debug info, improved tooltips

View File

@ -1,7 +1,7 @@
#!/bin/sh
###################### PARAMETERS ####################
version="0.6.0"
version="0.6.1"
gitpath="https://github.com/RetroShare/RetroShare.git"
workdir=retroshare06-${version}
#bubba3="Y" # comment out to compile for bubba3
@ -47,7 +47,7 @@ while [ ${#} -gt 0 ]; do
done
if test "${dist}" = "" ; then
dist="precise trusty vivid wily xenial"
dist="precise trusty vivid wily xenial wheezy squeeze jessie stretch"
fi
echo Attempting to get revision number...

View File

@ -1,2 +1,4 @@
#!/bin/sh
Apply dput ppa:retroshare/unstable retroshare06_0.6.0-1.#.changes
for i in `ls retroshare06_0.6.0-1.*.changes` ; do
dput ppa:retroshare/unstable $i
done

View File

@ -0,0 +1,6 @@
/download
/msys
/libs
/tools/7z.dll
/tools/7z.exe
/tools/curl.exe

View File

@ -0,0 +1,43 @@
@setlocal
@echo off
:: Initialize environment
call "%~dp0_env.bat"
set SevenZipUrl=http://7-zip.org/a/7z1602.msi
set SevenZipInstall=7z1602.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
if not exist "%DownloadPath%" mkdir "%DownloadPath%"
call :remove_dir "%TempPath%"
echo Download installation files
if not exist "%DownloadPath%\%SevenZipInstall%" call "%ToolsPath%\winhttpjs.bat" %SevenZipUrl% -saveTo "%DownloadPath%\%SevenZipInstall%"
if not exist "%DownloadPath%\%SevenZipInstall%" echo Cannot download 7z& goto :exit
if not exist "%DownloadPath%\%CurlInstall%" call "%ToolsPath%\winhttpjs.bat" %CurlUrl% -saveTo "%DownloadPath%\%CurlInstall%"
if not exist "%DownloadPath%\%CurlInstall%" echo Cannot download Curl& goto :exit
echo Unpack 7z
msiexec /a "%DownloadPath%\%SevenZipInstall%" /qb TARGETDIR="%TempPath%"
copy "%TempPath%\Files\7-Zip\7z.dll" "%ToolsPath%"
copy "%TempPath%\Files\7-Zip\7z.exe" "%ToolsPath%"
call :remove_dir "%TempPath%"
echo Unpack Curl
"%SevenZipExe%" x -o"%TempPath%" "%DownloadPath%\%CurlInstall%"
copy "%TempPath%\curl-7.50.1-win32-mingw\bin\curl.exe" "%ToolsPath%"
call :remove_dir "%TempPath%"
:exit
endlocal
exit /B 0
:remove_dir
if not exist %1 goto :EOF
del /s /f /q %1 >nul
rmdir /s /q %1
goto :EOF

View File

@ -0,0 +1,70 @@
@setlocal
@echo off
:: Initialize environment
call "%~dp0_env.bat"
set MSYSInstall=mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip
set CMakeInstall=cmake-3.1.0-win32-x86.zip
set CMakeUnpackPath=%MSYSPath%\msys\1.0
if not exist "%DownloadPath%" mkdir "%DownloadPath%"
echo Check existing installation
if not exist "%MSYSPath%\bin\mingw-get.exe" goto proceed
choice /M "Found existing MSYS version. Do you want to proceed?"
if %ERRORLEVEL%==2 goto exit
:proceed
echo Remove previous MSYS version
call :remove_dir "%MSYSPath%"
echo Download installation files
if not exist "%DownloadPath%\%MSYSInstall%" "%CurlExe%" -L -k http://sourceforge.net/projects/mingw/files/Installer/mingw-get/mingw-get-0.6.2-beta-20131004-1/%MSYSInstall%/download -o "%DownloadPath%\%MSYSInstall%"
if not exist "%DownloadPath%%\MSYSInstall%" echo Cannot download MSYS& goto :exit
if not exist "%DownloadPath%\%CMakeInstall%" "%CurlExe%" -L -k http://www.cmake.org/files/v3.1/cmake-3.1.0-win32-x86.zip -o "%DownloadPath%\%CMakeInstall%"
if not exist "%DownloadPath%\%CMakeInstall%" echo Cannot download CMake& goto :exit
echo Unpack MSYS
"%SevenZipExe%" x -o"%MSYSPath%" "%DownloadPath%\%MSYSInstall%"
echo Install MSYS
if not exist "%MSYSPath%\var\lib\mingw-get\data\profile.xml" copy "%MSYSPath%\var\lib\mingw-get\data\defaults.xml" "%MSYSPath%\var\lib\mingw-get\data\profile.xml"
pushd "%MSYSPath%\bin"
mingw-get.exe install mingw32-mingw-get
mingw-get.exe install msys-coreutils
mingw-get.exe install msys-base
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
popd
echo Unpack CMake
"%SevenZipExe%" x -o"%CMakeUnpackPath%" "%DownloadPath%\%CMakeInstall%"
echo Install CMake
set CMakeVersion=
for /D %%F in (%CMakeUnpackPath%\cmake*) do set CMakeVersion=%%~nxF
if "%CMakeVersion%"=="" echo CMake version not found.& goto :exit
echo Found CMake version %CMakeVersion%
set FoundProfile=
for /f "tokens=3" %%F in ('find /c /i "%CMakeVersion%" "%MSYSPath%\msys\1.0\etc\profile"') do set FoundProfile=%%F
if "%FoundProfile%"=="0" (
echo export PATH="${PATH}:/%CMakeVersion%/bin">>"%MSYSPath%\msys\1.0\etc\profile"
)
:exit
endlocal
exit /B 0
:remove_dir
if not exist %1 goto :EOF
del /s /f /q %1 >nul
rmdir /s /q %1
goto :EOF

View File

@ -0,0 +1,29 @@
@setlocal
@echo off
:: Initialize environment
call "%~dp0_env.bat"
set MSYSSH=%MSYSPath%\msys\1.0\bin\sh.exe
set MSYSCurPath=/%CurPath:~0,1%/%CurPath:~3%
set MSYSCurPath=%MSYSCurPath:\=/%
if not exist "%MSYSSH%" echo Please install MSYS first.&& exit /B 1
set GCCPath=
call :FIND_IN_PATH g++.exe GCCPath
if "%GCCPath%"=="" echo Please run %~nx0 in the Qt Command Prompt or add the path to MinGW bin folder to PATH variable.&& exit /B 1
"%MSYSSH%" --login -i -c "cd "%MSYSCurPath%" && make -f makefile %*"
exit /B %ERRORLEVEL%
:FIND_IN_PATH
SET PathTemp="%Path:;=";"%"
FOR %%P IN (%PathTemp%) DO (
IF EXIST "%%~P.\%~1" (
set %2=%%~P
goto :EOF
)
)

View File

@ -0,0 +1,226 @@
ZLIB_VERSION=1.2.3
BZIP2_VERSION=1.0.6
MINIUPNPC_VERSION=2.0
OPENSSL_VERSION=1.0.2h
SPEEX_VERSION=1.2rc2
SPEEXDSP_VERSION=1.2rc3
OPENCV_VERSION=2.4.13
LIBXML2_VERSION=2.9.3
LIBXSLT_VERSION=1.1.28
CURL_VERSION=7.46.0
TCL_VERSION=8.6.2
SQLCIPHER_VERSION=2.2.1
LIBMICROHTTPD_VERSION=0.9.46
FFMPEG_VERSION=3.1.2
all: dirs zlib bzip2 miniupnpc openssl speex speexdsp opencv libxml2 libxslt curl sqlcipher libmicrohttpd ffmpeg copylibs
download: \
download/zlib-$(ZLIB_VERSION).tar.gz \
download/bzip2-$(BZIP2_VERSION).tar.gz \
download/miniupnpc-$(MINIUPNPC_VERSION).tar.gz \
download/openssl-$(OPENSSL_VERSION).tar.gz \
download/speex-$(SPEEX_VERSION).tar.gz \
download/speexdsp-$(SPEEXDSP_VERSION).tar.gz \
download/opencv-$(OPENCV_VERSION).tar.gz \
download/libxml2-$(LIBXML2_VERSION).tar.gz \
download/libxslt-$(LIBXSLT_VERSION).tar.gz \
download/curl-$(CURL_VERSION).tar.gz \
download/tcl$(TCL_VERSION)-src.tar.gz \
download/sqlcipher-$(SQLCIPHER_VERSION).tar.gz \
download/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz \
download/ffmpeg-$(FFMPEG_VERSION).tar.gz
dirs:
mkdir -p download
mkdir -p libs/include
mkdir -p libs/lib
mkdir -p libs/bin
download/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/zlib-$(ZLIB_VERSION).tar.gz
zlib: download/zlib-$(ZLIB_VERSION).tar.gz
tar xvf download/zlib-$(ZLIB_VERSION).tar.gz
cd zlib-$(ZLIB_VERSION) && ./configure
#cd zlib-$(ZLIB_VERSION) && make install prefix="`pwd`/../libs"
cd zlib-$(ZLIB_VERSION) && make
cp zlib-$(ZLIB_VERSION)/zlib.h libs/include/
cp zlib-$(ZLIB_VERSION)/zconf.h libs/include/
cp zlib-$(ZLIB_VERSION)/libz.a libs/lib/
rm -r -f zlib-$(ZLIB_VERSION)
touch zlib
download/bzip2-$(BZIP2_VERSION).tar.gz:
wget http://bzip.org/$(BZIP2_VERSION)/bzip2-$(BZIP2_VERSION).tar.gz -O download/bzip2-$(BZIP2_VERSION).tar.gz
bzip2: download/bzip2-$(BZIP2_VERSION).tar.gz
tar xvf download/bzip2-$(BZIP2_VERSION).tar.gz
#cd bzip2-$(BZIP2_VERSION) && make install PREFIX="`pwd`/../libs"
cd bzip2-$(BZIP2_VERSION) && make
cp bzip2-$(BZIP2_VERSION)/bzlib.h libs/include/
cp bzip2-$(BZIP2_VERSION)/libbz2.a libs/lib/
rm -r -f bzip2-$(BZIP2_VERSION)
touch bzip2
download/miniupnpc-$(MINIUPNPC_VERSION).tar.gz:
wget http://miniupnp.free.fr/files/download.php?file=miniupnpc-$(MINIUPNPC_VERSION).tar.gz -O download/miniupnpc-$(MINIUPNPC_VERSION).tar.gz
miniupnpc: download/miniupnpc-$(MINIUPNPC_VERSION).tar.gz
tar xvf download/miniupnpc-$(MINIUPNPC_VERSION).tar.gz
cd miniupnpc-$(MINIUPNPC_VERSION) && CC=gcc && export CC && make -f Makefile.mingw init libminiupnpc.a miniupnpc.dll
mkdir -p libs/include/miniupnpc && cp miniupnpc-$(MINIUPNPC_VERSION)/*.h libs/include/miniupnpc/
cp miniupnpc-$(MINIUPNPC_VERSION)/miniupnpc.lib libs/lib/
cp miniupnpc-$(MINIUPNPC_VERSION)/miniupnpc.dll libs/bin/
rm -r -f miniupnpc-$(MINIUPNPC_VERSION)
touch miniupnpc
download/openssl-$(OPENSSL_VERSION).tar.gz:
wget --no-check-certificate https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz -O download/openssl-$(OPENSSL_VERSION).tar.gz
openssl: download/openssl-$(OPENSSL_VERSION).tar.gz
tar xvf download/openssl-$(OPENSSL_VERSION).tar.gz
#cd openssl-$(OPENSSL_VERSION) && ./config --prefix="`pwd`/../libs"
#cd openssl-$(OPENSSL_VERSION) && make install
cd openssl-$(OPENSSL_VERSION) && ./config shared
cd openssl-$(OPENSSL_VERSION) && make
mkdir -p libs/include/openssl && cp openssl-$(OPENSSL_VERSION)/include/openssl/*.h libs/include/openssl/
cp openssl-$(OPENSSL_VERSION)/libeay32.dll libs/bin/
cp openssl-$(OPENSSL_VERSION)/ssleay32.dll libs/bin/
cp openssl-$(OPENSSL_VERSION)/libcrypto.dll.a libs/lib/
cp openssl-$(OPENSSL_VERSION)/libssl.dll.a libs/lib/
rm -r -f openssl-$(OPENSSL_VERSION)
touch openssl
download/speex-$(SPEEX_VERSION).tar.gz:
wget http://downloads.xiph.org/releases/speex/speex-$(SPEEX_VERSION).tar.gz -O download/speex-$(SPEEX_VERSION).tar.gz
speex: download/speex-$(SPEEX_VERSION).tar.gz
tar xvf download/speex-$(SPEEX_VERSION).tar.gz
cd speex-$(SPEEX_VERSION) && ./configure
#cd speex-$(SPEEX_VERSION) && make install exec_prefix="`pwd`/../libs"
cd speex-$(SPEEX_VERSION) && make
mkdir -p libs/include/speex && cp speex-$(SPEEX_VERSION)/include/speex/*.h libs/include/speex/
cp speex-$(SPEEX_VERSION)/libspeex/.libs/libspeex.a libs/lib
rm -r -f speex-$(SPEEX_VERSION)
touch speex
download/speexdsp-$(SPEEXDSP_VERSION).tar.gz:
wget http://downloads.xiph.org/releases/speex/speexdsp-$(SPEEXDSP_VERSION).tar.gz -O download/speexdsp-$(SPEEXDSP_VERSION).tar.gz
speexdsp: download/speexdsp-$(SPEEXDSP_VERSION).tar.gz
tar xvf download/speexdsp-$(SPEEXDSP_VERSION).tar.gz
cd speexdsp-$(SPEEXDSP_VERSION) && ./configure
cd speexdsp-$(SPEEXDSP_VERSION) && make
mkdir -p libs/include/speex && cp speexdsp-$(SPEEXDSP_VERSION)/include/speex/*.h libs/include/speex/
cp speexdsp-$(SPEEXDSP_VERSION)/libspeexdsp/.libs/libspeexdsp.a libs/lib
rm -r -f speexdsp-$(SPEEXDSP_VERSION)
touch speexdsp
download/opencv-$(OPENCV_VERSION).tar.gz:
wget --no-check-certificate https://github.com/Itseez/opencv/archive/$(OPENCV_VERSION).tar.gz -O download/opencv-$(OPENCV_VERSION).tar.gz
opencv: download/opencv-$(OPENCV_VERSION).tar.gz
tar xvf download/opencv-$(OPENCV_VERSION).tar.gz
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`/install"
cd opencv-$(OPENCV_VERSION)/build && make install
cp -r opencv-$(OPENCV_VERSION)/build/install/include/* libs/include/
mkdir -p libs/lib/opencv && cp -r opencv-$(OPENCV_VERSION)/build/install/x86/mingw/staticlib/* libs/lib/opencv/
rm -r -f opencv-$(OPENCV_VERSION)
touch opencv
download/libxml2-$(LIBXML2_VERSION).tar.gz:
wget ftp://xmlsoft.org/libxml2/libxml2-$(LIBXML2_VERSION).tar.gz -O download/libxml2-$(LIBXML2_VERSION).tar.gz
libxml2: download/libxml2-$(LIBXML2_VERSION).tar.gz
tar xvf download/libxml2-$(LIBXML2_VERSION).tar.gz
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
mkdir -p libs/include/libxml && cp libxml2-$(LIBXML2_VERSION)/include/libxml/*.h libs/include/libxml/
cp libxml2-$(LIBXML2_VERSION)/.libs/libxml2.a libs/lib/
touch libxml2
download/libxslt-$(LIBXSLT_VERSION).tar.gz:
wget ftp://xmlsoft.org/libxml2/libxslt-$(LIBXSLT_VERSION).tar.gz -O download/libxslt-$(LIBXSLT_VERSION).tar.gz
libxslt: download/libxml2-$(LIBXML2_VERSION).tar.gz download/libxslt-$(LIBXSLT_VERSION).tar.gz
tar xvf download/libxml2-$(LIBXML2_VERSION).tar.gz
tar xvf download/libxslt-$(LIBXSLT_VERSION).tar.gz
tar xvf libxslt-$(LIBXSLT_VERSION)-fix.tar.gz
cd libxslt-$(LIBXSLT_VERSION) && ./configure --with-libxml-src=../libxml2-$(LIBXML2_VERSION) -enable-shared=no CFLAGS=-DLIBXML_STATIC
cd libxslt-$(LIBXSLT_VERSION) && make
mkdir -p libs/include/libxslt && cp libxslt-$(LIBXSLT_VERSION)/libxslt/*.h libs/include/libxslt/
cp libxslt-$(LIBXSLT_VERSION)/libxslt/.libs/libxslt.a libs/lib/
cp libxslt-$(LIBXSLT_VERSION)/libexslt/.libs/libexslt.a libs/lib/
rm -r -f libxml2-$(LIBXML2_VERSION)
rm -r -f libxslt-$(LIBXSLT_VERSION)
touch libxslt
download/curl-$(CURL_VERSION).tar.gz:
wget --no-check-certificate http://curl.haxx.se/download/curl-$(CURL_VERSION).tar.gz -O download/curl-$(CURL_VERSION).tar.gz
curl: download/curl-$(CURL_VERSION).tar.gz
tar xvf download/curl-$(CURL_VERSION).tar.gz
cd curl-$(CURL_VERSION) && ./configure --disable-shared --with-ssl="`pwd`/../libs"
#cd curl-$(CURL_VERSION) && make install exec_prefix="`pwd`/../libs"
cd curl-$(CURL_VERSION) && make
mkdir -p libs/include/curl && cp curl-$(CURL_VERSION)/include/curl/*.h libs/include/curl/
cp curl-$(CURL_VERSION)/lib/.libs/libcurl.a libs/lib/
rm -r -f curl-$(CURL_VERSION)
touch curl
download/tcl$(TCL_VERSION)-src.tar.gz:
wget http://prdownloads.sourceforge.net/tcl/tcl$(TCL_VERSION)-src.tar.gz -O download/tcl$(TCL_VERSION)-src.tar.gz
download/sqlcipher-$(SQLCIPHER_VERSION).tar.gz:
wget --no-check-certificate https://github.com/sqlcipher/sqlcipher/archive/v$(SQLCIPHER_VERSION).tar.gz -O download/sqlcipher-$(SQLCIPHER_VERSION).tar.gz
sqlcipher: download/tcl$(TCL_VERSION)-src.tar.gz download/sqlcipher-$(SQLCIPHER_VERSION).tar.gz
# tcl
tar xvf download/tcl$(TCL_VERSION)-src.tar.gz
mkdir -p tcl$(TCL_VERSION)/build
cd tcl$(TCL_VERSION)/build && ../win/configure
cd tcl$(TCL_VERSION)/build && make
#sqlcipher
tar xvf download/sqlcipher-$(SQLCIPHER_VERSION).tar.gz
cd sqlcipher-$(SQLCIPHER_VERSION) && ln -s ../tcl$(TCL_VERSION)/build/tclsh86.exe tclsh
mkdir -p tcl$(TCL_VERSION)/lib
ln -s `pwd`/tcl$(TCL_VERSION)/library `pwd`/tcl$(TCL_VERSION)/lib/tcl8.6
cd sqlcipher-$(SQLCIPHER_VERSION) && PATH=.:$$PATH:`pwd`/../tcl$(TCL_VERSION)/build && LIBS="-L`pwd`/../libs/lib -lgdi32 $$LIBS" && export LIBS && ./configure --disable-shared --enable-static --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -I`pwd`/../libs/include -I`pwd`/../tcl$(TCL_VERSION)/generic" LDFLAGS="-L`pwd`/../libs/lib -lcrypto -lgdi32" --with-tcl="`pwd`/../tcl$(TCL_VERSION)/build" && make install prefix="`pwd`/install"
cp -r sqlcipher-$(SQLCIPHER_VERSION)/install/include/* libs/include/
cp sqlcipher-$(SQLCIPHER_VERSION)/install/lib/libsqlcipher.a libs/lib/
cp sqlcipher-$(SQLCIPHER_VERSION)/install/bin/sqlcipher.exe libs/bin/
rm -r -f sqlcipher-$(SQLCIPHER_VERSION)
rm -r -f tcl$(TCL_VERSION)
touch sqlcipher
download/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz:
wget --no-check-certificate http://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz -O download/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz
libmicrohttpd: download/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz
tar xvf download/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz
cd libmicrohttpd-$(LIBMICROHTTPD_VERSION) && ./configure --disable-shared --enable-static --prefix="`pwd`/../libs"
cd libmicrohttpd-$(LIBMICROHTTPD_VERSION) && make install
rm -r -f libmicrohttpd-$(LIBMICROHTTPD_VERSION)
touch libmicrohttpd
download/ffmpeg-$(FFMPEG_VERSION).tar.gz:
wget --no-check-certificate https://ffmpeg.org/releases/ffmpeg-$(FFMPEG_VERSION).tar.gz -O download/ffmpeg-$(FFMPEG_VERSION).tar.gz
ffmpeg: download/ffmpeg-$(FFMPEG_VERSION).tar.gz
tar xvf download/ffmpeg-$(FFMPEG_VERSION).tar.gz
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"
cd ffmpeg-$(FFMPEG_VERSION) && make install
rm -r -f ffmpeg-$(FFMPEG_VERSION)
touch ffmpeg
copylibs:
read -p "Do you want to copy libs to retroshare? (yes|no)" answer; \
if [ "$$answer" = "yes" ] ; then \
cp -r libs ../../../../ ; \
fi

View File

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

View File

@ -0,0 +1,9 @@
set CurPath=%~dp0
set DownloadPath=%CurPath%download
set ToolsPath=%CurPath%tools
set TempPath=%CurPath%tmp
set MSYSPath=%CurPath%msys
set LibsPath=%CurPath%libs
set CurlExe=%ToolsPath%\curl.exe
set SevenZipExe=%ToolsPath%\7z.exe

View File

@ -0,0 +1,30 @@
@setlocal
@echo off
:: Initialize environment
call "%~dp0_env.bat"
::call :remove_dir "%DownloadPath%"
call :remove_dir "%MSYSPath%"
call :remove_dir "%TempPath%"
call :remove_file "%ToolsPath%\7z.exe"
call :remove_file "%ToolsPath%\7z.dll"
call :remove_file "%ToolsPath%\curl.exe"
call "%~dp0clean.bat"
endlocal
exit /B 0
:remove_dir
if not exist %1 goto :EOF
del /s /f /q %1 >nul
rmdir /s /q %1
goto :EOF
:remove_file
if not exist %1 goto :EOF
del /q %1 >nul
goto :EOF

View File

@ -0,0 +1,36 @@
@setlocal
@echo off
:: Initialize environment
call "%~dp0_env.bat"
call :remove_dir "%LibsPath%"
call :remove_file "%CurPath%bzip2"
call :remove_file "%CurPath%curl"
call :remove_file "%CurPath%ffmpeg"
call :remove_file "%CurPath%libmicrohttpd"
call :remove_file "%CurPath%libxml2"
call :remove_file "%CurPath%libxslt"
call :remove_file "%CurPath%miniupnpc"
call :remove_file "%CurPath%opencv"
call :remove_file "%CurPath%openssl"
call :remove_file "%CurPath%speex"
call :remove_file "%CurPath%speexdsp"
call :remove_file "%CurPath%sqlcipher"
call :remove_file "%CurPath%zlib"
endlocal
exit /B 0
:remove_dir
if not exist %1 goto :EOF
del /s /f /q %1 >nul
rmdir /s /q %1
goto :EOF
:remove_file
if not exist %1 goto :EOF
del /q %1 >nul
goto :EOF

View File

@ -0,0 +1,16 @@
@setlocal
@echo off
:: Initialize environment
call "%~dp0_env.bat"
if not exist "%MSYSPath%\bin\mingw-get.exe" exit /B 0
echo Update MSYS
pushd "%MSYSPath%\bin"
mingw-get.exe update
mingw-get.exe upgrade
popd
exit /B %ERRORLEVEL%

View File

@ -26,6 +26,7 @@
#include "bitdht/bdfilter.h"
#include "bitdht/bdmanager.h"
#include "util/bdfile.h"
#include <stdlib.h>
@ -39,7 +40,7 @@
**/
#define BDFILTER_ENTRY_DROP_PERIOD (7 * 24 * 3600)
bdFilter::bdFilter(const std::string &fname, const bdNodeId *ownid, uint32_t filterFlags, bdDhtFunctions *fns)
bdFilter::bdFilter(const std::string &fname, const bdNodeId *ownid, uint32_t filterFlags, bdDhtFunctions *fns, bdNodeManager *manager)
{
/* */
mOwnId = *ownid;
@ -49,6 +50,7 @@ bdFilter::bdFilter(const std::string &fname, const bdNodeId *ownid, uint32_t fi
loadBannedIpFile() ;
mFilterFlags = filterFlags;
mNodeManager = manager;
}
void bdFilter::writeBannedIpFile()
@ -220,16 +222,28 @@ void bdFilter::getFilteredPeers(std::list<bdFilteredPeer>& peers)
/* fast check if the addr is in the structure */
int bdFilter::addrOkay(struct sockaddr_in *addr)
{
std::map<uint32_t,bdFilteredPeer>::const_iterator it = mFiltered.find(addr->sin_addr.s_addr);
// first check upper layer
bool isAvailable, isBanned;
mNodeManager->doIsBannedCallback(addr, &isAvailable, &isBanned);
if (it == mFiltered.end())
return 1; // Address is Okay!
if(isAvailable) {
#ifdef DEBUG_FILTER
std::cerr << "bdFilter::addrOkay addr: " << inet_ntoa(addr->sin_addr) << " result from upper layer: " << (isBanned ? "banned" : "ok") << std::endl;
#endif
return !isBanned;
} else {
// fallback to own ban list
std::map<uint32_t,bdFilteredPeer>::const_iterator it = mFiltered.find(addr->sin_addr.s_addr);
if (it == mFiltered.end())
return 1; // Address is Okay
}
#ifdef DEBUG_FILTER
std::cerr << "Detected Packet From Banned Ip Address: " << inet_ntoa(addr->sin_addr);
std::cerr << std::endl;
std::cerr << "Detected Packet From Banned Ip Address: " << inet_ntoa(addr->sin_addr);
std::cerr << std::endl;
#endif
return 0;
return 0;
}

View File

@ -47,10 +47,12 @@ class bdFilteredPeer
time_t mLastSeen;
};
class bdNodeManager;
class bdFilter
{
public:
bdFilter(const std::string& fname,const bdNodeId *ownid, uint32_t filterFlags, bdDhtFunctions *fns);
bdFilter(const std::string& fname, const bdNodeId *ownid, uint32_t filterFlags, bdDhtFunctions *fns, bdNodeManager *manager);
// get the answer.
//bool filtered(std::list<bdFilteredPeer> &answer);
@ -77,9 +79,12 @@ bool isOwnIdWithoutBitDhtFlags(const bdId *id, uint32_t peerFlags);
bdNodeId mOwnId;
uint32_t mFilterFlags;
std::map<uint32_t,bdFilteredPeer> mFiltered;
bdDhtFunctions *mFns;
std::string mFilename ;
std::map<uint32_t,bdFilteredPeer> mFiltered;
bdDhtFunctions *mFns;
std::string mFilename ;
// have access to the manager for isBanned callback
bdNodeManager* mNodeManager;
};

View File

@ -337,20 +337,25 @@ class BitDhtCallback
public:
// ~BitDhtCallback();
// dummy cos not needed for standard dht behaviour;
virtual int dhtNodeCallback(const bdId * /*id*/, uint32_t /*peerflags*/) { return 0; }
// dummy cos not needed for standard dht behaviour;
virtual int dhtNodeCallback(const bdId * /*id*/, uint32_t /*peerflags*/) { return 0; }
// must be implemented.
virtual int dhtPeerCallback(const bdId *id, uint32_t status) = 0;
virtual int dhtValueCallback(const bdNodeId *id, std::string key, uint32_t status) = 0;
// must be implemented.
virtual int dhtPeerCallback(const bdId *id, uint32_t status) = 0;
virtual int dhtValueCallback(const bdNodeId *id, std::string key, uint32_t status) = 0;
// connection callback. Not required for basic behaviour, but forced for initial development.
virtual int dhtConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId *destId,
uint32_t mode, uint32_t point, uint32_t param, uint32_t cbtype, uint32_t errcode) = 0; /* { return 0; } */
// connection callback. Not required for basic behaviour, but forced for initial development.
virtual int dhtConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId *destId,
uint32_t mode, uint32_t point, uint32_t param, uint32_t cbtype, uint32_t errcode) = 0; /* { return 0; } */
// Generic Info callback - initially will be used to provide bad peers.
virtual int dhtInfoCallback(const bdId *id, uint32_t type, uint32_t flags, std::string info) = 0;
// Generic Info callback - initially will be used to provide bad peers.
virtual int dhtInfoCallback(const bdId *id, uint32_t type, uint32_t flags, std::string info) = 0;
// ask upper layer whether an IP is banned or not
// must not be implemented
// when set it will be used instead of the own ban list
// return code is used to express availability/absence
virtual int dhtIsBannedCallback(const sockaddr_in */*addr*/, bool */*isBanned*/) { return 0;}
};

View File

@ -69,7 +69,7 @@
bdNodeManager::bdNodeManager(bdNodeId *id, std::string dhtVersion, std::string bootfile, const std::string& filterfile,bdDhtFunctions *fns)
:bdNode(id, dhtVersion, bootfile, filterfile, fns)
:bdNode(id, dhtVersion, bootfile, filterfile, fns, this)
{
mMode = BITDHT_MGR_STATE_OFF;
mFns = fns;
@ -1179,10 +1179,9 @@ void bdNodeManager::doPeerCallback(const bdId *id, uint32_t status)
void bdNodeManager::doValueCallback(const bdNodeId *id, std::string key, uint32_t status)
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::doValueCallback()";
std::cerr << std::endl;
#ifdef DEBUG_MGR
#endif
/* search list */
std::list<BitDhtCallback *>::iterator it;
@ -1196,10 +1195,9 @@ void bdNodeManager::doValueCallback(const bdNodeId *id, std::string key, uint32_
void bdNodeManager::doInfoCallback(const bdId *id, uint32_t type, uint32_t flags, std::string info)
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::doInfoCallback()";
std::cerr << std::endl;
#ifdef DEBUG_MGR
#endif
/* search list */
std::list<BitDhtCallback *>::iterator it;
@ -1210,6 +1208,28 @@ void bdNodeManager::doInfoCallback(const bdId *id, uint32_t type, uint32_t flags
return;
}
void bdNodeManager::doIsBannedCallback(const sockaddr_in *addr, bool *isAvailable, bool *isBanned)
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::doIsBannedCallback()";
std::cerr << std::endl;
#endif
/* search list */
std::list<BitDhtCallback *>::iterator it;
*isBanned = false;
*isAvailable = false;
for(it = mCallbacks.begin(); it != mCallbacks.end(); it++)
{
// set isBanned to true as soon as one callback answers with true
bool banned;
if((*it)->dhtIsBannedCallback(addr, &banned))
{
*isBanned = *isBanned || banned;
*isAvailable = true;
}
}
}
#define BITDHT_IDENTITY_STRING_V1 "d1:"
#define BITDHT_IDENTITY_SIZE_V1 3

View File

@ -153,6 +153,9 @@ virtual void callbackConnect(bdId *srcId, bdId *proxyId, bdId *destId,
int isBitDhtPacket(char *data, int size, struct sockaddr_in &from);
// this function is used by bdFilter (must be public!)
void doIsBannedCallback(const sockaddr_in *addr, bool *isAvailable, bool* isBanned);
private:

View File

@ -70,10 +70,10 @@
#define HISTORY_PERIOD 60
bdNode::bdNode(bdNodeId *ownId, std::string dhtVersion, const std::string& bootfile, const std::string& filterfile, bdDhtFunctions *fns)
bdNode::bdNode(bdNodeId *ownId, std::string dhtVersion, const std::string& bootfile, const std::string& filterfile, bdDhtFunctions *fns, bdNodeManager *manager)
:mNodeSpace(ownId, fns),
mFilterPeers(filterfile,ownId, BITDHT_FILTER_REASON_OWNID, fns),
mQueryMgr(NULL),
mFilterPeers(filterfile,ownId, BITDHT_FILTER_REASON_OWNID, fns, manager),
mQueryMgr(NULL),
mConnMgr(NULL),
mOwnId(*ownId), mDhtVersion(dhtVersion), mStore(bootfile, fns), mFns(fns),
mFriendList(ownId), mHistory(HISTORY_PERIOD)

View File

@ -85,6 +85,7 @@ output -> call back to Udp().
*********/
class bdFilteredPeer ;
class bdNodeManager;
class bdNodeNetMsg
{
@ -122,7 +123,7 @@ class bdNode: public bdNodePublisher
public:
bdNode(bdNodeId *id, std::string dhtVersion, const std::string& bootfile, const std::string& filterfile,
bdDhtFunctions *fns);
bdDhtFunctions *fns, bdNodeManager* manager);
void init(); /* sets up the self referential classes (mQueryMgr & mConnMgr) */
@ -243,7 +244,7 @@ void recvPkt(char *msg, int len, struct sockaddr_in addr);
protected:
bdSpace mNodeSpace;
bdFilter mFilterPeers;
bdFilter mFilterPeers;
bdQueryManager *mQueryMgr;
bdConnectManager *mConnMgr;

View File

@ -87,8 +87,10 @@ bool UdpStack::getLocalAddress(struct sockaddr_in &local)
bool UdpStack::resetAddress(struct sockaddr_in &local)
{
std::cerr << "UdpStack::resetAddress(" << local << ")";
#ifdef DEBUG_UDP_RECV
std::cerr << "UdpStack::resetAddress(" << local << ")";
std::cerr << std::endl;
#endif
laddr = local;
return udpLayer->reset(local);

View File

@ -150,10 +150,10 @@ want generic resource caching mechanism
- dynamic handlers contain result data, and thus get deleted after a while
it is even possible to implement a resource-changed check at the highest level
this allows to compute everything on the server side and only send chanes to the client
this allows to compute everything on the server side and only send changes to the client
the different resource providers don't have to implement a resource changed check then
a top level change detector will poll them
of course this does not wokr with a deep resource tree with millions of nodes
of course this does not work with a deep resource tree with millions of nodes
for this we have the dynamic handlers,
they are created on demand and know how to listen for changes which affect them

View File

@ -0,0 +1,113 @@
/*
* libresapi local socket server
* Copyright (C) 2016 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 "ApiServerLocal.h"
#include "JsonStream.h"
namespace resource_api{
ApiServerLocal::ApiServerLocal(ApiServer* server, QObject *parent) :
QObject(parent), serverThread(this),
localListener(server) // Must have no parent to be movable to other thread
{
localListener.moveToThread(&serverThread);
serverThread.start();
}
ApiServerLocal::~ApiServerLocal() { serverThread.quit(); }
ApiLocalListener::ApiLocalListener(ApiServer *server, QObject *parent) :
QObject(parent), mApiServer(server), mLocalServer(this)
{
mLocalServer.removeServer(serverName());
#if QT_VERSION >= 0x050000
mLocalServer.setSocketOptions(QLocalServer::UserAccessOption);
#endif
connect(&mLocalServer, SIGNAL(newConnection()), this, SLOT(handleConnection()));
mLocalServer.listen(serverName());
}
void ApiLocalListener::handleConnection()
{
new ApiLocalConnectionHandler(mApiServer,
mLocalServer.nextPendingConnection(), this);
}
ApiLocalConnectionHandler::ApiLocalConnectionHandler(
ApiServer* apiServer, QLocalSocket* sock, QObject *parent) :
QObject(parent), mApiServer(apiServer), mLocalSocket(sock),
mState(WAITING_PATH)
{
connect(mLocalSocket, SIGNAL(disconnected()), this, SLOT(deleteLater()));
connect(sock, SIGNAL(readyRead()), this, SLOT(handlePendingRequests()));
}
ApiLocalConnectionHandler::~ApiLocalConnectionHandler()
{
mLocalSocket->close();
delete mLocalSocket;
}
void ApiLocalConnectionHandler::handlePendingRequests()
{
switch(mState)
{
case WAITING_PATH:
{
if(mLocalSocket->canReadLine())
{
readPath:
reqPath = mLocalSocket->readLine().constData();
mState = WAITING_DATA;
/* Because QLocalSocket is SOCK_STREAM some clients implementations
* like the one based on QLocalSocket feel free to send the whole
* request (PATH + DATA) in a single write(), causing readyRead()
* signal being emitted only once, in that case we should continue
* processing without waiting for readyRead() being fired again, so
* we don't break here as there may be more lines to read */
}
}
case WAITING_DATA:
{
if(mLocalSocket->canReadLine())
{
resource_api::JsonStream reqJson;
reqJson.setJsonString(std::string(mLocalSocket->readLine().constData()));
resource_api::Request req(reqJson);
req.setPath(reqPath);
std::string resultString = mApiServer->handleRequest(req);
mLocalSocket->write(resultString.c_str(), resultString.length());
mLocalSocket->write("\n\0");
mState = WAITING_PATH;
/* Because QLocalSocket is SOCK_STREAM some clients implementations
* like the one based on QLocalSocket feel free to coalesce multiple
* upper level write() into a single socket write(), causing
* readyRead() signal being emitted only once, in that case we should
* keep processing without waiting for readyRead() being fired again */
if(mLocalSocket->canReadLine()) goto readPath;
// Now there are no more requests to process we can break
break;
}
}
}
}
} // namespace resource_api

View File

@ -0,0 +1,87 @@
#pragma once
/*
* libresapi local socket server
* Copyright (C) 2016 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 <QLocalServer>
#include <QString>
#include <QThread>
#include <QLocalSocket>
#include <retroshare/rsinit.h>
#include <string>
#include "ApiServer.h"
namespace resource_api
{
class ApiLocalListener : public QObject
{
Q_OBJECT
public:
ApiLocalListener(ApiServer* server, QObject *parent=0);
~ApiLocalListener() { mLocalServer.close(); }
const static QString& serverName()
{
const static QString sockPath(RsAccounts::AccountDirectory()
.append("/libresapi.sock").c_str());
return sockPath;
}
public slots:
void handleConnection();
private:
ApiServer* mApiServer;
QLocalServer mLocalServer;
};
class ApiServerLocal : public QObject
{
Q_OBJECT
public:
ApiServerLocal(ApiServer* server, QObject *parent=0);
~ApiServerLocal();
private:
QThread serverThread;
ApiLocalListener localListener;
};
class ApiLocalConnectionHandler : public QObject
{
Q_OBJECT
public:
ApiLocalConnectionHandler(ApiServer* apiServer, QLocalSocket* sock, QObject *parent = 0);
~ApiLocalConnectionHandler();
enum State {WAITING_PATH, WAITING_DATA};
public slots:
void handlePendingRequests();
private:
ApiServer* mApiServer;
QLocalSocket* mLocalSocket;
State mState;
std::string reqPath;
};
} // namespace resource_api

View File

@ -559,7 +559,7 @@ int ApiServerMHD::accessHandlerCallback(MHD_Connection *connection,
return ((MHDHandlerBase*)(*con_cls))->handleRequest(connection, url, method, version, upload_data, upload_data_size);
}
// these characters are not allowe in the url, raise an error if they occur
// these characters are not allowed in the url, raise an error if they occur
// reason: don't want to serve files outside the current document root
const char *double_dots = "..";
if(strstr(url, double_dots))

View File

@ -193,6 +193,33 @@ public:
// then each handler should pop the top element
std::stack<std::string> mPath;
std::string mFullPath;
bool setPath(std::string reqPath)
{
std::string str;
for(std::string::reverse_iterator sit = reqPath.rbegin(); sit != reqPath.rend(); sit++)
{
if((*sit) != '/')
{
// add to front because we are traveling in reverse order
str = *sit + str;
}
else
{
if(str != "")
{
mPath.push(str);
str.clear();
}
}
}
if(str != "")
{
mPath.push(str);
}
mFullPath = reqPath;
return true;
}
// parameters should be used to influence the result
// for example include or exclude some information

View File

@ -55,7 +55,7 @@ bool RsControlModule::processShouldExit()
return mProcessShouldExit;
}
bool RsControlModule::askForPassword(const std::string &key_details, bool /* prev_is_bad */, std::string &password, bool& cancelled)
bool RsControlModule::askForPassword(const std::string &title, const std::string &key_details, bool /* prev_is_bad */, std::string &password, bool& cancelled)
{
cancelled = false ;
{
@ -67,6 +67,7 @@ bool RsControlModule::askForPassword(const std::string &key_details, bool /* pre
}
mWantPassword = true;
mTitle = title;
mKeyName = key_details;
mPassword = "";
mStateTokenServer->replaceToken(mStateToken);

View File

@ -32,7 +32,7 @@ public:
bool processShouldExit();
// from NotifyClient
virtual bool askForPassword(const std::string& key_details, bool prev_is_bad , std::string& password,bool& canceled);
virtual bool askForPassword(const std::string &title, const std::string& key_details, bool prev_is_bad , std::string& password,bool& canceled);
protected:
// from RsThread
@ -76,6 +76,7 @@ private:
// to notify that a password callback is waiting
// to answer the request, clear the flag and set the password
bool mWantPassword;
std::string mTitle;
std::string mKeyName;
std::string mPassword;
// for ssl cert generation:

View File

@ -8,11 +8,12 @@ TARGET = resapi
TARGET_PRL = libresapi
DESTDIR = lib
CONFIG += libmicrohttpd
INCLUDEPATH += ../../libretroshare/src
unix {
libresapihttpserver {
CONFIG += libmicrohttpd
unix {
webui_files.path = "$${DATA_DIR}/webui"
webui_files.files = webui/app.js webui/app.css webui/index.html
@ -81,9 +82,9 @@ unix {
QMAKE_EXTRA_COMPILERS += create_webfiles_html create_webfiles_js create_webfiles_css
}
}
win32{
win32 {
DEFINES *= WINDOWS_SYS
INCLUDEPATH += . $$INC_DIR
@ -104,9 +105,8 @@ win32{
# create dummy files
system($$MAKE_SRC\\init.bat .)
}
}
libmicrohttpd{
linux {
CONFIG += link_pkgconfig
PKGCONFIG *= libmicrohttpd
@ -173,3 +173,10 @@ HEADERS += \
util/ContentTypes.h \
api/ApiPluginHandler.h \
api/ChannelsHandler.h
libresapilocalserver {
CONFIG *= qt
QT *= network
SOURCES *= api/ApiServerLocal.cpp
HEADERS *= api/ApiServerLocal.h
}

View File

@ -34,7 +34,6 @@
#include "pqi/p3historymgr.h"
#include "retroshare/rspeers.h"
#include "retroshare/rsiface.h"
#include "retroshare/rsreputations.h"
#include "retroshare/rsidentity.h"
#include "rsserver/p3face.h"
#include "gxs/rsgixs.h"
@ -139,7 +138,7 @@ bool DistributedChatService::handleRecvChatLobbyMsgItem(RsChatMsgItem *ci)
return false ;
}
if(rsReputations->isIdentityBanned(cli->signature.keyId))
if(rsIdentity->isBanned(cli->signature.keyId))
{
std::cerr << "(WW) Received lobby msg/item from banned identity " << cli->signature.keyId << ". Dropping it." << std::endl;
return false ;
@ -169,7 +168,7 @@ bool DistributedChatService::handleRecvChatLobbyMsgItem(RsChatMsgItem *ci)
if(it == _chat_lobbys.end())
{
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << "Chatlobby for id " << std::hex << item->lobby_id << " has no record. Dropping the msg." << std::dec << std::endl;
std::cerr << "Chatlobby for id " << std::hex << cli->lobby_id << " has no record. Dropping the msg." << std::dec << std::endl;
#endif
return false;
}
@ -648,7 +647,7 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *
#endif
time_t now = time(NULL) ;
if(rsReputations->isIdentityBanned(item->signature.keyId))
if(rsIdentity->isBanned(item->signature.keyId))
{
std::cerr << "(WW) Received lobby msg/item from banned identity " << item->signature.keyId << ". Dropping it." << std::endl;
return ;

View File

@ -431,7 +431,7 @@ int FileIndexMonitor::filterResults(std::list<FileEntry*>& firesults,std::list<D
return !results.empty() ;
}
bool FileIndexMonitor::findLocalFile(const RsFileHash& hash,FileSearchFlags hint_flags, const RsPeerId& peer_id,std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<std::string>& parent_groups) const
bool FileIndexMonitor::findLocalFile(const RsFileHash& hash,FileSearchFlags hint_flags, const RsPeerId& peer_id,std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<RsNodeGroupId>& parent_groups) const
{
std::list<FileEntry *> results;
bool ok = false;
@ -1668,7 +1668,7 @@ int FileIndexMonitor::RequestDirDetails(void *ref, DirDetails &details, FileSear
return true ;
}
void FileIndexMonitor::locked_findShareFlagsAndParentGroups(FileEntry *file,FileStorageFlags& flags,std::list<std::string>& parent_groups) const
void FileIndexMonitor::locked_findShareFlagsAndParentGroups(FileEntry *file,FileStorageFlags& flags,std::list<RsNodeGroupId>& parent_groups) const
{
flags.clear() ;
static const FileStorageFlags PERMISSION_MASK = DIR_FLAGS_BROWSABLE_OTHERS | DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_GROUPS | DIR_FLAGS_NETWORK_WIDE_GROUPS ;

View File

@ -110,7 +110,7 @@ class FileIndexMonitor: public CacheSource, public RsTickingThread
virtual ~FileIndexMonitor();
/* external interface for filetransfer */
bool findLocalFile(const RsFileHash& hash,FileSearchFlags flags,const RsPeerId& peer_id, std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<std::string>& parent_groups) const;
bool findLocalFile(const RsFileHash& hash,FileSearchFlags flags,const RsPeerId& peer_id, std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<RsNodeGroupId>& parent_groups) const;
int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) ;
int SearchBoolExp(Expression *exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) const ;
@ -176,7 +176,7 @@ class FileIndexMonitor: public CacheSource, public RsTickingThread
time_t locked_saveFileIndexes(bool update_cache) ;
// Finds the share flags associated with this file entry.
void locked_findShareFlagsAndParentGroups(FileEntry *fe,FileStorageFlags& shareflags,std::list<std::string>& parent_groups) const ;
void locked_findShareFlagsAndParentGroups(FileEntry *fe, FileStorageFlags& shareflags, std::list<RsNodeGroupId> &parent_groups) const ;
std::string locked_findRealRoot(std::string base) const;

View File

@ -30,7 +30,11 @@
#include "bitdht/bdstddht.h"
#include "tcponudp/udprelay.h"
#ifdef RS_USE_DHT_STUNNER
#include "tcponudp/udpstunner.h"
#endif // RS_USE_DHT_STUNNER
#include "retroshare/rsbanlist.h"
#include <openssl/sha.h>
@ -76,6 +80,27 @@ virtual int dhtInfoCallback(const bdId *id, uint32_t type, uint32_t flags, std::
return mParent->InfoCallback(id, type, flags, info);
}
virtual int dhtIsBannedCallback(const sockaddr_in *addr, bool *isBanned)
{
// check whether ip filtering is enabled
// if not return 0 to signal that no filter is available
if(!rsBanList->ipFilteringEnabled())
return 0;
// now check the filter
if(rsBanList->isAddressAccepted(*(const sockaddr_storage*)addr, RSBANLIST_CHECKING_FLAGS_BLACKLIST, NULL)) {
*isBanned = false;
} else {
#ifdef DEBUG_BITDHT
std::cerr << "p3BitDht dhtIsBannedCallback: peer is banned " << sockaddr_storage_tostring(*(const sockaddr_storage*)addr) << std::endl;
#endif
*isBanned = true;
}
// return 1 to signal that a filter is available
return 1;
}
private:
p3BitDht *mParent;
@ -86,8 +111,10 @@ p3BitDht::p3BitDht(const RsPeerId& id, pqiConnectCb *cb, p3NetMgr *nm,
UdpStack *udpstack, std::string bootstrapfile,const std::string& filteredipfile)
:p3Config(), pqiNetAssistConnect(id, cb), mNetMgr(nm), dhtMtx("p3BitDht")
{
#ifdef RS_USE_DHT_STUNNER
mDhtStunner = NULL;
mProxyStunner = NULL;
#endif
mRelay = NULL;
mPeerSharer = NULL;
@ -168,13 +195,19 @@ bool p3BitDht::getOwnDhtId(std::string &ownDhtId)
return true;
}
#ifdef RS_USE_DHT_STUNNER
void p3BitDht::setupConnectBits(UdpStunner *dhtStunner, UdpStunner *proxyStunner, UdpRelayReceiver *relay)
{
mDhtStunner = dhtStunner;
mProxyStunner = proxyStunner;
mRelay = relay;
}
#else // RS_USE_DHT_STUNNER
void p3BitDht::setupConnectBits(UdpRelayReceiver *relay)
{
mRelay = relay;
}
#endif //RS_USE_DHT_STUNNER
void p3BitDht::setupPeerSharer(pqiNetAssistPeerShare *sharer)
{

View File

@ -136,7 +136,9 @@ class p3BitDhtRelayHandler
class UdpRelayReceiver;
#ifdef RS_USE_DHT_STUNNER
class UdpStunner;
#endif // RS_USE_DHT_STUNNER
class p3NetMgr;
class p3BitDht: public p3Config, public pqiNetAssistConnect, public RsDht
@ -174,8 +176,11 @@ public:
********** External RsDHT Interface (defined in libretroshare/src/retroshare/rsdht.h) *********
************************************************************************************************/
#ifdef RS_USE_DHT_STUNNER
void setupConnectBits(UdpStunner *dhtStunner, UdpStunner *proxyStunner, UdpRelayReceiver *relay);
#else // RS_USE_DHT_STUNNER
void setupConnectBits(UdpRelayReceiver *relay);
#endif // RS_USE_DHT_STUNNER
void setupPeerSharer(pqiNetAssistPeerShare *sharer);
void modifyNodesPerBucket(uint16_t count);
@ -359,8 +364,10 @@ private:
int removeTranslation_locked(const RsPeerId& pid);
UdpBitDht *mUdpBitDht; /* has own mutex, is static except for creation/destruction */
#ifdef RS_USE_DHT_STUNNER
UdpStunner *mDhtStunner;
UdpStunner *mProxyStunner;
#endif // RS_USE_DHT_STUNNER
UdpRelayReceiver *mRelay;
p3NetMgr *mNetMgr;

View File

@ -149,7 +149,7 @@ int p3BitDht::getNetFailedPeer(std::string peerId, PeerStatus &status)
std::string p3BitDht::getUdpAddressString()
{
std::string out;
#ifdef RS_USE_DHT_STUNNER
struct sockaddr_in extAddr;
uint8_t extStable;
@ -187,7 +187,10 @@ std::string p3BitDht::getUdpAddressString()
{
out += " ProxyExtAddr: Unknown ";
}
#else // RS_USE_DHT_STUNNER
// whitespaces taken from above
out = " DhtExtAddr: Unknown ProxyExtAddr: Unknown ";
#endif // RS_USE_DHT_STUNNER
return out;
}

View File

@ -81,6 +81,7 @@ int p3BitDht::InfoCallback(const bdId *id, uint32_t /*type*/, uint32_t /*flags*/
mPeerSharer->updatePeer(rsid, tmpaddr, outtype, outreason, outage);
}
#ifdef RS_USE_DHT_STUNNER
/* call to the Stunners to drop the address as well */
/* IDEALLY these addresses should all be filtered at UdpLayer level instead! */
if (mDhtStunner)
@ -91,6 +92,7 @@ int p3BitDht::InfoCallback(const bdId *id, uint32_t /*type*/, uint32_t /*flags*/
{
mProxyStunner->dropStunPeer(addr);
}
#endif // RS_USE_DHT_STUNNER
return 1;
}
@ -135,7 +137,7 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
}
}
#ifdef RS_USE_DHT_STUNNER
if ((mProxyStunner) && (mProxyStunner->needStunPeers()))
{
#ifdef DEBUG_BITDHT_COMMON
@ -156,6 +158,7 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
#endif
mDhtStunner->addStunPeer(id->addr, NULL);
}
#endif // RS_USE_DHT_STUNNER
}
return 1;
}
@ -683,7 +686,6 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId
#endif
struct sockaddr_in extaddr;
uint8_t extStable = 0;
sockaddr_clear(&extaddr);
bool connectOk = false;
@ -731,6 +733,9 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId
std::cerr << std::endl;
}
#ifdef RS_USE_DHT_STUNNER
uint8_t extStable = 0;
UdpStunner *stunner = mProxyStunner;
if (!proxyPort)
{
@ -849,6 +854,11 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId
std::cerr << std::endl;
#endif
}
#else // RS_USE_DHT_STUNNER
connectionAllowed = BITDHT_CONNECT_ERROR_TEMPUNAVAIL;
(void) connectOk;
(void) exclusivePort;
#endif // RS_USE_DHT_STUNNER
}
ca.mMode = mode;
@ -1188,7 +1198,6 @@ int p3BitDht::doActions()
else if (action.mMode == BITDHT_CONNECT_MODE_PROXY)
{
struct sockaddr_in extaddr;
uint8_t extStable = 0;
sockaddr_clear(&extaddr);
bool proxyPort = true;
bool exclusivePort = false;
@ -1234,6 +1243,9 @@ int p3BitDht::doActions()
std::cerr << std::endl;
}
}
#ifdef RS_USE_DHT_STUNNER
uint8_t extStable = 0;
UdpStunner *stunner = mProxyStunner;
if (!proxyPort)
{
@ -1333,6 +1345,11 @@ int p3BitDht::doActions()
connectionReqFailed = true;
failReason = CSB_UPDATE_RETRY_ATTEMPT;
}
#else // RS_USE_DHT_STUNNER
connectionReqFailed = true;
failReason = CSB_UPDATE_RETRY_ATTEMPT;
(void) connectOk;
#endif //RS_USE_DHT_STUNNER
}
if (doConnectionRequest)
@ -1416,7 +1433,9 @@ int p3BitDht::doActions()
{
std::cerr << "PeerAction: ERROR ERROR, we grabd Exclusive Port to do this, trying emergency release";
std::cerr << std::endl;
#ifdef RS_USE_DHT_STUNNER
mProxyStunner->releaseExclusiveMode(pid,false);
#endif // RS_USE_DHT_STUNNER
}
}
}
@ -2378,6 +2397,7 @@ void p3BitDht::ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd, bool addrCh
if (dpd->mExclusiveProxyLock)
{
#ifdef RS_USE_DHT_STUNNER
if (mProxyStunner->releaseExclusiveMode(pid, addrChgLikely))
{
dpd->mExclusiveProxyLock = false;
@ -2389,6 +2409,9 @@ void p3BitDht::ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd, bool addrCh
#endif
}
else
#else // RS_USE_DHT_STUNNER
(void)addrChgLikely;
#endif // RS_USE_DHT_STUNNER
{
dpd->mExclusiveProxyLock = false;

View File

@ -202,7 +202,7 @@ int p3BitDht::addBadPeer(const struct sockaddr_storage &addr, uint32_t /*reason*
addrv4.sin_addr = ap->sin_addr;
addrv4.sin_port = ap->sin_port;
#ifdef RS_USE_DHT_STUNNER
if (mDhtStunner)
{
mDhtStunner->dropStunPeer(addrv4);
@ -211,7 +211,7 @@ int p3BitDht::addBadPeer(const struct sockaddr_storage &addr, uint32_t /*reason*
{
mProxyStunner->dropStunPeer(addrv4);
}
#endif // RS_USE_DHT_STUNNER
return 1;
}

View File

@ -25,6 +25,7 @@
#include "ft/ftdbase.h"
#include "util/rsdir.h"
#include "retroshare/rspeers.h"
#include "serialiser/rsconfigitems.h"
@ -237,11 +238,13 @@ bool ftFiMonitor::saveList(bool &cleanup, std::list<RsItem *>& sList)
for(it = dirList.begin(); it != dirList.end(); ++it)
{
RsFileConfigItem *fi = new RsFileConfigItem();
RsFileConfigItem *fi = new RsFileConfigItem();
fi->file.path = (*it).filename ;
fi->file.name = (*it).virtualname ;
fi->flags = (*it).shareflags.toUInt32() ;
fi->parent_groups = (*it).parent_groups ;
for(std::list<RsNodeGroupId>::const_iterator it2( (*it).parent_groups.begin());it2!=(*it).parent_groups.end();++it2)
fi->parent_groups.ids.insert(*it2) ;
sList.push_back(fi);
}
@ -332,25 +335,53 @@ bool ftFiMonitor::loadList(std::list<RsItem *>& load)
continue ;
}
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it);
if (!fi)
{
delete (*it);
continue;
}
// 07/05/2016 - This ensures backward compatibility. Can be removed in a few weeks.
RsFileConfigItem_deprecated *fib = dynamic_cast<RsFileConfigItem_deprecated *>(*it);
if (fib)
{
/* ensure that it exists? */
/* ensure that it exists? */
SharedDirInfo info ;
info.filename = RsDirUtil::convertPathToUnix(fib->file.path);
info.virtualname = fib->file.name;
info.shareflags = FileStorageFlags(fib->flags) ;
info.shareflags &= PERMISSION_MASK ;
info.shareflags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // disabling this flag for know, for consistency reasons
SharedDirInfo info ;
info.filename = RsDirUtil::convertPathToUnix(fi->file.path);
info.virtualname = fi->file.name;
info.parent_groups = fi->parent_groups;
info.shareflags = FileStorageFlags(fi->flags) ;
info.shareflags &= PERMISSION_MASK ;
info.shareflags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // disabling this flag for know, for consistency reasons
for(std::list<std::string>::const_iterator itt(fib->parent_groups.begin());itt!=fib->parent_groups.end();++itt)
{
RsGroupInfo ginfo;
if(rsPeers->getGroupInfoByName(*itt,ginfo) )
{
info.parent_groups.push_back(ginfo.id) ;
std::cerr << "(II) converted old group ID \"" << *itt << "\" into corresponding new group id " << ginfo.id << std::endl;
}
else
std::cerr << "(EE) cannot convert old group ID \"" << *itt << "\" into corresponding new group id: no candidate found. " << std::endl;
}
dirList.push_back(info) ;
}
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it);
if (fi)
{
/* ensure that it exists? */
SharedDirInfo info ;
info.filename = RsDirUtil::convertPathToUnix(fi->file.path);
info.virtualname = fi->file.name;
info.shareflags = FileStorageFlags(fi->flags) ;
info.shareflags &= PERMISSION_MASK ;
info.shareflags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // disabling this flag for know, for consistency reasons
for(std::set<RsNodeGroupId>::const_iterator itt(fi->parent_groups.ids.begin());itt!=fi->parent_groups.ids.end();++itt)
info.parent_groups.push_back(*itt) ;
dirList.push_back(info) ;
}
dirList.push_back(info) ;
delete *it ;
}

View File

@ -395,7 +395,7 @@ bool ftExtraList::saveList(bool &cleanup, std::list<RsItem *>& sList)
std::map<RsFileHash, FileDetails>::const_iterator it;
for(it = mFiles.begin(); it != mFiles.end(); ++it)
{
RsFileConfigItem *fi = new RsFileConfigItem();
RsFileConfigItem_deprecated *fi = new RsFileConfigItem_deprecated();
fi->file.path = (it->second).info.path;
fi->file.name = (it->second).info.fname;
fi->file.hash = (it->second).info.hash;
@ -428,7 +428,7 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
for(it = load.begin(); it != load.end(); ++it)
{
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it);
RsFileConfigItem_deprecated *fi = dynamic_cast<RsFileConfigItem_deprecated *>(*it);
if (!fi)
{
delete (*it);

View File

@ -39,7 +39,7 @@ static const uint16_t GROUTER_CLIENT_ID_MESSAGES = 0x1001 ;
static const uint32_t RS_GROUTER_MATRIX_MAX_HIT_ENTRIES = 10 ; // max number of clues to store
static const uint32_t RS_GROUTER_MATRIX_MIN_TIME_BETWEEN_HITS = 60 ; // can be set to up to half the publish time interval. Prevents flooding routes.
static const uint32_t RS_GROUTER_MIN_CONFIG_SAVE_PERIOD = 10 ; // at most save config every 10 seconds
static const uint32_t RS_GROUTER_MIN_CONFIG_SAVE_PERIOD = 61 ; // at most save config every 10 seconds
static const uint32_t RS_GROUTER_MAX_KEEP_TRACKING_CLUES = 86400*10 ; // max time for which we keep record of tracking info: 10 days.
static const float RS_GROUTER_BASE_WEIGHT_ROUTED_MSG = 1.0f ; // base contribution of routed message clue to routing matrix

View File

@ -191,7 +191,6 @@
#include "turtle/p3turtle.h"
#include "gxs/rsgixs.h"
#include "retroshare/rspeers.h"
#include "retroshare/rsreputations.h"
#include "p3grouter.h"
#include "grouteritems.h"
@ -1863,15 +1862,6 @@ bool p3GRouter::locked_getLocallyRegisteredClientFromServiceId(const GRouterServ
return true ;
}
void p3GRouter::addTrackingInfo(const RsGxsMessageId& mid,const RsPeerId& peer_id)
{
RS_STACK_MUTEX(grMtx) ;
#ifdef GROUTER_DEBUG
grouter_debug() << "Received new routing clue for key " << mid << " from peer " << peer_id << std::endl;
#endif
_routing_matrix.addTrackingInfo(mid,peer_id) ;
_changed = true ;
}
void p3GRouter::addRoutingClue(const GRouterKeyId& id,const RsPeerId& peer_id)
{
RS_STACK_MUTEX(grMtx) ;
@ -1994,7 +1984,7 @@ bool p3GRouter::verifySignedDataItem(RsGRouterAbstractMsgItem *item,uint32_t& er
{
try
{
if(rsReputations->isIdentityBanned(item->signature.keyId))
if(rsIdentity->isBanned(item->signature.keyId))
{
std::cerr << "(WW) received global router message from banned identity " << item->signature.keyId << ". Rejecting the message." << std::endl;
return false ;
@ -2358,13 +2348,6 @@ bool p3GRouter::getRoutingCacheInfo(std::vector<GRouterRoutingCacheInfo>& infos)
return true ;
}
bool p3GRouter::getTrackingInfo(const RsGxsMessageId &mid, RsPeerId &provider_id)
{
RS_STACK_MUTEX(grMtx) ;
return _routing_matrix.getTrackingInfo(mid,provider_id) ;
}
// Dump everything
//
void p3GRouter::debugDump()

View File

@ -130,7 +130,6 @@ public:
//===================================================//
virtual void addRoutingClue(const GRouterKeyId& id,const RsPeerId& peer_id) ;
virtual void addTrackingInfo(const RsGxsMessageId& mid,const RsPeerId& peer_id) ;
//===================================================//
// Client/server request services //
@ -168,7 +167,6 @@ public:
// - Cache state (memory size, etc)
//
virtual bool getRoutingCacheInfo(std::vector<GRouterRoutingCacheInfo>& info) ;
virtual bool getTrackingInfo(const RsGxsMessageId& mid, RsPeerId& provider_id) ;
//===================================================//
// Derived from p3Service //

View File

@ -27,6 +27,7 @@
/*****
* #define RS_DATA_SERVICE_DEBUG 1
* #define RS_DATA_SERVICE_DEBUG_TIME 1
* #define RS_DATA_SERVICE_DEBUG_CACHE 1
****/
#include <fstream>
@ -123,6 +124,7 @@ RsDataService::RsDataService(const std::string &serviceDir, const std::string &d
: RsGeneralDataService(), mDbMutex("RsDataService"), mServiceDir(serviceDir), mDbName(dbName), mDbPath(mServiceDir + "/" + dbName), mServType(serviceType), mDb(NULL)
{
bool isNewDatabase = !RsDirUtil::fileExists(mDbPath);
mGrpMetaDataCache_ContainsAllDatabase = false ;
mDb = new RetroDb(mDbPath, RetroDb::OPEN_READWRITE_CREATE, key);
@ -710,25 +712,25 @@ int RsDataService::storeMessage(std::map<RsNxsMsg *, RsGxsMsgMetaData *> &msg)
// start a transaction
mDb->beginTransaction();
for(; mit != msg.end(); ++mit){
for(; mit != msg.end(); ++mit)
{
RsNxsMsg* msgPtr = mit->first;
RsGxsMsgMetaData* msgMetaPtr = mit->second;
#ifdef RS_DATA_SERVICE_DEBUG
std::cerr << "RsDataService::storeMessage() ";
std::cerr << " GroupId: " << msgMetaPtr->mGroupId.toStdString();
std::cerr << " MessageId: " << msgMetaPtr->mMsgId.toStdString();
std::cerr << std::endl;
std::cerr << "RsDataService::storeMessage() ";
std::cerr << " GroupId: " << msgMetaPtr->mGroupId.toStdString();
std::cerr << " MessageId: " << msgMetaPtr->mMsgId.toStdString();
std::cerr << std::endl;
#endif
// skip msg item if size if greater than
if(!validSize(msgPtr))
{
std::cerr << "RsDataService::storeMessage() ERROR invalid size";
std::cerr << std::endl;
continue;
}
{
std::cerr << "RsDataService::storeMessage() ERROR invalid size";
std::cerr << std::endl;
continue;
}
ContentValue cv;
@ -771,14 +773,18 @@ int RsDataService::storeMessage(std::map<RsNxsMsg *, RsGxsMsgMetaData *> &msg)
cv.put(KEY_CHILD_TS, (int32_t)msgMetaPtr->mChildTs);
if (!mDb->sqlInsert(MSG_TABLE_NAME, "", cv))
{
std::cerr << "RsDataService::storeMessage() sqlInsert Failed";
std::cerr << std::endl;
std::cerr << "\t For GroupId: " << msgMetaPtr->mGroupId.toStdString();
std::cerr << std::endl;
std::cerr << "\t & MessageId: " << msgMetaPtr->mMsgId.toStdString();
std::cerr << std::endl;
}
{
std::cerr << "RsDataService::storeMessage() sqlInsert Failed";
std::cerr << std::endl;
std::cerr << "\t For GroupId: " << msgMetaPtr->mGroupId.toStdString();
std::cerr << std::endl;
std::cerr << "\t & MessageId: " << msgMetaPtr->mMsgId.toStdString();
std::cerr << std::endl;
}
// This is needed so that mLastPost is correctly updated in the group meta when it is re-loaded.
locked_clearGrpMetaCache(msgMetaPtr->mGroupId);
}
// finish transaction
@ -881,6 +887,8 @@ int RsDataService::storeGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
cv.put(KEY_GRP_STATUS, (int32_t)grpMetaPtr->mGroupStatus);
cv.put(KEY_GRP_LAST_POST, (int32_t)grpMetaPtr->mLastPost);
locked_clearGrpMetaCache(grpMetaPtr->mGroupId);
if (!mDb->sqlInsert(GRP_TABLE_NAME, "", cv))
{
std::cerr << "RsDataService::storeGroup() sqlInsert Failed";
@ -904,6 +912,12 @@ int RsDataService::storeGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
return ret;
}
void RsDataService::locked_clearGrpMetaCache(const RsGxsGroupId& gid)
{
mGrpMetaDataCache.erase(gid) ; // cleans existing cache entry
mGrpMetaDataCache_ContainsAllDatabase = false;
}
int RsDataService::updateGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
{
@ -971,6 +985,8 @@ int RsDataService::updateGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
cv.put(KEY_GRP_LAST_POST, (int32_t)grpMetaPtr->mLastPost);
mDb->sqlUpdate(GRP_TABLE_NAME, "grpId='" + grpPtr->grpId.toStdString() + "'", cv);
locked_clearGrpMetaCache(grpMetaPtr->mGroupId);
}
// finish transaction
bool ret = mDb->commitTransaction();
@ -1231,6 +1247,9 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
if (c)
{
locked_retrieveMsgMeta(c, metaSet);
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << "Retrieving (all) Msg metadata grpId=" << grpId << ", " << std::dec << metaSet.size() << " messages" << std::endl;
#endif
}
}else{
@ -1245,6 +1264,9 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
if (c)
{
locked_retrieveMsgMeta(c, metaSet);
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << "Retrieving Msg metadata grpId=" << grpId << ", " << std::dec << metaSet.size() << " messages" << std::endl;
#endif
}
}
}
@ -1296,11 +1318,21 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaDat
int requestedGroups = grp.size();
#endif
if(grp.empty()){
if(grp.empty())
{
if(mGrpMetaDataCache_ContainsAllDatabase) // grab all the stash from the cache, so as to avoid decryption costs.
{
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << (void*)this << ": RsDataService::retrieveGxsGrpMetaData() retrieving all from cache!" << std::endl;
#endif
for(std::map<RsGxsGroupId,RsGxsGrpMetaData>::const_iterator it(mGrpMetaDataCache.begin());it!=mGrpMetaDataCache.end();++it)
grp[it->first] = new RsGxsGrpMetaData(it->second);
}
else
{
#ifdef RS_DATA_SERVICE_DEBUG
std::cerr << "RsDataService::retrieveGxsGrpMetaData() retrieving all";
std::cerr << std::endl;
std::cerr << "RsDataService::retrieveGxsGrpMetaData() retrieving all" << std::endl;
#endif
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpMetaColumns, "", "");
@ -1315,6 +1347,10 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaDat
if(g)
{
grp[g->mGroupId] = g;
mGrpMetaDataCache[g->mGroupId] = *g ;
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << (void *)this << ": Retrieving (all) Grp metadata grpId=" << g->mGroupId << std::endl;
#endif
}
valid = c->moveToNext();
@ -1325,12 +1361,29 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaDat
delete c;
}
mGrpMetaDataCache_ContainsAllDatabase = true ;
}
}else
{
std::map<RsGxsGroupId, RsGxsGrpMetaData *>::iterator mit = grp.begin();
for(; mit != grp.end(); ++mit)
{
std::map<RsGxsGroupId, RsGxsGrpMetaData>::const_iterator itt = mGrpMetaDataCache.find(mit->first) ;
if(itt != mGrpMetaDataCache.end())
{
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << "Retrieving Grp metadata grpId=" << mit->first << " from cache!" << std::endl;
#endif
grp[mit->first] = new RsGxsGrpMetaData(itt->second) ;
}
else
{
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << "Retrieving Grp metadata grpId=" << mit->first ;
#endif
const RsGxsGroupId& grpId = mit->first;
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpMetaColumns, "grpId='" + grpId.toStdString() + "'", "");
@ -1338,6 +1391,10 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaDat
{
bool valid = c->moveToFirst();
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
if(!valid)
std::cerr << " Empty query! GrpId " << grpId << " is not in database" << std::endl;
#endif
while(valid)
{
RsGxsGrpMetaData* g = locked_getGrpMeta(*c, 0);
@ -1345,6 +1402,10 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaDat
if(g)
{
grp[g->mGroupId] = g;
mGrpMetaDataCache[g->mGroupId] = *g ;
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << ". Got it. Updating cache." << std::endl;
#endif
}
valid = c->moveToNext();
@ -1354,7 +1415,11 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaDat
}
delete c;
}
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
else
std::cerr << ". not found!" << std::endl;
#endif
}
}
}
@ -1391,13 +1456,28 @@ int RsDataService::resetDataStore()
int RsDataService::updateGroupMetaData(GrpLocMetaData &meta)
{
RsStackMutex stack(mDbMutex);
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << (void*)this << ": Updating Grp Meta data: grpId = " << meta.grpId << std::endl;
#endif
RsStackMutex stack(mDbMutex);
RsGxsGroupId& grpId = meta.grpId;
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << (void*)this << ": erasing old entry from cache." << std::endl;
#endif
locked_clearGrpMetaCache(meta.grpId);
return mDb->sqlUpdate(GRP_TABLE_NAME, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", meta.val) ? 1 : 0;
}
int RsDataService::updateMessageMetaData(MsgLocMetaData &metaData)
{
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << (void*)this << ": Updating Msg Meta data: grpId = " << metaData.msgId.first << " msgId = " << metaData.msgId.second << std::endl;
#endif
RsStackMutex stack(mDbMutex);
RsGxsGroupId& grpId = metaData.msgId.first;
RsGxsMessageId& msgId = metaData.msgId.second;

View File

@ -340,6 +340,15 @@ private:
uint16_t mServType;
RetroDb* mDb;
// used to store metadata instead of reading it from the database.
// The boolean variable below is also used to force re-reading when
// the entre list of grp metadata is requested (which happens quite often)
void locked_clearGrpMetaCache(const RsGxsGroupId& gid);
std::map<RsGxsGroupId,RsGxsGrpMetaData> mGrpMetaDataCache ;
bool mGrpMetaDataCache_ContainsAllDatabase ;
};
#endif // RSDATASERVICE_H

View File

@ -881,8 +881,15 @@ int RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, const uin
{
// now check reputation of the message author
float reputation_threshold = ( (signFlag & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) && !(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)) ? (RsReputations::REPUTATION_THRESHOLD_ANTI_SPAM): (RsReputations::REPUTATION_THRESHOLD_DEFAULT) ;
float reputation_threshold = RsReputations::REPUTATION_THRESHOLD_DEFAULT;
if( (signFlag & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN) && !(details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN))
reputation_threshold = RsReputations::REPUTATION_THRESHOLD_ANTI_SPAM;
else if( (signFlag & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) && !(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
reputation_threshold = RsReputations::REPUTATION_THRESHOLD_ANTI_SPAM;
else
reputation_threshold = RsReputations::REPUTATION_THRESHOLD_DEFAULT;
if(details.mReputation.mOverallReputationScore < reputation_threshold)
{
#ifdef GEN_EXCH_DEBUG
@ -2004,10 +2011,7 @@ void RsGenExchange::publishMsgs()
// FIXTESTS global variable rsPeers not available in unittests!
if(rsPeers)
{
mRoutingClues[msg->metaData->mAuthorId].insert(rsPeers->getOwnId()) ;
mTrackingClues.push_back(std::make_pair(msg->msgId,rsPeers->getOwnId())) ;
}
computeHash(msg->msg, msg->metaData->mHash);
mDataAccess->addMsgData(msg);
@ -2015,6 +2019,9 @@ void RsGenExchange::publishMsgs()
delete[] metaDataBuff;
if(mNetService != NULL)
mNetService->stampMsgServerUpdateTS(grpId) ;
// add to published to allow acknowledgement
mMsgNotify.insert(std::make_pair(mit->first, std::make_pair(grpId, msgId)));
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE);
@ -2152,11 +2159,6 @@ void RsGenExchange::processRoutingClues()
rsGRouter->addRoutingClue(GRouterKeyId(it->first),(*it2) ) ;
mRoutingClues.clear() ;
for(std::list<std::pair<RsGxsMessageId,RsPeerId> >::const_iterator it = mTrackingClues.begin();it!=mTrackingClues.end();++it)
rsGRouter->addTrackingInfo((*it).first,(*it).second) ;
mTrackingClues.clear() ;
}
void RsGenExchange::processGroupDelete()
@ -2285,231 +2287,240 @@ bool RsGenExchange::checkKeys(const RsTlvSecurityKeySet& keySet)
void RsGenExchange::publishGrps()
{
RS_STACK_MUTEX(mGenMtx) ;
NxsGrpSignPendVect::iterator vit = mGrpsToPublish.begin();
typedef std::pair<bool, RsGxsGroupId> GrpNote;
std::map<uint32_t, GrpNote> toNotify;
while( vit != mGrpsToPublish.end() )
std::list<RsGxsGroupId> groups_to_subscribe ;
{
GxsGrpPendingSign& ggps = *vit;
RS_STACK_MUTEX(mGenMtx) ;
NxsGrpSignPendVect::iterator vit = mGrpsToPublish.begin();
/* do intial checks to see if this entry has expired */
time_t now = time(NULL) ;
uint32_t token = ggps.mToken;
typedef std::pair<bool, RsGxsGroupId> GrpNote;
std::map<uint32_t, GrpNote> toNotify;
while( vit != mGrpsToPublish.end() )
{
GxsGrpPendingSign& ggps = *vit;
/* do intial checks to see if this entry has expired */
time_t now = time(NULL) ;
uint32_t token = ggps.mToken;
if(now > (ggps.mStartTS + PENDING_SIGN_TIMEOUT) )
{
// timed out
toNotify.insert(std::make_pair(
token, GrpNote(false, RsGxsGroupId())));
delete ggps.mItem;
vit = mGrpsToPublish.erase(vit);
if(now > (ggps.mStartTS + PENDING_SIGN_TIMEOUT) )
{
// timed out
toNotify.insert(std::make_pair(
token, GrpNote(false, RsGxsGroupId())));
delete ggps.mItem;
vit = mGrpsToPublish.erase(vit);
continue;
}
continue;
}
RsGxsGroupId grpId;
RsNxsGrp* grp = new RsNxsGrp(mServType);
RsGxsGrpItem* grpItem = ggps.mItem;
RsGxsGroupId grpId;
RsNxsGrp* grp = new RsNxsGrp(mServType);
RsGxsGrpItem* grpItem = ggps.mItem;
RsTlvSecurityKeySet fullKeySet;
RsTlvSecurityKeySet fullKeySet;
if(!(ggps.mHaveKeys))
{
generateGroupKeys(fullKeySet, true);
ggps.mHaveKeys = true;
ggps.mKeys = fullKeySet;
}
else
fullKeySet = ggps.mKeys;
if(!(ggps.mHaveKeys))
{
generateGroupKeys(fullKeySet, true);
ggps.mHaveKeys = true;
ggps.mKeys = fullKeySet;
}
else
fullKeySet = ggps.mKeys;
// find private admin key
RsTlvPrivateRSAKey privAdminKey;
bool privKeyFound = false;
for(std::map<RsGxsId, RsTlvPrivateRSAKey>::iterator mit_keys = fullKeySet.private_keys.begin(); mit_keys != fullKeySet.private_keys.end(); ++mit_keys)
{
RsTlvPrivateRSAKey& key = mit_keys->second;
// find private admin key
RsTlvPrivateRSAKey privAdminKey;
bool privKeyFound = false;
for(std::map<RsGxsId, RsTlvPrivateRSAKey>::iterator mit_keys = fullKeySet.private_keys.begin(); mit_keys != fullKeySet.private_keys.end(); ++mit_keys)
{
RsTlvPrivateRSAKey& key = mit_keys->second;
if(key.keyFlags == (RSTLV_KEY_DISTRIB_ADMIN | RSTLV_KEY_TYPE_FULL))
{
privAdminKey = key;
privKeyFound = true;
}
}
if(key.keyFlags == (RSTLV_KEY_DISTRIB_ADMIN | RSTLV_KEY_TYPE_FULL))
{
privAdminKey = key;
privKeyFound = true;
}
}
uint8_t create = CREATE_FAIL;
uint8_t create = CREATE_FAIL;
if(privKeyFound)
{
// get group id from private admin key id
grpItem->meta.mGroupId = grp->grpId = RsGxsGroupId(privAdminKey.keyId);
if(privKeyFound)
{
// get group id from private admin key id
grpItem->meta.mGroupId = grp->grpId = RsGxsGroupId(privAdminKey.keyId);
ServiceCreate_Return ret = service_CreateGroup(grpItem, fullKeySet);
ServiceCreate_Return ret = service_CreateGroup(grpItem, fullKeySet);
bool serialOk = false, servCreateOk;
bool serialOk = false, servCreateOk;
if(ret == SERVICE_CREATE_SUCCESS)
{
uint32_t size = mSerialiser->size(grpItem);
char *gData = new char[size];
serialOk = mSerialiser->serialise(grpItem, gData, &size);
grp->grp.setBinData(gData, size);
delete[] gData;
servCreateOk = true;
if(ret == SERVICE_CREATE_SUCCESS)
{
uint32_t size = mSerialiser->size(grpItem);
char *gData = new char[size];
serialOk = mSerialiser->serialise(grpItem, gData, &size);
grp->grp.setBinData(gData, size);
delete[] gData;
servCreateOk = true;
}else
{
servCreateOk = false;
}
}else
{
servCreateOk = false;
}
if(serialOk && servCreateOk)
{
grp->metaData = new RsGxsGrpMetaData();
grpItem->meta.mPublishTs = time(NULL);
*(grp->metaData) = grpItem->meta;
if(serialOk && servCreateOk)
{
grp->metaData = new RsGxsGrpMetaData();
grpItem->meta.mPublishTs = time(NULL);
*(grp->metaData) = grpItem->meta;
// TODO: change when publish key optimisation added (public groups don't have publish key
grp->metaData->mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_ADMIN | GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED
| GXS_SERV::GROUP_SUBSCRIBE_PUBLISH;
// TODO: change when publish key optimisation added (public groups don't have publish key
grp->metaData->mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_ADMIN | GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED
| GXS_SERV::GROUP_SUBSCRIBE_PUBLISH;
create = createGroup(grp, fullKeySet);
create = createGroup(grp, fullKeySet);
#ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::publishGrps() ";
std::cerr << " GrpId: " << grp->grpId;
std::cerr << " CircleType: " << (uint32_t) grp->metaData->mCircleType;
std::cerr << " CircleId: " << grp->metaData->mCircleId.toStdString();
std::cerr << std::endl;
std::cerr << "RsGenExchange::publishGrps() ";
std::cerr << " GrpId: " << grp->grpId;
std::cerr << " CircleType: " << (uint32_t) grp->metaData->mCircleType;
std::cerr << " CircleId: " << grp->metaData->mCircleId.toStdString();
std::cerr << std::endl;
#endif
if(create == CREATE_SUCCESS)
{
// Here we need to make sure that no private keys are included. This is very important since private keys
// can be used to modify the group. Normally the private key set is whiped out by createGroup, but
if(create == CREATE_SUCCESS)
{
// Here we need to make sure that no private keys are included. This is very important since private keys
// can be used to modify the group. Normally the private key set is whiped out by createGroup, but
grp->metaData->keys.private_keys.clear() ;
uint32_t mdSize = grp->metaData->serial_size(RS_GXS_GRP_META_DATA_CURRENT_API_VERSION);
{
RsTemporaryMemory metaData(mdSize);
serialOk = grp->metaData->serialise(metaData, mdSize,RS_GXS_GRP_META_DATA_CURRENT_API_VERSION);
grp->metaData->keys.private_keys.clear() ;
uint32_t mdSize = grp->metaData->serial_size(RS_GXS_GRP_META_DATA_CURRENT_API_VERSION);
{
RsTemporaryMemory metaData(mdSize);
serialOk = grp->metaData->serialise(metaData, mdSize,RS_GXS_GRP_META_DATA_CURRENT_API_VERSION);
#warning TODO: grp->meta should be renamed grp->public_meta !
grp->meta.setBinData(metaData, mdSize);
}
grp->meta.setBinData(metaData, mdSize);
}
// Place back private keys for publisher and database storage
grp->metaData->keys.private_keys = fullKeySet.private_keys;
// Place back private keys for publisher and database storage
grp->metaData->keys.private_keys = fullKeySet.private_keys;
if(mDataStore->validSize(grp) && serialOk)
{
grpId = grp->grpId;
computeHash(grp->grp, grp->metaData->mHash);
grp->metaData->mRecvTS = time(NULL);
if(mDataStore->validSize(grp) && serialOk)
{
grpId = grp->grpId;
computeHash(grp->grp, grp->metaData->mHash);
grp->metaData->mRecvTS = time(NULL);
if(ggps.mIsUpdate)
mDataAccess->updateGroupData(grp);
else
mDataAccess->addGroupData(grp);
if(ggps.mIsUpdate)
mDataAccess->updateGroupData(grp);
else
mDataAccess->addGroupData(grp);
#warning this is bad: addGroupData/updateGroupData actially deletes grp. But it may be used below? grp should be a class object and not deleted manually!
if(mNetService!=NULL)
mNetService->subscribeStatusChanged(grpId,true) ;
}
else
{
create = CREATE_FAIL;
}
}
}
else if(ret == SERVICE_CREATE_FAIL_TRY_LATER)
{
// if the service is not ready yet, reset the start timestamp to give the service more time
// the service should have it's own timeout mechanism
// services should return SERVICE_CREATE_FAIL if the action timed out
// at the moment this is only important for the idservice:
// the idservice may ask the user for a password, and the user needs time
ggps.mStartTS = now;
create = CREATE_FAIL_TRY_LATER;
}
else if(ret == SERVICE_CREATE_FAIL)
create = CREATE_FAIL;
}
else
{
#ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::publishGrps() Could not find private publish keys " << std::endl;
#endif
create = CREATE_FAIL;
}
if(create == CREATE_FAIL)
{
groups_to_subscribe.push_back(grpId) ;
}
else
{
create = CREATE_FAIL;
}
}
}
else if(ret == SERVICE_CREATE_FAIL_TRY_LATER)
{
// if the service is not ready yet, reset the start timestamp to give the service more time
// the service should have it's own timeout mechanism
// services should return SERVICE_CREATE_FAIL if the action timed out
// at the moment this is only important for the idservice:
// the idservice may ask the user for a password, and the user needs time
ggps.mStartTS = now;
create = CREATE_FAIL_TRY_LATER;
}
else if(ret == SERVICE_CREATE_FAIL)
create = CREATE_FAIL;
}
else
{
#ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::publishGrps() failed to publish grp " << std::endl;
std::cerr << "RsGenExchange::publishGrps() Could not find private publish keys " << std::endl;
#endif
delete grp;
delete grpItem;
vit = mGrpsToPublish.erase(vit);
toNotify.insert(std::make_pair(
token, GrpNote(false, grpId)));
create = CREATE_FAIL;
}
}
else if(create == CREATE_FAIL_TRY_LATER)
{
if(create == CREATE_FAIL)
{
#ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::publishGrps() failed grp, trying again " << std::endl;
std::cerr << "RsGenExchange::publishGrps() failed to publish grp " << std::endl;
#endif
delete grp;
ggps.mLastAttemptTS = time(NULL);
++vit;
}
else if(create == CREATE_SUCCESS)
{
delete grpItem;
vit = mGrpsToPublish.erase(vit);
delete grp;
delete grpItem;
vit = mGrpsToPublish.erase(vit);
toNotify.insert(std::make_pair(
token, GrpNote(false, grpId)));
}
else if(create == CREATE_FAIL_TRY_LATER)
{
#ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::publishGrps() failed grp, trying again " << std::endl;
#endif
delete grp;
ggps.mLastAttemptTS = time(NULL);
++vit;
}
else if(create == CREATE_SUCCESS)
{
delete grpItem;
vit = mGrpsToPublish.erase(vit);
#ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::publishGrps() ok -> pushing to notifies"
<< std::endl;
std::cerr << "RsGenExchange::publishGrps() ok -> pushing to notifies"
<< std::endl;
#endif
// add to published to allow acknowledgement
toNotify.insert(std::make_pair(token,
GrpNote(true,grpId)));
}
}
std::map<uint32_t, GrpNote>::iterator mit = toNotify.begin();
std::list<RsGxsGroupId> grpChanged;
for(; mit != toNotify.end(); ++mit)
{
GrpNote& note = mit->second;
uint8_t status = note.first ? RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE
: RsTokenService::GXS_REQUEST_V2_STATUS_FAILED;
mGrpNotify.insert(std::make_pair(mit->first, note.second));
mDataAccess->updatePublicRequestStatus(mit->first, status);
if(note.first)
grpChanged.push_back(note.second);
}
if(!grpChanged.empty())
{
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PUBLISH, false);
gc->mGrpIdList = grpChanged;
mNotifications.push_back(gc);
#ifdef GEN_EXCH_DEBUG
std::cerr << " adding the following grp ids to notification: " << std::endl;
for(std::list<RsGxsGroupId>::const_iterator it(grpChanged.begin());it!=grpChanged.end();++it)
std::cerr << " " << *it << std::endl;
#endif
// add to published to allow acknowledgement
toNotify.insert(std::make_pair(token,
GrpNote(true,grpId)));
}
}
std::map<uint32_t, GrpNote>::iterator mit = toNotify.begin();
std::list<RsGxsGroupId> grpChanged;
for(; mit != toNotify.end(); ++mit)
{
GrpNote& note = mit->second;
uint8_t status = note.first ? RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE
: RsTokenService::GXS_REQUEST_V2_STATUS_FAILED;
mGrpNotify.insert(std::make_pair(mit->first, note.second));
mDataAccess->updatePublicRequestStatus(mit->first, status);
if(note.first)
grpChanged.push_back(note.second);
}
if(!grpChanged.empty())
{
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PUBLISH, false);
gc->mGrpIdList = grpChanged;
mNotifications.push_back(gc);
#ifdef GEN_EXCH_DEBUG
std::cerr << " adding the following grp ids to notification: " << std::endl;
for(std::list<RsGxsGroupId>::const_iterator it(grpChanged.begin());it!=grpChanged.end();++it)
std::cerr << " " << *it << std::endl;
#endif
}
}
// This is done off-mutex to avoid possible cross deadlocks with the net service.
if(mNetService!=NULL)
for(std::list<RsGxsGroupId>::const_iterator it(groups_to_subscribe.begin());it!=groups_to_subscribe.end();++it)
mNetService->subscribeStatusChanged((*it),true) ;
}
@ -2590,228 +2601,243 @@ void RsGenExchange::computeHash(const RsTlvBinaryData& data, RsFileHash& hash)
void RsGenExchange::processRecvdMessages()
{
RS_STACK_MUTEX(mGenMtx) ;
std::list<RsGxsMessageId> messages_to_reject ;
{
RS_STACK_MUTEX(mGenMtx) ;
#ifdef GEN_EXCH_DEBUG
if(!mMsgPendingValidate.empty())
std::cerr << "processing received messages" << std::endl;
if(!mMsgPendingValidate.empty())
std::cerr << "processing received messages" << std::endl;
#endif
NxsMsgPendingVect::iterator pend_it = mMsgPendingValidate.begin();
NxsMsgPendingVect::iterator pend_it = mMsgPendingValidate.begin();
#ifdef GEN_EXCH_DEBUG
if(!mMsgPendingValidate.empty())
std::cerr << " pending validation" << std::endl;
if(!mMsgPendingValidate.empty())
std::cerr << " pending validation" << std::endl;
#endif
for(; pend_it != mMsgPendingValidate.end();)
{
GxsPendingItem<RsNxsMsg*, RsGxsGrpMsgIdPair>& gpsi = *pend_it;
for(; pend_it != mMsgPendingValidate.end();)
{
GxsPendingItem<RsNxsMsg*, RsGxsGrpMsgIdPair>& gpsi = *pend_it;
#ifdef GEN_EXCH_DEBUG
std::cerr << " grp=" << gpsi.mId.first << ", msg=" << gpsi.mId.second << ", attempts=" << gpsi.mAttempts ;
std::cerr << " grp=" << gpsi.mId.first << ", msg=" << gpsi.mId.second << ", attempts=" << gpsi.mAttempts ;
#endif
if(gpsi.mAttempts == VALIDATE_MAX_ATTEMPTS)
{
if(gpsi.mAttempts == VALIDATE_MAX_ATTEMPTS)
{
#ifdef GEN_EXCH_DEBUG
std::cerr << " = max! deleting." << std::endl;
std::cerr << " = max! deleting." << std::endl;
#endif
delete gpsi.mItem;
pend_it = mMsgPendingValidate.erase(pend_it);
}
else
{
delete gpsi.mItem;
pend_it = mMsgPendingValidate.erase(pend_it);
}
else
{
#ifdef GEN_EXCH_DEBUG
std::cerr << " movign to recvd." << std::endl;
std::cerr << " movign to recvd." << std::endl;
#endif
mReceivedMsgs.push_back(gpsi.mItem);
++pend_it;
}
}
mReceivedMsgs.push_back(gpsi.mItem);
++pend_it;
}
}
if(mReceivedMsgs.empty())
return;
if(mReceivedMsgs.empty())
return;
std::vector<RsNxsMsg*>::iterator vit = mReceivedMsgs.begin();
GxsMsgReq msgIds;
std::map<RsNxsMsg*, RsGxsMsgMetaData*> msgs;
std::vector<RsNxsMsg*>::iterator vit = mReceivedMsgs.begin();
GxsMsgReq msgIds;
std::map<RsNxsMsg*, RsGxsMsgMetaData*> msgs;
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMetas;
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMetas;
// coalesce group meta retrieval for performance
for(; vit != mReceivedMsgs.end(); ++vit)
{
RsNxsMsg* msg = *vit;
grpMetas.insert(std::make_pair(msg->grpId, (RsGxsGrpMetaData*)NULL));
}
// coalesce group meta retrieval for performance
for(; vit != mReceivedMsgs.end(); ++vit)
{
RsNxsMsg* msg = *vit;
grpMetas.insert(std::make_pair(msg->grpId, (RsGxsGrpMetaData*)NULL));
}
mDataStore->retrieveGxsGrpMetaData(grpMetas);
mDataStore->retrieveGxsGrpMetaData(grpMetas);
#ifdef GEN_EXCH_DEBUG
std::cerr << " updating received messages:" << std::endl;
std::cerr << " updating received messages:" << std::endl;
#endif
for(vit = mReceivedMsgs.begin(); vit != mReceivedMsgs.end(); ++vit)
{
RsNxsMsg* msg = *vit;
RsGxsMsgMetaData* meta = new RsGxsMsgMetaData();
for(vit = mReceivedMsgs.begin(); vit != mReceivedMsgs.end(); ++vit)
{
RsNxsMsg* msg = *vit;
RsGxsMsgMetaData* meta = new RsGxsMsgMetaData();
bool ok = false;
bool ok = false;
if(msg->meta.bin_len != 0)
ok = meta->deserialise(msg->meta.bin_data, &(msg->meta.bin_len));
if(msg->meta.bin_len != 0)
ok = meta->deserialise(msg->meta.bin_data, &(msg->meta.bin_len));
msg->metaData = meta;
msg->metaData = meta;
#ifdef GEN_EXCH_DEBUG
std::cerr << " deserialised info: grp id=" << meta->mGroupId << ", msg id=" << meta->mMsgId ;
std::cerr << " deserialised info: grp id=" << meta->mGroupId << ", msg id=" << meta->mMsgId ;
#endif
uint8_t validateReturn = VALIDATE_FAIL;
uint8_t validateReturn = VALIDATE_FAIL;
if(ok)
{
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMetas.find(msg->grpId);
if(ok)
{
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMetas.find(msg->grpId);
#ifdef GEN_EXCH_DEBUG
std::cerr << " msg info : grp id=" << msg->grpId << ", msg id=" << msg->msgId << std::endl;
std::cerr << " msg info : grp id=" << msg->grpId << ", msg id=" << msg->msgId << std::endl;
#endif
RsGxsGrpMetaData* grpMeta = NULL ;
RsGxsGrpMetaData* grpMeta = NULL ;
// validate msg
if(mit != grpMetas.end())
{
grpMeta = mit->second;
validateReturn = validateMsg(msg, grpMeta->mGroupFlags, grpMeta->mSignFlags, grpMeta->keys);
// validate msg
if(mit != grpMetas.end())
{
grpMeta = mit->second;
validateReturn = validateMsg(msg, grpMeta->mGroupFlags, grpMeta->mSignFlags, grpMeta->keys);
#ifdef GEN_EXCH_DEBUG
std::cerr << " grpMeta.mSignFlags: " << std::hex << grpMeta->mSignFlags << std::dec << std::endl;
std::cerr << " grpMeta.mAuthFlags: " << std::hex << grpMeta->mAuthenFlags << std::dec << std::endl;
std::cerr << " message validation result: " << (int)validateReturn << std::endl;
std::cerr << " grpMeta.mSignFlags: " << std::hex << grpMeta->mSignFlags << std::dec << std::endl;
std::cerr << " grpMeta.mAuthFlags: " << std::hex << grpMeta->mAuthenFlags << std::dec << std::endl;
std::cerr << " message validation result: " << (int)validateReturn << std::endl;
#endif
}
}
if(validateReturn == VALIDATE_SUCCESS)
{
meta->mMsgStatus = GXS_SERV::GXS_MSG_STATUS_UNPROCESSED | GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD;
msgs.insert(std::make_pair(msg, meta));
if(validateReturn == VALIDATE_SUCCESS)
{
meta->mMsgStatus = GXS_SERV::GXS_MSG_STATUS_UNPROCESSED | GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD;
msgs.insert(std::make_pair(msg, meta));
std::vector<RsGxsMessageId> &msgv = msgIds[msg->grpId];
if (std::find(msgv.begin(), msgv.end(), msg->msgId) == msgv.end())
{
msgv.push_back(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);
}
NxsMsgPendingVect::iterator validated_entry = std::find(mMsgPendingValidate.begin(), mMsgPendingValidate.end(),
getMsgIdPair(*msg));
NxsMsgPendingVect::iterator validated_entry = std::find(mMsgPendingValidate.begin(), mMsgPendingValidate.end(),
getMsgIdPair(*msg));
if(validated_entry != mMsgPendingValidate.end()) mMsgPendingValidate.erase(validated_entry);
if(validated_entry != mMsgPendingValidate.end()) mMsgPendingValidate.erase(validated_entry);
computeHash(msg->msg, meta->mHash);
meta->recvTS = time(NULL);
computeHash(msg->msg, meta->mHash);
meta->recvTS = time(NULL);
#ifdef GEN_EXCH_DEBUG
std::cerr << " new status flags: " << meta->mMsgStatus << std::endl;
std::cerr << " computed hash: " << meta->mHash << std::endl;
std::cerr << "Message received. Identity=" << msg->metaData->mAuthorId << ", from peer " << msg->PeerId() << std::endl;
std::cerr << " new status flags: " << meta->mMsgStatus << std::endl;
std::cerr << " computed hash: " << meta->mHash << std::endl;
std::cerr << "Message received. Identity=" << msg->metaData->mAuthorId << ", from peer " << msg->PeerId() << std::endl;
#endif
if(!msg->metaData->mAuthorId.isNull())
mRoutingClues[msg->metaData->mAuthorId].insert(msg->PeerId()) ;
if(!msg->metaData->mAuthorId.isNull())
mRoutingClues[msg->metaData->mAuthorId].insert(msg->PeerId()) ;
}
if(grpMeta->mSignFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES)
mTrackingClues.push_back(std::make_pair(msg->msgId,msg->PeerId())) ;
}
if(validateReturn == VALIDATE_FAIL)
{
// In this case, we notify the network exchange service not to DL the message again, at least not yet.
#ifdef GEN_EXCH_DEBUG
std::cerr << "Notifying the network service to not download this message again." << std::endl;
#endif
mNetService->rejectMessage(msg->msgId) ;
}
}
else
{
#ifdef GEN_EXCH_DEBUG
std::cerr << " deserialisation failed!" <<std::endl;
#endif
validateReturn = VALIDATE_FAIL;
}
if(validateReturn == VALIDATE_FAIL)
{
if(validateReturn == VALIDATE_FAIL)
{
// In this case, we notify the network exchange service not to DL the message again, at least not yet.
#ifdef GEN_EXCH_DEBUG
std::cerr << "Validation failed for message id "
<< "msg->grpId: " << msg->grpId << ", msgId: " << msg->msgId << std::endl;
std::cerr << "Notifying the network service to not download this message again." << std::endl;
#endif
messages_to_reject.push_back(msg->msgId) ;
}
}
else
{
#ifdef GEN_EXCH_DEBUG
std::cerr << " deserialisation failed!" <<std::endl;
#endif
validateReturn = VALIDATE_FAIL;
}
NxsMsgPendingVect::iterator failed_entry = std::find(mMsgPendingValidate.begin(), mMsgPendingValidate.end(),
getMsgIdPair(*msg));
if(failed_entry != mMsgPendingValidate.end()) mMsgPendingValidate.erase(failed_entry);
delete msg;
}
else if(validateReturn == VALIDATE_FAIL_TRY_LATER)
{
if(validateReturn == VALIDATE_FAIL)
{
#ifdef GEN_EXCH_DEBUG
std::cerr << "failed to validate msg, trying again: "
<< "msg->grpId: " << msg->grpId << ", msgId: " << msg->msgId << std::endl;
std::cerr << "Validation failed for message id "
<< "msg->grpId: " << msg->grpId << ", msgId: " << msg->msgId << std::endl;
#endif
RsGxsGrpMsgIdPair id;
id.first = msg->grpId;
id.second = msg->msgId;
NxsMsgPendingVect::iterator failed_entry = std::find(mMsgPendingValidate.begin(), mMsgPendingValidate.end(),
getMsgIdPair(*msg));
// first check you haven't made too many attempts
if(failed_entry != mMsgPendingValidate.end()) mMsgPendingValidate.erase(failed_entry);
delete msg;
NxsMsgPendingVect::iterator vit = std::find(
mMsgPendingValidate.begin(), mMsgPendingValidate.end(), id);
if(vit == mMsgPendingValidate.end())
{
GxsPendingItem<RsNxsMsg*, RsGxsGrpMsgIdPair> item(msg, id);
mMsgPendingValidate.push_back(item);
}else
{
vit->mAttempts++;
}
}
}
// clean up resources from group meta retrieval
freeAndClearContainerResource<std::map<RsGxsGroupId, RsGxsGrpMetaData*>,
RsGxsGrpMetaData*>(grpMetas);
if(!msgIds.empty())
{
#ifdef GEN_EXCH_DEBUG
std::cerr << " removing existing and old messages from incoming list." << std::endl;
#endif
removeDeleteExistingMessages(msgs, msgIds);
}
else if(validateReturn == VALIDATE_FAIL_TRY_LATER)
{
#ifdef GEN_EXCH_DEBUG
std::cerr << " storing remaining messages" << std::endl;
std::cerr << "failed to validate msg, trying again: "
<< "msg->grpId: " << msg->grpId << ", msgId: " << msg->msgId << std::endl;
#endif
mDataStore->storeMessage(msgs);
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_RECEIVE, false);
c->msgChangeMap = msgIds;
mNotifications.push_back(c);
}
RsGxsGrpMsgIdPair id;
id.first = msg->grpId;
id.second = msg->msgId;
mReceivedMsgs.clear();
// first check you haven't made too many attempts
NxsMsgPendingVect::iterator vit = std::find(
mMsgPendingValidate.begin(), mMsgPendingValidate.end(), id);
if(vit == mMsgPendingValidate.end())
{
GxsPendingItem<RsNxsMsg*, RsGxsGrpMsgIdPair> item(msg, id);
mMsgPendingValidate.push_back(item);
}else
{
vit->mAttempts++;
}
}
}
// clean up resources from group meta retrieval
freeAndClearContainerResource<std::map<RsGxsGroupId, RsGxsGrpMetaData*>,
RsGxsGrpMetaData*>(grpMetas);
if(!msgIds.empty())
{
#ifdef GEN_EXCH_DEBUG
std::cerr << " removing existing and old messages from incoming list." << std::endl;
#endif
removeDeleteExistingMessages(msgs, msgIds);
#ifdef GEN_EXCH_DEBUG
std::cerr << " storing remaining messages" << std::endl;
#endif
mDataStore->storeMessage(msgs);
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_RECEIVE, false);
c->msgChangeMap = msgIds;
mNotifications.push_back(c);
}
mReceivedMsgs.clear();
}
// Done off-mutex to avoid cross deadlocks in the netservice that might call the RsGenExchange as an observer..
if(mNetService != NULL)
for(std::list<RsGxsMessageId>::const_iterator it(messages_to_reject.begin());it!=messages_to_reject.end();++it)
mNetService->rejectMessage(*it) ;
}
bool RsGenExchange::acceptNewGroup(const RsGxsGrpMetaData *grpMeta)
{
return true;
}
void RsGenExchange::processRecvdGroups()
{
RS_STACK_MUTEX(mGenMtx) ;
RS_STACK_MUTEX(mGenMtx) ;
if(mReceivedGrps.empty())
return;
NxsGrpPendValidVect::iterator vit = mReceivedGrps.begin();
#ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::Processing received groups" << std::endl;
#endif
NxsGrpPendValidVect::iterator vit = mReceivedGrps.begin();
std::vector<RsGxsGroupId> existingGrpIds;
std::list<RsGxsGroupId> grpIds;
@ -2826,12 +2852,12 @@ void RsGenExchange::processRecvdGroups()
RsGxsGrpMetaData* meta = new RsGxsGrpMetaData();
bool deserialOk = false;
if(grp->meta.bin_len != 0)
if(grp->meta.bin_len != 0)
deserialOk = meta->deserialise(grp->meta.bin_data, grp->meta.bin_len);
bool erase = true;
if(deserialOk)
if(deserialOk && acceptNewGroup(meta))
{
#ifdef GEN_EXCH_DEBUG
std::cerr << " processing validation for group " << meta->mGroupId << ", attempts number " << gpsi.mAttempts << std::endl;
@ -2911,8 +2937,10 @@ void RsGenExchange::processRecvdGroups()
}
else
{
std::cerr << "(EE) deserialise error in group meta data" << std::endl;
delete grp;
if(!deserialOk)
std::cerr << "(EE) deserialise error in group meta data" << std::endl;
delete grp;
delete meta;
erase = true;
}

View File

@ -259,6 +259,16 @@ public:
*/
virtual void receiveChanges(std::vector<RsGxsNotify*>& changes);
/*!
* \brief acceptNewGroup
* Early checks if the group can be accepted. This is mainly used to check wether the group is banned for some reasons.
* Returns true unless derived in GXS services.
*
* \param grpMeta Group metadata to check
* \return
*/
virtual bool acceptNewGroup(const RsGxsGrpMetaData *grpMeta) ;
bool subscribeToGroup(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe);
/*!
@ -595,6 +605,14 @@ public:
*/
void setGroupReputationCutOff(uint32_t& token, const RsGxsGroupId& grpId, int CutOff);
/*!
*
* @param token value set to be redeemed with acknowledgement
* @param grpId group id of the group to update
* @param CutOff The cut off value to set
*/
void updateGroupLastMsgTimeStamp(uint32_t& token, const RsGxsGroupId& grpId);
/*!
* @return storage time of messages in months
*/

View File

@ -96,7 +96,6 @@
* as these will be used very frequently.
*****/
typedef RsPeerId PeerId; // SHOULD BE REMOVED => RsPeerId (SSLID)
typedef PGPIdType RsPgpId;
/* Identity Interface for GXS Message Verification.
@ -150,7 +149,7 @@ public:
* @param keyref the KeyRef of the key being requested
* @return will
*/
virtual bool requestKey(const RsGxsId &id, const std::list<PeerId> &peers) = 0;
virtual bool requestKey(const RsGxsId &id, const std::list<RsPeerId> &peers) = 0;
virtual bool requestPrivateKey(const RsGxsId &id) = 0;

View File

@ -39,20 +39,20 @@ uint32_t RsGxsGrpMetaData::serial_size(uint32_t api_version)
s += mGroupId.serial_size();
s += mOrigGrpId.serial_size();
s += mParentGrpId.serial_size();
s += GetTlvStringSize(mGroupName);
s += 4;
s += 4;
s += 4; // mGroupFlags
s += 4; // mPublishTs
s += 4; // mCircleType
s += 4; // mAuthenFlag
s += mAuthorId.serial_size();
s += GetTlvStringSize(mServiceString);
s += mCircleId.serial_size();
s += signSet.TlvSize();
s += keys.TlvSize();
s += 4; // for mCircleType
s += mCircleId.serial_size();
s += 4; // mAuthenFlag
s += mParentGrpId.serial_size(); // mParentGroupId
if(api_version == RS_GXS_GRP_META_DATA_VERSION_ID_0002)
s += 4; // mSignFlag
s += 4; // mSignFlag
else if(api_version != RS_GXS_GRP_META_DATA_VERSION_ID_0001)
std::cerr << "(EE) wrong/unknown API version " << api_version << " requested in RsGxsGrpMetaData::serial_size()" << std::endl;
@ -203,7 +203,7 @@ bool RsGxsGrpMetaData::deserialise(void *data, uint32_t &pktsize)
int RsGxsMsgMetaData::refcount = 0;
RsGxsMsgMetaData::RsGxsMsgMetaData(){
clear();
//std::cout << "\nrefcount++ : " << ++refcount << std::endl;
return;
}
@ -227,8 +227,8 @@ uint32_t RsGxsMsgMetaData::serial_size()
s += signSet.TlvSize();
s += GetTlvStringSize(mMsgName);
s += 4; // mPublishTS
s += 4; // mMsgFlags
s += 4; // mPublishTS
s += 4; // mMsgFlags
return s;
}
@ -311,7 +311,7 @@ bool RsGxsMsgMetaData::deserialise(void *data, uint32_t *size)
ok &= signSet.GetTlv(data, *size, &offset);
ok &= GetTlvString(data, *size, &offset, 0, mMsgName);
uint32_t t;
uint32_t t=0;
ok &= getRawUInt32(data, *size, &offset, &t);
mPublishTs = t;
ok &= getRawUInt32(data, *size, &offset, &mMsgFlags);

View File

@ -56,24 +56,22 @@ public:
void clear();
void operator =(const RsGroupMetaData& rMeta);
//Sort data in same order than serialiser and deserializer
RsGxsGroupId mGroupId;
RsGxsGroupId mOrigGrpId;
RsGxsGroupId mParentGrpId;
std::string mGroupName;
uint32_t mGroupFlags; // GXS_SERV::FLAG_PRIVACY_RESTRICTED | GXS_SERV::FLAG_PRIVACY_PRIVATE | GXS_SERV::FLAG_PRIVACY_PUBLIC
uint32_t mPublishTs;
uint32_t mSignFlags;
uint32_t mCircleType;
uint32_t mAuthenFlags;
RsGxsId mAuthorId;
std::string mServiceString;
RsGxsCircleId mCircleId;
uint32_t mCircleType;
RsTlvKeySignatureSet signSet;
RsTlvSecurityKeySet keys;
std::string mServiceString;
uint32_t mAuthenFlags;
RsGxsGroupId mParentGrpId;
uint32_t mSignFlags;
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
@ -105,18 +103,17 @@ public:
void clear();
void operator =(const RsMsgMetaData& rMeta);
static int refcount;
//Sort data in same order than serialiser and deserializer
RsGxsGroupId mGroupId;
RsGxsMessageId mMsgId;
static int refcount;
RsGxsMessageId mThreadId;
RsGxsMessageId mParentId;
RsGxsMessageId mOrigMsgId;
RsGxsId mAuthorId;
RsTlvKeySignatureSet signSet;
std::string mServiceString;
std::string mMsgName;
time_t mPublishTs;
uint32_t mMsgFlags; // Whats this for?
@ -124,6 +121,7 @@ public:
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
// normally READ / UNREAD flags. LOCAL Data.
std::string mServiceString;
uint32_t mMsgStatus;
uint32_t mMsgSize;
time_t mChildTs;

View File

@ -204,9 +204,9 @@
#include "rsgxsnetservice.h"
#include "gxssecurity.h"
#include "retroshare/rsconfig.h"
#include "retroshare/rsreputations.h"
#include "retroshare/rsgxsflags.h"
#include "retroshare/rsgxscircles.h"
#include "retroshare/rspeers.h"
#include "pgp/pgpauxutils.h"
#include "util/rsdir.h"
#include "util/rsmemory.h"
@ -220,7 +220,7 @@
NXS_NET_DEBUG_3 publish key exchange
NXS_NET_DEBUG_4 vetting
NXS_NET_DEBUG_5 summary of transactions (useful to just know what comes in/out)
NXS_NET_DEBUG_6
NXS_NET_DEBUG_6 group sync statistics (e.g. number of posts at nighbour nodes, etc)
NXS_NET_DEBUG_7 encryption/decryption of transactions
***/
@ -233,7 +233,6 @@
//#define NXS_NET_DEBUG_6 1
//#define NXS_NET_DEBUG_7 1
#define GIXS_CUT_OFF 0
//#define NXS_FRAG
// The constant below have a direct influence on how fast forums/channels/posted/identity groups propagate and on the overloading of queues:
@ -244,6 +243,7 @@
// A small value for MAX_REQLIST_SIZE is likely to help messages to propagate in a chaotic network, but will also slow them down.
// A small SYNC_PERIOD fasten message propagation, but is likely to overload the server side of transactions (e.g. overload outqueues).
//
#define GIXS_CUT_OFF 0
#define SYNC_PERIOD 60
#define MAX_REQLIST_SIZE 20 // No more than 20 items per msg request list => creates smaller transactions that are less likely to be cancelled.
#define TRANSAC_TIMEOUT 2000 // In seconds. Has been increased to avoid epidemic transaction cancelling due to overloaded outqueues.
@ -266,8 +266,8 @@ static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_GXS_KEY_MISSING = 0x05 ;
|| defined(NXS_NET_DEBUG_4) || defined(NXS_NET_DEBUG_5) || defined(NXS_NET_DEBUG_6) || defined(NXS_NET_DEBUG_7)
static const RsPeerId peer_to_print = RsPeerId(std::string("")) ;
static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("" )) ; // use this to allow to this group id only, or "" for all IDs
static const uint32_t service_to_print = 0x215 ; // use this to allow to this service id only, or 0 for all services
static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("")) ; // use this to allow to this group id only, or "" for all IDs
static const uint32_t service_to_print = 0x211 ; // use this to allow to this service id only, or 0 for all services
// warning. Numbers should be SERVICE IDS (see serialiser/rsserviceids.h. E.g. 0x0215 for forums)
class nullstream: public std::ostream {};
@ -761,11 +761,11 @@ void RsGxsNetService::syncWithPeers()
msg->updateTS = updateTS;
if(encrypt_to_this_circle_id.isNull())
msg->grpId = grpId;
msg->grpId = grpId;
else
{
msg->grpId = hashGrpId(grpId,mNetMgr->getOwnId()) ;
msg->flag |= RsNxsSyncMsgReqItem::FLAG_USE_HASHED_GROUP_ID ;
msg->grpId = hashGrpId(grpId,mNetMgr->getOwnId()) ;
msg->flag |= RsNxsSyncMsgReqItem::FLAG_USE_HASHED_GROUP_ID ;
}
#ifdef NXS_NET_DEBUG_7
@ -928,17 +928,22 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs)
#ifdef NXS_NET_DEBUG_6
GXSNETDEBUG_PG(grs->PeerId(),grs->grpId) << "Received Grp update stats item from peer " << grs->PeerId() << " for group " << grs->grpId << ", reporting " << grs->number_of_posts << " posts." << std::endl;
#endif
RS_STACK_MUTEX(mNxsMutex) ;
RsGroupNetworkStatsRecord& rec(mGroupNetworkStats[grs->grpId]) ;
bool should_notify = false ;
{
RS_STACK_MUTEX(mNxsMutex) ;
RsGroupNetworkStatsRecord& rec(mGroupNetworkStats[grs->grpId]) ;
uint32_t old_count = rec.max_visible_count ;
uint32_t old_suppliers_count = rec.suppliers.size() ;
rec.suppliers.insert(grs->PeerId()) ;
rec.max_visible_count = std::max(rec.max_visible_count,grs->number_of_posts) ;
rec.update_TS = time(NULL) ;
if (old_count != rec.max_visible_count || old_suppliers_count != rec.suppliers.size())
uint32_t old_count = rec.max_visible_count ;
uint32_t old_suppliers_count = rec.suppliers.size() ;
rec.suppliers.insert(grs->PeerId()) ;
rec.max_visible_count = std::max(rec.max_visible_count,grs->number_of_posts) ;
rec.update_TS = time(NULL) ;
if (old_count != rec.max_visible_count || old_suppliers_count != rec.suppliers.size())
should_notify = true ;
}
if(should_notify)
mObserver->notifyChangedGroupStats(grs->grpId);
}
else
@ -2091,14 +2096,19 @@ void RsGxsNetService::updateServerSyncTS()
else
msui = mapIT->second;
if(grpMeta->mLastPost > msui->msgUpdateTS )
{
change = true;
msui->msgUpdateTS = grpMeta->mLastPost;
// (cyril) I'm removing this, because the msgUpdateTS is updated when new messages are received by calling locked_stampMsgServerUpdateTS().
// mLastPost is actually updated somewhere when loading group meta data. It's not clear yet whether it is set to the latest publish time (wrong)
// or the latest receive time (right). The former would cause problems because it would need to compare times coming from different (potentially async-ed)
// machines.
//
// if(grpMeta->mLastPost > msui->msgUpdateTS )
// {
// change = true;
// msui->msgUpdateTS = grpMeta->mLastPost;
#ifdef NXS_NET_DEBUG_0
GXSNETDEBUG__G(grpId) << " updated msgUpdateTS to last post = " << time(NULL) - grpMeta->mLastPost << " secs ago for group "<< grpId << std::endl;
// GXSNETDEBUG__G(grpId) << " updated msgUpdateTS to last post = " << time(NULL) - grpMeta->mLastPost << " secs ago for group "<< grpId << std::endl;
#endif
}
// }
// This is needed for group metadata updates to actually propagate: only a new grpUpdateTS will trigger the exchange of groups mPublishTs which
// will then be compared and pssibly trigger a MetaData transmission. mRecvTS is upated when creating, receiving for the first time, or receiving
@ -2118,6 +2128,7 @@ void RsGxsNetService::updateServerSyncTS()
if(change)
IndicateConfigChanged();
}
bool RsGxsNetService::locked_checkTransacTimedOut(NxsTransaction* tr)
{
return tr->mTimeOut < ((uint32_t) time(NULL));
@ -2590,6 +2601,8 @@ void RsGxsNetService::locked_processCompletedIncomingTrans(NxsTransaction* tr)
// for the grp id
locked_doMsgUpdateWork(tr->mTransaction, grpId);
// also update server sync TS, since we need to send the new message list to friends for comparison
locked_stampMsgServerUpdateTS(grpId);
}
}
else if(tr->mFlag == NxsTransaction::FLAG_STATE_FAILED)
@ -2923,9 +2936,8 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
#endif
continue;
}
// FIXTESTS global variable rsReputations not available in unittests!
if(rsReputations == 0){ std::cerr << "rsReputations==0, accepting all messages!" << std::endl; }
if(rsReputations && rsReputations->isIdentityBanned(syncItem->authorId))
if(rsIdentity && rsIdentity->isBanned(syncItem->authorId))
{
#ifdef NXS_NET_DEBUG_1
GXSNETDEBUG_PG(item->PeerId(),grpId) << ", Identity " << syncItem->authorId << " is banned. Not requesting message!" << std::endl;
@ -3169,8 +3181,8 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
latestVersion = grpSyncItem->publishTs > metaIter->second->mPublishTs;
}
// FIXTESTS global variable rsReputations not available in unittests!
if(rsReputations == 0){ std::cerr << "rsReputations==0, accepting all groups!" << std::endl; }
if(!grpSyncItem->authorId.isNull() && rsReputations && rsReputations->isIdentityBanned(grpSyncItem->authorId))
if(!grpSyncItem->authorId.isNull() && rsIdentity && rsIdentity->isBanned(grpSyncItem->authorId))
{
#ifdef NXS_NET_DEBUG_0
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId) << " Identity " << grpSyncItem->authorId << " is banned. Not syncing group." << std::endl;
@ -4089,7 +4101,7 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrpReqItem *item)
bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet, bool& should_encrypt)
bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& /* toVet */, bool& should_encrypt)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::canSendGrpId()"<< std::endl;
@ -4120,101 +4132,21 @@ bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpM
#endif
should_encrypt = true ;
return true ;
#ifdef TO_BE_REMOVED_OLD_VETTING_FOR_EXTERNAL_CIRCLES
const RsGxsCircleId& circleId = grpMeta.mCircleId;
if(circleId.isNull())
{
std::cerr << " EXTERNAL_CIRCLE missing NULL CircleId: " << grpMeta.mGroupId<< std::endl;
// ERROR, will never be shared.
return false;
}
if(mCircles->isLoaded(circleId))
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId)<< " EXTERNAL_CIRCLE, checking mCircles->canSend"<< std::endl;
#endif
// the sending authorisation is based on:
// getPgpId(peer_id) being a signer of one GxsId in the Circle
//
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
bool res = mCircles->canSend(circleId, pgpId);
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId)<< " answer is: " << res << std::endl;
#endif
return res ;
}
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId)<< " grp not ready. Adding to vetting list." << std::endl;
#endif
toVet.push_back(GrpIdCircleVet(grpMeta.mGroupId, circleId, grpMeta.mAuthorId));
return false;
#endif
}
if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " YOUREYESONLY, checking further" << std::endl;
#endif
bool res = checkPermissionsForFriendGroup(sslId,grpMeta) ;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Final answer: " << res << std::endl;
#endif
return res ;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId)<< " YOUREYESONLY, checking further"<< std::endl;
#endif
// a non empty internal circle id means this
// is the personal circle owner
if(!grpMeta.mInternalCircle.isNull())
{
const RsGxsCircleId& internalCircleId = grpMeta.mInternalCircle;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " have mInternalCircle - we are Group creator" << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " mCircleId: " << grpMeta.mCircleId << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " mInternalCircle: " << grpMeta.mInternalCircle << std::endl;
#endif
if(mCircles->isLoaded(internalCircleId))
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " circle Loaded - checking mCircles->canSend" << std::endl;
#endif
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
bool should_encrypt = false ;
bool res = mCircles->canSend(internalCircleId, pgpId,should_encrypt);
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " answer is: " << res << std::endl;
#endif
return res ;
}
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle Not Loaded - add to vetting"<< std::endl;
#endif
toVet.push_back(GrpIdCircleVet(grpMeta.mGroupId, internalCircleId, grpMeta.mAuthorId));
return false;
}
else
{
// an empty internal circle id means this peer can only
// send circle related info from peer he received it
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " mInternalCircle not set, someone else's personal circle"<< std::endl;
#endif
if(grpMeta.mOriginator == sslId)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Originator matches -> can send"<< std::endl;
#endif
return true;
}
else
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Originator doesn't match -> cannot send"<< std::endl;
#endif
return false;
}
}
}
return true;
@ -4224,121 +4156,51 @@ bool RsGxsNetService::checkCanRecvMsgFromPeer(const RsPeerId& sslId, const RsGxs
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::checkCanRecvMsgFromPeer()";
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " peer Id = " << sslId << ", grpId=" << grpMeta.mGroupId <<std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::checkCanRecvMsgFromPeer()";
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " peer Id = " << sslId << ", grpId=" << grpMeta.mGroupId <<std::endl;
#endif
// first do the simple checks
uint8_t circleType = grpMeta.mCircleType;
should_encrypt_id.clear() ;
// first do the simple checks
uint8_t circleType = grpMeta.mCircleType;
should_encrypt_id.clear() ;
if(circleType == GXS_CIRCLE_TYPE_LOCAL)
{
if(circleType == GXS_CIRCLE_TYPE_LOCAL)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " LOCAL_CIRCLE, cannot request sync from peer" << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " LOCAL_CIRCLE, cannot request sync from peer" << std::endl;
#endif
return false;
}
return false;
}
if(circleType == GXS_CIRCLE_TYPE_PUBLIC)
{
if(circleType == GXS_CIRCLE_TYPE_PUBLIC)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " PUBLIC_CIRCLE, can request msg sync" << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " PUBLIC_CIRCLE, can request msg sync" << std::endl;
#endif
return true;
}
return true;
}
if(circleType == GXS_CIRCLE_TYPE_EXTERNAL)
{
if(circleType == GXS_CIRCLE_TYPE_EXTERNAL)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: EXTERNAL => returning true. Msgs will be encrypted." << std::endl;
#endif
should_encrypt_id = grpMeta.mCircleId ;
return true ;
#ifdef TO_BE_REMOVED_OLD_VETTING_FOR_EXTERNAL_CIRCLES
const RsGxsCircleId& circleId = grpMeta.mCircleId;
if(circleId.isNull())
{
#ifdef NXS_NET_DEBUG_0
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " ERROR; EXTERNAL_CIRCLE missing NULL CircleId";
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << grpMeta.mGroupId;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: EXTERNAL => returning true. Msgs will be encrypted." << std::endl;
#endif
should_encrypt_id = grpMeta.mCircleId ;
return true ;
}
// should just be shared. ? no - this happens for
// Circle Groups which lose their CircleIds.
// return true;
}
if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY) // do not attempt to sync msg unless to originator or those permitted
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " YOUREYESONLY, checking further" << std::endl;
#endif
bool res = checkPermissionsForFriendGroup(sslId,grpMeta) ;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Final answer: " << res << std::endl;
#endif
return res ;
}
if(mCircles->isLoaded(circleId))
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " EXTERNAL_CIRCLE, checking mCircles->canSend" << std::endl;
#endif
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
return mCircles->canSend(circleId, pgpId);
}
else
mCircles->loadCircle(circleId); // simply request for next pass
return false;
#endif
}
if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY) // do not attempt to sync msg unless to originator or those permitted
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " YOUREYESONLY, checking further" << std::endl;
#endif
// a non empty internal circle id means this
// is the personal circle owner
if(!grpMeta.mInternalCircle.isNull())
{
const RsGxsCircleId& internalCircleId = grpMeta.mInternalCircle;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " have mInternalCircle - we are Group creator" << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " mCircleId: " << grpMeta.mCircleId << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " mInternalCircle: " << grpMeta.mInternalCircle << std::endl;
#endif
if(mCircles->isLoaded(internalCircleId))
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " circle Loaded - checking mCircles->canSend" << std::endl;
#endif
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
bool should_encrypt ;
return mCircles->canSend(internalCircleId, pgpId,should_encrypt);
}
else
mCircles->loadCircle(internalCircleId); // request for next pass
return false;
}
else
{
// an empty internal circle id means this peer can only
// send circle related info from peer he received it
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " mInternalCircle not set, someone else's personal circle" << std::endl;
#endif
if(grpMeta.mOriginator == sslId)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Originator matches -> can send" << std::endl;
#endif
return true;
}
else
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Originator doesn't match -> cannot send"<< std::endl;
#endif
return false;
}
}
}
return true;
return true;
}
bool RsGxsNetService::locked_CanReceiveUpdate(RsNxsSyncMsgReqItem *item,bool& grp_is_known)
@ -4615,17 +4477,17 @@ bool RsGxsNetService::canSendMsgIds(std::vector<RsGxsMsgMetaData*>& msgMetas, co
if(circleType == GXS_CIRCLE_TYPE_LOCAL)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: LOCAL => returning false" << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: LOCAL => returning false" << std::endl;
#endif
return false;
return false;
}
if(circleType == GXS_CIRCLE_TYPE_PUBLIC)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: PUBLIC => returning true" << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: PUBLIC => returning true" << std::endl;
#endif
return true;
return true;
}
const RsGxsCircleId& circleId = grpMeta.mCircleId;
@ -4633,119 +4495,116 @@ bool RsGxsNetService::canSendMsgIds(std::vector<RsGxsMsgMetaData*>& msgMetas, co
if(circleType == GXS_CIRCLE_TYPE_EXTERNAL)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: EXTERNAL => returning true. Msgs ids list will be encrypted." << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: EXTERNAL => returning true. Msgs ids list will be encrypted." << std::endl;
#endif
should_encrypt_id = circleId ;
should_encrypt_id = circleId ;
// For each message ID, check that the author is in the circle. If not, do not send the message, which means, remove it from the list.
// Unsigned messages are still transmitted. This is because in some groups (channels) the posts are not signed. Whether an unsigned post
// is allowed at this point is anyway already vetted by the RsGxsGenExchange service.
// For each message ID, check that the author is in the circle. If not, do not send the message, which means, remove it from the list.
// Unsigned messages are still transmitted. This is because in some groups (channels) the posts are not signed. Whether an unsigned post
// is allowed at this point is anyway already vetted by the RsGxsGenExchange service.
// Messages that stay in the list will be sent. As a consequence true is always returned.
// Messages put in vetting list will be dealt with later
// Messages that stay in the list will be sent. As a consequence true is always returned.
// Messages put in vetting list will be dealt with later
std::vector<MsgIdCircleVet> toVet;
std::vector<MsgIdCircleVet> toVet;
for(uint32_t i=0;i<msgMetas.size();)
if( msgMetas[i]->mAuthorId.isNull() ) // keep the message in this case
++i ;
else
{
if(mCircles->isLoaded(circleId) && mCircles->isRecipient(circleId, grpMeta.mGroupId, msgMetas[i]->mAuthorId))
{
++i ;
continue ;
}
for(uint32_t i=0;i<msgMetas.size();)
if( msgMetas[i]->mAuthorId.isNull() ) // keep the message in this case
++i ;
else
{
if(mCircles->isLoaded(circleId) && mCircles->isRecipient(circleId, grpMeta.mGroupId, msgMetas[i]->mAuthorId))
{
++i ;
continue ;
}
MsgIdCircleVet mic(msgMetas[i]->mMsgId, msgMetas[i]->mAuthorId);
toVet.push_back(mic);
MsgIdCircleVet mic(msgMetas[i]->mMsgId, msgMetas[i]->mAuthorId);
toVet.push_back(mic);
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " deleting MsgMeta entry for msg ID " << msgMetas[i]->mMsgId << " signed by " << msgMetas[i]->mAuthorId << " who is not in group circle " << circleId << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " deleting MsgMeta entry for msg ID " << msgMetas[i]->mMsgId << " signed by " << msgMetas[i]->mAuthorId << " who is not in group circle " << circleId << std::endl;
#endif
delete msgMetas[i] ;
msgMetas[i] = msgMetas[msgMetas.size()-1] ;
msgMetas.pop_back() ;
}
delete msgMetas[i] ;
msgMetas[i] = msgMetas[msgMetas.size()-1] ;
msgMetas.pop_back() ;
}
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle info not loaded. Putting in vetting list and returning false." << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle info not loaded. Putting in vetting list and returning false." << std::endl;
#endif
if(!toVet.empty())
mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, mPgpUtils, toVet, grpMeta.mGroupId, sslId, grpMeta.mCircleId));
if(!toVet.empty())
mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, mPgpUtils, toVet, grpMeta.mGroupId, sslId, grpMeta.mCircleId));
return true ;
return true ;
}
if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY)
{
if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: YOUR EYES ONLY" << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " YOUREYESONLY, checking further" << std::endl;
#endif
// a non empty internal circle id means this
// is the personal circle owner
if(!grpMeta.mInternalCircle.isNull())
{
const RsGxsCircleId& internalCircleId = grpMeta.mInternalCircle;
bool res = checkPermissionsForFriendGroup(sslId,grpMeta) ;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Group internal circle: " << internalCircleId << std::endl;
#endif
if(mCircles->isLoaded(internalCircleId))
{
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
bool should_encrypt = false ;
bool res= mCircles->canSend(internalCircleId, pgpId,should_encrypt);
if(should_encrypt)
std::cerr << "(EE) inconsistent response: vetting requests to encrypt circle of type YOUR_EYES_ONLY" << std::endl;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Answer from circle::canSend(): " << res << std::endl;
#endif
return res ;
}
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Not loaded. Putting in vetting list and returning false." << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Final answer: " << res << std::endl;
#endif
return res ;
}
std::vector<MsgIdCircleVet> toVet;
std::vector<RsGxsMsgMetaData*>::const_iterator vit = msgMetas.begin();
for(; vit != msgMetas.end(); ++vit)
{
const RsGxsMsgMetaData* const& meta = *vit;
MsgIdCircleVet mic(meta->mMsgId, meta->mAuthorId);
toVet.push_back(mic);
}
if(!toVet.empty())
mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, mPgpUtils,
toVet, grpMeta.mGroupId,
sslId, grpMeta.mCircleId));
return false;
}
else
{
// an empty internal circle id means this peer can only
// send circle related info from peer he received it
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Empty internal circle: cannot only send info from Peer we received it (grpMeta.mOriginator=" << grpMeta.mOriginator << " answer is: " << (grpMeta.mOriginator == sslId) << std::endl;
#endif
if(grpMeta.mOriginator == sslId)
return true;
else
return false;
}
}
return false;
return false;
}
/** inherited methods **/
bool RsGxsNetService::checkPermissionsForFriendGroup(const RsPeerId& sslId,const RsGxsGrpMetaData& grpMeta)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: YOUR EYES ONLY - ID = " << grpMeta.mInternalCircle << std::endl;
#endif
// a non empty internal circle id means this
// is the personal circle owner
if(!grpMeta.mInternalCircle.isNull())
{
RsGroupInfo ginfo ;
RsPgpId pgpId = mPgpUtils->getPGPId(sslId) ;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Group internal circle: " << grpMeta.mInternalCircle << ", We're owner. Sending to everyone in the group." << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Current destination is PGP Id: " << pgpId << std::endl;
#endif
if(!rsPeers->getGroupInfo(RsNodeGroupId(grpMeta.mInternalCircle),ginfo))
{
std::cerr << "(EE) Cannot get information for internal circle (group node) ID " << grpMeta.mInternalCircle << " which conditions dissemination of GXS group " << grpMeta.mGroupId << std::endl;
return false ;
}
bool res = (ginfo.peerIds.find(pgpId) != ginfo.peerIds.end());
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Final Answer is: " << res << std::endl;
#endif
return res ;
}
else
{
// An empty internal circle id means this peer can only
// send circle related info from peer he received it from.
// Normally this should be a pgp-based decision, but if we do that,
// A ---> B ----> A' ---...--->B' , then A' will also send to B' since B is the
// originator for A'. So A will lose control of who can see the data. This should
// be discussed further...
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Empty internal circle: cannot only send/recv info to/from Peer we received it from (grpMeta.mOriginator=" << grpMeta.mOriginator << ")" << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Final answer is: " << (grpMeta.mOriginator == sslId) << std::endl;
#endif
if(grpMeta.mOriginator == sslId)
return true;
else
return false;
}
}
void RsGxsNetService::pauseSynchronisation(bool /* enabled */)
{
@ -4759,7 +4618,13 @@ void RsGxsNetService::setSyncAge(uint32_t /* age */)
int RsGxsNetService::requestGrp(const std::list<RsGxsGroupId>& grpId, const RsPeerId& peerId)
{
RS_STACK_MUTEX(mNxsMutex) ;
mExplicitRequest[peerId].assign(grpId.begin(), grpId.end());
#ifdef NXS_NET_DEBUG_0
GXSNETDEBUG_P_(peerId) << "RsGxsNetService::requestGrp(): adding explicit group requests to peer " << peerId << std::endl;
for(std::list<RsGxsGroupId>::const_iterator it(grpId.begin());it!=grpId.end();++it)
GXSNETDEBUG_PG(peerId,*it) << " Group ID: " << *it << std::endl;
#endif
mExplicitRequest[peerId].assign(grpId.begin(), grpId.end());
return 1;
}
@ -4771,7 +4636,10 @@ void RsGxsNetService::processExplicitGroupRequests()
for(; cit != mExplicitRequest.end(); ++cit)
{
const RsPeerId& peerId = cit->first;
#ifdef NXS_NET_DEBUG_0
GXSNETDEBUG_P_(cit->first) << "RsGxsNetService::sending pending explicit group requests to peer " << cit->first << std::endl;
#endif
const RsPeerId& peerId = cit->first;
const std::list<RsGxsGroupId>& groupIdList = cit->second;
std::list<RsNxsItem*> grpSyncItems;
@ -4779,7 +4647,10 @@ void RsGxsNetService::processExplicitGroupRequests()
uint32_t transN = locked_getTransactionId();
for(; git != groupIdList.end(); ++git)
{
RsNxsSyncGrpItem* item = new RsNxsSyncGrpItem(mServType);
#ifdef NXS_NET_DEBUG_0
GXSNETDEBUG_PG(peerId,*git) << " group request for grp ID " << *git << " to peer " << peerId << std::endl;
#endif
RsNxsSyncGrpItem* item = new RsNxsSyncGrpItem(mServType);
item->grpId = *git;
item->PeerId(peerId);
item->flag = RsNxsSyncGrpItem::FLAG_REQUEST;
@ -4956,6 +4827,10 @@ void RsGxsNetService::handleRecvPublishKeys(RsNxsGroupPublishKeyItem *item)
// update the publish keys in this group meta info
RsGxsGrpMetaData *grpMeta = grpMetaMap[item->grpId] ;
if (!grpMeta) {
std::cerr << "(EE) RsGxsNetService::handleRecvPublishKeys() grpMeta not found." << std::endl;
return ;
}
// Check that the keys correspond, and that FULL keys are supplied, etc.
@ -5028,3 +4903,26 @@ bool RsGxsNetService::getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& gro
return true ;
}
bool RsGxsNetService::stampMsgServerUpdateTS(const RsGxsGroupId& gid)
{
RS_STACK_MUTEX(mNxsMutex) ;
return locked_stampMsgServerUpdateTS(gid) ;
}
bool RsGxsNetService::locked_stampMsgServerUpdateTS(const RsGxsGroupId& gid)
{
std::map<RsGxsGroupId,RsGxsServerMsgUpdateItem*>::iterator it = mServerMsgUpdateMap.find(gid) ;
if(mServerMsgUpdateMap.end() == it)
{
RsGxsServerMsgUpdateItem *item = new RsGxsServerMsgUpdateItem(mServType);
item->grpId = gid ;
item->msgUpdateTS = time(NULL) ;
}
else
it->second->msgUpdateTS = time(NULL) ;
return true;
}

View File

@ -155,7 +155,8 @@ public:
virtual void rejectMessage(const RsGxsMessageId& msg_id) ;
virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) ;
virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) ;
/* p3Config methods */
public:
@ -228,6 +229,13 @@ private:
*/
void locked_completeTransaction(NxsTransaction* trans);
/*!
* \brief locked_stampMsgServerUpdateTS
* updates the server msg time stamp. This function is the locked method for the one above with similar name
* \param gid group id to stamp.
* \return
*/
bool locked_stampMsgServerUpdateTS(const RsGxsGroupId& gid);
/*!
* This retrieves a unique transaction id that
* can be used in an outgoing transaction
@ -354,6 +362,15 @@ private:
bool canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet, bool &should_encrypt);
bool canSendMsgIds(std::vector<RsGxsMsgMetaData*>& msgMetas, const RsGxsGrpMetaData&, const RsPeerId& sslId, RsGxsCircleId &should_encrypt_id);
/*!
* \brief checkPermissionsForFriendGroup
* Checks that we can send/recv from that node, given that the grpMeta has a distribution limited to a local circle.
* \param sslId Candidate peer to send to or to receive from.
* \param grpMeta Contains info about the group id, internal circle id, etc.
* \return true only when the internal exists and validates as a friend node group, and contains the owner of sslId.
*/
bool checkPermissionsForFriendGroup(const RsPeerId& sslId,const RsGxsGrpMetaData& grpMeta) ;
bool checkCanRecvMsgFromPeer(const RsPeerId& sslId, const RsGxsGrpMetaData& meta, RsGxsCircleId& should_encrypt_id);
void locked_createTransactionFromPending(MsgRespPending* grpPend);

View File

@ -28,7 +28,6 @@
#include "rsgxsutil.h"
#include "retroshare/rsgxsflags.h"
#include "retroshare/rspeers.h"
#include "retroshare/rsreputations.h"
#include "pqi/pqihash.h"
#include "gxs/rsgixs.h"
@ -165,7 +164,7 @@ bool RsGxsIntegrityCheck::check()
std::cerr << "TimeStamping group authors' key ID " << grp->metaData->mAuthorId << " in group ID " << grp->grpId << std::endl;
#endif
if(rsReputations!=NULL && !rsReputations->isIdentityBanned(grp->metaData->mAuthorId))
if(rsIdentity!=NULL && !rsIdentity->isBanned(grp->metaData->mAuthorId))
used_gxs_ids.insert(grp->metaData->mAuthorId) ;
}
}
@ -247,7 +246,7 @@ bool RsGxsIntegrityCheck::check()
#ifdef GXSUTIL_DEBUG
std::cerr << "TimeStamping message authors' key ID " << msg->metaData->mAuthorId << " in message " << msg->msgId << ", group ID " << msg->grpId<< std::endl;
#endif
if(rsReputations!=NULL && !rsReputations->isIdentityBanned(msg->metaData->mAuthorId))
if(rsIdentity!=NULL && !rsIdentity->isBanned(msg->metaData->mAuthorId))
used_gxs_ids.insert(msg->metaData->mAuthorId) ;
}

View File

@ -144,6 +144,15 @@ public:
* \return false if the group is not found, true otherwise
*/
virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) =0;
/*!
* \brief stampMsgServerUpdateTS
* Updates the msgServerUpdateMap structure to time(NULL), so as to trigger sending msg lists to friends.
* This is needed when e.g. posting a new message to a group.
* \param gid the group to stamp in msgServerUpdateMap
* \return
*/
virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) =0;
};
#endif // RSGNP_H

View File

@ -10,6 +10,10 @@ DESTDIR = lib
#CONFIG += dsdv
# 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
@ -65,8 +69,7 @@ SOURCES *= serialiser/rstlvdsdv.cc \
bitdht {
HEADERS += dht/p3bitdht.h \
dht/connectstatebox.h \
dht/stunaddrassist.h
dht/connectstatebox.h
SOURCES += dht/p3bitdht.cc \
dht/p3bitdht_interface.cc \
@ -80,7 +83,6 @@ HEADERS += tcponudp/udppeer.h \
tcponudp/tcppacket.h \
tcponudp/tcpstream.h \
tcponudp/tou.h \
tcponudp/udpstunner.h \
tcponudp/udprelay.h \
SOURCES += tcponudp/udppeer.cc \
@ -88,9 +90,17 @@ SOURCES += tcponudp/udppeer.cc \
tcponudp/tcpstream.cc \
tcponudp/tou.cc \
tcponudp/bss_tou.c \
tcponudp/udpstunner.cc \
tcponudp/udprelay.cc \
useDhtStunner {
HEADERS += dht/stunaddrassist.h \
tcponudp/udpstunner.h
SOURCES += tcponudp/udpstunner.cc
DEFINES += RS_USE_DHT_STUNNER
}
DEFINES *= RS_USE_BITDHT
BITDHT_DIR = ../../libbitdht/src

View File

@ -71,13 +71,13 @@ bool PgpAuxUtilsImpl::parseSignature(unsigned char *sign, unsigned int signlen,
return AuthGPG::getAuthGPG()->parseSignature(sign,signlen,issuer);
}
bool PgpAuxUtilsImpl::askForDeferredSelfSignature(const void *data,
const uint32_t len,
unsigned char *sign,
bool PgpAuxUtilsImpl::askForDeferredSelfSignature(const void *data,
const uint32_t len,
unsigned char *sign,
unsigned int *signlen,
int& signature_result )
int& signature_result , std::string reason)
{
return RsServer::notify()->askForDeferredSelfSignature(data, len, sign, signlen, signature_result);
return RsServer::notify()->askForDeferredSelfSignature(data, len, sign, signlen, signature_result, reason);
}

View File

@ -43,7 +43,7 @@ class PgpAuxUtils
virtual bool parseSignature(unsigned char *sign, unsigned int signlen, RsPgpId& issuer) const =0;
virtual bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint) = 0;
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result ) = 0;
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result, std::string reason) = 0;
};
class PgpAuxUtilsImpl: public PgpAuxUtils
@ -58,7 +58,7 @@ public:
virtual bool getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const;
virtual bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint);
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result );
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result, std::string reason);
};

View File

@ -61,25 +61,25 @@ ops_parse_cb_return_t cb_get_passphrase(const ops_parser_content_t *content_,ops
{
case OPS_PARSER_CMD_GET_SK_PASSPHRASE_PREV_WAS_BAD: prev_was_bad = true ;
case OPS_PARSER_CMD_GET_SK_PASSPHRASE:
{
std::string passwd;
std::string uid_hint ;
if(cbinfo->cryptinfo.keydata->nuids > 0)
uid_hint = std::string((const char *)cbinfo->cryptinfo.keydata->uids[0].user_id) ;
uid_hint += "(" + RsPgpId(cbinfo->cryptinfo.keydata->key_id).toStdString()+")" ;
{
std::string passwd;
std::string uid_hint ;
bool cancelled = false ;
passwd = PGPHandler::passphraseCallback()(NULL,uid_hint.c_str(),NULL,prev_was_bad,&cancelled) ;
if(cbinfo->cryptinfo.keydata->nuids > 0)
uid_hint = std::string((const char *)cbinfo->cryptinfo.keydata->uids[0].user_id) ;
uid_hint += "(" + RsPgpId(cbinfo->cryptinfo.keydata->key_id).toStdString()+")" ;
if(cancelled)
*(unsigned char *)cbinfo->arg = 1;
bool cancelled = false ;
passwd = PGPHandler::passphraseCallback()(NULL,"",uid_hint.c_str(),NULL,prev_was_bad,&cancelled) ;
*(content->secret_key_passphrase.passphrase)= (char *)ops_mallocz(passwd.length()+1) ;
memcpy(*(content->secret_key_passphrase.passphrase),passwd.c_str(),passwd.length()) ;
return OPS_KEEP_MEMORY;
}
break;
if(cancelled)
*(unsigned char *)cbinfo->arg = 1;
*(content->secret_key_passphrase.passphrase)= (char *)ops_mallocz(passwd.length()+1) ;
memcpy(*(content->secret_key_passphrase.passphrase),passwd.c_str(),passwd.length()) ;
return OPS_KEEP_MEMORY;
}
break;
default:
break;
@ -1326,7 +1326,7 @@ bool PGPHandler::decryptTextFromFile(const RsPgpId&,std::string& text,const std:
return (bool)res ;
}
bool PGPHandler::SignDataBin(const RsPgpId& id,const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,bool use_raw_signature)
bool PGPHandler::SignDataBin(const RsPgpId& id,const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,bool use_raw_signature, std::string reason /* = "" */)
{
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
// need to find the key and to decrypt it.
@ -1357,7 +1357,7 @@ ops_secret_key_t *secret_key = NULL ;
for(int i=0;i<3;++i)
{
bool cancelled =false;
std::string passphrase = _passphrase_callback(NULL,uid_hint.c_str(),"Please enter passwd for encrypting your key : ",last_passwd_was_wrong,&cancelled) ;
std::string passphrase = _passphrase_callback(NULL,reason.c_str(),uid_hint.c_str(),"Please enter passwd for encrypting your key : ",last_passwd_was_wrong,&cancelled) ;//TODO reason
secret_key = ops_decrypt_secret_key_from_data(key,passphrase.c_str()) ;
@ -1448,8 +1448,8 @@ bool PGPHandler::privateSignCertificate(const RsPgpId& ownId,const RsPgpId& id_o
return false ;
}
bool cancelled = false;
std::string passphrase = _passphrase_callback(NULL,RsPgpId(skey->key_id).toStdString().c_str(),"Please enter passwd for encrypting your key : ",false,&cancelled) ;
bool cancelled = false;
std::string passphrase = _passphrase_callback(NULL,"",RsPgpId(skey->key_id).toStdString().c_str(),"Please enter passwd for encrypting your key : ",false,&cancelled) ;
ops_secret_key_t *secret_key = ops_decrypt_secret_key_from_data(skey,passphrase.c_str()) ;

View File

@ -16,7 +16,7 @@ extern "C" {
#include <openpgpsdk/keyring_local.h>
}
typedef std::string (*PassphraseCallback)(void *data, const char *uid_hint, const char *passphrase_info, int prev_was_bad,bool *cancelled) ;
typedef std::string (*PassphraseCallback)(void *data, const char *uid_title, const char *uid_hint, const char *passphrase_info, int prev_was_bad,bool *cancelled) ;
class PGPCertificateInfo
{
@ -85,8 +85,8 @@ class PGPHandler
std::string SaveCertificateToString(const RsPgpId& id,bool include_signatures) const ;
bool exportPublicKey(const RsPgpId& id,unsigned char *& mem,size_t& mem_size,bool armoured,bool include_signatures) const ;
bool parseSignature(unsigned char *sign, unsigned int signlen,RsPgpId& issuer_id) ;
bool SignDataBin(const RsPgpId& id,const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,bool make_raw_signature=false) ;
bool parseSignature(unsigned char *sign, unsigned int signlen,RsPgpId& issuer_id) ;
bool SignDataBin(const RsPgpId& id, const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, bool make_raw_signature=false, std::string reason = "") ;
bool VerifySignBin(const void *data, uint32_t data_len, unsigned char *sign, unsigned int sign_len, const PGPFingerprintType& withfingerprint) ;
bool privateSignCertificate(const RsPgpId& own_id,const RsPgpId& id_of_key_to_sign) ;

View File

@ -248,23 +248,25 @@ uint64_t PGPKeyParser::read_KeyID(unsigned char *& data)
uint32_t PGPKeyParser::write_125Size(unsigned char *data,uint32_t size)
{
if(size < 192)
if(size < 192)//192 To know if size is coded with One Char < 0xC0
{
data[0] = size ;
return 1;
}
if(size < 8384)
if(size < 8384)//8384 To know if size is coded with Two Chars < 0xE0. See RFC4880
{
data[0] = (size >> 8) + 192 ;
data[1] = (size & 255) - 192 ;
data[1] = (size - 192) & 0xFF ;//Warning data[1] could be "negative", recode it using 8bits type
data[0] = ((size - 192 - data[1]) >> 8) + 192 ;
return 2 ;
}
data[0] = 0xff ;
data[1] = (size >> 24) & 255 ;
data[2] = (size >> 16) & 255 ;
data[3] = (size >> 8) & 255 ;
data[4] = (size ) & 255 ;
data[0] = 0xFF ; //Else size is coded with 4 Chars + 1 at 0xFF
data[1] = (size >> 24) & 0xFF ;
data[2] = (size >> 16) & 0xFF ;
data[3] = (size >> 8) & 0xFF ;
data[4] = (size ) & 0xFF ;
return 5 ;
}
@ -274,16 +276,16 @@ uint32_t PGPKeyParser::read_125Size(unsigned char *& data)
uint8_t b1 = *data ;
++data ;
if(b1 < 192)
if(b1 < 192) //192 Size is coded with One Char. See RFC4880
return b1 ;
uint8_t b2 = *data ;
++data ;
if(b1 < 224)
return ((b1-192) << 8) + b2 + 192 ;
if(b1 < 224)//224 = 0xC0+0x20 Size is coded with Two Chars
return ((b1-192) << 8) + b2 + 192 ; // see RFC4880
if(b1 != 0xff)
if(b1 != 0xFF)// Else Coded with 4 Chars but first == 0xFF
throw std::runtime_error("GPG parsing error") ;
uint8_t b3 = *data ; ++data ;

View File

@ -86,14 +86,14 @@ bool AuthGPG::encryptTextToFile(const std::string& text,const std::string& outfi
// return PGPHandler::encryptTextToString(RsPgpId(pgp_id),text,outstr) ;
// }
std::string pgp_pwd_callback(void * /*hook*/, const char *uid_hint, const char * /*passphrase_info*/, int prev_was_bad,bool *cancelled)
std::string pgp_pwd_callback(void * /*hook*/, const char *uid_title, const char *uid_hint, const char * /*passphrase_info*/, int prev_was_bad,bool *cancelled)
{
#define GPG_DEBUG2
#ifdef GPG_DEBUG2
fprintf(stderr, "pgp_pwd_callback() called.\n");
#endif
std::string password;
RsServer::notify()->askForPassword(uid_hint, prev_was_bad, password,cancelled) ;
RsServer::notify()->askForPassword(uid_title, uid_hint, prev_was_bad, password,cancelled) ;
return password ;
}
@ -296,9 +296,9 @@ void AuthGPG::processServices()
delete operation;
}
bool AuthGPG::DoOwnSignature(const void *data, unsigned int datalen, void *buf_sigout, unsigned int *outl)
bool AuthGPG::DoOwnSignature(const void *data, unsigned int datalen, void *buf_sigout, unsigned int *outl, std::string reason /* = "" */)
{
return PGPHandler::SignDataBin(mOwnGpgId,data,datalen,(unsigned char *)buf_sigout,outl) ;
return PGPHandler::SignDataBin(mOwnGpgId,data,datalen,(unsigned char *)buf_sigout,outl,false,reason) ;
}
@ -605,9 +605,9 @@ bool AuthGPG::decryptDataBin(const void *data, unsigned int datalen, unsigned ch
{
return PGPHandler::decryptDataBin(mOwnGpgId,data,datalen,sign,signlen) ;
}
bool AuthGPG::SignDataBin(const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen)
bool AuthGPG::SignDataBin(const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen, std::string reason /*= ""*/)
{
return DoOwnSignature(data, datalen, sign, signlen);
return DoOwnSignature(data, datalen, sign, signlen, reason);
}
bool AuthGPG::VerifySignBin(const void *data, uint32_t datalen, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint)

View File

@ -208,7 +208,7 @@ class AuthGPG: public p3Config, public RsTickingThread, public PGPHandler
* There should also be Encryption Functions... (do later).
*
****/
virtual bool SignDataBin(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen);
virtual bool SignDataBin(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, std::string reason = "");
virtual bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, const PGPFingerprintType& withfingerprint);
virtual bool parseSignature(const void *sig, unsigned int siglen, RsPgpId& issuer_id);
@ -254,7 +254,7 @@ class AuthGPG: public p3Config, public RsTickingThread, public PGPHandler
//void createDummyFriends(void); //NYI
/* Internal functions */
bool DoOwnSignature(const void *, unsigned int, void *, unsigned int *);
bool DoOwnSignature(const void *, unsigned int, void *, unsigned int *, std::string reason);
bool VerifySignature(const void *data, int datalen, const void *sig, unsigned int siglen, const PGPFingerprintType& withfingerprint);
/* Sign/Trust stuff */

View File

@ -850,7 +850,7 @@ X509 *AuthSSLimpl::SignX509ReqWithGPG(X509_REQ *req, long /*days*/)
std::cerr << "Digest Applied: len: " << hashoutl << std::endl;
/* NOW Sign via GPG Functions */
if (!AuthGPG::getAuthGPG()->SignDataBin(buf_hashout, hashoutl, buf_sigout, (unsigned int *) &sigoutl))
if (!AuthGPG::getAuthGPG()->SignDataBin(buf_hashout, hashoutl, buf_sigout, (unsigned int *) &sigoutl,"AuthSSLimpl::SignX509ReqWithGPG()"))
{
sigoutl = 0;
goto err;

View File

@ -138,8 +138,6 @@ p3LinkMgrIMPL::p3LinkMgrIMPL(p3PeerMgrIMPL *peerMgr, p3NetMgrIMPL *netMgr)
mDNSResolver = new DNSResolver();
mRetryPeriod = MIN_RETRY_PERIOD;
lastGroupId = 1;
/* setup Banned Ip Address - static for now
*/

View File

@ -132,7 +132,7 @@ class peerConnectState
};
class p3tunnel;
class RsPeerGroupItem;
class RsPeerGroupItem_deprecated;
class RsGroupInfo;
class p3PeerMgr;
@ -339,9 +339,6 @@ private:
std::map<RsPeerId, peerConnectState> mFriendList;
std::map<RsPeerId, peerConnectState> mOthersList;
std::list<RsPeerGroupItem *> groupList;
uint32_t lastGroupId;
/* relatively static list of banned ip addresses */
std::list<struct sockaddr_storage> mBannedIpList;
};

View File

@ -169,12 +169,13 @@ void p3NetMgrIMPL::setManagers(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr)
// mDhtMgr = dhtMgr;
//}
#ifdef RS_USE_DHT_STUNNER
void p3NetMgrIMPL::setAddrAssist(pqiAddrAssist *dhtStun, pqiAddrAssist *proxyStun)
{
mDhtStunner = dhtStun;
mProxyStunner = proxyStun;
}
#endif // RS_USE_DHT_STUNNER
/***** Framework / initial implementation for a connection manager.
@ -445,6 +446,7 @@ void p3NetMgrIMPL::slowTick()
netAssistTick();
updateNetStateBox_temporal();
#ifdef RS_USE_DHT_STUNNER
if (mDhtStunner)
{
mDhtStunner->tick();
@ -454,7 +456,7 @@ void p3NetMgrIMPL::slowTick()
{
mProxyStunner->tick();
}
#endif // RS_USE_DHT_STUNNER
}
#define STARTUP_DELAY 5
@ -1734,11 +1736,12 @@ void p3NetMgrIMPL::updateNetStateBox_temporal()
std::cerr << "p3NetMgrIMPL::updateNetStateBox_temporal() ";
std::cerr << std::endl;
#endif
uint8_t isstable = 0;
struct sockaddr_storage tmpaddr;
sockaddr_storage_clear(tmpaddr);
#ifdef RS_USE_DHT_STUNNER
uint8_t isstable = 0;
if (mDhtStunner)
{
@ -1776,6 +1779,7 @@ void p3NetMgrIMPL::updateNetStateBox_temporal()
}
}
#endif // RS_USE_DHT_STUNNER
{
@ -1789,7 +1793,7 @@ void p3NetMgrIMPL::updateNetStateBox_temporal()
/* now we check if a WebIP address is required? */
#ifdef NETMGR_DEBUG_STATEBOX
{
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
@ -1805,7 +1809,6 @@ void p3NetMgrIMPL::updateNetStateBox_temporal()
std::string nattypestr = NetStateNatTypeString(natType);
std::string netmodestr = NetStateNetworkModeString(netMode);
#ifdef NETMGR_DEBUG_STATEBOX
std::cerr << "p3NetMgrIMPL::updateNetStateBox_temporal() NetStateBox Thinking";
std::cerr << std::endl;
std::cerr << "\tNetState: " << netstatestr;
@ -1818,10 +1821,9 @@ void p3NetMgrIMPL::updateNetStateBox_temporal()
std::cerr << std::endl;
std::cerr << "\tNatType: " << nattypestr;
std::cerr << std::endl;
#endif
}
#endif
updateNatSetting();
@ -1869,7 +1871,7 @@ void p3NetMgrIMPL::updateNatSetting()
std::cerr << std::endl;
#endif
#ifdef RS_USE_DHT_STUNNER
switch(natType)
{
case RSNET_NATTYPE_RESTRICTED_CONE:
@ -1894,7 +1896,7 @@ void p3NetMgrIMPL::updateNatSetting()
mProxyStunner->setRefreshPeriod(NET_STUNNER_PERIOD_SLOW);
break;
}
#endif // RS_USE_DHT_STUNNER
/* This controls the Attach mode of the DHT...
* which effectively makes the DHT "attach" to Open Nodes.

View File

@ -209,7 +209,9 @@ virtual bool getDHTEnabled();
/************************************************************************************************/
void setManagers(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr);
#ifdef RS_USE_DHT_STUNNER
void setAddrAssist(pqiAddrAssist *dhtStun, pqiAddrAssist *proxyStun);
#endif // RS_USE_DHT_STUNNER
void tick();
@ -319,8 +321,10 @@ private:
p3LinkMgr *mLinkMgr;
//p3BitDht *mBitDht;
#ifdef RS_USE_DHT_STUNNER
pqiAddrAssist *mDhtStunner;
pqiAddrAssist *mProxyStunner;
#endif // RS_USE_DHT_STUNNER
RsMutex mNetMtx; /* protects below */

View File

@ -245,10 +245,10 @@ void p3Notify::notifyDownloadComplete (const std::string& fileHash )
void p3Notify::notifyDownloadCompleteCount (uint32_t count ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDownloadCompleteCount (count) ; }
void p3Notify::notifyHistoryChanged (uint32_t msgId , int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyHistoryChanged (msgId,type) ; }
bool p3Notify::askForPassword (const std::string& key_details , bool prev_is_bad , std::string& password,bool *cancelled)
bool p3Notify::askForPassword (const std::string& title , const std::string& key_details , bool prev_is_bad , std::string& password,bool *cancelled)
{
FOR_ALL_NOTIFY_CLIENTS
if( (*it)->askForPassword(key_details,prev_is_bad,password,*cancelled))
if( (*it)->askForPassword(title,key_details,prev_is_bad,password,*cancelled))
return true ;
return false ;
@ -261,10 +261,10 @@ bool p3Notify::askForPluginConfirmation (const std::string& plugin_filen
return false ;
}
bool p3Notify::askForDeferredSelfSignature (const void * data , const uint32_t len , unsigned char *sign, unsigned int *signlen,int& signature_result )
bool p3Notify::askForDeferredSelfSignature (const void * data , const uint32_t len , unsigned char *sign, unsigned int *signlen,int& signature_result, std::string reason /*=""*/)
{
FOR_ALL_NOTIFY_CLIENTS
if( (*it)->askForDeferredSelfSignature(data,len,sign,signlen,signature_result))
if( (*it)->askForDeferredSelfSignature(data,len,sign,signlen,signature_result, reason))
return true ;
return false ;

View File

@ -116,12 +116,12 @@ class p3Notify: public RsNotify
void notifyPeerStatusChangedSummary () ;
void notifyDiscInfoChanged () ;
bool askForDeferredSelfSignature (const void * /* data */, const uint32_t /* len */, unsigned char * /* sign */, unsigned int * /* signlen */,int& signature_result ) ;
bool askForDeferredSelfSignature (const void * /* data */, const uint32_t /* len */, unsigned char * /* sign */, unsigned int * /* signlen */, int& signature_result , std::string reason = "") ;
void notifyDownloadComplete (const std::string& /* fileHash */) ;
void notifyDownloadCompleteCount (uint32_t /* count */) ;
void notifyHistoryChanged (uint32_t /* msgId */, int /* type */) ;
bool askForPassword (const std::string& /* key_details */, bool /* prev_is_bad */, std::string&, bool *cancelled /* password */ ) ;
bool askForPassword (const std::string& title, const std::string& /* key_details */, bool /* prev_is_bad */, std::string&, bool *cancelled /* password */ ) ;
bool askForPluginConfirmation (const std::string& /* plugin_filename */, const std::string& /* plugin_file_hash */) ;
private:

View File

@ -75,7 +75,7 @@ static struct RsLog::logInfo p3peermgrzoneInfo = {RsLog::Default, "p3peermgr"};
static const std::string kConfigDefaultProxyServerIpAddr = "127.0.0.1";
static const uint16_t kConfigDefaultProxyServerPortTor = 9050; // standard port.
static const uint16_t kConfigDefaultProxyServerPortI2P = 10; // there is no standard port though
static const uint16_t kConfigDefaultProxyServerPortI2P = 4447; // I2Pd's standard port
static const std::string kConfigKeyExtIpFinder = "USE_EXTR_IP_FINDER";
static const std::string kConfigKeyProxyServerIpAddrTor = "PROXY_SERVER_IPADDR";
@ -130,8 +130,6 @@ p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const RsPgpId& gpg_own_
mOwnState.vs_disc = RS_VS_DISC_FULL;
mOwnState.vs_dht = RS_VS_DHT_FULL;
lastGroupId = 1;
// setup default ProxyServerAddress.
// Tor
sockaddr_storage_clear(mProxyServerAddressTor);
@ -1071,7 +1069,7 @@ bool p3PeerMgrIMPL::removeFriend(const RsPgpId &id)
std::list<RsPgpId> ids ;
ids.push_back(id) ;
assignPeersToGroup("", ids, false);
assignPeersToGroup(RsNodeGroupId(), ids, false);
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
@ -1145,7 +1143,7 @@ bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId)
/* remove id from all groups */
assignPeersToGroup("", pgpid_toRemove, false);
assignPeersToGroup(RsNodeGroupId(), pgpid_toRemove, false);
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
@ -1915,7 +1913,7 @@ RsSerialiser *p3PeerMgrIMPL::setupSerialiser()
bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
{
/* create a list of current peers */
cleanup = false;
cleanup = true;
bool useExtAddrFinder = mNetMgr->getIPServersEnabled();
/* gather these information before mPeerMtx is locked! */
@ -1971,7 +1969,6 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
#endif
saveData.push_back(item);
saveCleanupList.push_back(item);
/* iterate through all friends and save */
std::map<RsPeerId, peerState>::iterator it;
@ -2003,7 +2000,6 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
item->domain_port = (it->second).hiddenPort;
saveData.push_back(item);
saveCleanupList.push_back(item);
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::saveList() Peer Config Item:" << std::endl;
item->print(std::cerr, 10);
@ -2024,7 +2020,6 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
}
saveData.push_back(sitem) ;
saveCleanupList.push_back(sitem);
// Now save config for network digging strategies
@ -2066,14 +2061,14 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
vitem->tlvkvs.pairs.push_back(kv) ;
saveData.push_back(vitem);
saveCleanupList.push_back(vitem);
/* save groups */
std::list<RsPeerGroupItem *>::iterator groupIt;
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) {
saveData.push_back(*groupIt); // no delete
}
for ( std::map<RsNodeGroupId,RsGroupInfo>::iterator groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt)
{
RsNodeGroupItem *itm = new RsNodeGroupItem(groupIt->second);
saveData.push_back(itm) ;
}
return true;
}
@ -2294,7 +2289,8 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
continue;
}
RsPeerGroupItem *gitem = dynamic_cast<RsPeerGroupItem *>(*it) ;
RsPeerGroupItem_deprecated *gitem = dynamic_cast<RsPeerGroupItem_deprecated *>(*it) ;
if (gitem)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
@ -2304,20 +2300,54 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
gitem->print(std::cerr, 10);
std::cerr << std::endl;
#endif
RsGroupInfo ginfo ;
ginfo.flag = gitem->flag ;
ginfo.name = gitem->name ;
ginfo.peerIds = gitem->pgpList.ids ;
groupList.push_back(gitem); // don't delete
do { ginfo.id = RsNodeGroupId::random(); } while(groupList.find(ginfo.id) != groupList.end()) ;
if ((gitem->flag & RS_GROUP_FLAG_STANDARD) == 0) {
/* calculate group id */
uint32_t groupId = atoi(gitem->id.c_str());
if (groupId > lastGroupId) {
lastGroupId = groupId;
}
}
// Ensure backward compatibility when loading the group in old format. The id must matchthe standard default id.
continue;
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_FRIENDS )) ginfo.id = RS_GROUP_ID_FRIENDS ;
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_COWORKERS)) ginfo.id = RS_GROUP_ID_COWORKERS ;
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_FAMILY )) ginfo.id = RS_GROUP_ID_FAMILY ;
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_FAVORITES)) ginfo.id = RS_GROUP_ID_FAVORITES ;
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_OTHERS )) ginfo.id = RS_GROUP_ID_OTHERS ;
if(!ginfo.id.isNull())
{
groupList[ginfo.id] = ginfo ;
std::cerr << "(II) Creating new group for old format local group \"" << gitem->name << "\". Id=" << ginfo.id << std::endl;
}
else
std::cerr << "(EE) no group corresponding to old format group with ID=\"" << gitem->id << "\"" << std::endl;
continue;
}
RsNodeGroupItem *gitem2 = dynamic_cast<RsNodeGroupItem*>(*it) ;
if (gitem2)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::loadList() Peer group item:" << std::endl;
gitem->print(std::cerr, 10);
std::cerr << std::endl;
#endif
RsGroupInfo info ;
info.peerIds = gitem2->pgpList.ids ;
info.id = gitem2->id ;
info.name = gitem2->name ;
info.flag = gitem2->flag ;
std::cerr << "(II) Loaded group in new format. ID = " << info.id << std::endl;
groupList[info.id] = info ;
continue;
}
RsPeerBandwidthLimitsItem *pblitem = dynamic_cast<RsPeerBandwidthLimitsItem*>(*it) ;
if(pblitem)
@ -2363,42 +2393,19 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
/* Standard groups */
const int standardGroupCount = 5;
const char *standardGroup[standardGroupCount] = { RS_GROUP_ID_FRIENDS, RS_GROUP_ID_FAMILY, RS_GROUP_ID_COWORKERS, RS_GROUP_ID_OTHERS, RS_GROUP_ID_FAVORITES };
bool foundStandardGroup[standardGroupCount] = { false, false, false, false, false };
const RsNodeGroupId standardGroupIds [standardGroupCount] = { RS_GROUP_ID_FRIENDS, RS_GROUP_ID_FAMILY, RS_GROUP_ID_COWORKERS, RS_GROUP_ID_OTHERS, RS_GROUP_ID_FAVORITES };
const char *standardGroupNames[standardGroupCount] = { RS_GROUP_DEFAULT_NAME_FRIENDS, RS_GROUP_DEFAULT_NAME_FAMILY, RS_GROUP_DEFAULT_NAME_COWORKERS, RS_GROUP_DEFAULT_NAME_OTHERS, RS_GROUP_DEFAULT_NAME_FAVORITES };
std::list<RsPeerGroupItem *>::iterator groupIt;
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) {
if ((*groupIt)->flag & RS_GROUP_FLAG_STANDARD) {
int i;
for (i = 0; i < standardGroupCount; ++i) {
if ((*groupIt)->id == standardGroup[i]) {
foundStandardGroup[i] = true;
break;
}
}
for(uint32_t k=0;k<standardGroupCount;++k)
if(groupList.find(standardGroupIds[k]) == groupList.end())
{
RsGroupInfo info ;
info.id = standardGroupIds[k];
info.name = standardGroupNames[k];
info.flag |= RS_GROUP_FLAG_STANDARD;
if (i >= standardGroupCount) {
/* No more a standard group, remove the flag standard */
(*groupIt)->flag &= ~RS_GROUP_FLAG_STANDARD;
}
} else {
uint32_t groupId = atoi((*groupIt)->id.c_str());
if (groupId == 0) {
rs_sprintf((*groupIt)->id, "%lu", lastGroupId++);
}
groupList[info.id] = info;
}
}
/* Initialize standard groups */
for (int i = 0; i < standardGroupCount; ++i) {
if (foundStandardGroup[i] == false) {
RsPeerGroupItem *gitem = new RsPeerGroupItem;
gitem->id = standardGroup[i];
gitem->name = standardGroup[i];
gitem->flag |= RS_GROUP_FLAG_STANDARD;
groupList.push_back(gitem);
}
}
}
// If we are hidden - don't want ExtAddrFinder - ever!
@ -2478,19 +2485,16 @@ bool p3PeerMgrIMPL::addGroup(RsGroupInfo &groupInfo)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RsPeerGroupItem *groupItem = new RsPeerGroupItem;
groupItem->set(groupInfo);
do { groupInfo.id = RsNodeGroupId::random(); } while(groupList.find(groupInfo.id) != groupList.end()) ;
rs_sprintf(groupItem->id, "%lu", ++lastGroupId);
RsGroupInfo groupItem(groupInfo) ;
// remove standard flag
groupItem->flag &= ~RS_GROUP_FLAG_STANDARD;
groupItem->PeerId(getOwnId());
groupItem.flag &= ~RS_GROUP_FLAG_STANDARD;
groupList[groupInfo.id] = groupItem;
groupList.push_back(groupItem);
groupInfo.id = groupItem->id;
std::cerr << "(II) Added new group with ID " << groupInfo.id << ", name=\"" << groupInfo.name << "\"" << std::endl;
}
RsServer::notify()->notifyListChange(NOTIFY_LIST_GROUPLIST, NOTIFY_TYPE_ADD);
@ -2500,35 +2504,39 @@ bool p3PeerMgrIMPL::addGroup(RsGroupInfo &groupInfo)
return true;
}
bool p3PeerMgrIMPL::editGroup(const std::string &groupId, RsGroupInfo &groupInfo)
bool p3PeerMgrIMPL::editGroup(const RsNodeGroupId& groupId, RsGroupInfo &groupInfo)
{
if (groupId.empty()) {
if (groupId.isNull())
return false;
}
bool changed = false;
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::list<RsPeerGroupItem*>::iterator groupIt;
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) {
if ((*groupIt)->id == groupId) {
break;
}
}
std::map<RsNodeGroupId,RsGroupInfo>::iterator it = groupList.find(groupId) ;
if (groupIt != groupList.end()) {
if ((*groupIt)->flag & RS_GROUP_FLAG_STANDARD) {
// can't edit standard groups
} else {
changed = true;
(*groupIt)->set(groupInfo);
}
}
}
if(it == groupList.end())
{
std::cerr << "(EE) cannot find local node group with ID " << groupId << std::endl;
return false ;
}
if (changed) {
if (it->second.flag & RS_GROUP_FLAG_STANDARD)
{
// can't edit standard groups
std::cerr << "(EE) cannot edit standard group with ID " << groupId << std::endl;
return false ;
}
else
{
changed = true;
it->second = groupInfo;
}
}
if (changed)
{
RsServer::notify()->notifyListChange(NOTIFY_LIST_GROUPLIST, NOTIFY_TYPE_MOD);
IndicateConfigChanged();
@ -2537,31 +2545,35 @@ bool p3PeerMgrIMPL::editGroup(const std::string &groupId, RsGroupInfo &groupInfo
return changed;
}
bool p3PeerMgrIMPL::removeGroup(const std::string &groupId)
bool p3PeerMgrIMPL::removeGroup(const RsNodeGroupId& groupId)
{
if (groupId.empty()) {
return false;
}
bool changed = false;
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::list<RsPeerGroupItem*>::iterator groupIt;
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) {
if ((*groupIt)->id == groupId) {
break;
}
}
std::map<RsNodeGroupId,RsGroupInfo>::iterator it = groupList.find(groupId) ;
if (groupIt != groupList.end()) {
if ((*groupIt)->flag & RS_GROUP_FLAG_STANDARD) {
if (it != groupList.end()) {
if (it->second.flag & RS_GROUP_FLAG_STANDARD)
{
// can't remove standard groups
} else {
std::cerr << "(EE) cannot remove standard group with ID " << groupId << std::endl;
return false ;
}
#warning we need to check that the local group is not used. Otherwise deleting it is going to cause problems!
// else if(!it->second.used_gxs_groups.empty())
// {
// std::cerr << "(EE) cannot remove standard group with ID " << groupId << " because it is used in the following groups: " << std::endl;
// for(std::set<RsGxsGroupId>::const_iterator it2(it->second.used_gxs_groups.begin());it2!=it->second.used_gxs_groups.end();++it2)
// std::cerr << " " << *it2 << std::endl;
//
// return false ;
// }
else
{
changed = true;
delete(*groupIt);
groupList.erase(groupIt);
groupList.erase(it);
}
}
}
@ -2575,82 +2587,83 @@ bool p3PeerMgrIMPL::removeGroup(const std::string &groupId)
return changed;
}
bool p3PeerMgrIMPL::getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo)
bool p3PeerMgrIMPL::getGroupInfoByName(const std::string& groupName, RsGroupInfo &groupInfo)
{
if (groupId.empty()) {
return false;
}
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
for(std::map<RsNodeGroupId,RsGroupInfo>::iterator it = groupList.begin();it!=groupList.end();++it)
if(it->second.name == groupName)
{
groupInfo = it->second ;
return true ;
}
std::cerr << "(EE) getGroupInfoByName: no known group for name " << groupName << std::endl;
return false ;
}
bool p3PeerMgrIMPL::getGroupInfo(const RsNodeGroupId& groupId, RsGroupInfo &groupInfo)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::list<RsPeerGroupItem*>::iterator groupIt;
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) {
if ((*groupIt)->id == groupId) {
(*groupIt)->get(groupInfo);
std::map<RsNodeGroupId,RsGroupInfo>::iterator it = groupList.find(groupId) ;
return true;
}
}
if(it == groupList.end())
return false ;
return false;
groupInfo = it->second;
return true;
}
bool p3PeerMgrIMPL::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
bool p3PeerMgrIMPL::getGroupInfoList(std::list<RsGroupInfo>& groupInfoList)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::list<RsPeerGroupItem*>::iterator groupIt;
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) {
RsGroupInfo groupInfo;
(*groupIt)->get(groupInfo);
groupInfoList.push_back(groupInfo);
}
for (std::map<RsNodeGroupId,RsGroupInfo> ::const_iterator groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt)
groupInfoList.push_back(groupIt->second);
return true;
}
// groupId == "" && assign == false -> remove from all groups
bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign)
{
if (groupId.empty() && assign == true) {
return false;
}
// groupId.isNull() && assign == false -> remove from all groups
if (peerIds.empty()) {
bool p3PeerMgrIMPL::assignPeersToGroup(const RsNodeGroupId &groupId, const std::list<RsPgpId> &peerIds, bool assign)
{
if (groupId.isNull() && assign == true)
return false;
if (peerIds.empty())
return false;
}
bool changed = false;
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::list<RsPeerGroupItem*>::iterator groupIt;
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) {
if (groupId.empty() || (*groupIt)->id == groupId) {
RsPeerGroupItem *groupItem = *groupIt;
for (std::map<RsNodeGroupId,RsGroupInfo>::iterator groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt)
if (groupId.isNull() || groupIt->first == groupId)
{
RsGroupInfo& groupItem = groupIt->second;
std::list<RsPgpId>::const_iterator peerIt;
for (peerIt = peerIds.begin(); peerIt != peerIds.end(); ++peerIt) {
std::set<RsPgpId>::iterator peerIt1 = std::find(groupItem->pgpList.ids.begin(), groupItem->pgpList.ids.end(), *peerIt);
if (assign) {
if (peerIt1 == groupItem->pgpList.ids.end()) {
groupItem->pgpList.ids.insert(*peerIt);
changed = true;
}
} else {
if (peerIt1 != groupItem->pgpList.ids.end()) {
groupItem->pgpList.ids.erase(peerIt1);
changed = true;
}
for (std::list<RsPgpId>::const_iterator peerIt = peerIds.begin(); peerIt != peerIds.end(); ++peerIt)
{
std::set<RsPgpId>::iterator peerIt1 = groupItem.peerIds.find(*peerIt);
if (assign)
{
groupItem.peerIds.insert(*peerIt);
changed = true;
}
else
{
groupItem.peerIds.erase(*peerIt);
changed = true;
}
}
if (groupId.empty() == false) {
if (!groupId.isNull())
break;
}
}
}
}
if (changed) {

View File

@ -106,7 +106,7 @@ class peerState
uint32_t maxDnRate ;
};
class RsPeerGroupItem;
class RsNodeGroupItem;
class RsGroupInfo;
std::string textPeerState(peerState &state);
@ -139,11 +139,12 @@ virtual bool removeAllFriendLocations(const RsPgpId &gpgid) = 0;
/* This is solely used by p3peers - makes sense */
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool removeGroup(const std::string &groupId) = 0;
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool editGroup(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool removeGroup(const RsNodeGroupId &groupId) = 0;
virtual bool getGroupInfo(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool getGroupInfoByName(const std::string& groupName, RsGroupInfo &groupInfo) = 0;
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0;
virtual bool assignPeersToGroup(const RsNodeGroupId &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0;
virtual bool resetOwnExternalAddressList() = 0 ;
@ -231,181 +232,182 @@ virtual bool locked_computeCurrentBestOwnExtAddressCandidate(sockaddr_storage
class p3PeerMgrIMPL: public p3PeerMgr, public p3Config
{
public:
public:
/************************************************************************************************/
/* EXTERNAL INTERFACE */
/************************************************************************************************/
/************************************************************************************************/
/* EXTERNAL INTERFACE */
/************************************************************************************************/
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));
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId);
virtual bool removeFriend(const RsPgpId &pgp_id);
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));
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId);
virtual bool removeFriend(const RsPgpId &pgp_id);
virtual bool isFriend(const RsPeerId &ssl_id);
virtual bool isFriend(const RsPeerId &ssl_id);
virtual bool getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId> &ids);
virtual bool removeAllFriendLocations(const RsPgpId &gpgid);
virtual bool getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId> &ids);
virtual bool removeAllFriendLocations(const RsPgpId &gpgid);
/******************** Groups **********************/
/* This is solely used by p3peers - makes sense */
/******************** Groups **********************/
/* This is solely used by p3peers - makes sense */
virtual bool addGroup(RsGroupInfo &groupInfo);
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
virtual bool removeGroup(const std::string &groupId);
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign);
virtual bool addGroup(RsGroupInfo &groupInfo);
virtual bool editGroup(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo);
virtual bool removeGroup(const RsNodeGroupId &groupId);
virtual bool getGroupInfo(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo);
virtual bool getGroupInfoByName(const std::string& groupName, RsGroupInfo &groupInfo) ;
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
virtual bool assignPeersToGroup(const RsNodeGroupId &groupId, const std::list<RsPgpId> &peerIds, bool assign);
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) ;
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) ;
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) ;
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) ;
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) ;
/**************** Set Net Info ****************/
/*
* These functions are used by:
* 1) p3linkmgr
* 2) p3peers - reasonable
* 3) p3disc - reasonable
*/
/**************** Set Net Info ****************/
/*
* These functions are used by:
* 1) p3linkmgr
* 2) p3peers - reasonable
* 3) p3disc - reasonable
*/
virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
virtual bool addCandidateForOwnExternalAddress(const RsPeerId& from, const struct sockaddr_storage &addr) ;
virtual bool getExtAddressReportedByFriends(struct sockaddr_storage& addr, uint8_t &isstable) ;
virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
virtual bool addCandidateForOwnExternalAddress(const RsPeerId& from, const struct sockaddr_storage &addr) ;
virtual bool getExtAddressReportedByFriends(struct sockaddr_storage& addr, uint8_t &isstable) ;
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
virtual bool setLocation(const RsPeerId &pid, const std::string &location);
virtual bool setHiddenDomainPort(const RsPeerId &id, const std::string &domain_addr, const uint16_t domain_port);
virtual bool updateCurrentAddress(const RsPeerId& id, const pqiIpAddress &addr);
virtual bool updateLastContact(const RsPeerId& id);
virtual bool updateAddressList(const RsPeerId& id, const pqiIpAddrSet &addrs);
virtual bool setLocation(const RsPeerId &pid, const std::string &location);
virtual bool setHiddenDomainPort(const RsPeerId &id, const std::string &domain_addr, const uint16_t domain_port);
virtual bool updateCurrentAddress(const RsPeerId& id, const pqiIpAddress &addr);
virtual bool updateLastContact(const RsPeerId& id);
virtual bool updateAddressList(const RsPeerId& id, const pqiIpAddrSet &addrs);
virtual bool resetOwnExternalAddressList() ;
// THIS MUST ONLY BE CALLED BY NETMGR!!!!
virtual bool UpdateOwnAddress(const struct sockaddr_storage &local_addr, const struct sockaddr_storage &ext_addr);
/**************** Net Status Info ****************/
/*
* MUST RATIONALISE THE DATA FROM THESE FUNCTIONS
* These functions are used by:
* 1) p3face-config ... to remove!
* 2) p3peers - reasonable
* 3) p3disc - reasonable
*/
// THIS MUST ONLY BE CALLED BY NETMGR!!!!
virtual bool UpdateOwnAddress(const struct sockaddr_storage &local_addr, const struct sockaddr_storage &ext_addr);
/**************** Net Status Info ****************/
/*
* MUST RATIONALISE THE DATA FROM THESE FUNCTIONS
* These functions are used by:
* 1) p3face-config ... to remove!
* 2) p3peers - reasonable
* 3) p3disc - reasonable
*/
virtual bool getOwnNetStatus(peerState &state);
virtual bool getFriendNetStatus(const RsPeerId &id, peerState &state);
virtual bool getOthersNetStatus(const RsPeerId &id, peerState &state);
virtual bool getOwnNetStatus(peerState &state);
virtual bool getFriendNetStatus(const RsPeerId &id, peerState &state);
virtual bool getOthersNetStatus(const RsPeerId &id, peerState &state);
virtual bool getPeerName(const RsPeerId& ssl_id, std::string& name);
virtual bool getGpgId(const RsPeerId& sslId, RsPgpId& gpgId);
virtual uint32_t getConnectionType(const RsPeerId& sslId);
virtual bool getPeerName(const RsPeerId& ssl_id, std::string& name);
virtual bool getGpgId(const RsPeerId& sslId, RsPgpId& gpgId);
virtual uint32_t getConnectionType(const RsPeerId& sslId);
virtual bool setProxyServerAddress(const uint32_t type, const struct sockaddr_storage &proxy_addr);
virtual bool getProxyServerAddress(const uint32_t type, struct sockaddr_storage &proxy_addr);
virtual bool getProxyServerStatus(const uint32_t type, uint32_t &proxy_status);
virtual bool isHidden();
virtual bool isHidden(const uint32_t type);
virtual bool isHiddenPeer(const RsPeerId &ssl_id);
virtual bool isHiddenPeer(const RsPeerId &ssl_id, const uint32_t type);
virtual bool getProxyAddress(const RsPeerId& ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port);
virtual uint32_t hiddenDomainToHiddenType(const std::string &domain);
virtual uint32_t getHiddenType(const RsPeerId &ssl_id);
virtual bool setProxyServerAddress(const uint32_t type, const struct sockaddr_storage &proxy_addr);
virtual bool getProxyServerAddress(const uint32_t type, struct sockaddr_storage &proxy_addr);
virtual bool getProxyServerStatus(const uint32_t type, uint32_t &proxy_status);
virtual bool isHidden();
virtual bool isHidden(const uint32_t type);
virtual bool isHiddenPeer(const RsPeerId &ssl_id);
virtual bool isHiddenPeer(const RsPeerId &ssl_id, const uint32_t type);
virtual bool getProxyAddress(const RsPeerId& ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port);
virtual uint32_t hiddenDomainToHiddenType(const std::string &domain);
virtual uint32_t getHiddenType(const RsPeerId &ssl_id);
virtual int getFriendCount(bool ssl, bool online);
virtual int getFriendCount(bool ssl, bool online);
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
// Single Use Function... shouldn't be here. used by p3serverconfig.cc
virtual bool haveOnceConnected();
// Single Use Function... shouldn't be here. used by p3serverconfig.cc
virtual bool haveOnceConnected();
virtual bool setMaxRates(const RsPgpId& pid,uint32_t maxUp,uint32_t maxDn);
virtual bool getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn);
virtual bool getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn);
virtual bool setMaxRates(const RsPgpId& pid,uint32_t maxUp,uint32_t maxDn);
virtual bool getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn);
virtual bool getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn);
/************************************************************************************************/
/* Extra IMPL Functions (used by p3LinkMgr, p3NetMgr + Setup) */
/************************************************************************************************/
/************************************************************************************************/
/* Extra IMPL Functions (used by p3LinkMgr, p3NetMgr + Setup) */
/************************************************************************************************/
p3PeerMgrIMPL( const RsPeerId& ssl_own_id,
const RsPgpId& gpg_own_id,
const std::string& gpg_own_name,
const std::string& ssl_own_location) ;
p3PeerMgrIMPL( const RsPeerId& ssl_own_id,
const RsPgpId& gpg_own_id,
const std::string& gpg_own_name,
const std::string& ssl_own_location) ;
void setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr);
void setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr);
bool forceHiddenNode();
bool setupHiddenNode(const std::string &hiddenAddress, const uint16_t hiddenPort);
bool forceHiddenNode();
bool setupHiddenNode(const std::string &hiddenAddress, const uint16_t hiddenPort);
void tick();
void tick();
const RsPeerId& getOwnId();
bool setOwnNetworkMode(uint32_t netMode);
bool setOwnVisState(uint16_t vs_disc, uint16_t vs_dht);
const RsPeerId& getOwnId();
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,
struct sockaddr_storage &lAddr, struct sockaddr_storage &eAddr,
pqiIpAddrSet &histAddrs, std::string &dyndns);
protected:
/* Internal Functions */
/* Internal Functions */
bool removeUnusedLocations();
bool removeBannedIps();
bool removeUnusedLocations();
bool removeBannedIps();
void printPeerLists(std::ostream &out);
void printPeerLists(std::ostream &out);
virtual bool locked_computeCurrentBestOwnExtAddressCandidate(sockaddr_storage &addr, uint32_t &count);
virtual bool locked_computeCurrentBestOwnExtAddressCandidate(sockaddr_storage &addr, uint32_t &count);
protected:
/*****************************************************************/
/*********************** p3config ******************************/
/* Key Functions to be overloaded for Full Configuration */
virtual RsSerialiser *setupSerialiser();
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
virtual void saveDone();
virtual bool loadList(std::list<RsItem *>& load);
/*****************************************************************/
protected:
/*****************************************************************/
/*********************** p3config ******************************/
/* Key Functions to be overloaded for Full Configuration */
virtual RsSerialiser *setupSerialiser();
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
virtual void saveDone();
virtual bool loadList(std::list<RsItem *>& load);
/*****************************************************************/
/* other important managers */
/* other important managers */
p3LinkMgrIMPL *mLinkMgr;
p3NetMgrIMPL *mNetMgr;
p3LinkMgrIMPL *mLinkMgr;
p3NetMgrIMPL *mNetMgr;
private:
RsMutex mPeerMtx; /* protects below */
RsMutex mPeerMtx; /* protects below */
bool mStatusChanged;
bool mStatusChanged;
std::list<pqiMonitor *> clients;
std::list<pqiMonitor *> clients;
peerState mOwnState;
peerState mOwnState;
std::map<RsPeerId, peerState> mFriendList; // <SSLid , peerState>
std::map<RsPeerId, peerState> mOthersList;
std::map<RsPeerId, peerState> mFriendList; // <SSLid , peerState>
std::map<RsPeerId, peerState> mOthersList;
std::map<RsPeerId,sockaddr_storage> mReportedOwnAddresses ;
std::list<RsPeerGroupItem *> groupList;
uint32_t lastGroupId;
std::map<RsPeerId,sockaddr_storage> mReportedOwnAddresses ;
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
std::map<RsNodeGroupId,RsGroupInfo> groupList;
uint32_t lastGroupId;
std::map<RsPgpId, ServicePermissionFlags> mFriendsPermissionFlags ; // permission flags for each gpg key
std::map<RsPgpId, PeerBandwidthLimits> mPeerBandwidthLimits ; // bandwidth limits for each gpg key
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
struct sockaddr_storage mProxyServerAddressTor;
struct sockaddr_storage mProxyServerAddressI2P;
uint32_t mProxyServerStatusTor ;
uint32_t mProxyServerStatusI2P ;
std::map<RsPgpId, ServicePermissionFlags> mFriendsPermissionFlags ; // permission flags for each gpg key
std::map<RsPgpId, PeerBandwidthLimits> mPeerBandwidthLimits ; // bandwidth limits for each gpg key
struct sockaddr_storage mProxyServerAddressTor;
struct sockaddr_storage mProxyServerAddressI2P;
uint32_t mProxyServerStatusTor ;
uint32_t mProxyServerStatusI2P ;
};

View File

@ -27,31 +27,10 @@
#ifndef PQI_TOP_HEADER
#define PQI_TOP_HEADER
/* This just includes the standard headers required.
*/
#include "pqi/pqi_base.h"
#include "pqi/pqinetwork.h"
#include "serialiser/rsserial.h"
#include <iostream>
#include <functional>
#include <algorithm>
/********************** SEARCH INTERFACE ***************************/
// this is an interface.... so should be
// classified as virtual = 0;
class SearchInterface
{
public:
SearchInterface() { return; }
virtual ~SearchInterface() { return; }
};
class P3Interface: public SearchInterface
class P3Interface
{
public:
P3Interface() {return; }
@ -61,16 +40,13 @@ virtual int tick() { return 1; }
virtual int status() { return 1; }
virtual int SendRsRawItem(RsRawItem *) = 0;
#ifdef TO_BE_REMOVED
virtual RsRawItem *GetRsRawItem() = 0;
#endif
};
/* interface to allow outgoing messages to be sent directly
* through to the pqiperson, rather than being queued
/**
* @brief Interface to allow outgoing messages to be sent directly through to
* the pqiperson, rather than being queued
*/
class pqiPublisher
{
public:
@ -80,6 +56,4 @@ virtual bool sendItem(RsRawItem *item) = 0;
};
#endif // PQI_TOP_HEADER

View File

@ -115,6 +115,7 @@ virtual void updatePeer(const RsPeerId& id, const struct sockaddr_storage &addr
};
#ifdef RS_USE_DHT_STUNNER
/* this is for the Stunners
*
*
@ -132,7 +133,7 @@ virtual void setRefreshPeriod(int32_t period) = 0;
virtual int tick() = 0; /* for internal accounting */
};
#endif // RS_USE_DHT_STUNNER
#define NETASSIST_KNOWN_PEER_OFFLINE 0x0001
#define NETASSIST_KNOWN_PEER_ONLINE 0x0002

View File

@ -25,16 +25,23 @@
#include "pqi/pqihandler.h"
#include "util/rsdebug.h"
#include "util/rsstring.h"
#include "retroshare/rspeers.h"
#include <stdlib.h>
#include <time.h>
#include <stdlib.h> // for NULL
#include <time.h> // for time, time_t
#include <algorithm> // for sort
#include <iostream> // for dec
#include <string> // for string, char_traits, operator+, bas...
#include <utility> // for pair
#include "pqi/pqi_base.h" // for PQInterface, RsBwRates
#include "retroshare/rsconfig.h" // for RSTrafficClue
#include "retroshare/rsids.h" // for t_RsGenericIdType
#include "retroshare/rspeers.h" // for RsPeers, rsPeers
#include "serialiser/rsserial.h" // for RsItem, RsRawItem
#include "util/rsdebug.h" // for pqioutput, PQL_DEBUG_BASIC, PQL_ALERT
#include "util/rsstring.h" // for rs_sprintf_append
using std::dec;
#include <time.h>
#include <sys/time.h>
#ifdef WINDOWS_SYS
#include <sys/timeb.h>
#endif

View File

@ -26,15 +26,20 @@
#ifndef MRK_PQI_HANDLER_HEADER
#define MRK_PQI_HANDLER_HEADER
#include "pqi/pqi.h"
#include "pqi/pqiqos.h"
#include <stdint.h> // for uint32_t
#include <time.h> // for time_t, NULL
#include <list> // for list
#include <map> // for map
#include "util/rsthreads.h"
#include "retroshare/rstypes.h"
#include "retroshare/rsconfig.h"
#include "pqi/pqi.h" // for P3Interface, pqiPublisher
#include "retroshare/rstypes.h" // for RsPeerId
#include "util/rsthreads.h" // for RsStackMutex, RsMutex
#include <map>
#include <list>
class PQInterface;
class RSTrafficClue;
class RsBwRates;
class RsItem;
class RsRawItem;
class SearchModule
{

View File

@ -23,9 +23,12 @@
*
*/
#include "pqi/pqi.h"
#include "pqi/pqiloopback.h"
#include <stddef.h> // for NULL
class RsItem;
/***
#define LOOPBACK_DEBUG 1
***/

View File

@ -26,12 +26,12 @@
#ifndef MRK_PQI_LOOPBACK_HEADER
#define MRK_PQI_LOOPBACK_HEADER
// The standard data types and the search interface.
#include "pqi/pqi.h"
#include <list> // for list
#include <map>
#include <list>
#include <iostream>
#include "pqi/pqi_base.h" // for NetInterface (ptr only), PQInterface
#include "retroshare/rstypes.h" // for RsPeerId
class RsItem;
class pqiloopback: public PQInterface
{
@ -47,8 +47,7 @@ virtual RsItem *GetItem();
virtual int tick();
virtual int status();
virtual int notifyEvent(NetInterface */*ni*/, int /*event*/) { return 0; } /* Not used */
private:
private:
std::list<RsItem *> objs;
};

View File

@ -243,6 +243,7 @@ int pqiNetStateBox::updateNetState()
void pqiNetStateBox::clearOldNetworkData()
{
#ifdef RS_USE_DHT_STUNNER
/* check if any measurements are too old to consider */
time_t now = time(NULL);
if (now - mStunProxyTS > NETSTATE_PARAM_TIMEOUT)
@ -254,6 +255,14 @@ void pqiNetStateBox::clearOldNetworkData()
{
mStunDhtSet = false;
}
#else
//Set values, as they are not updated.
mStunProxySet = true;
mStunDhtSet = true;
mStunProxyStable = true;
mStunDhtStable = true;
#endif
}

View File

@ -63,8 +63,8 @@ public:
virtual int connect(const struct sockaddr_storage &raddr) { return ni->connect(raddr); }
virtual int listen() { return ni->listen(); }
virtual int stoplistening() { return ni->stoplistening(); }
virtual int reset() { return ni->reset(); }
virtual int disconnect() { return ni->reset(); }
virtual int reset() { pqistreamer::reset(); return ni->reset(); }
virtual int disconnect() { return reset() ; }
virtual bool connect_parameter(uint32_t type, uint32_t value) { return ni->connect_parameter(type, value);}
virtual bool connect_parameter(uint32_t type, std::string value) { return ni->connect_parameter(type, value);}
virtual bool connect_additional_address(uint32_t type, const struct sockaddr_storage &addr) { return ni->connect_additional_address(type, addr); }

View File

@ -25,6 +25,8 @@
#include "pqiqosstreamer.h"
//#define DEBUG_PQIQOSSTREAMER 1
const float pqiQoSstreamer::PQI_QOS_STREAMER_ALPHA = 2.0f ;
pqiQoSstreamer::pqiQoSstreamer(PQInterface *parent, RsSerialiser *rss, const RsPeerId& peerid, BinInterface *bio_in, int bio_flagsin)
@ -60,6 +62,11 @@ void pqiQoSstreamer::locked_storeInOutputQueue(void *ptr,int size,int priority)
void pqiQoSstreamer::locked_clear_out_queue()
{
#ifdef DEBUG_PQIQOSSTREAMER
if(qos_queue_size() > 0)
std::cerr << " pqiQoSstreamer::locked_clear_out_queue(): clearing " << qos_queue_size() << " pending outqueue elements." << std::endl;
#endif
pqiQoS::clear() ;
_total_item_size = 0 ;
_total_item_count = 0 ;

View File

@ -1548,6 +1548,7 @@ int pqissl::senddata(void *data, int len)
#ifdef PQISSL_DEBUG
std::cout << "Sending data thread=" << pthread_self() << ", ssl=" << (void*)this << ", size=" << len << std::endl ;
#endif
ERR_clear_error();
tmppktlen = SSL_write(ssl_connection, data, len) ;
if (len != tmppktlen)
@ -1638,6 +1639,8 @@ int pqissl::readdata(void *data, int len)
#ifdef PQISSL_DEBUG
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) ;
#ifdef PQISSL_DEBUG
std::cerr << "have read " << tmppktlen << " bytes" << std::endl ;
@ -1661,8 +1664,6 @@ int pqissl::readdata(void *data, int len)
int error = SSL_get_error(ssl_connection, tmppktlen);
unsigned long err2 = ERR_get_error();
//printSSLError(ssl_connection, tmppktlen, error, err2, out);
if ((error == SSL_ERROR_ZERO_RETURN) && (err2 == 0))
{
/* this code will be called when
@ -1761,7 +1762,10 @@ int pqissl::readdata(void *data, int len)
rs_sprintf_append(out, "SSL_read() UNKNOWN ERROR: %d Resetting!", error);
rslog(RSL_ALERT, pqisslzone, out);
std::cerr << out << std::endl ;
std::cerr << ", SSL_read() output is " << tmppktlen << std::endl ;
printSSLError(ssl_connection, tmppktlen, error, err2, out);
rslog(RSL_ALERT, pqisslzone, "pqissl::readdata() -> calling reset()");
reset_locked();
return -1;

View File

@ -24,18 +24,25 @@
*/
#include <iostream>
#include <fstream>
#include <time.h>
#include "util/rsdebug.h"
#include "util/rsstring.h"
#include "util/rsprint.h"
#include "util/rsscopetimer.h"
#include "pqi/pqistreamer.h"
#include "rsserver/p3face.h"
#include "serialiser/rsserial.h"
#include <stdlib.h> // for free, realloc, exit
#include <string.h> // for memcpy, memset, memcmp
#include <time.h> // for NULL, time, time_t
#include <algorithm> // for min
#include <iostream> // for operator<<, ostream, basic_ostream
#include <string> // for string, allocator, operator<<, oper...
#include <utility> // for pair
#include "pqi/p3notify.h" // for p3Notify
#include "retroshare/rsids.h" // for operator<<
#include "retroshare/rsnotify.h" // for RS_SYS_WARNING
#include "rsserver/p3face.h" // for RsServer
#include "serialiser/rsserial.h" // for RsItem, RsSerialiser, getRsItemSize
#include "util/rsdebug.h" // for pqioutput, PQL_ALERT, PQL_DEBUG_ALL
#include "util/rsmemory.h" // for rs_malloc
#include "util/rsprint.h" // for BinToHex
#include "util/rsstring.h" // for rs_sprintf_append, rs_sprintf
static struct RsLog::logInfo pqistreamerzoneInfo = {RsLog::Default, "pqistreamer"};
#define pqistreamerzone &pqistreamerzoneInfo
@ -135,17 +142,7 @@ pqistreamer::~pqistreamer()
if (mRsSerialiser)
delete mRsSerialiser;
// clean up outgoing. (cntrl packets)
locked_clear_out_queue() ;
if (mPkt_wpending)
{
free(mPkt_wpending);
mPkt_wpending = NULL;
mPkt_wpending_size = 0 ;
}
free_rpend_locked();
free_pend_locked();
// clean up incoming.
while(!mIncoming.empty())
@ -156,6 +153,7 @@ pqistreamer::~pqistreamer()
delete i;
}
if(mIncomingSize != 0)
std::cerr << "(EE) inconsistency after deleting pqistreamer queue. Remaining items: " << mIncomingSize << std::endl;
return;
@ -282,7 +280,7 @@ int pqistreamer::tick_recv(uint32_t timeout)
}
if(!(mBio->isactive()))
{
free_rpend_locked();
free_pend_locked();
}
return 1;
}
@ -295,6 +293,7 @@ int pqistreamer::tick_send(uint32_t timeout)
/* short circuit everything is bio isn't active */
if (!(mBio->isactive()))
{
free_pend_locked();
return 0;
}
@ -690,7 +689,7 @@ int pqistreamer::handleincoming_locked()
if(!(mBio->isactive()))
{
mReading_state = reading_state_initial ;
free_rpend_locked();
free_pend_locked();
return 0;
}
else
@ -762,7 +761,7 @@ start_packet_read:
}
}
#ifdef DEBUG_PQISTREAMER
std::cerr << "[" << (void*)pthread_self() << "] " << "block 0 : " << RsUtil::BinToHex(block,8) << std::endl;
std::cerr << "[" << (void*)pthread_self() << "] " << "block 0 : " << RsUtil::BinToHex((unsigned char*)block,8) << std::endl;
#endif
readbytes += blen;
@ -806,12 +805,12 @@ continue_packet:
else
extralen = getRsItemSize(block) - blen; // old style packet type
#ifdef DEBUG_PQISTREAMER
#ifdef DEBUG_PACKET_SLICING
std::cerr << "[" << (void*)pthread_self() << "] " << "continuing packet getRsItemSize(block) = " << getRsItemSize(block) << std::endl ;
std::cerr << "[" << (void*)pthread_self() << "] " << "continuing packet extralen = " << extralen << std::endl ;
std::cerr << "[" << (void*)pthread_self() << "] " << "continuing packet state=" << mReading_state << std::endl ;
std::cerr << "[" << (void*)pthread_self() << "] " << "block 1 : " << RsUtil::BinToHex(block,8) << std::endl;
std::cerr << "[" << (void*)pthread_self() << "] " << "block 1 : " << RsUtil::BinToHex((unsigned char*)block,8) << std::endl;
#endif
if (extralen + (uint32_t)blen > maxlen)
{
@ -874,7 +873,7 @@ continue_packet:
if (extralen != (uint32_t)(tmplen = mBio->readdata(extradata, extralen)))
{
#ifdef DEBUG_PQISTREAMER
#ifdef DEBUG_PACKET_SLICING
if(tmplen > 0)
std::cerr << "[" << (void*)pthread_self() << "] " << "Incomplete packet read ! This is a real problem ;-)" << std::endl ;
#endif
@ -921,9 +920,9 @@ continue_packet:
// we assume readdata() returned either -1 or the complete read size.
}
}
#ifdef DEBUG_PQISTREAMER
#ifdef DEBUG_PACKET_SLICING
std::cerr << "[" << (void*)pthread_self() << "] " << "continuing packet state=" << mReading_state << std::endl ;
std::cerr << "[" << (void*)pthread_self() << "] " << "block 2 : " << RsUtil::BinToHex(extradata,8) << std::endl;
std::cerr << "[" << (void*)pthread_self() << "] " << "block 2 : " << RsUtil::BinToHex((unsigned char*)extradata,8) << std::endl;
#endif
mFailed_read_attempts = 0 ;
@ -952,7 +951,7 @@ continue_packet:
std::cerr << "Inputing partial packet " << RsUtil::BinToHex((char*)block,8) << std::endl;
#endif
uint32_t packet_length = 0 ;
pkt = addPartialPacket(block,pktlen,slice_packet_id,is_packet_starting,is_packet_ending,packet_length) ;
pkt = addPartialPacket_locked(block,pktlen,slice_packet_id,is_packet_starting,is_packet_ending,packet_length) ;
pktlen = packet_length ;
}
@ -997,7 +996,7 @@ continue_packet:
return 0;
}
RsItem *pqistreamer::addPartialPacket(const void *block, uint32_t len, uint32_t slice_packet_id, bool is_packet_starting, bool is_packet_ending, uint32_t &total_len)
RsItem *pqistreamer::addPartialPacket_locked(const void *block, uint32_t len, uint32_t slice_packet_id, bool is_packet_starting, bool is_packet_ending, uint32_t &total_len)
{
#ifdef DEBUG_PACKET_SLICING
std::cerr << "Receiving partial packet. size=" << len << ", ID=" << std::hex << slice_packet_id << std::dec << ", starting:" << is_packet_starting << ", ending:" << is_packet_ending ;
@ -1180,7 +1179,7 @@ void pqistreamer::outSentBytes_locked(uint32_t outb)
#ifdef DEBUG_PQISTREAMER
{
std::string out;
rs_sprintf(out, "pqistreamer::outSentBytes(): %d@%gkB/s", outb, getRate(false));
rs_sprintf(out, "pqistreamer::outSentBytes(): %d@%gkB/s", outb, RateInterface::getRate(false));
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out);
}
#endif
@ -1210,7 +1209,7 @@ void pqistreamer::inReadBytes_locked(uint32_t inb)
#ifdef DEBUG_PQISTREAMER
{
std::string out;
rs_sprintf(out, "pqistreamer::inReadBytes(): %d@%gkB/s", inb, getRate(true));
rs_sprintf(out, "pqistreamer::inReadBytes(): %d@%gkB/s", inb, RateInterface::getRate(true));
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out);
}
#endif
@ -1237,14 +1236,53 @@ void pqistreamer::allocate_rpend_locked()
memset(mPkt_rpending,0,mPkt_rpend_size) ;
}
void pqistreamer::free_rpend_locked()
{
if(!mPkt_rpending)
return;
// clean everything that is half-finished, to avoid causing issues when re-connecting later on.
free(mPkt_rpending);
mPkt_rpending = 0;
mPkt_rpend_size = 0;
int pqistreamer::reset()
{
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
#ifdef DEBUG_PQISTREAMER
std::cerr << "pqistreamer::reset()" << std::endl;
#endif
free_pend_locked();
return 1 ;
}
void pqistreamer::free_pend_locked()
{
if(mPkt_rpending)
{
#ifdef DEBUG_PQISTREAMER
std::cerr << "pqistreamer::free_pend_locked(): pending input packet buffer" << std::endl;
#endif
free(mPkt_rpending);
mPkt_rpending = 0;
}
mPkt_rpend_size = 0;
if (mPkt_wpending)
{
#ifdef DEBUG_PQISTREAMER
std::cerr << "pqistreamer::free_pend_locked(): pending output packet buffer" << std::endl;
#endif
free(mPkt_wpending);
mPkt_wpending = NULL;
}
mPkt_wpending_size = 0 ;
#ifdef DEBUG_PQISTREAMER
if(!mPartialPackets.empty())
std::cerr << "pqistreamer::free_pend_locked(): " << mPartialPackets.size() << " pending input partial packets" << std::endl;
#endif
// also delete any incoming partial packet
for(std::map<uint32_t,PartialPacketRecord>::iterator it(mPartialPackets.begin());it!=mPartialPackets.end();++it)
free(it->second.mem) ;
mPartialPackets.clear() ;
// clean up outgoing. (cntrl packets)
locked_clear_out_queue() ;
}
int pqistreamer::gatherStatistics(std::list<RSTrafficClue>& outqueue_lst,std::list<RSTrafficClue>& inqueue_lst)

View File

@ -27,18 +27,19 @@
#ifndef MRK_PQI_STREAMER_HEADER
#define MRK_PQI_STREAMER_HEADER
// Only dependent on the base stuff.
#include "pqi/pqi_base.h"
#include "util/rsthreads.h"
#include "retroshare/rstypes.h"
#include <stdint.h> // for uint32_t
#include <time.h> // for time_t
#include <iostream> // for operator<<, basic_ostream, cerr, endl
#include <list> // for list
#include <map> // for map
#include <list>
#include "pqi/pqi_base.h" // for BinInterface (ptr only), PQInterface
#include "retroshare/rsconfig.h" // for RSTrafficClue
#include "retroshare/rstypes.h" // for RsPeerId
#include "util/rsthreads.h" // for RsMutex
// Fully implements the PQInterface.
// and communicates with peer etc via the BinInterface.
//
// The interface does not handle connection, just communication.
// possible bioflags: BIN_FLAGS_NO_CLOSE | BIN_FLAGS_NO_DELETE
class RsItem;
class RsSerialiser;
struct PartialPacketRecord
{
@ -46,6 +47,12 @@ struct PartialPacketRecord
uint32_t size ;
};
/**
* @brief Fully implements the PQInterface and communicates with peer etc via
* the BinInterface.
* The interface does not handle connection, just communication.
* Possible BIN_FLAGS: BIN_FLAGS_NO_CLOSE | BIN_FLAGS_NO_DELETE
*/
class pqistreamer: public PQInterface
{
public:
@ -74,6 +81,7 @@ class pqistreamer: public PQInterface
virtual float getRate(bool b) ;
protected:
virtual int reset() ;
int tick_bio();
int tick_send(uint32_t timeout);
@ -117,7 +125,8 @@ class pqistreamer: public PQInterface
int inAllowedBytes_locked();
void inReadBytes_locked(uint32_t );
// cleans up everything that's pending / half finished.
void free_pend_locked();
// RsSerialiser - determines which packets can be serialised.
RsSerialiser *mRsSerialiser;
@ -126,7 +135,7 @@ class pqistreamer: public PQInterface
uint32_t mPkt_wpending_size; // ... and its size.
void allocate_rpend_locked(); // use these two functions to allocate/free the buffer below
void free_rpend_locked();
int mPkt_rpend_size; // size of pkt_rpending.
void *mPkt_rpending; // storage for read in pending packets.
@ -170,7 +179,7 @@ class pqistreamer: public PQInterface
bool mAcceptsPacketSlicing ;
time_t mLastSentPacketSlicingProbe ;
void locked_addTrafficClue(const RsItem *pqi, uint32_t pktsize, std::list<RSTrafficClue> &lst);
RsItem *addPartialPacket(const void *block, uint32_t len, uint32_t slice_packet_id,bool packet_starting,bool packet_ending,uint32_t& total_len);
RsItem *addPartialPacket_locked(const void *block, uint32_t len, uint32_t slice_packet_id,bool packet_starting,bool packet_ending,uint32_t& total_len);
std::map<uint32_t,PartialPacketRecord> mPartialPackets ;
};

View File

@ -99,7 +99,7 @@ struct SharedDirInfo
std::string filename ;
std::string virtualname ;
FileStorageFlags shareflags ; // DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_GROUPS | ...
std::list<std::string> parent_groups ;
std::list<RsNodeGroupId> parent_groups ;
};
class RsFiles

View File

@ -103,9 +103,6 @@ public:
//===================================================//
virtual void addRoutingClue(const GRouterKeyId& destination, const RsPeerId& source) =0;
virtual void addTrackingInfo(const RsGxsMessageId& mid,const RsPeerId& peer_id) =0;
virtual bool getTrackingInfo(const RsGxsMessageId& mid, RsPeerId& provider_id) =0;
};
// To access the GRouter from anywhere

View File

@ -33,7 +33,8 @@ namespace GXS_SERV {
static const uint32_t FLAG_AUTHOR_AUTHENTICATION_GPG = 0x00000100;
static const uint32_t FLAG_AUTHOR_AUTHENTICATION_REQUIRED = 0x00000200;
static const uint32_t FLAG_AUTHOR_AUTHENTICATION_IFNOPUBSIGN = 0x00000400;
static const uint32_t FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES = 0x00000800;
static const uint32_t FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES = 0x00000800; // not used anymore
static const uint32_t FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN = 0x00001000;
static const uint32_t FLAG_GROUP_SIGN_PUBLISH_MASK = 0x000000ff;
static const uint32_t FLAG_GROUP_SIGN_PUBLISH_ENCRYPTED = 0x00000001;
@ -105,6 +106,7 @@ namespace GXS_SERV {
#define IS_MSG_UNPROCESSED(status) (status & GXS_SERV::GXS_MSG_STATUS_UNPROCESSED)
#define IS_GROUP_PGP_AUTHED(signFlags) (signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG)
#define IS_GROUP_PGP_KNOWN_AUTHED(signFlags) (signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN)
#define IS_GROUP_MESSAGE_TRACKING(signFlags) (signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES)
#define IS_GROUP_ADMIN(subscribeFlags) (subscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN)

View File

@ -62,6 +62,7 @@ extern RsIdentity *rsIdentity;
// Unicode symbols. NOT utf-8 bytes, because of multi byte characters
#define RSID_MAXIMUM_NICKNAME_SIZE 30
#define RSID_MINIMUM_NICKNAME_SIZE 2
std::string rsIdTypeToString(uint32_t idtype);
@ -221,46 +222,48 @@ public:
RsIdentity(RsGxsIface *gxs): RsGxsIfaceHelper(gxs) { return; }
virtual ~RsIdentity() { return; }
/********************************************************************************************/
/********************************************************************************************/
// For Other Services....
// It should be impossible for them to get a message which we don't have the identity.
// Its a major error if we don't have the identity.
/********************************************************************************************/
/********************************************************************************************/
// We cache all identities, and provide alternative (instantaneous)
// functions to extract info, rather than the standard Token system.
// For Other Services....
// It should be impossible for them to get a message which we don't have the identity.
// Its a major error if we don't have the identity.
//virtual bool getNickname(const RsGxsId &id, std::string &nickname) = 0;
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details) = 0;
// We cache all identities, and provide alternative (instantaneous)
// functions to extract info, rather than the standard Token system.
// Fills up list of all own ids. Returns false if ids are not yet loaded.
virtual bool getOwnIds(std::list<RsGxsId> &ownIds) = 0;
virtual bool isOwnId(const RsGxsId& id) = 0;
//virtual bool getNickname(const RsGxsId &id, std::string &nickname) = 0;
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details) = 0;
//
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,
bool absOpinion, int score) = 0;
virtual bool createIdentity(uint32_t& token, RsIdentityParameters &params) = 0;
// Fills up list of all own ids. Returns false if ids are not yet loaded.
virtual bool getOwnIds(std::list<RsGxsId> &ownIds) = 0;
virtual bool isOwnId(const RsGxsId& id) = 0;
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
//
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,
bool absOpinion, int score) = 0;
virtual bool createIdentity(uint32_t& token, RsIdentityParameters &params) = 0;
virtual bool parseRecognTag(const RsGxsId &id, const std::string &nickname,
const std::string &tag, RsRecognTagDetails &details) = 0;
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
uint16_t tag_class, uint16_t tag_type, std::string &tag) = 0;
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
virtual bool parseRecognTag(const RsGxsId &id, const std::string &nickname,
const std::string &tag, RsRecognTagDetails &details) = 0;
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
uint16_t tag_class, uint16_t tag_type, std::string &tag) = 0;
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
virtual bool isARegularContact(const RsGxsId& id) = 0 ;
// Specific RsIdentity Functions....
/* Specific Service Data */
/* We expose these initially for testing / GUI purposes.
virtual bool isBanned(const RsGxsId& id) =0;
virtual time_t getLastUsageTS(const RsGxsId &id) =0;
// Specific RsIdentity Functions....
/* Specific Service Data */
/* We expose these initially for testing / GUI purposes.
*/
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups) = 0;
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions) = 0;
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups) = 0;
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions) = 0;
};

View File

@ -73,14 +73,13 @@ template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> c
memcpy(bytes,id.toByteArray(),ID_SIZE_IN_BYTES) ;
}
// Random initialization. Can be useful for testing.
// Random initialization. Can be useful for testing and to generate new ids.
//
static t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER> random()
{
t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER> id ;
for(uint32_t i=0;i<ID_SIZE_IN_BYTES;++i)
id.bytes[i] = RSRandom::random_u32() & 0xff ;
RSRandom::random_bytes(id.bytes,ID_SIZE_IN_BYTES) ;
return id ;
}
@ -163,8 +162,8 @@ template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> t
int n=0;
if(s.length() != ID_SIZE_IN_BYTES*2)
{
if(!s.empty())
std::cerr << "t_RsGenericIdType<>::t_RsGenericIdType(std::string&): supplied string in constructor has wrong size. Expected ID size=" << ID_SIZE_IN_BYTES << " String=\"" << s << "\"" << std::endl;
if(!s.empty())
std::cerr << "t_RsGenericIdType<>::t_RsGenericIdType(std::string&): supplied string in constructor has wrong size. Expected ID size=" << ID_SIZE_IN_BYTES*2 << " String=\"" << s << "\" = " << s.length() << std::endl;
clear();
return;
@ -220,6 +219,7 @@ static const uint32_t RS_GENERIC_ID_GXS_CIRCLE_ID_TYPE = 0x0008 ;
static const uint32_t RS_GENERIC_ID_GROUTER_ID_TYPE = 0x0009 ;
static const uint32_t RS_GENERIC_ID_GXS_TUNNEL_ID_TYPE = 0x0010 ;
static const uint32_t RS_GENERIC_ID_GXS_DISTANT_CHAT_ID_TYPE = 0x0011 ;
static const uint32_t RS_GENERIC_ID_NODE_GROUP_ID_TYPE = 0x0012 ;
typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_SSL_ID_TYPE> SSLIdType ;
typedef t_RsGenericIdType< PGP_KEY_ID_SIZE , true, RS_GENERIC_ID_PGP_ID_TYPE> PGPIdType ;
@ -231,4 +231,5 @@ typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_GXS_I
typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_GXS_CIRCLE_ID_TYPE > GXSCircleId ;
typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_GXS_TUNNEL_ID_TYPE > GXSTunnelId ;
typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_GXS_DISTANT_CHAT_ID_TYPE > DistantChatPeerId ;
typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_NODE_GROUP_ID_TYPE > RsNodeGroupId ;

View File

@ -229,12 +229,12 @@ class NotifyClient
virtual void notifyPeerStatusChangedSummary () {}
virtual void notifyDiscInfoChanged () {}
virtual bool askForDeferredSelfSignature (const void * /* data */, const uint32_t /* len */, unsigned char * /* sign */, unsigned int * /* signlen */,int& signature_result ) { signature_result = false ;return true; }
virtual bool askForDeferredSelfSignature (const void * /* data */, const uint32_t /* len */, unsigned char * /* sign */, unsigned int * /* signlen */,int& signature_result , std::string /*reason = ""*/) { signature_result = false ;return true; }
virtual void notifyDownloadComplete (const std::string& /* fileHash */) {}
virtual void notifyDownloadCompleteCount (uint32_t /* count */) {}
virtual void notifyHistoryChanged (uint32_t /* msgId */, int /* type */) {}
virtual bool askForPassword (const std::string& /* key_details */, bool /* prev_is_bad */, std::string& /* password */,bool& /* cancelled */ ) { return false ;}
virtual bool askForPassword (const std::string& /* title */, const std::string& /* key_details */, bool /* prev_is_bad */, std::string& /* password */,bool& /* cancelled */ ) { return false ;}
virtual bool askForPluginConfirmation (const std::string& /* plugin_filename */, const std::string& /* plugin_file_hash */) { return false ;}
};

View File

@ -185,11 +185,17 @@ const uint32_t RS_NET_PROXY_STATUS_OK = 0x0001 ;
/* Groups */
#define RS_GROUP_ID_FRIENDS "Friends"
#define RS_GROUP_ID_FAMILY "Family"
#define RS_GROUP_ID_COWORKERS "Co-Workers"
#define RS_GROUP_ID_OTHERS "Other Contacts"
#define RS_GROUP_ID_FAVORITES "Favorites"
static const RsNodeGroupId RS_GROUP_ID_FRIENDS ("00000000000000000000000000000001");
static const RsNodeGroupId RS_GROUP_ID_FAMILY ("00000000000000000000000000000002");
static const RsNodeGroupId RS_GROUP_ID_COWORKERS ("00000000000000000000000000000003");
static const RsNodeGroupId RS_GROUP_ID_OTHERS ("00000000000000000000000000000004");
static const RsNodeGroupId RS_GROUP_ID_FAVORITES ("00000000000000000000000000000005");
#define RS_GROUP_DEFAULT_NAME_FRIENDS "Friends"
#define RS_GROUP_DEFAULT_NAME_FAMILY "Family"
#define RS_GROUP_DEFAULT_NAME_COWORKERS "Co-Workers"
#define RS_GROUP_DEFAULT_NAME_OTHERS "Other Contacts"
#define RS_GROUP_DEFAULT_NAME_FAVORITES "Favorites"
const uint32_t RS_GROUP_FLAG_STANDARD = 0x0001;
@ -295,7 +301,7 @@ class RsGroupInfo
public:
RsGroupInfo();
std::string id;
RsNodeGroupId id;
std::string name;
uint32_t flag;
@ -346,7 +352,7 @@ public:
virtual bool getGPGValidList(std::list<RsPgpId> &gpg_ids) = 0;
virtual bool getGPGAllList(std::list<RsPgpId> &gpg_ids) = 0;
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId>& ids) = 0;
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) = 0;
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, std::string reason = "") = 0;
/* Add/Remove Friends */
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT) = 0;
@ -399,14 +405,15 @@ public:
virtual bool trustGPGCertificate(const RsPgpId &gpg_id, uint32_t trustlvl) = 0;
/* Group Stuff */
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool removeGroup(const std::string &groupId) = 0;
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
virtual bool addGroup(RsGroupInfo& groupInfo) = 0;
virtual bool editGroup(const RsNodeGroupId& groupId, RsGroupInfo& groupInfo) = 0;
virtual bool removeGroup(const RsNodeGroupId& groupId) = 0;
virtual bool getGroupInfo(const RsNodeGroupId& groupId, RsGroupInfo& groupInfo) = 0;
virtual bool getGroupInfoByName(const std::string& groupId, RsGroupInfo& groupInfo) = 0;
virtual bool getGroupInfoList(std::list<RsGroupInfo>& groupInfoList) = 0;
// groupId == "" && assign == false -> remove from all groups
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId& peerId, bool assign) = 0;
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0;
virtual bool assignPeerToGroup(const RsNodeGroupId& groupId, const RsPgpId& peerId, bool assign) = 0;
virtual bool assignPeersToGroup(const RsNodeGroupId& groupId, const std::list<RsPgpId>& peerIds, bool assign) = 0;
/* Group sharing permission */
@ -421,7 +428,7 @@ public:
//
virtual FileSearchFlags computePeerPermissionFlags(
const RsPeerId& peer_id, FileStorageFlags file_sharing_flags,
const std::list<std::string>& file_parent_groups) = 0;
const std::list<RsNodeGroupId>& file_parent_groups) = 0;
/* Service permission flags */

View File

@ -83,6 +83,7 @@ virtual ~RsPosted() { return; }
/* Specific Service Data */
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups) = 0;
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts, std::vector<RsGxsComment> &cmts) = 0;
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts) = 0;
//Not currently used
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts) = 0;

View File

@ -50,14 +50,25 @@ public:
};
virtual bool setOwnOpinion(const RsGxsId& key_id, const Opinion& op) =0;
virtual bool getReputationInfo(const RsGxsId& id,ReputationInfo& info) =0 ;
virtual void setNodeAutoBanThreshold(uint32_t n) =0;
virtual uint32_t nodeAutoBanThreshold() =0;
virtual bool getReputationInfo(const RsGxsId& id, const RsPgpId &ownerNode, ReputationInfo& info) =0;
// parameters
// virtual void setNodeAutoBanThreshold(uint32_t n) =0;
// virtual uint32_t nodeAutoBanThreshold() =0;
virtual void setNodeAutoPositiveOpinionForContacts(bool b) =0;
virtual bool nodeAutoPositiveOpinionForContacts() =0;
virtual float nodeAutoBanIdentitiesLimit() =0;
virtual void setNodeAutoBanIdentitiesLimit(float f) =0;
// This one is a proxy designed to allow fast checking of a GXS id.
// it basically returns true if assessment is not ASSESSMENT_OK
virtual bool isIdentityBanned(const RsGxsId& id) =0;
virtual bool isIdentityBanned(const RsGxsId& id) =0;
virtual bool isNodeBanned(const RsPgpId& id) =0;
virtual void banNode(const RsPgpId& id,bool b) =0;
};
// To access reputations from anywhere

View File

@ -212,7 +212,7 @@ class FileInfo
DwlSpeed priority ;
time_t lastTS;
std::list<std::string> parent_groups ;
std::list<RsNodeGroupId> parent_groups ;
};
std::ostream &operator<<(std::ostream &out, const FileInfo& info);
@ -236,14 +236,14 @@ public:
RsPeerId id;
std::string name;
RsFileHash hash;
std::string path;
uint64_t count;
uint32_t age;
FileStorageFlags flags;
uint32_t min_age ; // minimum age of files in this subtree
std::string path;
uint64_t count;
uint32_t age;
FileStorageFlags flags;
uint32_t min_age ; // minimum age of files in this subtree
std::vector<DirStub> children;
std::list<std::string> parent_groups; // parent groups for the shared directory
std::list<DirStub> children;
std::list<RsNodeGroupId> parent_groups; // parent groups for the shared directory
};
std::ostream &operator<<(std::ostream &out, const DirDetails& details);

View File

@ -1,8 +1,7 @@
#define RS_MAJOR_VERSION 0
#define RS_MINOR_VERSION 6
#define RS_BUILD_NUMBER 0
#define RS_BUILD_NUMBER 1
#define RS_BUILD_NUMBER_ADD "x" // <-- do we need this?
// The revision number should be the 4 first bytes of the git revision hash, which is obtained using:
// git log --pretty="%H" | head -1 | cut -c1-8
//

View File

@ -1,6 +1,6 @@
#define RS_MAJOR_VERSION 0
#define RS_MINOR_VERSION 6
#define RS_BUILD_NUMBER 0
#define RS_BUILD_NUMBER 1
#define RS_BUILD_NUMBER_ADD ""
// The revision number should be the 4 first bytes of the git revision hash, which is obtained using:

View File

@ -635,9 +635,9 @@ bool p3Peers::getAssociatedSSLIds(const RsPgpId &gpg_id, std::list<RsPeerId> &id
return mPeerMgr->getAssociatedPeers(gpg_id, ids);
}
bool p3Peers::gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen)
bool p3Peers::gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, std::string reason /* = "" */)
{
return AuthGPG::getAuthGPG()->SignDataBin(data,len,sign,signlen);
return AuthGPG::getAuthGPG()->SignDataBin(data,len,sign,signlen, reason);
}
bool p3Peers::getGPGDetails(const RsPgpId &pgp_id, RsPeerDetails &d)
@ -1280,7 +1280,7 @@ bool p3Peers::addGroup(RsGroupInfo &groupInfo)
return res ;
}
bool p3Peers::editGroup(const std::string &groupId, RsGroupInfo &groupInfo)
bool p3Peers::editGroup(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::editGroup()" << std::endl;
@ -1292,7 +1292,7 @@ bool p3Peers::editGroup(const std::string &groupId, RsGroupInfo &groupInfo)
return res ;
}
bool p3Peers::removeGroup(const std::string &groupId)
bool p3Peers::removeGroup(const RsNodeGroupId &groupId)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeGroup()" << std::endl;
@ -1303,7 +1303,15 @@ bool p3Peers::removeGroup(const std::string &groupId)
return res ;
}
bool p3Peers::getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo)
bool p3Peers::getGroupInfoByName(const std::string& groupName, RsGroupInfo &groupInfo)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getGroupInfo()" << std::endl;
#endif
return mPeerMgr->getGroupInfoByName(groupName, groupInfo);
}
bool p3Peers::getGroupInfo(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getGroupInfo()" << std::endl;
@ -1321,7 +1329,7 @@ bool p3Peers::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
return mPeerMgr->getGroupInfoList(groupInfoList);
}
bool p3Peers::assignPeerToGroup(const std::string &groupId, const RsPgpId& peerId, bool assign)
bool p3Peers::assignPeerToGroup(const RsNodeGroupId &groupId, const RsPgpId& peerId, bool assign)
{
std::list<RsPgpId> peerIds;
peerIds.push_back(peerId);
@ -1329,7 +1337,7 @@ bool p3Peers::assignPeerToGroup(const std::string &groupId, const RsPgpId& peerI
return assignPeersToGroup(groupId, peerIds, assign);
}
bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign)
bool p3Peers::assignPeersToGroup(const RsNodeGroupId &groupId, const std::list<RsPgpId> &peerIds, bool assign)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::assignPeersToGroup()" << std::endl;
@ -1343,7 +1351,7 @@ bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<RsP
FileSearchFlags p3Peers::computePeerPermissionFlags(const RsPeerId& peer_ssl_id,
FileStorageFlags share_flags,
const std::list<std::string>& directory_parent_groups)
const std::list<RsNodeGroupId>& directory_parent_groups)
{
// We should be able to do that in O(1), using groups based on packs of bits.
//
@ -1354,7 +1362,7 @@ FileSearchFlags p3Peers::computePeerPermissionFlags(const RsPeerId& peer_ssl_id,
bool found = false ;
RsPgpId pgp_id = getGPGId(peer_ssl_id) ;
for(std::list<std::string>::const_iterator it(directory_parent_groups.begin());it!=directory_parent_groups.end() && !found;++it)
for(std::list<RsNodeGroupId>::const_iterator it(directory_parent_groups.begin());it!=directory_parent_groups.end() && !found;++it)
{
RsGroupInfo info ;
if(!getGroupInfo(*it,info))

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