mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge branch 'master' into gxs_mail_experiments
This commit is contained in:
commit
5159e326c7
@ -1,5 +1,199 @@
|
||||
retroshare06 (0.6.2-1.XXXXXX~YYYYYY) YYYYYY; urgency=low
|
||||
|
||||
5b3b903 csoler Sun, 23 Apr 2017 17:33:21 +0200 added missing line for ubuntu zesty
|
||||
73bfc27 csoler Sun, 23 Apr 2017 17:33:50 +0200 Merge pull request #784 from PhenomRetroShare/Fix_RelaySettingsPage
|
||||
4c326f5 Phenom Sun, 23 Apr 2017 10:27:18 +0200 Fix Relay setting page.
|
||||
0e087db defnax Sat, 22 Apr 2017 17:32:59 +0200 Fixed to use right icons for context menu actions
|
||||
8b9c447 electr Sat, 22 Apr 2017 10:13:23 +0200 fixed possible crash and return value in rsGetHostByName(), thanks to Kotyara for reporting this
|
||||
4ab6021 csoler Fri, 21 Apr 2017 19:45:30 +0200 Merge pull request #782 from PhenomRetroShare/Fix_MacOSX_Compilation
|
||||
936dcba Phenom Fri, 21 Apr 2017 18:50:36 +0200 Fix UnitTest compilation.
|
||||
969b5ce Phenom Fri, 21 Apr 2017 15:57:57 +0200 Fix MacOSX compilation.
|
||||
7400a8d csoler Thu, 20 Apr 2017 20:59:12 +0200 Merge pull request #780 from csoler/v0.6-ImprovedGUI
|
||||
5f8bf03 csoler Thu, 20 Apr 2017 20:54:51 +0200 added mechanism to allow services to document the names of their items, and improved bandwidth graph to show names for GXS services. Other services still need to supply their own names
|
||||
ccfd12b csoler Wed, 19 Apr 2017 18:53:49 +0200 Merge pull request #778 from csoler/v0.6-ImprovedGUI
|
||||
f406b81 csoler Wed, 19 Apr 2017 18:46:58 +0200 removed all FFT code and cleaned up deleted code in graphwidget.cpp
|
||||
1da89dd csoler Wed, 19 Apr 2017 17:16:30 +0200 changed FFT code in graph widget into a more efficient one, with free licence
|
||||
e95ddb9 csoler Tue, 18 Apr 2017 20:28:36 +0200 Merge pull request #767 from PhenomRetroShare/Fix_CommentWithLineReturn
|
||||
5f969e7 csoler Tue, 18 Apr 2017 20:27:20 +0200 Merge pull request #776 from PhenomRetroShare/Fix_ClangWarnings
|
||||
3ab39c6 csoler Tue, 18 Apr 2017 20:26:14 +0200 Merge pull request #777 from PhenomRetroShare/Fix_EncodeRadixInRSLinks
|
||||
3c5e61a Phenom Tue, 18 Apr 2017 17:36:43 +0200 Encode Radix in RSLinks.
|
||||
3733137 Phenom Tue, 18 Apr 2017 11:25:41 +0200 Fix Clang warnings: implicit conversion
|
||||
7d9a803 Phenom Tue, 18 Apr 2017 11:18:10 +0200 Fix Clang warnings: bdnet_inet_ntoa C-linkage
|
||||
4faaaf7 csoler Mon, 17 Apr 2017 22:03:48 +0200 Merge pull request #775 from csoler/v0.6-PRTest
|
||||
87dd614 Phenom Fri, 7 Apr 2017 19:32:19 +0200 Fix Clang Warnings: private field 'encoding_debug_file' is not used
|
||||
4f939b2 Phenom Fri, 7 Apr 2017 19:29:27 +0200 Fix Clang warnings: unused function 'set_item_background'
|
||||
76f7573 Phenom Fri, 7 Apr 2017 18:48:40 +0200 Fix Clang warnings: comparison of array != a null pointer is always true
|
||||
0bbd149 Phenom Fri, 7 Apr 2017 18:42:22 +0200 Fix Clang warnings: comparison of integers of different signs
|
||||
a476a81 Phenom Fri, 7 Apr 2017 18:40:02 +0200 Fix Clang warnings: function 'update_children_background' is not needed
|
||||
d8a7313 Phenom Fri, 7 Apr 2017 18:32:55 +0200 Fix Clang warnings: implicit conversion from 'double' to 'int'
|
||||
19196e2 Phenom Fri, 7 Apr 2017 18:21:49 +0200 Fix Clang warnings: ariable 'status' is used uninitialized
|
||||
a3a53b9 Phenom Fri, 7 Apr 2017 18:19:42 +0200 Fix Clang warnings: unused parameter 'req'
|
||||
94ac821 Phenom Wed, 29 Mar 2017 18:13:17 +0200 Fix Clang warnings: Unused variable Pi
|
||||
fd92bca Phenom Tue, 28 Mar 2017 21:18:25 +0200 Fix Clang warnings: variable 'layout' is used uninitialized
|
||||
8d85cf5 Phenom Tue, 28 Mar 2017 21:16:05 +0200 Fix Clang warnings: 'xxxWidget::sizeHint' hides overloaded vf
|
||||
6f2d7bb Phenom Sun, 19 Mar 2017 10:51:48 +0100 Fix Clang warnings: implicit conversion from 'double' to 'int'
|
||||
07b67e9 Phenom Sun, 19 Mar 2017 10:40:34 +0100 Fix Clang warnings: 'PopupDistantChatDialog::init' hides overloaded virtual function
|
||||
eea49d9 Phenom Sat, 18 Mar 2017 11:56:11 +0100 Fix Clang warnings: change ChatDialog::init definition
|
||||
9319caf Phenom Sat, 18 Mar 2017 11:32:56 +0100 Fix Clang warnings: 'Node::advance' hides overloaded virtual function
|
||||
13c8f7d Phenom Sat, 18 Mar 2017 11:28:29 +0100 Fix Clang warnings: Infinite recursion
|
||||
e0225ef Phenom Sat, 18 Mar 2017 11:19:42 +0100 Fix Clang warnings: 'ChatLobbyDialog::init' hides overloaded virtual function
|
||||
de4f6c0 Phenom Sat, 18 Mar 2017 10:42:38 +0100 Fix Clang warnings: Z-order assignment to spacer
|
||||
32eeb95 Phenom Sat, 18 Mar 2017 10:25:23 +0100 Fix Clang warnings: unused private field
|
||||
4ac3b3f Phenom Sat, 18 Mar 2017 10:20:57 +0100 Fix Clang warnings: implicit conversion of NULL to bool
|
||||
e83104e Phenom Sat, 18 Mar 2017 10:19:31 +0100 Fix Clang warnings: Add author and date to #warning
|
||||
039908b Phenom Thu, 16 Mar 2017 22:58:06 +0100 Fix Clang warnings: private field not used
|
||||
872f42b Phenom Thu, 16 Mar 2017 22:55:18 +0100 Fix Clang warnings: Overloaded vf hide in pluginmanager
|
||||
2204309 Phenom Thu, 16 Mar 2017 22:11:33 +0100 Fix Clang warnings: extraneous parentheses
|
||||
dc533b1 Phenom Thu, 16 Mar 2017 22:01:22 +0100 Fix Clang warnings: private field not used
|
||||
6532150 Phenom Thu, 16 Mar 2017 21:04:38 +0100 Fix Clang warnings: Overloaded vf hide in p3dhtmgr
|
||||
5bc6558 Phenom Thu, 16 Mar 2017 18:28:48 +0100 Fix Clang warnings: explicitly assigning value to itself
|
||||
6fecac5 Phenom Thu, 16 Mar 2017 17:50:25 +0100 Fix Clang warnings: Overloaded vf hide
|
||||
cf963c0 Phenom Wed, 15 Mar 2017 20:41:39 +0100 Fix Clang warnings: struct declared as class
|
||||
105840a Phenom Wed, 15 Mar 2017 19:03:39 +0100 Fix Clang Warning: Overloaded vf hide
|
||||
da4b168 Phenom Wed, 15 Mar 2017 18:55:24 +0100 Fix Clang warnings: mFns is not used
|
||||
cbc264f Phenom Wed, 15 Mar 2017 18:53:30 +0100 Fix clang warning:Implicit conversion from enumeration
|
||||
b2e37fe csoler Sat, 15 Apr 2017 20:24:06 +0200 Merge pull request #773 from csoler/v0.6-Identity
|
||||
273aae7 csoler Sat, 15 Apr 2017 19:01:13 +0200 fixed sharing of own identity
|
||||
98e1a6d electr Thu, 13 Apr 2017 14:12:46 +0200 Merge pull request #770 from Sonetio/fix_reselecting_accounts
|
||||
144d570 Konrad Thu, 13 Apr 2017 13:40:30 +0200 Fixed: Thread safe access to RsControlModule member variables
|
||||
dcc8c6e Konrad Thu, 13 Apr 2017 13:31:32 +0200 Changed: Using PeersHandler::mRsPeers instead of rsPeers
|
||||
a382d68 electr Thu, 13 Apr 2017 09:22:19 +0200 Merge pull request #769 from electron128/fix-gui-multiinstance
|
||||
aa81cc1 Konrad Wed, 12 Apr 2017 20:24:18 +0200 Added: Functions for handling PGP account details requests
|
||||
9402b8e Konrad Mon, 10 Apr 2017 23:42:22 +0200 Fixed: mFixedPassword remained empty after logging
|
||||
e1350a0 Konrad Mon, 10 Apr 2017 22:58:23 +0200 Fixed: Re-selecting accounts via RsControlModule; Added: Sending feedback about incorrect password
|
||||
3130ec9 csoler Mon, 10 Apr 2017 20:02:14 +0200 added GUI async call to ID serialised data. Allows to copy+paste identities.
|
||||
4c9b620 electr Sun, 9 Apr 2017 10:26:18 +0200 fixed --base-dir command line argument in rs-gui when running multiple instances. Only forward "link" and "rsfile" arguments to a running instance. Start a new instance if other arguments are present.
|
||||
7f12ca2 electr Sun, 9 Apr 2017 09:57:48 +0200 fixed name of local socket where RS waits for rslinks etc.
|
||||
d66e653 csoler Sat, 8 Apr 2017 23:39:05 +0200 fixed bug in deserialisation of group informaiton
|
||||
54cd402 csoler Sat, 8 Apr 2017 21:43:07 +0200 fixed a few bugs in latest identity link code
|
||||
6d29038 csoler Sat, 8 Apr 2017 21:12:48 +0200 added RSLink for GXS identities
|
||||
4f5da86 csoler Sat, 8 Apr 2017 19:07:33 +0200 added method to serialise/deserialise groups to/from memory and export of GxsIdentities to memory chunk in radix format
|
||||
f175533 Phenom Sat, 8 Apr 2017 14:06:47 +0200 Fix comment view when they have line return.
|
||||
4067c95 electr Wed, 5 Apr 2017 18:49:32 +0200 Merge pull request #760 from Sonetio/windows_service
|
||||
6e65fcd Konrad Sat, 1 Apr 2017 14:32:49 +0200 Removed: Unused #include statement
|
||||
8543525 Konrad Sat, 1 Apr 2017 14:28:55 +0200 Fixed: Linker problem
|
||||
fbc1bb4 Konrad Wed, 29 Mar 2017 16:06:39 +0200 Added: function for handling autosubscribing lobbies
|
||||
22956be Konrad Tue, 28 Mar 2017 11:24:16 +0200 Deleted: functions for hadling particular lobbies types in ChatHandler
|
||||
6e53002 Konrad Tue, 28 Mar 2017 11:20:51 +0200 Added: tokens in PeersHandler
|
||||
efd6ce3 Konrad Tue, 28 Mar 2017 11:19:50 +0200 Changed: Simplified asking for deferred self signature
|
||||
5694581 Konrad Tue, 28 Mar 2017 11:18:27 +0200 Changed: Qt dependecies are optional
|
||||
4031e49 Konrad Mon, 27 Mar 2017 16:11:04 +0200 Deleted: unused stateTokens
|
||||
c33107c Konrad Sun, 26 Mar 2017 19:12:04 +0200 Fixed: backward comptiblity
|
||||
bef7540 Konrad Sun, 26 Mar 2017 15:11:07 +0200 Fixed building on Travis CI
|
||||
dbcf2d2 csoler Sat, 25 Mar 2017 20:27:18 +0100 Merge pull request #756 from RetroPooh/guistuff
|
||||
04af39f csoler Sat, 25 Mar 2017 20:24:40 +0100 Merge pull request #754 from PhenomRetroShare/Fix_WinNoSQLCipherCompil
|
||||
ccb632a csoler Sat, 25 Mar 2017 19:26:12 +0100 Merge pull request #749 from PhenomRetroShare/Fix_WindowsHeightAtFirstStart
|
||||
8624c93 Konrad Sat, 25 Mar 2017 18:33:35 +0100 Added functions for hadling particular lobbies types to ChatHandler
|
||||
194878a Konrad Sat, 25 Mar 2017 18:31:13 +0100 Added functions for handling own and not own identities to IdentityHandler
|
||||
cb32f30 Konrad Sat, 25 Mar 2017 18:28:31 +0100 Added states handling to PeersHandler
|
||||
28d37c2 Konrad Sat, 25 Mar 2017 18:25:26 +0100 Added password storing to RsControlModule for GUI benefits
|
||||
39967b7 Konrad Sat, 25 Mar 2017 18:23:28 +0100 Added name of requests to be used by GUI
|
||||
ae95b49 Konrad Sat, 25 Mar 2017 18:20:53 +0100 Added SettingsHandler to handle response to settings requests
|
||||
cb04134 Konrad Sat, 25 Mar 2017 18:15:47 +0100 Added Windows support to libresapi when working with retroshare_android_service
|
||||
b0d2249 Konrad Sat, 25 Mar 2017 18:12:39 +0100 Added Windows support to retroshare-android-service
|
||||
f5e7217 RetroP Tue, 21 Mar 2017 17:24:59 +0300 statistics - router - fix bold marking for tunnel speeds over 1mbs
|
||||
85cfda1 RetroP Tue, 21 Mar 2017 16:52:40 +0300 add tree item counters for channels,forums,posted
|
||||
50c81d7 RetroP Tue, 21 Mar 2017 16:41:39 +0300 chat lobby list - mark signed lobbies with color
|
||||
000dabf RetroP Tue, 21 Mar 2017 15:02:46 +0300 chat lobby list - add tree item counters
|
||||
19bd51d RetroP Tue, 21 Mar 2017 14:57:06 +0300 searchdialog - mark current downloads green
|
||||
5efa8e3 Phenom Fri, 17 Mar 2017 22:14:14 +0100 Fix Windows Compilation with CONFIG+=no_sqlcipher
|
||||
ca0521c csoler Thu, 16 Mar 2017 21:01:27 +0100 allowed to edit subject hen editing forum posts. Only the latest subject is visible
|
||||
107d48f Phenom Wed, 15 Mar 2017 22:50:51 +0100 Fix windows height at first start.
|
||||
2046dbe csoler Wed, 15 Mar 2017 20:53:01 +0100 merged latest fixes from official 0.6.2 release branch
|
||||
e4fad45 csoler Wed, 15 Mar 2017 20:51:40 +0100 fixed layout in ConfCertDialog, removed overnumerous tabs
|
||||
2114374 csoler Wed, 15 Mar 2017 19:26:07 +0100 fixed update of Tor proxy address in hidden nodes server page
|
||||
44f2971 csoler Tue, 14 Mar 2017 20:04:22 +0100 Merge pull request #682 from csoler/v0.6-EditPosts
|
||||
a0d1089 csoler Sat, 11 Mar 2017 18:15:35 +0100 added branch parameter to makeSourcePackage script
|
||||
fdab480 csoler Sat, 11 Mar 2017 18:10:14 +0100 added minimum version number for debian stretch
|
||||
733b114 thunde Fri, 10 Mar 2017 15:57:40 +0100 Updated languages from Transifex
|
||||
ed5779f csoler Fri, 10 Mar 2017 15:39:22 +0100 Merge pull request #743 from mestaritonttu/patch-22
|
||||
69c3df6 csoler Fri, 10 Mar 2017 15:36:50 +0100 fixed bug in total item size estimation in pqiqosstreamer due to item slicing
|
||||
c377bf3 csoler Fri, 10 Mar 2017 15:12:10 +0100 fixed debug output for groups with no data
|
||||
fd84639 csoler Fri, 10 Mar 2017 15:05:41 +0100 removed some debug info
|
||||
c87de3e csoler Fri, 10 Mar 2017 10:48:40 +0100 fixed mistake in pointer handling
|
||||
cf2edb5 csoler Thu, 9 Mar 2017 22:47:06 +0100 fixed memory leak in deleteGroup and removed unnecessary pointer in the functions called below
|
||||
a545481 csoler Thu, 9 Mar 2017 22:05:06 +0100 fixed memory leak when receving multi-chunk file lists
|
||||
5b819eb csoler Thu, 9 Mar 2017 20:59:01 +0100 added missing virtual destructor causing a memory leak
|
||||
1f8fd95 csoler Thu, 9 Mar 2017 20:48:26 +0100 fixed uninitialised memory read in chacha20 test code
|
||||
d5f2ae8 csoler Thu, 9 Mar 2017 20:39:12 +0100 fixed memory leak recently introduced with openssl-1.1.0 changes
|
||||
f76454d csoler Thu, 9 Mar 2017 13:05:03 +0100 updated full pipeline packaging script for debian
|
||||
999e845 mestar Wed, 8 Mar 2017 13:17:34 +0200 Fix grammar
|
||||
e6cf628 csoler Tue, 7 Mar 2017 21:58:59 +0100 Merge pull request #740 from RetroPooh/trstats
|
||||
283a2ee csoler Tue, 7 Mar 2017 21:54:56 +0100 Merge pull request #717 from PhenomRetroShare/Fix_SettingListWidth
|
||||
b3b2a4b csoler Tue, 7 Mar 2017 21:54:10 +0100 Merge pull request #726 from mestaritonttu/patch-8
|
||||
bbc27b2 csoler Tue, 7 Mar 2017 21:53:21 +0100 Merge pull request #736 from mestaritonttu/patch-18
|
||||
3d0c28d csoler Tue, 7 Mar 2017 21:52:19 +0100 Merge pull request #724 from mestaritonttu/patch-6
|
||||
ed22b48 csoler Tue, 7 Mar 2017 21:51:51 +0100 Merge pull request #738 from mestaritonttu/patch-20
|
||||
376be42 csoler Tue, 7 Mar 2017 21:51:13 +0100 Merge pull request #739 from mestaritonttu/patch-21
|
||||
b3578f6 csoler Tue, 7 Mar 2017 21:50:20 +0100 Merge pull request #734 from mestaritonttu/patch-16
|
||||
d9c084b csoler Tue, 7 Mar 2017 21:49:52 +0100 Merge pull request #730 from mestaritonttu/patch-12
|
||||
5bad326 csoler Tue, 7 Mar 2017 21:49:14 +0100 Merge pull request #725 from mestaritonttu/patch-7
|
||||
ec21698 csoler Tue, 7 Mar 2017 21:48:30 +0100 Merge pull request #727 from mestaritonttu/patch-9
|
||||
7d8e06b csoler Tue, 7 Mar 2017 21:47:43 +0100 Merge pull request #732 from mestaritonttu/patch-14
|
||||
f3e29bd csoler Tue, 7 Mar 2017 21:47:00 +0100 Merge pull request #731 from mestaritonttu/patch-13
|
||||
17c44db csoler Tue, 7 Mar 2017 21:46:21 +0100 Merge pull request #733 from mestaritonttu/patch-15
|
||||
5f9f061 csoler Tue, 7 Mar 2017 21:45:50 +0100 Merge pull request #735 from mestaritonttu/patch-17
|
||||
8881a44 csoler Tue, 7 Mar 2017 21:45:11 +0100 Merge pull request #737 from mestaritonttu/patch-19
|
||||
160c289 csoler Tue, 7 Mar 2017 21:44:42 +0100 Merge pull request #728 from mestaritonttu/patch-10
|
||||
22308bc csoler Tue, 7 Mar 2017 21:44:14 +0100 Merge pull request #729 from mestaritonttu/patch-11
|
||||
fedffd7 csoler Tue, 7 Mar 2017 21:43:36 +0100 Merge pull request #723 from mestaritonttu/patch-5
|
||||
d3f0f9d RetroP Tue, 7 Mar 2017 17:50:13 +0300 router stats - mark active tunnels bold
|
||||
87f9dba mestar Tue, 7 Mar 2017 14:05:21 +0200 Improvements and typo fixes in strings
|
||||
222cf48 mestar Tue, 7 Mar 2017 14:03:05 +0200 Various improvements and fixes to strings
|
||||
83283d9 mestar Tue, 7 Mar 2017 13:58:43 +0200 Remove extra your
|
||||
7005126 mestar Tue, 7 Mar 2017 13:57:10 +0200 Added whitespace to strings
|
||||
6ec5415 mestar Tue, 7 Mar 2017 13:55:02 +0200 ASCII uppercase
|
||||
28d2e27 mestar Tue, 7 Mar 2017 13:53:08 +0200 Remove whitespace from string
|
||||
931531b mestar Tue, 7 Mar 2017 13:51:28 +0200 Fix typo
|
||||
65c7ca7 mestar Tue, 7 Mar 2017 13:49:57 +0200 Clarify sorting by posts
|
||||
21b7861 mestar Tue, 7 Mar 2017 13:48:14 +0200 Fix grammar
|
||||
ba18fcd mestar Tue, 7 Mar 2017 13:45:31 +0200 Fix grammar
|
||||
a4c2015 mestar Tue, 7 Mar 2017 13:41:45 +0200 Fix typos
|
||||
6b4f7e3 mestar Tue, 7 Mar 2017 13:39:39 +0200 Removed extra "to"
|
||||
b444567 mestar Tue, 7 Mar 2017 13:34:53 +0200 Added period
|
||||
400dde9 mestar Tue, 7 Mar 2017 13:09:04 +0200 Added whitespace
|
||||
c9a4a55 mestar Tue, 7 Mar 2017 13:06:22 +0200 Fix grammar
|
||||
86e7243 mestar Tue, 7 Mar 2017 12:56:25 +0200 Fix typos
|
||||
d7dc9cc mestar Tue, 7 Mar 2017 12:53:18 +0200 Whitespace inside <p>
|
||||
a518225 csoler Tue, 7 Mar 2017 11:27:17 +0100 Merge pull request #716 from felisucoibi/master
|
||||
6a6bcf7 thunde Mon, 6 Mar 2017 21:46:42 +0100 Fixed Windows compile of VOIP
|
||||
dc65d3f Phenom Sun, 5 Mar 2017 13:22:30 +0100 Fix Setting list width.
|
||||
0316c8c thunde Mon, 6 Mar 2017 06:34:06 +0100 Added workaround for crash on Windows 7 for Qt versions with gcc 5.3.0. The call to GetProcAddress in openssl (cryptlib.c) finds an function pointer to the not existing function _OPENSSL_isservice in the executable running on Windows 7.
|
||||
313e1b3 csoler Sun, 5 Mar 2017 20:08:53 +0100 updated translation files
|
||||
88a5c03 csoler Sun, 5 Mar 2017 20:08:36 +0100 removed some debug info
|
||||
94c9c94 thunde Sun, 5 Mar 2017 14:30:45 +0100 updated version number to 0.6.2 in rsversion.in
|
||||
b71f475 csoler Sun, 5 Mar 2017 14:14:46 +0100 qick fix to allow re-advertising for known forums/channels during the same session. Will be reset at restart (probably best)
|
||||
fbd72dd csoler Sun, 5 Mar 2017 13:57:49 +0100 fixed settings SoundPage
|
||||
15bb0ff felisu Sun, 5 Mar 2017 02:45:37 +0100 Update ChatPage.h
|
||||
951820f felisu Sun, 5 Mar 2017 02:45:07 +0100 Update ForumPage.h
|
||||
63174aa felisu Sun, 5 Mar 2017 02:44:18 +0100 Update PostedPage.h
|
||||
ca75515 felisu Sun, 5 Mar 2017 02:43:40 +0100 Update MessagePage.h
|
||||
d3cdd15 csoler Sat, 4 Mar 2017 21:20:34 +0100 fixed uninitialised memory read in GxsReputation
|
||||
dec5c5c csoler Sat, 4 Mar 2017 21:13:34 +0100 suppressed uninitialised memory leak in LocalDirectoryStorage
|
||||
b14e4d5 csoler Sat, 4 Mar 2017 21:08:10 +0100 removed memory leak due to missing delete for BWGraph
|
||||
0bd0056 csoler Sat, 4 Mar 2017 20:52:41 +0100 fixed memory leak in RsGxsNetService
|
||||
7111579 csoler Sat, 4 Mar 2017 20:52:06 +0100 fixed memory leak in config of msgService
|
||||
2302c46 csoler Sat, 4 Mar 2017 16:41:10 +0100 updated version number in changelog
|
||||
0024ddf csoler Sat, 4 Mar 2017 16:39:39 +0100 fixed utf8 bug in ShareManager
|
||||
3600905 csoler Sat, 4 Mar 2017 12:04:41 +0100 updated packaging files
|
||||
c715b03 csoler Sat, 4 Mar 2017 11:56:51 +0100 updated version number to 0.6.2
|
||||
5e2a253 csoler Sat, 4 Mar 2017 11:44:31 +0100 updated ubuntu changelog
|
||||
bd8189c csoler Tue, 28 Feb 2017 18:05:44 +0100 added test to prevent msgs with a different name to be used as different version
|
||||
763f227 csoler Sun, 26 Feb 2017 20:39:40 +0100 merged upstream/master into v0.6-EditPosts branch
|
||||
22f2edb csoler Sat, 11 Feb 2017 10:45:30 +0100 removed debug info and added comment
|
||||
ea82d26 csoler Thu, 9 Feb 2017 23:35:59 +0100 fixed signature verification bug for versionned messages
|
||||
5bf8376 csoler Thu, 9 Feb 2017 21:49:24 +0100 fixed a few more bugs in post version UI
|
||||
8deeec6 csoler Thu, 9 Feb 2017 18:45:55 +0100 fixed UI for post versions
|
||||
b93130a csoler Thu, 9 Feb 2017 16:15:35 +0100 fixed a few bugs in post version collecting
|
||||
f8056e5 csoler Thu, 9 Feb 2017 14:49:43 +0100 added collection of older posts versions.
|
||||
6681985 csoler Wed, 8 Feb 2017 20:40:47 +0100 merged upstream/master
|
||||
dfcb66d csoler Fri, 3 Feb 2017 13:02:53 +0100 added spinbox to show older versions
|
||||
777a73e csoler Fri, 3 Feb 2017 12:48:51 +0100 added GUI for editing forum messages
|
||||
|
||||
-- Retroshare Dev Team <contact@retroshare.net> Dim, 23 Apr 2017 16:00:00 +0100
|
||||
|
||||
retroshare06 (0.6.2-1.931442~trusty) trusty; urgency=low
|
||||
|
||||
931442a csoler Sat, 4 Mar 2017 00:07:51 +0100 fixed compilation
|
||||
b4e0a8f csoler Sat, 4 Mar 2017 00:04:52 +0100 removed unused file DirectoriesPage.{cpp,ui,h}
|
||||
e257563 csoler Sat, 4 Mar 2017 00:01:21 +0100 merged Directories settings page into Transfers and renamed it Files
|
||||
|
@ -2,7 +2,7 @@ Source: retroshare06
|
||||
Section: devel
|
||||
Priority: standard
|
||||
Maintainer: Cyril Soler <csoler@users.sourceforge.net>
|
||||
Build-Depends: debhelper (>= 7), libglib2.0-dev, libupnp-dev, libssl-dev, libxss-dev, libgnome-keyring-dev, libbz2-dev, libspeex-dev, libspeexdsp-dev, libxslt1-dev, cmake, libcurl4-openssl-dev, libopencv-dev, tcl8.6, libsqlcipher-dev, libmicrohttpd-dev, libavcodec-dev, qtmultimedia5-dev, qttools5-dev, libqt5x11extras5-dev, qt5-default
|
||||
Build-Depends: debhelper (>= 7), libglib2.0-dev, libupnp-dev, libssl-dev, libxss-dev, libgnome-keyring-dev, libbz2-dev, libspeex-dev, libspeexdsp-dev, libxslt1-dev, cmake, libcurl4-openssl-dev, libopencv-dev, tcl8.6, libsqlcipher-dev (>= 3.4.0), libmicrohttpd-dev, libavcodec-dev, qtmultimedia5-dev, qttools5-dev, libqt5x11extras5-dev, qt5-default
|
||||
Standards-Version: 3.9.6
|
||||
Homepage: http://retroshare.sourceforge.net
|
||||
|
||||
|
44
build_scripts/Debian+Ubuntu/control.zesty
Normal file
44
build_scripts/Debian+Ubuntu/control.zesty
Normal file
@ -0,0 +1,44 @@
|
||||
Source: retroshare06
|
||||
Section: devel
|
||||
Priority: standard
|
||||
Maintainer: Cyril Soler <csoler@users.sourceforge.net>
|
||||
Build-Depends: debhelper (>= 7), libglib2.0-dev, libupnp-dev, libssl-dev, libxss-dev, libgnome-keyring-dev, libbz2-dev, libspeex-dev, libspeexdsp-dev, libxslt1-dev, cmake, libcurl4-openssl-dev, libopencv-dev, tcl8.6, libsqlcipher-dev, libmicrohttpd-dev, libavcodec-dev, qtmultimedia5-dev, qttools5-dev, libqt5x11extras5-dev, qt5-default
|
||||
Standards-Version: 3.9.6
|
||||
Homepage: http://retroshare.sourceforge.net
|
||||
|
||||
Package: retroshare06-voip-plugin
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, retroshare06, libspeex1, libspeexdsp1, libqt5multimedia5
|
||||
Description: RetroShare VOIP plugin
|
||||
This package provides a plugin for RetroShare, a secured Friend-to-Friend communication
|
||||
plateform. The plugin adds voice-over-IP functionality to the private chat window. Both
|
||||
friends chatting together need the plugin installed to be able to talk together.
|
||||
|
||||
Package: retroshare06-feedreader-plugin
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, retroshare06
|
||||
Description: RetroShare FeedReader plugin
|
||||
This package provides a plugin for RetroShare, a secured Friend-to-Friend communication
|
||||
plateform. The plugin adds a RSS feed reader tab to retroshare.
|
||||
|
||||
Package: retroshare06-nogui
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, gnome-keyring
|
||||
Conflicts: retroshare06
|
||||
Description: Secure communication with friends
|
||||
This is the command-line client for RetroShare network. This client
|
||||
can be contacted and talked-to using SSL. Clients exist for portable
|
||||
devices running e.g. Android.
|
||||
|
||||
Package: retroshare06
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, gnome-keyring
|
||||
Conflicts: retroshare06-nogui
|
||||
Description: Secure communication with friends
|
||||
RetroShare is a Open Source cross-platform, private and secure decentralised
|
||||
commmunication platform. It lets you to securely chat and share files with your
|
||||
friends and family, using a web-of-trust to authenticate peers and OpenSSL to
|
||||
encrypt all communication. RetroShare provides filesharing, chat, messages,
|
||||
forums and channels.
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
version="0.6.2"
|
||||
gitpath="https://github.com/RetroShare/RetroShare.git"
|
||||
workdir=retroshare06-${version}
|
||||
branch="v0.6.2-official_release"
|
||||
#bubba3="Y" # comment out to compile for bubba3
|
||||
######################################################
|
||||
|
||||
@ -53,7 +54,7 @@ while [ ${#} -gt 0 ]; do
|
||||
done
|
||||
|
||||
if test "${dist}" = "" ; then
|
||||
dist="precise trusty vivid xenial yakkety"
|
||||
dist="precise trusty vivid xenial yakkety zesty"
|
||||
fi
|
||||
|
||||
echo Attempting to get revision number...
|
||||
@ -66,6 +67,7 @@ echo " "Commit count : ${ccount}
|
||||
echo " "Date : ${date}
|
||||
echo " "Time : ${time}
|
||||
echo " "Hash : ${hhsh}
|
||||
echo " "Using branch : ${branch}
|
||||
echo " "Using revision : ${rev}
|
||||
|
||||
echo Done.
|
||||
@ -80,7 +82,7 @@ echo Extracting base archive...
|
||||
mkdir -p ${workdir}/src
|
||||
echo Checking out latest snapshot...
|
||||
cd ${workdir}/src
|
||||
git clone --depth 1 https://github.com/RetroShare/RetroShare.git .
|
||||
git clone --depth 1 https://github.com/RetroShare/RetroShare.git --single-branch --branch $branch .
|
||||
cd -
|
||||
|
||||
if ! test -d ${workdir}/src/libretroshare/; then
|
||||
@ -114,6 +116,8 @@ for i in ${dist}; do
|
||||
|
||||
if test "${i}" = "lucid" ; then
|
||||
cp ../control.ubuntu_lucid debian/control
|
||||
elif test "${i}" = "zesty" ; then
|
||||
cp ../control.zesty debian/control
|
||||
elif test "${i}" = "squeeze" ; then
|
||||
cp ../control.squeeze_bubba3 debian/control
|
||||
elif test "${i}" = "precise" ; then
|
||||
|
@ -58,7 +58,7 @@
|
||||
/*************************************/
|
||||
|
||||
UdpBitDht::UdpBitDht(UdpPublisher *pub, bdNodeId *id, std::string appVersion, std::string bootstrapfile, const std::string& filteredipfile, bdDhtFunctions *fns)
|
||||
:UdpSubReceiver(pub), dhtMtx(true), mFns(fns)
|
||||
:UdpSubReceiver(pub), dhtMtx(true)//, mFns(fns)
|
||||
{
|
||||
std::string usedVersion;
|
||||
|
||||
|
@ -119,7 +119,7 @@ void clearDataTransferred();
|
||||
|
||||
bdMutex dhtMtx; /* for all class data (below) */
|
||||
bdNodeManager *mBitDhtManager;
|
||||
bdDhtFunctions *mFns;
|
||||
//bdDhtFunctions *mFns;
|
||||
|
||||
|
||||
uint32_t mReadBytes;
|
||||
|
@ -144,6 +144,11 @@ std::string bloomFilter::getFilter()
|
||||
bytes++;
|
||||
}
|
||||
|
||||
if (bytes==0)
|
||||
{
|
||||
std::cerr << "(EE) Error. Cannot allocate memory for 0 byte in " << __PRETTY_FUNCTION__ << std::endl;
|
||||
return std::string();
|
||||
}
|
||||
// convert to binary array.
|
||||
uint8_t *tmparray = (uint8_t *) malloc(bytes);
|
||||
|
||||
|
@ -103,8 +103,6 @@ int bdnet_inet_aton(const char *name, struct in_addr *addr);
|
||||
int bdnet_checkTTL(int fd);
|
||||
|
||||
void bdsockaddr_clear(struct sockaddr_in *addr);
|
||||
/* thread-safe version of inet_ntoa */
|
||||
std::string bdnet_inet_ntoa(struct in_addr in);
|
||||
|
||||
/* Extra stuff to declare for windows error handling (mimics unix errno)
|
||||
*/
|
||||
@ -175,4 +173,7 @@ int usleep(unsigned int usec);
|
||||
} /* C Interface */
|
||||
#endif
|
||||
|
||||
/* thread-safe version of inet_ntoa */
|
||||
std::string bdnet_inet_ntoa(struct in_addr in);
|
||||
|
||||
#endif /* BITDHT_UNIVERSAL_NETWORK_HEADER */
|
||||
|
@ -17,6 +17,10 @@
|
||||
#include "ChannelsHandler.h"
|
||||
#include "StatsHandler.h"
|
||||
|
||||
#ifdef LIBRESAPI_QT
|
||||
#include "SettingsHandler.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
data types in json http://json.org/
|
||||
string (utf-8 unicode)
|
||||
@ -237,6 +241,9 @@ public:
|
||||
mApiPluginHandler(sts, ifaces),
|
||||
mChannelsHandler(ifaces.mGxsChannels),
|
||||
mStatsHandler()
|
||||
#ifdef LIBRESAPI_QT
|
||||
,mSettingsHandler(sts)
|
||||
#endif
|
||||
{
|
||||
// the dynamic cast is to not confuse the addResourceHandler template like this:
|
||||
// addResourceHandler(derived class, parent class)
|
||||
@ -262,7 +269,11 @@ public:
|
||||
&ChannelsHandler::handleRequest);
|
||||
router.addResourceHandler("stats", dynamic_cast<ResourceRouter*>(&mStatsHandler),
|
||||
&StatsHandler::handleRequest);
|
||||
}
|
||||
#ifdef LIBRESAPI_QT
|
||||
router.addResourceHandler("settings", dynamic_cast<ResourceRouter*>(&mSettingsHandler),
|
||||
&SettingsHandler::handleRequest);
|
||||
#endif
|
||||
}
|
||||
|
||||
PeersHandler mPeersHandler;
|
||||
IdentityHandler mIdentityHandler;
|
||||
@ -274,6 +285,10 @@ public:
|
||||
ApiPluginHandler mApiPluginHandler;
|
||||
ChannelsHandler mChannelsHandler;
|
||||
StatsHandler mStatsHandler;
|
||||
|
||||
#ifdef LIBRESAPI_QT
|
||||
SettingsHandler mSettingsHandler;
|
||||
#endif
|
||||
};
|
||||
|
||||
ApiServer::ApiServer():
|
||||
@ -362,6 +377,9 @@ std::string ApiServer::handleRequest(Request &request)
|
||||
if(data.isRawData())
|
||||
return data.getRawData();
|
||||
|
||||
if(!resp.mCallbackName.empty())
|
||||
outstream << resource_api::makeKeyValueReference("callback_name", resp.mCallbackName);
|
||||
|
||||
outstream << resource_api::makeKeyValue("debug_msg", debugString.str());
|
||||
outstream << resource_api::makeKeyValueReference("returncode", returncode);
|
||||
if(!resp.mStateToken.isNull())
|
||||
|
@ -252,6 +252,9 @@ public:
|
||||
|
||||
StateToken mStateToken;
|
||||
|
||||
//Just for GUI benefit
|
||||
std::string mCallbackName;
|
||||
|
||||
// the result
|
||||
StreamBase& mDataStream;
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include <retroshare/rshistory.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
@ -144,8 +145,10 @@ ChatHandler::ChatHandler(StateTokenServer *sts, RsNotify *notify, RsMsgs *msgs,
|
||||
|
||||
addResourceHandler("*", this, &ChatHandler::handleWildcard);
|
||||
addResourceHandler("lobbies", this, &ChatHandler::handleLobbies);
|
||||
addResourceHandler("create_lobby", this, &ChatHandler::handleCreateLobby);
|
||||
addResourceHandler("subscribe_lobby", this, &ChatHandler::handleSubscribeLobby);
|
||||
addResourceHandler("unsubscribe_lobby", this, &ChatHandler::handleUnsubscribeLobby);
|
||||
addResourceHandler("autosubscribe_lobby", this, &ChatHandler::handleAutoSubsribeLobby);
|
||||
addResourceHandler("clear_lobby", this, &ChatHandler::handleClearLobby);
|
||||
addResourceHandler("lobby_participants", this, &ChatHandler::handleLobbyParticipants);
|
||||
addResourceHandler("messages", this, &ChatHandler::handleMessages);
|
||||
@ -889,6 +892,15 @@ void ChatHandler::handleUnsubscribeLobby(Request &req, Response &resp)
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void ChatHandler::handleAutoSubsribeLobby(Request& req, Response& resp)
|
||||
{
|
||||
ChatLobbyId chatId = 0;
|
||||
bool autosubsribe;
|
||||
req.mStream << makeKeyValueReference("chatid", chatId) << makeKeyValueReference("autosubsribe", autosubsribe);
|
||||
mRsMsgs->setLobbyAutoSubscribe(chatId, autosubsribe);
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void ChatHandler::handleClearLobby(Request &req, Response &resp)
|
||||
{
|
||||
ChatLobbyId id = 0;
|
||||
@ -930,13 +942,14 @@ void ChatHandler::handleMessages(Request &req, Response &resp)
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
|
||||
ChatId id(req.mPath.top());
|
||||
ChatId id(req.mPath.top());
|
||||
|
||||
// make response a list
|
||||
resp.mDataStream.getStreamToMember();
|
||||
if(id.isNotSet())
|
||||
{
|
||||
resp.setFail("\""+req.mPath.top()+"\" is not a valid chat id");
|
||||
return;
|
||||
resp.setFail("\""+req.mPath.top()+"\" is not a valid chat id");
|
||||
return;
|
||||
}
|
||||
std::map<ChatId, std::list<Msg> >::iterator mit = mMsgs.find(id);
|
||||
if(mit == mMsgs.end())
|
||||
@ -973,10 +986,11 @@ void ChatHandler::handleSendMessage(Request &req, Response &resp)
|
||||
void ChatHandler::handleMarkChatAsRead(Request &req, Response &resp)
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
|
||||
ChatId id(req.mPath.top());
|
||||
ChatId id(req.mPath.top());
|
||||
|
||||
if(id.isNotSet())
|
||||
{
|
||||
resp.setFail("\""+req.mPath.top()+"\" is not a valid chat id");
|
||||
resp.setFail("\""+req.mPath.top()+"\" is not a valid chat id");
|
||||
return;
|
||||
}
|
||||
std::map<ChatId, std::list<Msg> >::iterator mit = mMsgs.find(id);
|
||||
@ -1197,4 +1211,37 @@ void ChatHandler::handleCloseDistantChatConnexion(Request& req, Response& resp)
|
||||
else resp.setFail("Failed to close distant chat");
|
||||
}
|
||||
|
||||
void ChatHandler::handleCreateLobby(Request& req, Response& resp)
|
||||
{
|
||||
std::set<RsPeerId> invited_identites;
|
||||
std::string lobby_name;
|
||||
std::string lobby_topic;
|
||||
std::string gxs_id;
|
||||
|
||||
req.mStream << makeKeyValueReference("lobby_name", lobby_name);
|
||||
req.mStream << makeKeyValueReference("lobby_topic", lobby_topic);
|
||||
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
|
||||
|
||||
RsGxsId gxsId(gxs_id);
|
||||
|
||||
bool lobby_public;
|
||||
bool pgp_signed;
|
||||
|
||||
req.mStream << makeKeyValueReference("lobby_public", lobby_public);
|
||||
req.mStream << makeKeyValueReference("pgp_signed", pgp_signed);
|
||||
|
||||
ChatLobbyFlags lobby_flags;
|
||||
|
||||
if(lobby_public)
|
||||
lobby_flags |= RS_CHAT_LOBBY_FLAGS_PUBLIC;
|
||||
|
||||
if(pgp_signed)
|
||||
lobby_flags |= RS_CHAT_LOBBY_FLAGS_PGP_SIGNED;
|
||||
|
||||
mRsMsgs->createChatLobby(lobby_name, gxsId, lobby_topic, invited_identites, lobby_flags);
|
||||
|
||||
tick();
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
} // namespace resource_api
|
||||
|
@ -118,8 +118,10 @@ public:
|
||||
private:
|
||||
void handleWildcard(Request& req, Response& resp);
|
||||
void handleLobbies(Request& req, Response& resp);
|
||||
void handleCreateLobby(Request& req, Response& resp);
|
||||
void handleSubscribeLobby(Request& req, Response& resp);
|
||||
void handleUnsubscribeLobby(Request& req, Response& resp);
|
||||
void handleAutoSubsribeLobby(Request& req, Response& resp);
|
||||
void handleClearLobby(Request& req, Response& resp);
|
||||
ResponseTask* handleLobbyParticipants(Request& req, Response& resp);
|
||||
void handleMessages(Request& req, Response& resp);
|
||||
|
@ -10,8 +10,8 @@
|
||||
namespace resource_api
|
||||
{
|
||||
|
||||
FileSearchHandler::FileSearchHandler(StateTokenServer *sts, RsNotify *notify, RsTurtle *turtle, RsFiles *files):
|
||||
mStateTokenServer(sts), mNotify(notify), mTurtle(turtle), mFiles(files),
|
||||
FileSearchHandler::FileSearchHandler(StateTokenServer *sts, RsNotify *notify, RsTurtle *turtle, RsFiles */*files*/):
|
||||
mStateTokenServer(sts), mNotify(notify), mTurtle(turtle),// mFiles(files),
|
||||
mMtx("FileSearchHandler")
|
||||
{
|
||||
mNotify->registerNotifyClient(this);
|
||||
|
@ -24,7 +24,7 @@ private:
|
||||
StateTokenServer* mStateTokenServer;
|
||||
RsNotify* mNotify;
|
||||
RsTurtle* mTurtle;
|
||||
RsFiles* mFiles;
|
||||
//RsFiles* mFiles;
|
||||
|
||||
class Search{
|
||||
public:
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "IdentityHandler.h"
|
||||
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "Operators.h"
|
||||
@ -95,15 +96,59 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
class DeleteIdentityTask : public GxsResponseTask
|
||||
{
|
||||
public:
|
||||
DeleteIdentityTask(RsIdentity* idservice) :
|
||||
GxsResponseTask(idservice, idservice->getTokenService()),
|
||||
mToken(0),
|
||||
mRsIdentity(idservice)
|
||||
{}
|
||||
|
||||
protected:
|
||||
virtual void gxsDoWork(Request &req, Response &resp)
|
||||
{
|
||||
RsGxsIdGroup group;
|
||||
std::string gxs_id;
|
||||
|
||||
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
|
||||
group.mMeta.mGroupId = RsGxsGroupId(gxs_id);
|
||||
|
||||
mRsIdentity->deleteIdentity(mToken, group);
|
||||
addWaitingToken(mToken);
|
||||
|
||||
done();
|
||||
return;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t mToken;
|
||||
RsIdentity* mRsIdentity;
|
||||
RsGxsId mId;
|
||||
};
|
||||
|
||||
IdentityHandler::IdentityHandler(StateTokenServer *sts, RsNotify *notify, RsIdentity *identity):
|
||||
mStateTokenServer(sts), mNotify(notify), mRsIdentity(identity),
|
||||
mMtx("IdentityHandler Mtx"), mStateToken(sts->getNewToken())
|
||||
{
|
||||
mNotify->registerNotifyClient(this);
|
||||
|
||||
addResourceHandler("*", this, &IdentityHandler::handleWildcard);
|
||||
addResourceHandler("own", this, &IdentityHandler::handleOwn);
|
||||
addResourceHandler("create_identity", this, &IdentityHandler::handleCreateIdentity);
|
||||
addResourceHandler("*", this, &IdentityHandler::handleWildcard);
|
||||
addResourceHandler("own", this, &IdentityHandler::handleOwn);
|
||||
|
||||
addResourceHandler("own_ids", this, &IdentityHandler::handleOwnIdsRequest);
|
||||
addResourceHandler("notown_ids", this, &IdentityHandler::handleNotOwnIdsRequest);
|
||||
|
||||
addResourceHandler("add_contact", this, &IdentityHandler::handleAddContact);
|
||||
addResourceHandler("remove_contact", this, &IdentityHandler::handleRemoveContact);
|
||||
|
||||
addResourceHandler("create_identity", this, &IdentityHandler::handleCreateIdentity);
|
||||
addResourceHandler("delete_identity", this, &IdentityHandler::handleDeleteIdentity);
|
||||
|
||||
addResourceHandler("get_identity_details", this, &IdentityHandler::handleGetIdentityDetails);
|
||||
|
||||
addResourceHandler("set_ban_node", this, &IdentityHandler::handleSetBanNode);
|
||||
addResourceHandler("set_opinion", this, &IdentityHandler::handleSetOpinion);
|
||||
}
|
||||
|
||||
IdentityHandler::~IdentityHandler()
|
||||
@ -162,6 +207,7 @@ void IdentityHandler::handleWildcard(Request & /*req*/, Response &resp)
|
||||
<< makeKeyValueReference("gxs_id", grp.mMeta.mGroupId)
|
||||
<< makeKeyValueReference("pgp_id",grp.mPgpId )
|
||||
<< makeKeyValueReference("name", grp.mMeta.mGroupName)
|
||||
<< makeKeyValueReference("contact", grp.mIsAContact)
|
||||
<< makeKeyValueReference("own", own)
|
||||
<< makeKeyValueReference("pgp_linked", pgp_linked);
|
||||
}
|
||||
@ -172,6 +218,313 @@ void IdentityHandler::handleWildcard(Request & /*req*/, Response &resp)
|
||||
else resp.setFail();
|
||||
}
|
||||
|
||||
|
||||
void IdentityHandler::handleNotOwnIdsRequest(Request & /*req*/, Response &resp)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
resp.mStateToken = mStateToken;
|
||||
}
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
uint32_t token;
|
||||
mRsIdentity->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts);
|
||||
|
||||
time_t start = time(NULL);
|
||||
while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
&&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED)
|
||||
&&((time(NULL) < (start+10)))
|
||||
)
|
||||
{
|
||||
#ifdef WINDOWS_SYS
|
||||
Sleep(500);
|
||||
#else
|
||||
usleep(500*1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
if(mRsIdentity->getTokenService()->requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
{
|
||||
std::vector<RsGxsIdGroup> grps;
|
||||
ok &= mRsIdentity->getGroupData(token, grps);
|
||||
for(std::vector<RsGxsIdGroup>::iterator vit = grps.begin(); vit != grps.end(); vit++)
|
||||
{
|
||||
RsGxsIdGroup& grp = *vit;
|
||||
//electron: not very happy about this, i think the flags should stay hidden in rsidentities
|
||||
if(!(grp.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) && grp.mIsAContact)
|
||||
{
|
||||
bool pgp_linked = (grp.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility ) ;
|
||||
resp.mDataStream.getStreamToMember()
|
||||
<< makeKeyValueReference("id", grp.mMeta.mGroupId) /// @deprecated using "id" as key can cause problems in some JS based languages like Qml @see gxs_id instead
|
||||
<< makeKeyValueReference("gxs_id", grp.mMeta.mGroupId)
|
||||
<< makeKeyValueReference("pgp_id",grp.mPgpId )
|
||||
<< makeKeyValueReference("name", grp.mMeta.mGroupName)
|
||||
<< makeKeyValueReference("pgp_linked", pgp_linked);
|
||||
}
|
||||
}
|
||||
}
|
||||
else ok = false;
|
||||
|
||||
if(ok) resp.setOk();
|
||||
else resp.setFail();
|
||||
}
|
||||
|
||||
void IdentityHandler::handleOwnIdsRequest(Request & /*req*/, Response &resp)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
resp.mStateToken = mStateToken;
|
||||
}
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
uint32_t token;
|
||||
mRsIdentity->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts);
|
||||
|
||||
time_t start = time(NULL);
|
||||
while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
&&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED)
|
||||
&&((time(NULL) < (start+10)))
|
||||
)
|
||||
{
|
||||
#ifdef WINDOWS_SYS
|
||||
Sleep(500);
|
||||
#else
|
||||
usleep(500*1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
if(mRsIdentity->getTokenService()->requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
{
|
||||
std::vector<RsGxsIdGroup> grps;
|
||||
ok &= mRsIdentity->getGroupData(token, grps);
|
||||
for(std::vector<RsGxsIdGroup>::iterator vit = grps.begin(); vit != grps.end(); vit++)
|
||||
{
|
||||
RsGxsIdGroup& grp = *vit;
|
||||
//electron: not very happy about this, i think the flags should stay hidden in rsidentities
|
||||
if(vit->mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN)
|
||||
{
|
||||
bool pgp_linked = (grp.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility ) ;
|
||||
resp.mDataStream.getStreamToMember()
|
||||
<< makeKeyValueReference("own_gxs_id", grp.mMeta.mGroupId)
|
||||
<< makeKeyValueReference("pgp_id",grp.mPgpId )
|
||||
<< makeKeyValueReference("name", grp.mMeta.mGroupName)
|
||||
<< makeKeyValueReference("pgp_linked", pgp_linked);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
ok = false;
|
||||
|
||||
if(ok) resp.setOk();
|
||||
else resp.setFail();
|
||||
}
|
||||
|
||||
void IdentityHandler::handleAddContact(Request& req, Response& resp)
|
||||
{
|
||||
std::string gxs_id;
|
||||
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
|
||||
|
||||
mRsIdentity->setAsRegularContact(RsGxsId(gxs_id), true);
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/
|
||||
mStateTokenServer->replaceToken(mStateToken);
|
||||
}
|
||||
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void IdentityHandler::handleRemoveContact(Request& req, Response& resp)
|
||||
{
|
||||
std::string gxs_id;
|
||||
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
|
||||
|
||||
mRsIdentity->setAsRegularContact(RsGxsId(gxs_id), false);
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/
|
||||
mStateTokenServer->replaceToken(mStateToken);
|
||||
}
|
||||
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void IdentityHandler::handleGetIdentityDetails(Request& req, Response& resp)
|
||||
{
|
||||
std::string gxs_id;
|
||||
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
uint32_t token;
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(RsGxsGroupId(gxs_id));
|
||||
mRsIdentity->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds);
|
||||
|
||||
time_t start = time(NULL);
|
||||
while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
&&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED)
|
||||
&&((time(NULL) < (start+10)))
|
||||
)
|
||||
{
|
||||
#ifdef WINDOWS_SYS
|
||||
Sleep(500);
|
||||
#else
|
||||
usleep(500*1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
RsGxsIdGroup data;
|
||||
std::vector<RsGxsIdGroup> datavector;
|
||||
if (!mRsIdentity->getGroupData(token, datavector))
|
||||
{
|
||||
resp.setFail();
|
||||
return;
|
||||
}
|
||||
|
||||
if(datavector.empty())
|
||||
{
|
||||
resp.setFail();
|
||||
return;
|
||||
}
|
||||
|
||||
data = datavector[0];
|
||||
|
||||
resp.mDataStream << makeKeyValue("gxs_name", data.mMeta.mGroupName);
|
||||
resp.mDataStream << makeKeyValue("gxs_id", data.mMeta.mGroupId.toStdString());
|
||||
|
||||
resp.mDataStream << makeKeyValue("pgp_id_known", data.mPgpKnown);
|
||||
resp.mDataStream << makeKeyValue("pgp_id", data.mPgpId.toStdString());
|
||||
|
||||
std::string pgp_name;
|
||||
if (data.mPgpKnown)
|
||||
{
|
||||
RsPeerDetails details;
|
||||
rsPeers->getGPGDetails(data.mPgpId, details);
|
||||
pgp_name = details.name;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility)
|
||||
pgp_name = "[Unknown node]";
|
||||
else
|
||||
pgp_name = "Anonymous Id";
|
||||
}
|
||||
resp.mDataStream << makeKeyValue("pgp_name", pgp_name);
|
||||
|
||||
resp.mDataStream << makeKeyValue("last_usage", (uint32_t)data.mLastUsageTS);
|
||||
|
||||
bool isAnonymous = false;
|
||||
if(!data.mPgpKnown)
|
||||
{
|
||||
if (!(data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility))
|
||||
isAnonymous = true;
|
||||
}
|
||||
resp.mDataStream << makeKeyValue("anonymous", isAnonymous);
|
||||
|
||||
|
||||
bool isOwnId = (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
|
||||
resp.mDataStream << makeKeyValue("own", isOwnId);
|
||||
|
||||
std::string type;
|
||||
if(isOwnId)
|
||||
{
|
||||
if (data.mPgpKnown && !data.mPgpId.isNull())
|
||||
type = "Identity owned by you, linked to your Retroshare node";
|
||||
else
|
||||
type = "Anonymous identity, owned by you";
|
||||
}
|
||||
else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility)
|
||||
{
|
||||
if (data.mPgpKnown)
|
||||
{
|
||||
if (rsPeers->isGPGAccepted(data.mPgpId))
|
||||
type = "Linked to a friend Retroshare node";
|
||||
else
|
||||
type = "Linked to a known Retroshare node";
|
||||
}
|
||||
else
|
||||
type = "Linked to unknown Retroshare node";
|
||||
}
|
||||
else
|
||||
type = "Anonymous identity";
|
||||
|
||||
resp.mDataStream << makeKeyValue("type", type);
|
||||
|
||||
resp.mDataStream << makeKeyValue("bannned_node", rsReputations->isNodeBanned(data.mPgpId));
|
||||
|
||||
RsReputations::ReputationInfo info;
|
||||
rsReputations->getReputationInfo(RsGxsId(data.mMeta.mGroupId), data.mPgpId, info);
|
||||
resp.mDataStream << makeKeyValue("friends_positive_votes", info.mFriendsPositiveVotes);
|
||||
resp.mDataStream << makeKeyValue("friends_negative_votes", info.mFriendsNegativeVotes);
|
||||
resp.mDataStream << makeKeyValue("overall_reputation_level", (int)info.mOverallReputationLevel);
|
||||
resp.mDataStream << makeKeyValue("own_opinion", (int)info.mOwnOpinion);
|
||||
|
||||
RsIdentityDetails details;
|
||||
mRsIdentity->getIdDetails(RsGxsId(data.mMeta.mGroupId), details);
|
||||
StreamBase& usagesStream = resp.mDataStream.getStreamToMember("usages");
|
||||
usagesStream.getStreamToMember();
|
||||
|
||||
for(std::map<RsIdentityUsage,time_t>::const_iterator it(details.mUseCases.begin()); it != details.mUseCases.end(); ++it)
|
||||
{
|
||||
usagesStream.getStreamToMember()
|
||||
<< makeKeyValue("usage_time", (uint32_t)data.mLastUsageTS)
|
||||
<< makeKeyValue("usage_service", (int)(it->first.mServiceId))
|
||||
<< makeKeyValue("usage_case", (int)(it->first.mUsageCode));
|
||||
}
|
||||
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void IdentityHandler::handleSetBanNode(Request& req, Response& resp)
|
||||
{
|
||||
std::string pgp_id;
|
||||
req.mStream << makeKeyValueReference("pgp_id", pgp_id);
|
||||
RsPgpId pgpId(pgp_id);
|
||||
|
||||
bool banned_node;
|
||||
req.mStream << makeKeyValueReference("banned_node", banned_node);
|
||||
rsReputations->banNode(pgpId, banned_node);
|
||||
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void IdentityHandler::handleSetOpinion(Request& req, Response& resp)
|
||||
{
|
||||
std::string gxs_id;
|
||||
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
|
||||
RsGxsId gxsId(gxs_id);
|
||||
|
||||
int own_opinion;
|
||||
req.mStream << makeKeyValueReference("own_opinion", own_opinion);
|
||||
|
||||
RsReputations::Opinion opinion;
|
||||
switch(own_opinion)
|
||||
{
|
||||
case 0:
|
||||
opinion = RsReputations::OPINION_NEGATIVE;
|
||||
break;
|
||||
case 1: opinion =
|
||||
RsReputations::OPINION_NEUTRAL;
|
||||
break;
|
||||
case 2:
|
||||
opinion = RsReputations::OPINION_POSITIVE;
|
||||
break;
|
||||
default:
|
||||
resp.setFail();
|
||||
return;
|
||||
}
|
||||
rsReputations->setOwnOpinion(gxsId, opinion);
|
||||
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
ResponseTask* IdentityHandler::handleOwn(Request & /* req */, Response &resp)
|
||||
{
|
||||
StateToken state;
|
||||
@ -192,4 +545,9 @@ ResponseTask* IdentityHandler::handleCreateIdentity(Request & /* req */, Respons
|
||||
return new CreateIdentityTask(mRsIdentity);
|
||||
}
|
||||
|
||||
ResponseTask* IdentityHandler::handleDeleteIdentity(Request& req, Response& resp)
|
||||
{
|
||||
return new DeleteIdentityTask(mRsIdentity);
|
||||
}
|
||||
|
||||
} // namespace resource_api
|
||||
|
@ -23,8 +23,20 @@ public:
|
||||
|
||||
private:
|
||||
void handleWildcard(Request& req, Response& resp);
|
||||
void handleNotOwnIdsRequest(Request& req, Response& resp);
|
||||
void handleOwnIdsRequest(Request& req, Response& resp);
|
||||
|
||||
void handleAddContact(Request& req, Response& resp);
|
||||
void handleRemoveContact(Request& req, Response& resp);
|
||||
|
||||
void handleGetIdentityDetails(Request& req, Response& resp);
|
||||
|
||||
void handleSetBanNode(Request& req, Response& resp);
|
||||
void handleSetOpinion(Request& req, Response& resp);
|
||||
|
||||
ResponseTask *handleOwn(Request& req, Response& resp);
|
||||
ResponseTask *handleCreateIdentity(Request& req, Response& resp);
|
||||
ResponseTask *handleDeleteIdentity(Request& req, Response& resp);
|
||||
|
||||
StateTokenServer* mStateTokenServer;
|
||||
RsNotify* mNotify;
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <util/radix64.h>
|
||||
#include <retroshare/rsstatus.h>
|
||||
#include <retroshare/rsiface.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -12,6 +14,12 @@
|
||||
namespace resource_api
|
||||
{
|
||||
|
||||
#define PEER_STATE_ONLINE 1
|
||||
#define PEER_STATE_BUSY 2
|
||||
#define PEER_STATE_AWAY 3
|
||||
#define PEER_STATE_AVAILABLE 4
|
||||
#define PEER_STATE_INACTIVE 5
|
||||
#define PEER_STATE_OFFLINE 6
|
||||
// todo: groups, add friend, remove friend, permissions
|
||||
|
||||
void peerDetailsToStream(StreamBase& stream, RsPeerDetails& details)
|
||||
@ -21,7 +29,50 @@ void peerDetailsToStream(StreamBase& stream, RsPeerDetails& details)
|
||||
<< makeKeyValueReference("name", details.name)
|
||||
<< makeKeyValueReference("location", details.location)
|
||||
<< makeKeyValueReference("pgp_id", details.gpg_id)
|
||||
;
|
||||
<< makeKeyValueReference("pgp_id", details.gpg_id);
|
||||
|
||||
if(details.state & RS_PEER_STATE_CONNECTED)
|
||||
{
|
||||
std::list<StatusInfo> statusInfo;
|
||||
rsStatus->getStatusList(statusInfo);
|
||||
|
||||
std::string state_string;
|
||||
std::list<StatusInfo>::iterator it;
|
||||
for (it = statusInfo.begin(); it != statusInfo.end(); ++it)
|
||||
{
|
||||
if (it->id == details.id)
|
||||
{
|
||||
switch (it->status)
|
||||
{
|
||||
case RS_STATUS_INACTIVE:
|
||||
state_string = "inactive";
|
||||
break;
|
||||
|
||||
case RS_STATUS_ONLINE:
|
||||
state_string = "online";
|
||||
break;
|
||||
|
||||
case RS_STATUS_AWAY:
|
||||
state_string = "away";
|
||||
break;
|
||||
|
||||
case RS_STATUS_BUSY:
|
||||
state_string = "busy";
|
||||
break;
|
||||
default:
|
||||
state_string = "undefined";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
stream << makeKeyValueReference("state_string", state_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string state_string = "undefined";
|
||||
stream << makeKeyValueReference("state_string", state_string);
|
||||
}
|
||||
}
|
||||
|
||||
bool peerInfoToStream(StreamBase& stream, RsPeerDetails& details, RsPeers* peers, std::list<RsGroupInfo>& grpInfo, bool have_avatar)
|
||||
@ -29,7 +80,9 @@ bool peerInfoToStream(StreamBase& stream, RsPeerDetails& details, RsPeers* peers
|
||||
bool ok = true;
|
||||
peerDetailsToStream(stream, details);
|
||||
stream << makeKeyValue("is_online", peers->isOnline(details.id))
|
||||
<< makeKeyValue("chat_id", ChatId(details.id).toStdString());
|
||||
<< makeKeyValue("chat_id", ChatId(details.id).toStdString())
|
||||
<< makeKeyValue("custom_state_string", rsMsgs->getCustomStateString(details.id));
|
||||
|
||||
|
||||
std::string avatar_address = "/"+details.id.toStdString()+"/avatar_image";
|
||||
|
||||
@ -54,6 +107,84 @@ bool peerInfoToStream(StreamBase& stream, RsPeerDetails& details, RsPeers* peers
|
||||
return ok;
|
||||
}
|
||||
|
||||
std::string peerStateString(int peerState)
|
||||
{
|
||||
if (peerState & RS_PEER_STATE_CONNECTED) {
|
||||
return "Connected";
|
||||
} else if (peerState & RS_PEER_STATE_UNREACHABLE) {
|
||||
return "Unreachable";
|
||||
} else if (peerState & RS_PEER_STATE_ONLINE) {
|
||||
return "Available";
|
||||
} else if (peerState & RS_PEER_STATE_FRIEND) {
|
||||
return "Offline";
|
||||
}
|
||||
|
||||
return "Neighbor";
|
||||
}
|
||||
|
||||
std::string connectStateString(RsPeerDetails &details)
|
||||
{
|
||||
std::string stateString;
|
||||
bool isConnected = false;
|
||||
|
||||
switch (details.connectState) {
|
||||
case 0:
|
||||
stateString = peerStateString(details.state);
|
||||
break;
|
||||
case RS_PEER_CONNECTSTATE_TRYING_TCP:
|
||||
stateString = "Trying TCP";
|
||||
break;
|
||||
case RS_PEER_CONNECTSTATE_TRYING_UDP:
|
||||
stateString = "Trying UDP";
|
||||
break;
|
||||
case RS_PEER_CONNECTSTATE_CONNECTED_TCP:
|
||||
stateString = "Connected: TCP";
|
||||
isConnected = true;
|
||||
break;
|
||||
case RS_PEER_CONNECTSTATE_CONNECTED_UDP:
|
||||
stateString = "Connected: UDP";
|
||||
isConnected = true;
|
||||
break;
|
||||
case RS_PEER_CONNECTSTATE_CONNECTED_TOR:
|
||||
stateString = "Connected: Tor";
|
||||
isConnected = true;
|
||||
break;
|
||||
case RS_PEER_CONNECTSTATE_CONNECTED_I2P:
|
||||
stateString = "Connected: I2P";
|
||||
isConnected = true;
|
||||
break;
|
||||
case RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN:
|
||||
stateString = "Connected: Unknown";
|
||||
isConnected = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(isConnected) {
|
||||
stateString += " ";
|
||||
if(details.actAsServer)
|
||||
stateString += "inbound connection";
|
||||
else
|
||||
stateString += "outbound connection";
|
||||
}
|
||||
|
||||
if (details.connectStateString.empty() == false) {
|
||||
if (stateString.empty() == false) {
|
||||
stateString += ": ";
|
||||
}
|
||||
stateString += details.connectStateString;
|
||||
}
|
||||
|
||||
/* HACK to display DHT Status info too */
|
||||
if (details.foundDHT) {
|
||||
if (stateString.empty() == false) {
|
||||
stateString += ", ";
|
||||
}
|
||||
stateString += "DHT: Contact";
|
||||
}
|
||||
|
||||
return stateString;
|
||||
}
|
||||
|
||||
PeersHandler::PeersHandler(StateTokenServer* sts, RsNotify* notify, RsPeers *peers, RsMsgs* msgs):
|
||||
mStateTokenServer(sts),
|
||||
mNotify(notify),
|
||||
@ -63,7 +194,15 @@ PeersHandler::PeersHandler(StateTokenServer* sts, RsNotify* notify, RsPeers *pee
|
||||
mNotify->registerNotifyClient(this);
|
||||
mStateTokenServer->registerTickClient(this);
|
||||
addResourceHandler("*", this, &PeersHandler::handleWildcard);
|
||||
addResourceHandler("examine_cert", this, &PeersHandler::handleExamineCert);
|
||||
addResourceHandler("get_state_string", this, &PeersHandler::handleGetStateString);
|
||||
addResourceHandler("set_state_string", this, &PeersHandler::handleSetStateString);
|
||||
addResourceHandler("get_custom_state_string", this, &PeersHandler::handleGetCustomStateString);
|
||||
addResourceHandler("set_custom_state_string", this, &PeersHandler::handleSetCustomStateString);
|
||||
addResourceHandler("get_pgp_options", this, &PeersHandler::handleGetPGPOptions);
|
||||
addResourceHandler("set_pgp_options", this, &PeersHandler::handleSetPGPOptions);
|
||||
addResourceHandler("get_node_options", this, &PeersHandler::handleGetNodeOptions);
|
||||
addResourceHandler("set_node_options", this, &PeersHandler::handleSetNodeOptions);
|
||||
addResourceHandler("examine_cert", this, &PeersHandler::handleExamineCert);
|
||||
}
|
||||
|
||||
PeersHandler::~PeersHandler()
|
||||
@ -82,6 +221,12 @@ void PeersHandler::notifyListChange(int list, int /* type */)
|
||||
}
|
||||
}
|
||||
|
||||
void PeersHandler::notifyPeerStatusChanged(const std::string& /*peer_id*/, uint32_t /*state*/)
|
||||
{
|
||||
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/
|
||||
mStateTokenServer->replaceToken(mStateToken);
|
||||
}
|
||||
|
||||
void PeersHandler::notifyPeerHasNewAvatar(std::string /*peer_id*/)
|
||||
{
|
||||
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/
|
||||
@ -100,6 +245,27 @@ void PeersHandler::tick()
|
||||
mStateTokenServer->discardToken(mStateToken);
|
||||
mStateToken = mStateTokenServer->getNewToken();
|
||||
}
|
||||
|
||||
StatusInfo statusInfo;
|
||||
rsStatus->getOwnStatus(statusInfo);
|
||||
if(statusInfo.status != status)
|
||||
{
|
||||
status = statusInfo.status;
|
||||
|
||||
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/
|
||||
mStateTokenServer->discardToken(mStringStateToken);
|
||||
mStringStateToken = mStateTokenServer->getNewToken();
|
||||
}
|
||||
|
||||
std::string custom_state = rsMsgs->getCustomStateString();
|
||||
if(custom_state != custom_state_string)
|
||||
{
|
||||
custom_state_string = custom_state;
|
||||
|
||||
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/
|
||||
mStateTokenServer->discardToken(mCustomStateToken);
|
||||
mCustomStateToken = mStateTokenServer->getNewToken();
|
||||
}
|
||||
}
|
||||
|
||||
void PeersHandler::notifyUnreadMsgCountChanged(const RsPeerId &peer, uint32_t count)
|
||||
@ -121,6 +287,73 @@ static bool have_avatar(RsMsgs* msgs, const RsPeerId& id)
|
||||
return size != 0;
|
||||
}
|
||||
|
||||
void PeersHandler::handleGetStateString(Request& /*req*/, Response& resp)
|
||||
{
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
resp.mStateToken = mStringStateToken;
|
||||
}
|
||||
|
||||
std::string state_string;
|
||||
StatusInfo statusInfo;
|
||||
if (rsStatus->getOwnStatus(statusInfo))
|
||||
{
|
||||
if(statusInfo.status == RS_STATUS_ONLINE)
|
||||
state_string = "online";
|
||||
else if(statusInfo.status == RS_STATUS_BUSY)
|
||||
state_string = "busy";
|
||||
else if(statusInfo.status == RS_STATUS_AWAY)
|
||||
state_string = "away";
|
||||
else if(statusInfo.status == RS_STATUS_INACTIVE)
|
||||
state_string = "inactive";
|
||||
else
|
||||
state_string = "undefined";
|
||||
}
|
||||
else
|
||||
state_string = "undefined";
|
||||
|
||||
resp.mDataStream << makeKeyValueReference("state_string", state_string);
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void PeersHandler::handleSetStateString(Request& req, Response& resp)
|
||||
{
|
||||
std::string state_string;
|
||||
req.mStream << makeKeyValueReference("state_string", state_string);
|
||||
|
||||
uint32_t status = RS_STATUS_OFFLINE;
|
||||
if(state_string == "online")
|
||||
status = RS_STATUS_ONLINE;
|
||||
else if(state_string == "busy")
|
||||
status = RS_STATUS_BUSY;
|
||||
else if(state_string == "away")
|
||||
status = RS_STATUS_AWAY;
|
||||
|
||||
rsStatus->sendStatus(RsPeerId(), status);
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void PeersHandler::handleGetCustomStateString(Request& /*req*/, Response& resp)
|
||||
{
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
resp.mStateToken = mCustomStateToken;
|
||||
}
|
||||
|
||||
std::string custom_state_string = rsMsgs->getCustomStateString();
|
||||
resp.mDataStream << makeKeyValueReference("custom_state_string", custom_state_string);
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void PeersHandler::handleSetCustomStateString(Request& req, Response& resp)
|
||||
{
|
||||
std::string custom_state_string;
|
||||
req.mStream << makeKeyValueReference("custom_state_string", custom_state_string);
|
||||
|
||||
rsMsgs->setCustomStateString(custom_state_string);
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void PeersHandler::handleWildcard(Request &req, Response &resp)
|
||||
{
|
||||
bool ok = false;
|
||||
@ -176,6 +409,9 @@ void PeersHandler::handleWildcard(Request &req, Response &resp)
|
||||
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/
|
||||
unread_msgs = mUnreadMsgsCounts;
|
||||
}
|
||||
std::list<StatusInfo> statusInfo;
|
||||
rsStatus->getStatusList(statusInfo);
|
||||
|
||||
// list all peers
|
||||
ok = true;
|
||||
std::list<RsPgpId> identities;
|
||||
@ -216,6 +452,11 @@ void PeersHandler::handleWildcard(Request &req, Response &resp)
|
||||
StreamBase& locationStream = itemStream.getStreamToMember("locations");
|
||||
// mark as list (in case list is empty)
|
||||
locationStream.getStreamToMember();
|
||||
|
||||
int bestPeerState = 0;
|
||||
unsigned int bestRSState = 0;
|
||||
std::string bestCustomStateString;
|
||||
|
||||
for(std::vector<RsPeerDetails>::iterator vit = detailsVec.begin(); vit != detailsVec.end(); ++vit)
|
||||
{
|
||||
if(vit->gpg_id == *lit)
|
||||
@ -226,8 +467,85 @@ void PeersHandler::handleWildcard(Request &req, Response &resp)
|
||||
unread = unread_msgs.find(vit->id)->second;
|
||||
stream << makeKeyValueReference("unread_msgs", unread);
|
||||
peerInfoToStream(stream,*vit, mRsPeers, grpInfo, have_avatar(mRsMsgs, vit->id));
|
||||
}
|
||||
|
||||
|
||||
/* Custom state string */
|
||||
std::string customStateString;
|
||||
if (vit->state & RS_PEER_STATE_CONNECTED)
|
||||
{
|
||||
customStateString = rsMsgs->getCustomStateString(vit->id);
|
||||
}
|
||||
|
||||
int peerState = 0;
|
||||
|
||||
if (vit->state & RS_PEER_STATE_CONNECTED)
|
||||
{
|
||||
// get the status info for this ssl id
|
||||
int rsState = 0;
|
||||
std::list<StatusInfo>::iterator it;
|
||||
for (it = statusInfo.begin(); it != statusInfo.end(); ++it)
|
||||
{
|
||||
if (it->id == vit->id)
|
||||
{
|
||||
rsState = it->status;
|
||||
switch (rsState)
|
||||
{
|
||||
case RS_STATUS_INACTIVE:
|
||||
peerState = PEER_STATE_INACTIVE;
|
||||
break;
|
||||
|
||||
case RS_STATUS_ONLINE:
|
||||
peerState = PEER_STATE_ONLINE;
|
||||
break;
|
||||
|
||||
case RS_STATUS_AWAY:
|
||||
peerState = PEER_STATE_AWAY;
|
||||
break;
|
||||
|
||||
case RS_STATUS_BUSY:
|
||||
peerState = PEER_STATE_BUSY;
|
||||
break;
|
||||
}
|
||||
|
||||
/* find the best ssl contact for the gpg item */
|
||||
if (bestPeerState == 0 || peerState < bestPeerState)
|
||||
{
|
||||
bestPeerState = peerState;
|
||||
bestRSState = rsState;
|
||||
bestCustomStateString = customStateString;
|
||||
}
|
||||
else if (peerState == bestPeerState)
|
||||
{
|
||||
/* equal state */
|
||||
if (bestCustomStateString.empty() && !customStateString.empty())
|
||||
{
|
||||
bestPeerState = peerState;
|
||||
bestRSState = rsState;
|
||||
bestCustomStateString = customStateString;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
itemStream << makeKeyValue("custom_state_string", bestCustomStateString);
|
||||
|
||||
std::string state_string;
|
||||
|
||||
if(bestRSState == RS_STATUS_ONLINE)
|
||||
state_string = "online";
|
||||
else if(bestRSState == RS_STATUS_BUSY)
|
||||
state_string = "busy";
|
||||
else if(bestRSState == RS_STATUS_AWAY)
|
||||
state_string = "away";
|
||||
else if(bestRSState == RS_STATUS_INACTIVE)
|
||||
state_string = "inactive";
|
||||
else
|
||||
state_string = "undefined";
|
||||
|
||||
itemStream << makeKeyValue("state_string", state_string);
|
||||
}
|
||||
resp.mStateToken = getCurrentStateToken();
|
||||
}
|
||||
@ -300,6 +618,237 @@ void PeersHandler::handleExamineCert(Request &req, Response &resp)
|
||||
}
|
||||
}
|
||||
|
||||
void PeersHandler::handleGetPGPOptions(Request& req, Response& resp)
|
||||
{
|
||||
std::string pgp_id;
|
||||
req.mStream << makeKeyValueReference("pgp_id", pgp_id);
|
||||
|
||||
RsPgpId pgp(pgp_id);
|
||||
RsPeerDetails detail;
|
||||
|
||||
if(!mRsPeers->getGPGDetails(pgp, detail))
|
||||
{
|
||||
resp.setFail();
|
||||
return;
|
||||
}
|
||||
|
||||
std::string pgp_key = mRsPeers->getPGPKey(detail.gpg_id, false);
|
||||
|
||||
resp.mDataStream << makeKeyValue("pgp_fingerprint", detail.fpr.toStdString());
|
||||
resp.mDataStream << makeKeyValueReference("pgp_key", pgp_key);
|
||||
|
||||
resp.mDataStream << makeKeyValue("direct_transfer", detail.service_perm_flags & RS_NODE_PERM_DIRECT_DL);
|
||||
resp.mDataStream << makeKeyValue("allow_push", detail.service_perm_flags & RS_NODE_PERM_ALLOW_PUSH);
|
||||
resp.mDataStream << makeKeyValue("require_WL", detail.service_perm_flags & RS_NODE_PERM_REQUIRE_WL);
|
||||
|
||||
resp.mDataStream << makeKeyValue("own_sign", detail.ownsign);
|
||||
resp.mDataStream << makeKeyValue("trustLvl", detail.trustLvl);
|
||||
|
||||
uint32_t max_upload_speed = 0;
|
||||
uint32_t max_download_speed = 0;
|
||||
|
||||
mRsPeers->getPeerMaximumRates(pgp, max_upload_speed, max_download_speed);
|
||||
|
||||
resp.mDataStream << makeKeyValueReference("maxUploadSpeed", max_upload_speed);
|
||||
resp.mDataStream << makeKeyValueReference("maxDownloadSpeed", max_download_speed);
|
||||
|
||||
StreamBase& signersStream = resp.mDataStream.getStreamToMember("gpg_signers");
|
||||
|
||||
// mark as list (in case list is empty)
|
||||
signersStream.getStreamToMember();
|
||||
|
||||
for(std::list<RsPgpId>::const_iterator it(detail.gpgSigners.begin()); it != detail.gpgSigners.end(); ++it)
|
||||
{
|
||||
RsPeerDetails detail;
|
||||
if(!mRsPeers->getGPGDetails(*it, detail))
|
||||
continue;
|
||||
|
||||
std::string pgp_id = (*it).toStdString();
|
||||
std::string name = detail.name;
|
||||
|
||||
signersStream.getStreamToMember()
|
||||
<< makeKeyValueReference("pgp_id", pgp_id)
|
||||
<< makeKeyValueReference("name", name);
|
||||
}
|
||||
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void PeersHandler::handleSetPGPOptions(Request& req, Response& resp)
|
||||
{
|
||||
std::string pgp_id;
|
||||
req.mStream << makeKeyValueReference("pgp_id", pgp_id);
|
||||
|
||||
RsPgpId pgp(pgp_id);
|
||||
RsPeerDetails detail;
|
||||
|
||||
if(!mRsPeers->getGPGDetails(pgp, detail))
|
||||
{
|
||||
resp.setFail();
|
||||
return;
|
||||
}
|
||||
|
||||
int trustLvl;
|
||||
req.mStream << makeKeyValueReference("trustLvl", trustLvl);
|
||||
|
||||
if(trustLvl != (int)detail.trustLvl)
|
||||
mRsPeers->trustGPGCertificate(pgp, trustLvl);
|
||||
|
||||
int max_upload_speed;
|
||||
int max_download_speed;
|
||||
|
||||
req.mStream << makeKeyValueReference("max_upload_speed", max_upload_speed);
|
||||
req.mStream << makeKeyValueReference("max_download_speed", max_download_speed);
|
||||
|
||||
mRsPeers->setPeerMaximumRates(pgp, (uint32_t)max_upload_speed, (uint32_t)max_download_speed);
|
||||
|
||||
bool direct_transfer;
|
||||
bool allow_push;
|
||||
bool require_WL;
|
||||
|
||||
req.mStream << makeKeyValueReference("direct_transfer", direct_transfer);
|
||||
req.mStream << makeKeyValueReference("allow_push", allow_push);
|
||||
req.mStream << makeKeyValueReference("require_WL", require_WL);
|
||||
|
||||
ServicePermissionFlags flags(0);
|
||||
|
||||
if(direct_transfer)
|
||||
flags = flags | RS_NODE_PERM_DIRECT_DL;
|
||||
if(allow_push)
|
||||
flags = flags | RS_NODE_PERM_ALLOW_PUSH;
|
||||
if(require_WL)
|
||||
flags = flags | RS_NODE_PERM_REQUIRE_WL;
|
||||
|
||||
mRsPeers->setServicePermissionFlags(pgp, flags);
|
||||
|
||||
bool own_sign;
|
||||
req.mStream << makeKeyValueReference("own_sign", own_sign);
|
||||
|
||||
if(own_sign)
|
||||
mRsPeers->signGPGCertificate(pgp);
|
||||
|
||||
resp.mStateToken = getCurrentStateToken();
|
||||
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void PeersHandler::handleGetNodeOptions(Request& req, Response& resp)
|
||||
{
|
||||
std::string peer_id;
|
||||
req.mStream << makeKeyValueReference("peer_id", peer_id);
|
||||
|
||||
RsPeerId peerId(peer_id);
|
||||
RsPeerDetails detail;
|
||||
if(!mRsPeers->getPeerDetails(peerId, detail))
|
||||
{
|
||||
resp.setFail();
|
||||
return;
|
||||
}
|
||||
|
||||
resp.mDataStream << makeKeyValue("peer_id", detail.id.toStdString());
|
||||
resp.mDataStream << makeKeyValue("name", detail.name);
|
||||
resp.mDataStream << makeKeyValue("location", detail.location);
|
||||
resp.mDataStream << makeKeyValue("pgp_id", detail.gpg_id.toStdString());
|
||||
resp.mDataStream << makeKeyValue("last_contact", detail.lastConnect);
|
||||
|
||||
std::string status_message = mRsMsgs->getCustomStateString(detail.id);
|
||||
resp.mDataStream << makeKeyValueReference("status_message", status_message);
|
||||
|
||||
std::string encryption;
|
||||
RsPeerCryptoParams cdet;
|
||||
if(RsControl::instance()->getPeerCryptoDetails(detail.id, cdet) && cdet.connexion_state != 0)
|
||||
{
|
||||
encryption = cdet.cipher_version;
|
||||
encryption += ": ";
|
||||
encryption += cdet.cipher_name;
|
||||
|
||||
if(cdet.cipher_version != "TLSv1.2")
|
||||
encryption += cdet.cipher_bits_1;
|
||||
}
|
||||
else
|
||||
encryption = "Not connected";
|
||||
|
||||
resp.mDataStream << makeKeyValueReference("encryption", encryption);
|
||||
|
||||
resp.mDataStream << makeKeyValue("is_hidden_node", detail.isHiddenNode);
|
||||
if (detail.isHiddenNode)
|
||||
{
|
||||
resp.mDataStream << makeKeyValue("local_address", detail.hiddenNodeAddress);
|
||||
resp.mDataStream << makeKeyValue("local_port", (int)detail.hiddenNodePort);
|
||||
resp.mDataStream << makeKeyValue("ext_address", std::string("none"));
|
||||
resp.mDataStream << makeKeyValue("ext_port", 0);
|
||||
resp.mDataStream << makeKeyValue("dyn_dns", std::string("none"));
|
||||
}
|
||||
else
|
||||
{
|
||||
resp.mDataStream << makeKeyValue("local_address", detail.localAddr);
|
||||
resp.mDataStream << makeKeyValue("local_port", (int)detail.localPort);
|
||||
resp.mDataStream << makeKeyValue("ext_address", detail.extAddr);
|
||||
resp.mDataStream << makeKeyValue("ext_port", (int)detail.extPort);
|
||||
resp.mDataStream << makeKeyValue("dyn_dns", detail.dyndns);
|
||||
}
|
||||
|
||||
resp.mDataStream << makeKeyValue("connection_status", connectStateString(detail));
|
||||
|
||||
StreamBase& addressesStream = resp.mDataStream.getStreamToMember("ip_addresses");
|
||||
|
||||
// mark as list (in case list is empty)
|
||||
addressesStream.getStreamToMember();
|
||||
|
||||
for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin()); it != detail.ipAddressList.end(); ++it)
|
||||
{
|
||||
addressesStream.getStreamToMember() << makeKeyValue("ip_address", (*it));
|
||||
}
|
||||
|
||||
std::string certificate = mRsPeers->GetRetroshareInvite(detail.id, false);
|
||||
resp.mDataStream << makeKeyValueReference("certificate", certificate);
|
||||
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void PeersHandler::handleSetNodeOptions(Request& req, Response& resp)
|
||||
{
|
||||
std::string peer_id;
|
||||
req.mStream << makeKeyValueReference("peer_id", peer_id);
|
||||
|
||||
RsPeerId peerId(peer_id);
|
||||
RsPeerDetails detail;
|
||||
if(!mRsPeers->getPeerDetails(peerId, detail))
|
||||
{
|
||||
resp.setFail();
|
||||
return;
|
||||
}
|
||||
|
||||
std::string local_address;
|
||||
std::string ext_address;
|
||||
std::string dyn_dns;
|
||||
int local_port;
|
||||
int ext_port;
|
||||
|
||||
req.mStream << makeKeyValueReference("local_address", local_address);
|
||||
req.mStream << makeKeyValueReference("local_port", local_port);
|
||||
req.mStream << makeKeyValueReference("ext_address", ext_address);
|
||||
req.mStream << makeKeyValueReference("ext_port", ext_port);
|
||||
req.mStream << makeKeyValueReference("dyn_dns", dyn_dns);
|
||||
|
||||
if(!detail.isHiddenNode)
|
||||
{
|
||||
if(detail.localAddr != local_address || (int)detail.localPort != local_port)
|
||||
mRsPeers->setLocalAddress(peerId, local_address, local_port);
|
||||
if(detail.extAddr != ext_address || (int)detail.extPort != ext_port)
|
||||
mRsPeers->setExtAddress(peerId, ext_address, ext_port);
|
||||
if(detail.dyndns != dyn_dns)
|
||||
mRsPeers->setDynDNS(peerId, dyn_dns);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(detail.hiddenNodeAddress != local_address || detail.hiddenNodePort != local_port)
|
||||
rsPeers->setHiddenNode(peerId, local_address, local_port);
|
||||
}
|
||||
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
StateToken PeersHandler::getCurrentStateToken()
|
||||
{
|
||||
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
// from NotifyClient
|
||||
// note: this may get called from foreign threads
|
||||
virtual void notifyListChange(int list, int type); // friends list change
|
||||
virtual void notifyPeerStatusChanged(const std::string& /*peer_id*/, uint32_t /*state*/);
|
||||
virtual void notifyPeerHasNewAvatar(std::string /*peer_id*/);
|
||||
|
||||
// from Tickable
|
||||
@ -35,6 +36,18 @@ private:
|
||||
void handleWildcard(Request& req, Response& resp);
|
||||
void handleExamineCert(Request& req, Response& resp);
|
||||
|
||||
void handleGetStateString(Request& req, Response& resp);
|
||||
void handleSetStateString(Request& req, Response& resp);
|
||||
|
||||
void handleGetCustomStateString(Request& req, Response& resp);
|
||||
void handleSetCustomStateString(Request& req, Response& resp);
|
||||
|
||||
void handleGetPGPOptions(Request& req, Response& resp);
|
||||
void handleSetPGPOptions(Request& req, Response& resp);
|
||||
|
||||
void handleGetNodeOptions(Request& req, Response& resp);
|
||||
void handleSetNodeOptions(Request& req, Response& resp);
|
||||
|
||||
// a helper which ensures proper mutex locking
|
||||
StateToken getCurrentStateToken();
|
||||
|
||||
@ -44,9 +57,14 @@ private:
|
||||
RsMsgs* mRsMsgs; // required for avatar data
|
||||
|
||||
std::list<RsPeerId> mOnlinePeers;
|
||||
uint32_t status;
|
||||
std::string custom_state_string;
|
||||
|
||||
RsMutex mMtx;
|
||||
StateToken mStateToken; // mutex protected
|
||||
StateToken mStringStateToken; // mutex protected
|
||||
StateToken mCustomStateToken; // mutex protected
|
||||
|
||||
std::map<RsPeerId, uint32_t> mUnreadMsgsCounts;
|
||||
};
|
||||
} // namespace resource_api
|
||||
|
@ -37,6 +37,13 @@ ResponseTask* ResourceRouter::handleRequest(Request& req, Response& resp)
|
||||
if(vit->first == req.mPath.top())
|
||||
{
|
||||
req.mPath.pop();
|
||||
|
||||
//Just for GUI benefit
|
||||
std::string callbackName;
|
||||
req.mStream << makeKeyValueReference("callback_name", callbackName);
|
||||
resp.mCallbackName = callbackName;
|
||||
//
|
||||
|
||||
return vit->second->handleRequest(req, resp);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <retroshare/rsinit.h>
|
||||
#include <retroshare/rsiface.h>
|
||||
#include <util/rsdir.h>
|
||||
|
||||
#include "api/ApiServer.h"
|
||||
#include "api/Operators.h"
|
||||
@ -23,7 +24,9 @@ RsControlModule::RsControlModule(int argc, char **argv, StateTokenServer* sts, A
|
||||
mDataMtx("RsControlModule::mDataMtx"),
|
||||
mRunState(WAITING_INIT),
|
||||
mAutoLoginNextTime(false),
|
||||
mWantPassword(false)
|
||||
mWantPassword(false),
|
||||
mPrevIsBad(false),
|
||||
mPassword("")
|
||||
{
|
||||
mStateToken = sts->getNewToken();
|
||||
this->argc = argc;
|
||||
@ -55,13 +58,16 @@ bool RsControlModule::processShouldExit()
|
||||
return mProcessShouldExit;
|
||||
}
|
||||
|
||||
bool RsControlModule::askForPassword(const std::string &title, 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 ;
|
||||
{
|
||||
RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
|
||||
|
||||
mPrevIsBad = prev_is_bad;
|
||||
|
||||
if(mFixedPassword != "")
|
||||
{
|
||||
{
|
||||
password = mFixedPassword;
|
||||
return true;
|
||||
}
|
||||
@ -69,25 +75,31 @@ bool RsControlModule::askForPassword(const std::string &title, const std::string
|
||||
mWantPassword = true;
|
||||
mTitle = title;
|
||||
mKeyName = key_details;
|
||||
mPassword = "";
|
||||
|
||||
if(mPassword != "")
|
||||
{
|
||||
password = mPassword;
|
||||
mWantPassword = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
mStateTokenServer->replaceToken(mStateToken);
|
||||
}
|
||||
|
||||
bool wait = true;
|
||||
while(wait)
|
||||
int i = 0;
|
||||
while(i<100)
|
||||
{
|
||||
usleep(5*1000);
|
||||
|
||||
RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
|
||||
wait = mWantPassword;
|
||||
if(!wait && mPassword != "")
|
||||
|
||||
if(mPassword != "")
|
||||
{
|
||||
password = mPassword;
|
||||
mPassword = "";
|
||||
password = mPassword;
|
||||
mWantPassword = false;
|
||||
mStateTokenServer->replaceToken(mStateToken);
|
||||
return true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -124,6 +136,11 @@ void RsControlModule::run()
|
||||
bool login_ok = false;
|
||||
while(!login_ok)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mDataMtx); // ********** LOCKED **********
|
||||
mPassword = "";
|
||||
}
|
||||
|
||||
// skip account selection if autologin is available
|
||||
if(initResult != RS_INIT_HAVE_ACCOUNT)
|
||||
setRunState(WAITING_ACCOUNT_SELECT);
|
||||
@ -174,8 +191,19 @@ void RsControlModule::run()
|
||||
std::cerr << "RsControlModule::run() LockAndLoadCertificates failed. Unexpected switch value: " << retVal << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
{
|
||||
RsStackMutex stack(mDataMtx); // ********** LOCKED **********
|
||||
mLoadPeerId.clear();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
RsStackMutex stack(mDataMtx); // ********** LOCKED **********
|
||||
mFixedPassword = mPassword;
|
||||
mPassword = "";
|
||||
}
|
||||
|
||||
setRunState(WAITING_STARTUP);
|
||||
|
||||
std::cerr << "RsControlModule: login ok, starting Retroshare worker threads..." << std::endl;
|
||||
@ -305,7 +333,8 @@ void RsControlModule::handlePassword(Request &req, Response &resp)
|
||||
|
||||
resp.mDataStream
|
||||
<< makeKeyValueReference("want_password", mWantPassword)
|
||||
<< makeKeyValueReference("key_name", mKeyName);
|
||||
<< makeKeyValueReference("key_name", mKeyName)
|
||||
<< makeKeyValueReference("prev_is_bad", mPrevIsBad);
|
||||
resp.mStateToken = mStateToken;
|
||||
resp.setOk();
|
||||
}
|
||||
@ -425,17 +454,18 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp)
|
||||
RsPeerId ssl_id;
|
||||
std::string err_string;
|
||||
// give the password to the password callback
|
||||
{
|
||||
RsStackMutex stack(mDataMtx); // ********** LOCKED **********
|
||||
mFixedPassword = pgp_password;
|
||||
}
|
||||
{
|
||||
RsStackMutex stack(mDataMtx); // ********** LOCKED **********
|
||||
mPassword = pgp_password;
|
||||
mFixedPassword = pgp_password;
|
||||
}
|
||||
bool ssl_ok = RsAccounts::GenerateSSLCertificate(pgp_id, "", ssl_name, "", hidden_port!=0, ssl_password, ssl_id, err_string);
|
||||
|
||||
// clear fixed password to restore normal password operation
|
||||
{
|
||||
RsStackMutex stack(mDataMtx); // ********** LOCKED **********
|
||||
mFixedPassword = "";
|
||||
}
|
||||
// {
|
||||
// RsStackMutex stack(mDataMtx); // ********** LOCKED **********
|
||||
// mFixedPassword = "";
|
||||
// }
|
||||
|
||||
if (ssl_ok)
|
||||
{
|
||||
@ -456,6 +486,20 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp)
|
||||
resp.setFail("could not create a new location. Error: "+err_string);
|
||||
}
|
||||
|
||||
bool RsControlModule::askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result, std::string reason /*=""*/)
|
||||
{
|
||||
if(rsPeers->gpgSignData(data,len,sign,signlen,reason))
|
||||
{
|
||||
signature_result = SELF_SIGNATURE_RESULT_SUCCESS;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
signature_result = SELF_SIGNATURE_RESULT_FAILED;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void RsControlModule::setRunState(RunState s, std::string errstr)
|
||||
{
|
||||
RsStackMutex stack(mDataMtx); // ********** LOCKED **********
|
||||
|
@ -31,8 +31,9 @@ public:
|
||||
// returns true if the process should terminate
|
||||
bool processShouldExit();
|
||||
|
||||
// from NotifyClient
|
||||
virtual bool askForPassword(const std::string &title, const std::string& key_details, bool prev_is_bad , std::string& password,bool& canceled);
|
||||
// from NotifyClient
|
||||
virtual bool askForPassword(const std::string &title, const std::string& key_details, bool prev_is_bad , std::string& password,bool& canceled) override;
|
||||
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result, std::string reason = "") override;
|
||||
|
||||
protected:
|
||||
// from RsThread
|
||||
@ -76,6 +77,7 @@ private:
|
||||
// to notify that a password callback is waiting
|
||||
// to answer the request, clear the flag and set the password
|
||||
bool mWantPassword;
|
||||
bool mPrevIsBad ;
|
||||
std::string mTitle;
|
||||
std::string mKeyName;
|
||||
std::string mPassword;
|
||||
|
182
libresapi/src/api/SettingsHandler.cpp
Normal file
182
libresapi/src/api/SettingsHandler.cpp
Normal file
@ -0,0 +1,182 @@
|
||||
#include "SettingsHandler.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <retroshare/rsinit.h>
|
||||
|
||||
namespace resource_api
|
||||
{
|
||||
#define SETTINGS_FILE (QString::fromUtf8(RsAccounts::AccountDirectory().c_str()) + "/Sonet.conf")
|
||||
|
||||
SettingsHandler::SettingsHandler(StateTokenServer *sts, const QString settingsGroup) :
|
||||
QSettings(SETTINGS_FILE, QSettings::IniFormat),
|
||||
mStateTokenServer(sts),
|
||||
mMtx("SettingsHandler Mutex"),
|
||||
mStateToken(sts->getNewToken())
|
||||
{
|
||||
RsPeerId sPreferedId;
|
||||
m_bValid = RsAccounts::GetPreferredAccountId(sPreferedId);
|
||||
|
||||
if (!settingsGroup.isEmpty())
|
||||
beginGroup(settingsGroup);
|
||||
|
||||
addResourceHandler("*", this, &SettingsHandler::handleSettingsRequest);
|
||||
addResourceHandler("get_advanced_mode", this, &SettingsHandler::handleGetAdvancedMode);
|
||||
addResourceHandler("set_advanced_mode", this, &SettingsHandler::handleSetAdvancedMode);
|
||||
addResourceHandler("get_flickable_grid_mode", this, &SettingsHandler::handleGetFlickableGridMode);
|
||||
addResourceHandler("set_flickable_grid_mode", this, &SettingsHandler::handleSetFlickableGridMode);
|
||||
addResourceHandler("get_auto_login", this, &SettingsHandler::handleGetAutoLogin);
|
||||
addResourceHandler("set_auto_login", this, &SettingsHandler::handleSetAutoLogin);
|
||||
}
|
||||
|
||||
SettingsHandler::~SettingsHandler()
|
||||
{
|
||||
sync();
|
||||
}
|
||||
|
||||
void SettingsHandler::handleSettingsRequest(Request &/*req*/, Response &resp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SettingsHandler::handleGetAdvancedMode(Request &/*req*/, Response &resp)
|
||||
{
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
resp.mStateToken = mStateToken;
|
||||
}
|
||||
|
||||
bool advanced_mode = valueFromGroup("General", "Advanced", false).toBool();
|
||||
resp.mDataStream << makeKeyValueReference("advanced_mode", advanced_mode);
|
||||
resp.setOk();
|
||||
sync();
|
||||
}
|
||||
|
||||
void SettingsHandler::handleSetAdvancedMode(Request &req, Response &resp)
|
||||
{
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
resp.mStateToken = mStateToken;
|
||||
}
|
||||
|
||||
bool advanced_mode;
|
||||
req.mStream << makeKeyValueReference("advanced_mode", advanced_mode);
|
||||
setValueToGroup("General", "Advanced", advanced_mode);
|
||||
resp.setOk();
|
||||
sync();
|
||||
}
|
||||
|
||||
void SettingsHandler::handleGetFlickableGridMode(Request &/*req*/, Response &resp)
|
||||
{
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
resp.mStateToken = mStateToken;
|
||||
}
|
||||
|
||||
bool flickable_grid_mode = valueFromGroup("General", "FlickableGrid", false).toBool();
|
||||
resp.mDataStream << makeKeyValueReference("flickable_grid_mode", flickable_grid_mode);
|
||||
resp.setOk();
|
||||
sync();
|
||||
}
|
||||
|
||||
void SettingsHandler::handleSetFlickableGridMode(Request &req, Response &resp)
|
||||
{
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
resp.mStateToken = mStateToken;
|
||||
}
|
||||
|
||||
bool flickable_grid_mode;
|
||||
req.mStream << makeKeyValueReference("flickable_grid_mode", flickable_grid_mode);
|
||||
setValueToGroup("General", "FlickableGrid", flickable_grid_mode);
|
||||
|
||||
resp.setOk();
|
||||
sync();
|
||||
}
|
||||
|
||||
void SettingsHandler::handleGetAutoLogin(Request &/*req*/, Response &resp)
|
||||
{
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
resp.mStateToken = mStateToken;
|
||||
}
|
||||
|
||||
bool autoLogin = RsInit::getAutoLogin();;
|
||||
resp.mDataStream << makeKeyValueReference("auto_login", autoLogin);
|
||||
resp.setOk();
|
||||
sync();
|
||||
}
|
||||
|
||||
void SettingsHandler::handleSetAutoLogin(Request &req, Response &resp)
|
||||
{
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
resp.mStateToken = mStateToken;
|
||||
}
|
||||
|
||||
bool autoLogin;
|
||||
req.mStream << makeKeyValueReference("auto_login", autoLogin);
|
||||
RsInit::setAutoLogin(autoLogin);
|
||||
|
||||
resp.setOk();
|
||||
sync();
|
||||
}
|
||||
|
||||
QVariant SettingsHandler::value(const QString &key, const QVariant &defaultVal) const
|
||||
{
|
||||
if (m_bValid == false)
|
||||
{
|
||||
return defaultVal.isNull() ? defaultValue(key) : defaultVal;
|
||||
}
|
||||
return QSettings::value(key, defaultVal.isNull() ? defaultValue(key) : defaultVal);
|
||||
}
|
||||
|
||||
void SettingsHandler::setValue(const QString &key, const QVariant &val)
|
||||
{
|
||||
if (m_bValid == false)
|
||||
{
|
||||
std::cerr << "RSettings::setValue() Calling on invalid object, key = " << key.toStdString() << std::endl;
|
||||
return;
|
||||
}
|
||||
if (val == defaultValue(key))
|
||||
QSettings::remove(key);
|
||||
else if (val != value(key))
|
||||
QSettings::setValue(key, val);
|
||||
}
|
||||
|
||||
QVariant SettingsHandler::valueFromGroup(const QString &group, const QString &key, const QVariant &defaultVal)
|
||||
{
|
||||
beginGroup(group);
|
||||
QVariant val = value(key, defaultVal);
|
||||
endGroup();
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void SettingsHandler::setValueToGroup(const QString &group, const QString &key, const QVariant &val)
|
||||
{
|
||||
beginGroup(group);
|
||||
setValue(key, val);
|
||||
endGroup();
|
||||
}
|
||||
|
||||
void SettingsHandler::setDefault(const QString &key, const QVariant &val)
|
||||
{
|
||||
_defaults.insert(key, val);
|
||||
}
|
||||
|
||||
QVariant SettingsHandler::defaultValue(const QString &key) const
|
||||
{
|
||||
if (_defaults.contains(key))
|
||||
return _defaults.value(key);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void SettingsHandler::reset()
|
||||
{
|
||||
/* Static method, so we have to create a QSettings object. */
|
||||
QSettings settings(SETTINGS_FILE, QSettings::IniFormat);
|
||||
settings.clear();
|
||||
}
|
||||
} // namespace resource_api
|
||||
|
59
libresapi/src/api/SettingsHandler.h
Normal file
59
libresapi/src/api/SettingsHandler.h
Normal file
@ -0,0 +1,59 @@
|
||||
#ifndef SETTINGSHANDLER_H
|
||||
#define SETTINGSHANDLER_H
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#include <util/rsthreads.h>
|
||||
|
||||
#include "ResourceRouter.h"
|
||||
#include "StateTokenServer.h"
|
||||
|
||||
/* Reimplemented class RSettings*/
|
||||
namespace resource_api
|
||||
{
|
||||
class SettingsHandler : public ResourceRouter, public QSettings
|
||||
{
|
||||
public:
|
||||
SettingsHandler(StateTokenServer* sts, const QString group = QString());
|
||||
~SettingsHandler();
|
||||
|
||||
static void reset();
|
||||
|
||||
QVariant value(const QString &key,
|
||||
const QVariant &defaultVal = QVariant()) const;
|
||||
|
||||
void setValue(const QString &key, const QVariant &val);
|
||||
|
||||
QVariant valueFromGroup(const QString &group, const QString &key,
|
||||
const QVariant &defaultVal = QVariant());
|
||||
void setValueToGroup(const QString &group, const QString &key,
|
||||
const QVariant &val);
|
||||
|
||||
protected:
|
||||
void setDefault(const QString &key, const QVariant &val);
|
||||
QVariant defaultValue(const QString &key) const;
|
||||
|
||||
bool m_bValid;
|
||||
|
||||
private:
|
||||
void handleSettingsRequest(Request& req, Response& resp);
|
||||
|
||||
void handleGetAdvancedMode(Request& req, Response& resp);
|
||||
void handleSetAdvancedMode(Request& req, Response& resp);
|
||||
|
||||
void handleGetFlickableGridMode(Request& req, Response& resp);
|
||||
void handleSetFlickableGridMode(Request& req, Response& resp);
|
||||
|
||||
void handleGetAutoLogin(Request& req, Response& resp);
|
||||
void handleSetAutoLogin(Request& req, Response& resp);
|
||||
|
||||
QHash<QString, QVariant> _defaults;
|
||||
|
||||
StateTokenServer* mStateTokenServer;
|
||||
|
||||
RsMutex mMtx;
|
||||
StateToken mStateToken; // mutex protected
|
||||
};
|
||||
} // namespace resource_api
|
||||
|
||||
#endif // SETTINGSHANDLER_H
|
@ -10,6 +10,40 @@ DESTDIR = lib
|
||||
|
||||
INCLUDEPATH += ../../libretroshare/src
|
||||
|
||||
retroshare_android_service {
|
||||
win32 {
|
||||
OBJECTS_DIR = temp/obj
|
||||
|
||||
LIBS_DIR = $$PWD/../../libs/lib
|
||||
LIBS += $$OUT_PWD/../../libretroshare/src/lib/libretroshare.a
|
||||
LIBS += $$OUT_PWD/../../openpgpsdk/src/lib/libops.a
|
||||
|
||||
for(lib, LIB_DIR):LIBS += -L"$$lib"
|
||||
for(bin, BIN_DIR):LIBS += -L"$$bin"
|
||||
|
||||
|
||||
LIBS += -lssl -lcrypto -lpthread -lminiupnpc -lz -lws2_32
|
||||
LIBS += -luuid -lole32 -liphlpapi -lcrypt32 -lgdi32
|
||||
LIBS += -lwinmm
|
||||
|
||||
DEFINES *= WINDOWS_SYS WIN32_LEAN_AND_MEAN _USE_32BIT_TIME_T
|
||||
|
||||
DEPENDPATH += . $$INC_DIR
|
||||
INCLUDEPATH += . $$INC_DIR
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4) {
|
||||
# Qt 5
|
||||
RC_INCLUDEPATH += $$_PRO_FILE_PWD_/../../libretroshare/src
|
||||
} else {
|
||||
# Qt 4
|
||||
QMAKE_RC += --include-dir=$$_PRO_FILE_PWD_/../../libretroshare/src
|
||||
}
|
||||
}
|
||||
|
||||
DEPENDPATH += . ../../libretroshare/src/
|
||||
INCLUDEPATH += ../../libretroshare/src/
|
||||
}
|
||||
|
||||
libresapihttpserver {
|
||||
CONFIG += libmicrohttpd
|
||||
|
||||
@ -183,3 +217,11 @@ libresapilocalserver {
|
||||
SOURCES *= api/ApiServerLocal.cpp
|
||||
HEADERS *= api/ApiServerLocal.h
|
||||
}
|
||||
|
||||
qt_dependencies {
|
||||
CONFIG *= qt
|
||||
QT *= core
|
||||
|
||||
SOURCES += api/SettingsHandler.cpp
|
||||
HEADERS += api/SettingsHandler.h
|
||||
}
|
||||
|
@ -35,17 +35,17 @@
|
||||
#include "util/rsmemory.h"
|
||||
#include "util/rsprint.h"
|
||||
|
||||
#include <serialiser/rsmsgitems.h>
|
||||
#include "rsitems/rsmsgitems.h"
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include <retroshare/rsiface.h>
|
||||
#include "retroshare/rsmsgs.h"
|
||||
#include "retroshare/rsidentity.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
|
||||
#include <rsserver/p3face.h>
|
||||
#include <services/p3idservice.h>
|
||||
#include <gxs/gxssecurity.h>
|
||||
#include <turtle/p3turtle.h>
|
||||
#include <retroshare/rsids.h>
|
||||
#include "rsserver/p3face.h"
|
||||
#include "services/p3idservice.h"
|
||||
#include "gxs/gxssecurity.h"
|
||||
#include "turtle/p3turtle.h"
|
||||
#include "retroshare/rsids.h"
|
||||
#include "distantchat.h"
|
||||
|
||||
//#define DEBUG_DISTANT_CHAT
|
||||
@ -89,10 +89,10 @@ bool DistantChatService::handleOutgoingItem(RsChatItem *item)
|
||||
std::cerr << "p3ChatService::handleOutgoingItem(): sending to " << item->PeerId() << ": interpreted as a distant chat virtual peer id." << std::endl;
|
||||
#endif
|
||||
|
||||
uint32_t size = item->serial_size() ;
|
||||
uint32_t size = RsChatSerialiser().size(item) ;
|
||||
RsTemporaryMemory mem(size) ;
|
||||
|
||||
if(!item->serialise(mem,size))
|
||||
if(!RsChatSerialiser().serialise(item,mem,&size))
|
||||
{
|
||||
std::cerr << "(EE) serialisation error. Something's really wrong!" << std::endl;
|
||||
return false;
|
||||
@ -149,10 +149,10 @@ bool DistantChatService::acceptDataFromPeer(const RsGxsId& gxs_id,const RsGxsTun
|
||||
|
||||
// we do not use handleOutGoingItem() because there's no distant chat contact, as the chat is refused.
|
||||
|
||||
uint32_t size = item->serial_size() ;
|
||||
uint32_t size = RsChatSerialiser().size(item) ;
|
||||
RsTemporaryMemory mem(size) ;
|
||||
|
||||
if(!item->serialise(mem,size))
|
||||
if(!RsChatSerialiser().serialise(item,mem,&size))
|
||||
{
|
||||
std::cerr << "(EE) serialisation error. Something's really wrong!" << std::endl;
|
||||
return false;
|
||||
|
@ -222,7 +222,7 @@ bool DistributedChatService::checkSignature(RsChatLobbyBouncingObject *obj,const
|
||||
|
||||
mGixs->requestKey(obj->signature.keyId,peer_list,RsIdentityUsage(RS_SERVICE_TYPE_CHAT,RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION,RsGxsGroupId(),RsGxsMessageId(),obj->lobby_id));
|
||||
|
||||
uint32_t size = obj->signed_serial_size() ;
|
||||
uint32_t size = RsChatSerialiser(RsServiceSerializer::SERIALIZATION_FLAG_SIGNATURE).size(dynamic_cast<RsItem*>(obj)) ;
|
||||
RsTemporaryMemory memory(size) ;
|
||||
|
||||
#ifdef DEBUG_CHAT_LOBBIES
|
||||
@ -230,7 +230,7 @@ bool DistributedChatService::checkSignature(RsChatLobbyBouncingObject *obj,const
|
||||
std::cerr << " signature id: " << obj->signature.keyId << std::endl;
|
||||
#endif
|
||||
|
||||
if(!obj->serialise_signed_part(memory,size))
|
||||
if(!RsChatSerialiser(RsServiceSerializer::SERIALIZATION_FLAG_SIGNATURE).serialise(dynamic_cast<RsItem*>(obj),memory,&size))
|
||||
{
|
||||
std::cerr << " (EE) Cannot serialise message item. " << std::endl;
|
||||
return false ;
|
||||
@ -239,7 +239,7 @@ bool DistributedChatService::checkSignature(RsChatLobbyBouncingObject *obj,const
|
||||
uint32_t error_status ;
|
||||
RsIdentityUsage use_info(RS_SERVICE_TYPE_CHAT,RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION,RsGxsGroupId(),RsGxsMessageId(),obj->lobby_id) ;
|
||||
|
||||
if(!mGixs->validateData(memory,obj->signed_serial_size(),obj->signature,false,use_info,error_status))
|
||||
if(!mGixs->validateData(memory,size,obj->signature,false,use_info,error_status))
|
||||
{
|
||||
bool res = false ;
|
||||
|
||||
@ -415,7 +415,7 @@ void DistributedChatService::checkSizeAndSendLobbyMessage(RsChatItem *msg)
|
||||
//
|
||||
static const uint32_t MAX_ITEM_SIZE = 32000 ;
|
||||
|
||||
if(msg->serial_size() > MAX_ITEM_SIZE)
|
||||
if(RsChatSerialiser().size(msg) > MAX_ITEM_SIZE)
|
||||
{
|
||||
std::cerr << "(EE) Chat item exceeds maximum serial size. It will be dropped." << std::endl;
|
||||
delete msg ;
|
||||
@ -970,10 +970,10 @@ bool DistributedChatService::locked_initLobbyBouncableObject(const ChatLobbyId&
|
||||
|
||||
// now sign the object, if the lobby expects it
|
||||
|
||||
uint32_t size = item.signed_serial_size() ;
|
||||
uint32_t size = RsChatSerialiser(RsServiceSerializer::SERIALIZATION_FLAG_SIGNATURE).size(dynamic_cast<RsItem*>(&item)) ;
|
||||
RsTemporaryMemory memory(size) ;
|
||||
|
||||
if(!item.serialise_signed_part(memory,size))
|
||||
if(!RsChatSerialiser(RsServiceSerializer::SERIALIZATION_FLAG_SIGNATURE).serialise(dynamic_cast<RsItem*>(&item),memory,&size))
|
||||
{
|
||||
std::cerr << "(EE) Cannot sign message item. " << std::endl;
|
||||
return false ;
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "gxstrans/p3gxstrans.h"
|
||||
|
||||
#include "chat/p3chatservice.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
|
||||
/****
|
||||
* #define CHAT_DEBUG 1
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "serialiser/rsmsgitems.h"
|
||||
#include "rsitems/rsmsgitems.h"
|
||||
#include "services/p3service.h"
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "chat/distantchat.h"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,8 +27,11 @@
|
||||
|
||||
#include "openssl/bn.h"
|
||||
#include "retroshare/rstypes.h"
|
||||
#include "serialiser/rsserializer.h"
|
||||
#include "serialiser/rstlvkeys.h"
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "rsitems/rsserviceids.h"
|
||||
#include "rsitems/itempriorities.h"
|
||||
#include "rsitems/rsitem.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
|
||||
#include "serialiser/rstlvidset.h"
|
||||
@ -79,7 +82,7 @@ const uint8_t RS_PKT_SUBTYPE_OUTGOING_MAP = 0x1B ;
|
||||
|
||||
typedef uint64_t ChatLobbyId ;
|
||||
typedef uint64_t ChatLobbyMsgId ;
|
||||
typedef std::string ChatLobbyNickName ;
|
||||
typedef std::string ChatLobbyNickName ;
|
||||
typedef uint64_t DistantChatDHSessionId ;
|
||||
|
||||
class RsChatItem: public RsItem
|
||||
@ -91,11 +94,9 @@ class RsChatItem: public RsItem
|
||||
}
|
||||
|
||||
virtual ~RsChatItem() {}
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) = 0 ;
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) { return out; } // derived from RsItem, but should be removed
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) = 0 ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() = 0 ; // deserialise is handled using a constructor
|
||||
virtual void clear() {}
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -108,14 +109,14 @@ public:
|
||||
RsChatMsgItem() :RsChatItem(RS_PKT_SUBTYPE_DEFAULT) {}
|
||||
RsChatMsgItem(uint8_t subtype) :RsChatItem(subtype) {}
|
||||
|
||||
RsChatMsgItem(void *data,uint32_t size,uint8_t subtype = RS_PKT_SUBTYPE_DEFAULT) ; // deserialization
|
||||
//RsChatMsgItem() {}
|
||||
|
||||
virtual ~RsChatMsgItem() {}
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
// derived from RsItem
|
||||
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
virtual void clear() {}
|
||||
|
||||
uint32_t chatFlags;
|
||||
uint32_t sendTime;
|
||||
@ -138,21 +139,15 @@ public:
|
||||
RsTlvKeySignature signature ;
|
||||
|
||||
virtual RsChatLobbyBouncingObject *duplicate() const = 0 ;
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
// returns the size in bytes of the data chunk to sign.
|
||||
|
||||
virtual uint32_t signed_serial_size() =0;
|
||||
virtual bool serialise_signed_part(void *data,uint32_t& size) = 0;
|
||||
|
||||
protected:
|
||||
// The functions below handle the serialisation of data that is specific to the bouncing object level.
|
||||
// They are called by serial_size() and serialise() from children, but should not overload the serial_size() and
|
||||
// serialise() methods, otherwise the wrong method will be called when serialising from this top level class.
|
||||
|
||||
uint32_t serialized_size(bool include_signature) ;
|
||||
bool serialise_to_memory(void *data,uint32_t tlvsize,uint32_t& offset,bool include_signature) ;
|
||||
bool deserialise_from_memory(void *data,uint32_t rssize,uint32_t& offset) ;
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
virtual uint32_t PacketId() const= 0;
|
||||
};
|
||||
|
||||
class RsChatLobbyMsgItem: public RsChatMsgItem, public RsChatLobbyBouncingObject
|
||||
@ -160,55 +155,44 @@ class RsChatLobbyMsgItem: public RsChatMsgItem, public RsChatLobbyBouncingObject
|
||||
public:
|
||||
RsChatLobbyMsgItem() :RsChatMsgItem(RS_PKT_SUBTYPE_CHAT_LOBBY_SIGNED_MSG) {}
|
||||
|
||||
RsChatLobbyMsgItem(void *data,uint32_t size) ; // deserialization /// TODO!!!
|
||||
|
||||
virtual ~RsChatLobbyMsgItem() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
virtual RsChatLobbyBouncingObject *duplicate() const { return new RsChatLobbyMsgItem(*this) ; }
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
|
||||
virtual uint32_t signed_serial_size() ;
|
||||
virtual bool serialise_signed_part(void *data,uint32_t& size) ;// Isn't it better that items can serialize themselves ?
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
ChatLobbyMsgId parent_msg_id ; // Used for threaded chat.
|
||||
|
||||
protected:
|
||||
virtual uint32_t PacketId() const { return RsChatMsgItem::PacketId() ; }
|
||||
};
|
||||
|
||||
class RsChatLobbyEventItem: public RsChatItem, public RsChatLobbyBouncingObject
|
||||
{
|
||||
public:
|
||||
RsChatLobbyEventItem() :RsChatItem(RS_PKT_SUBTYPE_CHAT_LOBBY_SIGNED_EVENT) {}
|
||||
RsChatLobbyEventItem(void *data,uint32_t size) ; // deserialization /// TODO!!!
|
||||
public:
|
||||
RsChatLobbyEventItem() :RsChatItem(RS_PKT_SUBTYPE_CHAT_LOBBY_SIGNED_EVENT) {}
|
||||
|
||||
virtual ~RsChatLobbyEventItem() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
virtual RsChatLobbyBouncingObject *duplicate() const { return new RsChatLobbyEventItem(*this) ; }
|
||||
//
|
||||
virtual bool serialise(void *data,uint32_t& size) ;
|
||||
virtual uint32_t serial_size() ;
|
||||
virtual ~RsChatLobbyEventItem() {}
|
||||
virtual RsChatLobbyBouncingObject *duplicate() const { return new RsChatLobbyEventItem(*this) ; }
|
||||
//
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
virtual uint32_t signed_serial_size() ;
|
||||
virtual bool serialise_signed_part(void *data,uint32_t& size) ;
|
||||
// members.
|
||||
//
|
||||
uint8_t event_type ; // used for defining the type of event.
|
||||
std::string string1; // used for any string
|
||||
uint32_t sendTime; // used to check for old looping messages
|
||||
|
||||
// members.
|
||||
//
|
||||
uint8_t event_type ; // used for defining the type of event.
|
||||
std::string string1; // used for any string
|
||||
uint32_t sendTime; // used to check for old looping messages
|
||||
protected:
|
||||
virtual uint32_t PacketId() const { return RsChatItem::PacketId() ; }
|
||||
};
|
||||
|
||||
class RsChatLobbyListRequestItem: public RsChatItem
|
||||
{
|
||||
public:
|
||||
RsChatLobbyListRequestItem() : RsChatItem(RS_PKT_SUBTYPE_CHAT_LOBBY_LIST_REQUEST) {}
|
||||
RsChatLobbyListRequestItem(void *data,uint32_t size) ;
|
||||
virtual ~RsChatLobbyListRequestItem() {}
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ;
|
||||
virtual uint32_t serial_size() ;
|
||||
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
};
|
||||
|
||||
struct VisibleChatLobbyInfo
|
||||
@ -224,13 +208,9 @@ class RsChatLobbyListItem: public RsChatItem
|
||||
{
|
||||
public:
|
||||
RsChatLobbyListItem() : RsChatItem(RS_PKT_SUBTYPE_CHAT_LOBBY_LIST) {}
|
||||
RsChatLobbyListItem(void *data,uint32_t size) ;
|
||||
virtual ~RsChatLobbyListItem() {}
|
||||
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ;
|
||||
virtual uint32_t serial_size() ;
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
std::vector<VisibleChatLobbyInfo> lobbies ;
|
||||
};
|
||||
@ -239,48 +219,38 @@ class RsChatLobbyUnsubscribeItem: public RsChatItem
|
||||
{
|
||||
public:
|
||||
RsChatLobbyUnsubscribeItem() :RsChatItem(RS_PKT_SUBTYPE_CHAT_LOBBY_UNSUBSCRIBE) {}
|
||||
RsChatLobbyUnsubscribeItem(void *data,uint32_t size) ; // deserialization
|
||||
|
||||
virtual ~RsChatLobbyUnsubscribeItem() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
uint64_t lobby_id ;
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
};
|
||||
|
||||
class RsChatLobbyConnectChallengeItem: public RsChatItem
|
||||
{
|
||||
public:
|
||||
RsChatLobbyConnectChallengeItem() :RsChatItem(RS_PKT_SUBTYPE_CHAT_LOBBY_CHALLENGE) {}
|
||||
RsChatLobbyConnectChallengeItem(void *data,uint32_t size) ; // deserialization
|
||||
|
||||
virtual ~RsChatLobbyConnectChallengeItem() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
uint64_t challenge_code ;
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
};
|
||||
|
||||
class RsChatLobbyInviteItem: public RsChatItem
|
||||
{
|
||||
public:
|
||||
RsChatLobbyInviteItem() :RsChatItem(RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE) {}
|
||||
RsChatLobbyInviteItem(void *data,uint32_t size) ; // deserialization
|
||||
virtual ~RsChatLobbyInviteItem() {}
|
||||
|
||||
virtual ~RsChatLobbyInviteItem() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
ChatLobbyId lobby_id ;
|
||||
std::string lobby_name ;
|
||||
std::string lobby_topic ;
|
||||
ChatLobbyFlags lobby_flags ;
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -289,22 +259,18 @@ class RsChatLobbyInviteItem: public RsChatItem
|
||||
*/
|
||||
struct RsPrivateChatMsgConfigItem : RsChatItem
|
||||
{
|
||||
RsPrivateChatMsgConfigItem() :RsChatItem(RS_PKT_SUBTYPE_PRIVATECHATMSG_CONFIG) {}
|
||||
RsPrivateChatMsgConfigItem(void *data,uint32_t size) ; // deserialization
|
||||
RsPrivateChatMsgConfigItem() :
|
||||
RsChatItem(RS_PKT_SUBTYPE_PRIVATECHATMSG_CONFIG) {}
|
||||
|
||||
virtual ~RsPrivateChatMsgConfigItem() {}
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size);
|
||||
virtual uint32_t serial_size();
|
||||
/* Deserialize is handled using a constructor,it would be better have a
|
||||
* deserialize method as constructor cannot fails while deserialization can.
|
||||
*/
|
||||
virtual void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx );
|
||||
|
||||
/* set data from RsChatMsgItem to RsPrivateChatMsgConfigItem */
|
||||
/** set data from RsChatMsgItem to RsPrivateChatMsgConfigItem */
|
||||
void set(RsChatMsgItem *ci, const RsPeerId &peerId, uint32_t confFlags);
|
||||
/* get data from RsPrivateChatMsgConfigItem to RsChatMsgItem */
|
||||
/** get data from RsPrivateChatMsgConfigItem to RsChatMsgItem */
|
||||
void get(RsChatMsgItem *ci);
|
||||
|
||||
RsPeerId configPeerId;
|
||||
@ -314,43 +280,20 @@ struct RsPrivateChatMsgConfigItem : RsChatItem
|
||||
std::string message;
|
||||
uint32_t recvTime;
|
||||
};
|
||||
class RsPrivateChatDistantInviteConfigItem: public RsChatItem
|
||||
{
|
||||
public:
|
||||
RsPrivateChatDistantInviteConfigItem() :RsChatItem(RS_PKT_SUBTYPE_DISTANT_INVITE_CONFIG) {}
|
||||
RsPrivateChatDistantInviteConfigItem(void *data,uint32_t size) ; // deserialization
|
||||
|
||||
virtual ~RsPrivateChatDistantInviteConfigItem() {}
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
|
||||
unsigned char aes_key[16] ;
|
||||
RsFileHash hash ;
|
||||
std::string encrypted_radix64_string ;
|
||||
RsPgpId destination_pgp_id ;
|
||||
uint32_t time_of_validity ;
|
||||
uint32_t last_hit_time ;
|
||||
uint32_t flags ;
|
||||
};
|
||||
class RsChatLobbyConfigItem: public RsChatItem
|
||||
{
|
||||
public:
|
||||
RsChatLobbyConfigItem() :RsChatItem(RS_PKT_SUBTYPE_CHAT_LOBBY_CONFIG) { lobby_Id = 0; }
|
||||
RsChatLobbyConfigItem(void *data,uint32_t size) ; // deserialization
|
||||
RsChatLobbyConfigItem() :RsChatItem(RS_PKT_SUBTYPE_CHAT_LOBBY_CONFIG) { lobby_Id = 0; }
|
||||
|
||||
virtual ~RsChatLobbyConfigItem() {}
|
||||
virtual ~RsChatLobbyConfigItem() {}
|
||||
|
||||
virtual void clear() { lobby_Id = 0; }
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
virtual void clear() { lobby_Id = 0; }
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
uint64_t lobby_Id;
|
||||
uint32_t flags ;
|
||||
uint64_t lobby_Id;
|
||||
uint32_t flags ;
|
||||
};
|
||||
|
||||
// This class contains activity info for the sending peer: active, idle, typing, etc.
|
||||
@ -359,13 +302,10 @@ class RsChatStatusItem: public RsChatItem
|
||||
{
|
||||
public:
|
||||
RsChatStatusItem() :RsChatItem(RS_PKT_SUBTYPE_CHAT_STATUS) {}
|
||||
RsChatStatusItem(void *data,uint32_t size) ; // deserialization
|
||||
|
||||
virtual ~RsChatStatusItem() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
uint32_t flags ;
|
||||
std::string status_string;
|
||||
@ -377,183 +317,20 @@ class RsChatAvatarItem: public RsChatItem
|
||||
{
|
||||
public:
|
||||
RsChatAvatarItem() :RsChatItem(RS_PKT_SUBTYPE_CHAT_AVATAR) {setPriorityLevel(QOS_PRIORITY_RS_CHAT_AVATAR_ITEM) ;}
|
||||
RsChatAvatarItem(void *data,uint32_t size) ; // deserialization
|
||||
|
||||
virtual ~RsChatAvatarItem() ;
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
uint32_t image_size ; // size of data in bytes
|
||||
unsigned char *image_data ; // image
|
||||
};
|
||||
|
||||
// This class contains the public Diffie-Hellman parameters to be sent
|
||||
// when performing a DH agreement over a distant chat tunnel.
|
||||
//
|
||||
class RsChatDHPublicKeyItem: public RsChatItem
|
||||
struct RsChatSerialiser : RsServiceSerializer
|
||||
{
|
||||
public:
|
||||
RsChatDHPublicKeyItem() :RsChatItem(RS_PKT_SUBTYPE_DISTANT_CHAT_DH_PUBLIC_KEY) {setPriorityLevel(QOS_PRIORITY_RS_CHAT_ITEM) ;}
|
||||
RsChatDHPublicKeyItem(void *data,uint32_t size) ; // deserialization
|
||||
RsChatSerialiser(SerializationFlags flags = SERIALIZATION_FLAG_NONE) :
|
||||
RsServiceSerializer( RS_SERVICE_TYPE_CHAT,
|
||||
RsGenericSerializer::FORMAT_BINARY, flags ) {}
|
||||
|
||||
virtual ~RsChatDHPublicKeyItem() { BN_free(public_key) ; }
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
|
||||
// Private data to DH public key item
|
||||
//
|
||||
BIGNUM *public_key ;
|
||||
|
||||
RsTlvKeySignature signature ; // signs the public key in a row.
|
||||
RsTlvPublicRSAKey gxs_key ; // public key of the signer
|
||||
|
||||
private:
|
||||
RsChatDHPublicKeyItem(const RsChatDHPublicKeyItem&) : RsChatItem(RS_PKT_SUBTYPE_DISTANT_CHAT_DH_PUBLIC_KEY) {} // make the object non copy-able
|
||||
const RsChatDHPublicKeyItem& operator=(const RsChatDHPublicKeyItem&) { return *this ;}
|
||||
};
|
||||
|
||||
|
||||
struct PrivateOugoingMapItem : RsChatItem
|
||||
{
|
||||
PrivateOugoingMapItem() : RsChatItem(RS_PKT_SUBTYPE_OUTGOING_MAP) {}
|
||||
|
||||
uint32_t serial_size()
|
||||
{
|
||||
uint32_t s = 8; /* header */
|
||||
s += 4; // number of entries
|
||||
for( auto entry : store )
|
||||
{
|
||||
s += 8; // key size
|
||||
s += entry.second.serial_size();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
bool serialise(void* data, uint32_t& pktsize)
|
||||
{
|
||||
uint32_t tlvsize = serial_size();
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (pktsize < tlvsize) return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok = ok && setRsItemHeader(data, tlvsize, PacketId(), tlvsize)
|
||||
&& (offset += 8);
|
||||
|
||||
ok = ok && setRawUInt32(data, tlvsize, &offset, store.size());
|
||||
|
||||
for( auto entry : store )
|
||||
{
|
||||
ok = ok && setRawUInt64(data, tlvsize, &offset, entry.first);
|
||||
|
||||
uint8_t* hdrPtr = static_cast<uint8_t*>(data) + offset;
|
||||
uint32_t tmpsize = entry.second.serial_size();
|
||||
ok = ok && entry.second.serialise(hdrPtr, tmpsize)
|
||||
&& (offset += tmpsize);
|
||||
|
||||
}
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
std::cerr << "PrivateOugoingMapItem::serialise() Size Error!"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
PrivateOugoingMapItem* deserialise(const uint8_t* data, uint32_t& pktsize)
|
||||
{
|
||||
/* get the type and size */
|
||||
uint8_t* dataPtr = const_cast<uint8_t*>(data);
|
||||
uint32_t rstype = getRsItemId(dataPtr);
|
||||
uint32_t rssize = getRsItemSize(dataPtr);
|
||||
|
||||
uint32_t offset = 0;
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
||||
(RS_SERVICE_TYPE_CHAT != getRsItemService(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_OUTGOING_MAP != getRsItemSubType(rstype))
|
||||
) return NULL; /* wrong type */
|
||||
|
||||
if (pktsize < rssize) return NULL; /* check size not enough data */
|
||||
|
||||
/* set the packet length */
|
||||
pktsize = rssize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
/* ready to load */
|
||||
PrivateOugoingMapItem* item = new PrivateOugoingMapItem();
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
// get map size first */
|
||||
uint32_t s = 0;
|
||||
ok = ok && getRawUInt32(dataPtr, rssize, &offset, &s);
|
||||
|
||||
for(uint32_t i=0; i<s && ok; ++i)
|
||||
{
|
||||
uint64_t msgId;
|
||||
|
||||
ok = ok && getRawUInt64(dataPtr, rssize, &offset, &msgId);
|
||||
|
||||
uint8_t* hdrPtr = const_cast<uint8_t*>(data); hdrPtr += offset;
|
||||
uint32_t tmpSize = getRsItemSize(hdrPtr);
|
||||
RsChatMsgItem msgItem(hdrPtr, tmpSize); offset+= tmpSize;
|
||||
item->store.insert(std::make_pair(msgId, msgItem));
|
||||
}
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
/* error */
|
||||
std::cerr << "(EE) size error in packet deserialisation: p3MsgItem,"
|
||||
<< " subtype " << getRsItemSubType(rstype) << ". offset="
|
||||
<< offset << " != rssize=" << rssize << std::endl;
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
std::cerr << "(EE) size error in packet deserialisation: p3MsgItem,"
|
||||
<< " subtype " << getRsItemSubType(rstype) << std::endl;
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t /*indent*/ = 0)
|
||||
{
|
||||
return out << "PrivateOugoingMapItem store size: " << store.size()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
std::map<uint64_t, RsChatMsgItem> store;
|
||||
};
|
||||
|
||||
class RsChatSerialiser: public RsSerialType
|
||||
{
|
||||
public:
|
||||
RsChatSerialiser() :RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_CHAT) {}
|
||||
|
||||
virtual uint32_t size (RsItem *item)
|
||||
{
|
||||
return static_cast<RsChatItem *>(item)->serial_size() ;
|
||||
}
|
||||
virtual bool serialise(RsItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
return static_cast<RsChatItem *>(item)->serialise(data,*size) ;
|
||||
}
|
||||
virtual RsItem *deserialise (void *data, uint32_t *size) ;
|
||||
virtual RsItem *create_item(uint16_t service_id,uint8_t item_sub_id) const;
|
||||
};
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "tcponudp/udprelay.h"
|
||||
#include "bitdht/bdstddht.h"
|
||||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
|
@ -22,7 +22,7 @@
|
||||
* Please report all bugs and problems to "retroshare.project@gmail.com".
|
||||
*
|
||||
*/
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "rsitems/rsserviceids.h"
|
||||
|
||||
#include "file_sharing/p3filelists.h"
|
||||
#include "file_sharing/directory_storage.h"
|
||||
|
@ -24,342 +24,41 @@
|
||||
*/
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
|
||||
#include "serialiser/rstypeserializer.h"
|
||||
|
||||
#include "file_sharing/rsfilelistitems.h"
|
||||
|
||||
RsItem* RsFileListsSerialiser::deserialise(void *data, uint32_t *size)
|
||||
void RsFileListsSyncRequestItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileListsSerialiser::deserialise()" << std::endl;
|
||||
#endif
|
||||
/* get the type and size */
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || (getRsItemService(rstype) != RS_SERVICE_TYPE_FILE_DATABASE))
|
||||
return NULL; /* wrong type */
|
||||
|
||||
switch(getRsItemSubType(rstype))
|
||||
{
|
||||
case RS_PKT_SUBTYPE_FILELISTS_SYNC_REQ_ITEM: return deserialFileListsSyncRequestItem(data, size);
|
||||
case RS_PKT_SUBTYPE_FILELISTS_SYNC_RSP_ITEM: return deserialFileListsSyncResponseItem(data, size);
|
||||
// case RS_PKT_SUBTYPE_FILELISTS_CONFIG_ITEM: return deserialFileListsConfigItem (data, size);
|
||||
|
||||
default:
|
||||
{
|
||||
std::cerr << "(WW) RsFileListsSerialiser::deserialise() : unhandled item type " << getRsItemSubType(rstype) << std::endl;
|
||||
return NULL;
|
||||
|
||||
}
|
||||
}
|
||||
RsTypeSerializer::serial_process (j,ctx,entry_hash,"entry_hash") ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,flags ,"flags") ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,last_known_recurs_modf_TS,"last_known_recurs_modf_TS") ;
|
||||
RsTypeSerializer::serial_process<uint64_t>(j,ctx,request_id,"request_id") ;
|
||||
}
|
||||
void RsFileListsSyncResponseItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process (j,ctx,entry_hash,"entry_hash") ;
|
||||
RsTypeSerializer::serial_process (j,ctx,checksum,"checksum") ;
|
||||
RsTypeSerializer::serial_process<uint32_t> (j,ctx,flags ,"flags") ;
|
||||
RsTypeSerializer::serial_process<uint32_t> (j,ctx,last_known_recurs_modf_TS,"last_known_recurs_modf_TS") ;
|
||||
RsTypeSerializer::serial_process<uint64_t> (j,ctx,request_id,"request_id") ;
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,directory_content_data,"directory_content_data") ;
|
||||
}
|
||||
|
||||
uint32_t RsFileListsSerialiser::size(RsItem *item)
|
||||
RsItem *RsFileListsSerialiser::create_item(uint16_t service,uint8_t type) const
|
||||
{
|
||||
RsFileListsItem *flst_item = dynamic_cast<RsFileListsItem*>(item) ;
|
||||
if(service != RS_SERVICE_TYPE_FILE_DATABASE)
|
||||
return NULL ;
|
||||
|
||||
if(flst_item != NULL)
|
||||
return flst_item->serial_size() ;
|
||||
else
|
||||
{
|
||||
std::cerr << "RsFileListsSerialiser::serialise(): Not an RsFileListsItem!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool RsFileListsSerialiser::serialise(RsItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
RsFileListsItem *flst_item = dynamic_cast<RsFileListsItem*>(item) ;
|
||||
|
||||
if(flst_item != NULL)
|
||||
return flst_item->serialise(data,*size) ;
|
||||
else
|
||||
{
|
||||
std::cerr << "RsFileListsSerialiser::serialise(): Not an RsFileListsItem!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool RsFileListsItem::serialise_header(void *data,uint32_t& pktsize,uint32_t& tlvsize, uint32_t& offset) const
|
||||
{
|
||||
tlvsize = serial_size() ;
|
||||
offset = 0;
|
||||
|
||||
if (pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
if(!setRsItemHeader(data, tlvsize, PacketId(), tlvsize))
|
||||
{
|
||||
std::cerr << "RsFileTransferItem::serialise_header(): ERROR. Not enough size!" << std::endl;
|
||||
return false ;
|
||||
}
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileItemSerialiser::serialiseData() Header: " << ok << std::endl;
|
||||
#endif
|
||||
offset += 8;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool RsFileListsSyncRequestItem::serialise(void *data, uint32_t& size) const
|
||||
{
|
||||
uint32_t tlvsize,offset=0;
|
||||
bool ok = true;
|
||||
|
||||
if(!serialise_header(data,size,tlvsize,offset))
|
||||
return false ;
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileListsSerialiser::serialiseFileListsSyncReqItem()" << std::endl;
|
||||
#endif
|
||||
|
||||
/* RsFileListsSyncMsgItem */
|
||||
|
||||
ok &= entry_hash.serialise(data, size, offset);
|
||||
ok &= setRawUInt32(data, size, &offset, flags );
|
||||
ok &= setRawUInt32(data, size, &offset, last_known_recurs_modf_TS);
|
||||
ok &= setRawUInt64(data, size, &offset, request_id);
|
||||
|
||||
if(offset != tlvsize){
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileListsSerialiser::serialiseNxsSynMsgItem() FAIL Size Error! " << std::endl;
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
if (!ok)
|
||||
switch(type)
|
||||
{
|
||||
std::cerr << "RsFileListsSerialiser::serialiseNxsSynMsgItem() NOK" << std::endl;
|
||||
case RS_PKT_SUBTYPE_FILELISTS_SYNC_REQ_ITEM: return new RsFileListsSyncRequestItem();
|
||||
case RS_PKT_SUBTYPE_FILELISTS_SYNC_RSP_ITEM: return new RsFileListsSyncResponseItem();
|
||||
default:
|
||||
return NULL ;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool RsFileListsSyncResponseItem::serialise(void *data, uint32_t& size) const
|
||||
{
|
||||
uint32_t tlvsize,offset=0;
|
||||
bool ok = true;
|
||||
|
||||
if(!serialise_header(data,size,tlvsize,offset))
|
||||
return false ;
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileListsSerialiser::serialiseFileListsSyncReqItem()" << std::endl;
|
||||
#endif
|
||||
|
||||
/* RsFileListsSyncMsgItem */
|
||||
|
||||
ok &= entry_hash.serialise(data, size, offset);
|
||||
ok &= checksum.serialise(data, size, offset);
|
||||
ok &= setRawUInt32(data, size, &offset, flags );
|
||||
ok &= setRawUInt32(data, size, &offset, last_known_recurs_modf_TS);
|
||||
ok &= setRawUInt64(data, size, &offset, request_id);
|
||||
ok &= directory_content_data.SetTlv(data,size,&offset) ;
|
||||
|
||||
if(offset != tlvsize){
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileListsSerialiser::serialiseNxsSynMsgItem() FAIL Size Error! " << std::endl;
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
if (!ok)
|
||||
{
|
||||
std::cerr << "RsFileListsSerialiser::serialiseNxsSynMsgItem() NOK" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
//============================================================================================================================//
|
||||
// Deserialisation //
|
||||
//============================================================================================================================//
|
||||
|
||||
//RsFileListsConfigItem* RsFileListsSerialiser::deserialFileListsConfigItem(void *data, uint32_t *size)
|
||||
//{
|
||||
// NOT_IMPLEMENTED();
|
||||
//
|
||||
// return NULL ;
|
||||
//}
|
||||
|
||||
RsFileListsSyncRequestItem* RsFileListsSerialiser::deserialFileListsSyncRequestItem(void *data, uint32_t *size)
|
||||
{
|
||||
bool ok = checkItemHeader(data,size,RS_PKT_SUBTYPE_FILELISTS_SYNC_REQ_ITEM);
|
||||
uint32_t offset = 8;
|
||||
|
||||
RsFileListsSyncRequestItem* item = new RsFileListsSyncRequestItem();
|
||||
|
||||
ok &= item->entry_hash.deserialise(data, *size, offset);
|
||||
ok &= getRawUInt32(data, *size, &offset, &item->flags);
|
||||
ok &= getRawUInt32(data, *size, &offset, &item->last_known_recurs_modf_TS);
|
||||
ok &= getRawUInt64(data, *size, &offset, &item->request_id);
|
||||
|
||||
if (offset != *size)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileListsSerialiser::deserialNxsGrp() FAIL size mismatch" << std::endl;
|
||||
#endif
|
||||
/* error */
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileListsSerialiser::deserialNxsGrp() NOK" << std::endl;
|
||||
#endif
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
RsFileListsSyncResponseItem* RsFileListsSerialiser::deserialFileListsSyncResponseItem(void *data, uint32_t *size)
|
||||
{
|
||||
bool ok = checkItemHeader(data,size,RS_PKT_SUBTYPE_FILELISTS_SYNC_RSP_ITEM);
|
||||
uint32_t offset = 8;
|
||||
|
||||
RsFileListsSyncResponseItem* item = new RsFileListsSyncResponseItem();
|
||||
|
||||
/*
|
||||
uint32_t entry_index ; // index of the directory to sync
|
||||
uint32_t flags; // used to say that it's a request or a response, say that the directory has been removed, ask for further update, etc.
|
||||
uint32_t last_known_recurs_modf_TS; // time of last modification, computed over all files+directories below.
|
||||
uint64_t request_id; // use to determine if changes that have occured since last hash
|
||||
*/
|
||||
|
||||
ok &= item->entry_hash.deserialise(data, *size, offset);
|
||||
ok &= item->checksum.deserialise(data, *size, offset);
|
||||
ok &= getRawUInt32(data, *size, &offset, &item->flags);
|
||||
ok &= getRawUInt32(data, *size, &offset, &item->last_known_recurs_modf_TS);
|
||||
ok &= getRawUInt64(data, *size, &offset, &item->request_id);
|
||||
|
||||
ok &= item->directory_content_data.GetTlv(data,*size,&offset) ;
|
||||
|
||||
if (offset != *size)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileListsSerialiser::deserialNxsGrp() FAIL size mismatch" << std::endl;
|
||||
#endif
|
||||
/* error */
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileListsSerialiser::deserialNxsGrp() NOK" << std::endl;
|
||||
#endif
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
bool RsFileListsSerialiser::checkItemHeader(void *data,uint32_t *size,uint8_t subservice_type)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileListsSerialiser::checkItemHeader()" << std::endl;
|
||||
#endif
|
||||
/* get the type and size */
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || (RS_SERVICE_TYPE_FILE_DATABASE != getRsItemService(rstype)) || (subservice_type != getRsItemSubType(rstype)))
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileListsSerialiser::checkItemHeader() FAIL wrong type" << std::endl;
|
||||
#endif
|
||||
return false; /* wrong type */
|
||||
}
|
||||
|
||||
if (*size < rssize) /* check size */
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileListsSerialiser::checkItemHeader() FAIL wrong size" << std::endl;
|
||||
#endif
|
||||
return false; /* not enough data */
|
||||
}
|
||||
|
||||
/* set the packet length */
|
||||
*size = rssize;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//============================================================================================================================//
|
||||
// Sizes //
|
||||
//============================================================================================================================//
|
||||
|
||||
uint32_t RsFileListsSyncRequestItem::serial_size()const
|
||||
{
|
||||
|
||||
uint32_t s = 8; //header size
|
||||
|
||||
s += RsFileHash::serial_size(); // entry hash
|
||||
s += 4; // flags
|
||||
s += 4; // last_known_recurs_modf_TS
|
||||
s += 8; // request_id
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
uint32_t RsFileListsSyncResponseItem::serial_size()const
|
||||
{
|
||||
|
||||
uint32_t s = 8; //header size
|
||||
|
||||
s += RsFileHash::serial_size(); // entry hash
|
||||
s += RsFileHash::serial_size(); // checksum
|
||||
s += 4; // flags
|
||||
s += 4; // last_known_recurs_modf_TS
|
||||
s += 8; // request_id
|
||||
s += directory_content_data.TlvSize();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void RsFileListsSyncRequestItem::clear()
|
||||
{
|
||||
}
|
||||
void RsFileListsSyncResponseItem::clear()
|
||||
{
|
||||
directory_content_data.TlvClear();
|
||||
}
|
||||
std::ostream& RsFileListsSyncRequestItem::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsFileListsSyncReqItem", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
|
||||
printIndent(out , int_Indent); out << "Entry hash: " << entry_hash << std::endl;
|
||||
printIndent(out , int_Indent); out << "Flags: " << (uint32_t) flags << std::endl;
|
||||
printIndent(out , int_Indent); out << "Last modf TS: " << last_known_recurs_modf_TS << std::endl;
|
||||
printIndent(out , int_Indent); out << "request id: " << std::hex << request_id << std::dec << std::endl;
|
||||
|
||||
printRsItemEnd(out ,"RsFileListsSyncReqItem", indent);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& RsFileListsSyncResponseItem::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsFileListsSyncDirItem", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
|
||||
printIndent(out , int_Indent); out << "Entry hash: " << entry_hash << std::endl;
|
||||
printIndent(out , int_Indent); out << "Checksum : " << checksum << std::endl;
|
||||
printIndent(out , int_Indent); out << "Flags: " << (uint32_t) flags << std::endl;
|
||||
printIndent(out , int_Indent); out << "Last modf TS: " << last_known_recurs_modf_TS << std::endl;
|
||||
printIndent(out , int_Indent); out << "request id: " << std::hex << request_id << std::dec << std::endl;
|
||||
printIndent(out , int_Indent); out << "Data size: " << directory_content_data.bin_len << std::endl;
|
||||
|
||||
printRsItemEnd(out ,"RsFileListsSyncDirItem", indent);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
@ -27,13 +27,16 @@
|
||||
#include <map>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "rsitems/rsserviceids.h"
|
||||
#include "rsitems/itempriorities.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rstlvitem.h"
|
||||
#include "serialiser/rstlvkeys.h"
|
||||
#include "gxs/rsgxsdata.h"
|
||||
|
||||
#include "serialiser/rsserializer.h"
|
||||
|
||||
// These items have "flag type" numbers, but this is not used.
|
||||
|
||||
const uint8_t RS_PKT_SUBTYPE_FILELISTS_SYNC_REQ_ITEM = 0x01;
|
||||
@ -54,12 +57,7 @@ public:
|
||||
}
|
||||
virtual ~RsFileListsItem(){}
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const = 0 ;
|
||||
virtual uint32_t serial_size() const = 0 ;
|
||||
virtual void clear() = 0;
|
||||
virtual std::ostream &print(std::ostream &out, uint16_t indent = 0) = 0;
|
||||
|
||||
bool serialise_header(void *data,uint32_t& pktsize,uint32_t& tlvsize, uint32_t& offset) const;
|
||||
|
||||
static const uint32_t FLAGS_SYNC_REQUEST = 0x0001 ;
|
||||
static const uint32_t FLAGS_SYNC_RESPONSE = 0x0002 ;
|
||||
@ -79,12 +77,10 @@ public:
|
||||
|
||||
RsFileListsSyncRequestItem() : RsFileListsItem(RS_PKT_SUBTYPE_FILELISTS_SYNC_REQ_ITEM) {}
|
||||
|
||||
virtual void clear();
|
||||
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
||||
virtual void clear(){}
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const;
|
||||
virtual uint32_t serial_size() const ;
|
||||
|
||||
RsFileHash entry_hash ; // hash of the directory to sync
|
||||
uint32_t flags; // used to say that it's a request or a response, say that the directory has been removed, ask for further update, etc.
|
||||
uint32_t last_known_recurs_modf_TS; // time of last modification, computed over all files+directories below.
|
||||
@ -98,10 +94,8 @@ public:
|
||||
RsFileListsSyncResponseItem() : RsFileListsItem(RS_PKT_SUBTYPE_FILELISTS_SYNC_RSP_ITEM) {}
|
||||
|
||||
virtual void clear();
|
||||
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const;
|
||||
virtual uint32_t serial_size() const ;
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
RsFileHash entry_hash ; // hash of the directory to sync
|
||||
RsFileHash checksum ; // checksum of the bindary data, for checking
|
||||
@ -112,24 +106,15 @@ public:
|
||||
RsTlvBinaryData directory_content_data ; // encoded binary data. This allows to vary the encoding format, in a way that is transparent to the serialiser.
|
||||
};
|
||||
|
||||
class RsFileListsSerialiser : public RsSerialType
|
||||
class RsFileListsSerialiser : public RsServiceSerializer
|
||||
{
|
||||
public:
|
||||
|
||||
RsFileListsSerialiser() : RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_FILE_DATABASE) {}
|
||||
RsFileListsSerialiser() : RsServiceSerializer(RS_SERVICE_TYPE_FILE_DATABASE) {}
|
||||
|
||||
virtual ~RsFileListsSerialiser() {}
|
||||
|
||||
virtual uint32_t size(RsItem *item);
|
||||
virtual bool serialise(RsItem *item, void *data, uint32_t *size);
|
||||
virtual RsItem* deserialise(void *data, uint32_t *size);
|
||||
|
||||
private:
|
||||
RsFileListsSyncRequestItem *deserialFileListsSyncRequestItem(void *data, uint32_t *size); /* RS_PKT_SUBTYPE_SYNC_GRP */
|
||||
RsFileListsSyncResponseItem *deserialFileListsSyncResponseItem(void *data, uint32_t *size); /* RS_PKT_SUBTYPE_SYNC_GRP */
|
||||
// RsFileListsSyncResponseItem *deserialFileListsConfigItem (void *data, uint32_t *size); /* RS_PKT_SUBTYPE_SYNC_GRP */
|
||||
|
||||
bool checkItemHeader(void *data, uint32_t *size, uint8_t subservice_type);
|
||||
virtual RsItem *create_item(uint16_t service,uint8_t type) const ;
|
||||
};
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h> /* for (u)sleep() */
|
||||
#include <time.h>
|
||||
|
@ -53,7 +53,7 @@ class p3ServiceControl;
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
|
||||
#include "retroshare/rsfiles.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <retroshare/rstypes.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include "ft/ftextralist.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
#include "util/rsdir.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h> /* for (u)sleep() */
|
||||
@ -396,7 +396,8 @@ 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_deprecated *fi = new RsFileConfigItem_deprecated();
|
||||
RsFileConfigItem *fi = new RsFileConfigItem();
|
||||
|
||||
fi->file.path = (it->second).info.path;
|
||||
fi->file.name = (it->second).info.fname;
|
||||
fi->file.hash = (it->second).info.hash;
|
||||
@ -429,7 +430,7 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
|
||||
for(it = load.begin(); it != load.end(); ++it)
|
||||
{
|
||||
|
||||
RsFileConfigItem_deprecated *fi = dynamic_cast<RsFileConfigItem_deprecated *>(*it);
|
||||
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it);
|
||||
if (!fi)
|
||||
{
|
||||
delete (*it);
|
||||
|
@ -49,8 +49,8 @@ const int ftserverzone = 29539;
|
||||
#include "pqi/pqi.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
|
||||
#include "serialiser/rsfiletransferitems.h"
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "rsitems/rsfiletransferitems.h"
|
||||
#include "rsitems/rsserviceids.h"
|
||||
|
||||
/***
|
||||
* #define SERVER_DEBUG 1
|
||||
@ -64,7 +64,7 @@ static const time_t FILE_TRANSFER_LOW_PRIORITY_TASKS_PERIOD = 5 ; // low priorit
|
||||
|
||||
/* Setup */
|
||||
ftServer::ftServer(p3PeerMgr *pm, p3ServiceControl *sc)
|
||||
: p3Service(),
|
||||
: p3Service(),RsServiceSerializer(RS_SERVICE_TYPE_TURTLE), // should be FT, but this is for backward compatibility
|
||||
mPeerMgr(pm), mServiceCtrl(sc),
|
||||
mFileDatabase(NULL),
|
||||
mFtController(NULL), mFtExtra(NULL),
|
||||
@ -459,14 +459,12 @@ bool ftServer::FileDetails(const RsFileHash &hash, FileSearchFlags hintflags, Fi
|
||||
return false;
|
||||
}
|
||||
|
||||
RsTurtleGenericTunnelItem *ftServer::deserialiseItem(void *data,uint32_t size) const
|
||||
RsItem *ftServer::create_item(uint16_t service,uint8_t item_type) const
|
||||
{
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
|
||||
#ifdef SERVER_DEBUG
|
||||
FTSERVER_DEBUG() << "p3turtle: deserialising packet: " << std::endl ;
|
||||
#endif
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || (RS_SERVICE_TYPE_TURTLE != getRsItemService(rstype)))
|
||||
if (RS_SERVICE_TYPE_TURTLE != service)
|
||||
{
|
||||
FTSERVER_ERROR() << " Wrong type !!" << std::endl ;
|
||||
return NULL; /* wrong type */
|
||||
@ -474,14 +472,14 @@ RsTurtleGenericTunnelItem *ftServer::deserialiseItem(void *data,uint32_t size) c
|
||||
|
||||
try
|
||||
{
|
||||
switch(getRsItemSubType(rstype))
|
||||
switch(item_type)
|
||||
{
|
||||
case RS_TURTLE_SUBTYPE_FILE_REQUEST : return new RsTurtleFileRequestItem(data,size) ;
|
||||
case RS_TURTLE_SUBTYPE_FILE_DATA : return new RsTurtleFileDataItem(data,size) ;
|
||||
case RS_TURTLE_SUBTYPE_FILE_MAP_REQUEST : return new RsTurtleFileMapRequestItem(data,size) ;
|
||||
case RS_TURTLE_SUBTYPE_FILE_MAP : return new RsTurtleFileMapItem(data,size) ;
|
||||
case RS_TURTLE_SUBTYPE_CHUNK_CRC_REQUEST : return new RsTurtleChunkCrcRequestItem(data,size) ;
|
||||
case RS_TURTLE_SUBTYPE_CHUNK_CRC : return new RsTurtleChunkCrcItem(data,size) ;
|
||||
case RS_TURTLE_SUBTYPE_FILE_REQUEST : return new RsTurtleFileRequestItem();
|
||||
case RS_TURTLE_SUBTYPE_FILE_DATA : return new RsTurtleFileDataItem();
|
||||
case RS_TURTLE_SUBTYPE_FILE_MAP_REQUEST : return new RsTurtleFileMapRequestItem();
|
||||
case RS_TURTLE_SUBTYPE_FILE_MAP : return new RsTurtleFileMapItem();
|
||||
case RS_TURTLE_SUBTYPE_CHUNK_CRC_REQUEST : return new RsTurtleChunkCrcRequestItem();
|
||||
case RS_TURTLE_SUBTYPE_CHUNK_CRC : return new RsTurtleChunkCrcItem();
|
||||
|
||||
default:
|
||||
return NULL ;
|
||||
@ -1189,7 +1187,8 @@ bool ftServer::encryptItem(RsTurtleGenericTunnelItem *clear_item,const RsFileHas
|
||||
FTSERVER_DEBUG() << " random nonce : " << RsUtil::BinToHex(initialization_vector,ENCRYPTED_FT_INITIALIZATION_VECTOR_SIZE) << std::endl;
|
||||
#endif
|
||||
|
||||
uint32_t total_data_size = ENCRYPTED_FT_HEADER_SIZE + ENCRYPTED_FT_INITIALIZATION_VECTOR_SIZE + ENCRYPTED_FT_EDATA_SIZE + clear_item->serial_size() + ENCRYPTED_FT_AUTHENTICATION_TAG_SIZE ;
|
||||
uint32_t item_serialized_size = size(clear_item) ;
|
||||
uint32_t total_data_size = ENCRYPTED_FT_HEADER_SIZE + ENCRYPTED_FT_INITIALIZATION_VECTOR_SIZE + ENCRYPTED_FT_EDATA_SIZE + item_serialized_size + ENCRYPTED_FT_AUTHENTICATION_TAG_SIZE ;
|
||||
|
||||
#ifdef SERVER_DEBUG
|
||||
FTSERVER_DEBUG() << " clear part size : " << clear_item->serial_size() << std::endl;
|
||||
@ -1204,7 +1203,7 @@ bool ftServer::encryptItem(RsTurtleGenericTunnelItem *clear_item,const RsFileHas
|
||||
return false ;
|
||||
|
||||
uint8_t *edata = (uint8_t*)encrypted_item->data_bytes ;
|
||||
uint32_t edata_size = clear_item->serial_size() ;
|
||||
uint32_t edata_size = item_serialized_size;
|
||||
uint32_t offset = 0;
|
||||
|
||||
edata[0] = 0xae ;
|
||||
@ -1227,7 +1226,8 @@ bool ftServer::encryptItem(RsTurtleGenericTunnelItem *clear_item,const RsFileHas
|
||||
offset += ENCRYPTED_FT_EDATA_SIZE ;
|
||||
|
||||
uint32_t ser_size = (uint32_t)((int)total_data_size - (int)offset);
|
||||
clear_item->serialize(&edata[offset], ser_size);
|
||||
|
||||
serialise(clear_item,&edata[offset], &ser_size);
|
||||
|
||||
#ifdef SERVER_DEBUG
|
||||
FTSERVER_DEBUG() << " clear item : " << RsUtil::BinToHex(&edata[offset],std::min(50,(int)total_data_size-(int)offset)) << "(...)" << std::endl;
|
||||
@ -1331,7 +1331,7 @@ bool ftServer::decryptItem(RsTurtleGenericDataItem *encrypted_item,const RsFileH
|
||||
return false ;
|
||||
}
|
||||
|
||||
decrypted_item = deserialiseItem(&edata[clear_item_offset],edata_size) ;
|
||||
decrypted_item = dynamic_cast<RsTurtleGenericTunnelItem*>(deserialise(&edata[clear_item_offset],&edata_size)) ;
|
||||
|
||||
if(decrypted_item == NULL)
|
||||
return false ;
|
||||
|
@ -68,7 +68,7 @@ class p3PeerMgr;
|
||||
class p3ServiceControl;
|
||||
class p3FileDatabase;
|
||||
|
||||
class ftServer: public p3Service, public RsFiles, public ftDataSend, public RsTurtleClientService
|
||||
class ftServer: public p3Service, public RsFiles, public ftDataSend, public RsTurtleClientService, public RsServiceSerializer
|
||||
{
|
||||
|
||||
public:
|
||||
@ -97,7 +97,8 @@ public:
|
||||
//
|
||||
virtual bool handleTunnelRequest(const RsFileHash& hash,const RsPeerId& peer_id) ;
|
||||
virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
|
||||
virtual RsTurtleGenericTunnelItem *deserialiseItem(void *data,uint32_t size) const ;
|
||||
virtual RsItem *create_item(uint16_t service,uint8_t item_type) const ;
|
||||
virtual RsServiceSerializer *serializer() { return this ; }
|
||||
|
||||
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ;
|
||||
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ;
|
||||
|
@ -27,539 +27,48 @@
|
||||
#include <stdexcept>
|
||||
|
||||
#include <util/rsmemory.h>
|
||||
#include <serialiser/itempriorities.h>
|
||||
#include <rsitems/itempriorities.h>
|
||||
#include <ft/ftturtlefiletransferitem.h>
|
||||
|
||||
uint32_t RsTurtleFileRequestItem::serial_size() const
|
||||
#include <serialiser/rstypeserializer.h>
|
||||
|
||||
void RsTurtleFileMapRequestItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
uint32_t s = 0 ;
|
||||
|
||||
s += 8 ; // header
|
||||
s += 4 ; // tunnel id
|
||||
s += 8 ; // file offset
|
||||
s += 4 ; // chunk size
|
||||
|
||||
return s ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,tunnel_id,"tunnel_id") ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,direction,"direction") ;
|
||||
}
|
||||
|
||||
uint32_t RsTurtleFileDataItem::serial_size() const
|
||||
void RsTurtleFileMapItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
uint32_t s = 0 ;
|
||||
|
||||
s += 8 ; // header
|
||||
s += 4 ; // tunnel id
|
||||
s += 8 ; // file offset
|
||||
s += 4 ; // chunk size
|
||||
s += chunk_size ; // actual data size.
|
||||
|
||||
return s ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,tunnel_id,"tunnel_id") ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,direction,"direction") ;
|
||||
RsTypeSerializer::serial_process (j,ctx,compressed_map._map,"map") ;
|
||||
}
|
||||
void RsTurtleChunkCrcRequestItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,tunnel_id,"tunnel_id") ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,chunk_number,"chunk_number") ;
|
||||
}
|
||||
void RsTurtleChunkCrcItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,tunnel_id,"tunnel_id") ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,chunk_number,"chunk_number") ;
|
||||
RsTypeSerializer::serial_process (j,ctx,check_sum,"check_sum") ;
|
||||
}
|
||||
|
||||
uint32_t RsTurtleFileMapRequestItem::serial_size() const
|
||||
void RsTurtleFileRequestItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
uint32_t s = 0 ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,tunnel_id,"tunnel_id") ;
|
||||
RsTypeSerializer::serial_process<uint64_t>(j,ctx,chunk_offset,"chunk_offset") ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,chunk_size,"chunk_size") ;
|
||||
}
|
||||
void RsTurtleFileDataItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,tunnel_id,"tunnel_id") ;
|
||||
RsTypeSerializer::serial_process<uint64_t>(j,ctx,chunk_offset,"chunk_offset") ;
|
||||
|
||||
s += 8 ; // header
|
||||
s += 4 ; // tunnel id
|
||||
s += 4 ; // direction
|
||||
RsTypeSerializer::TlvMemBlock_proxy prox(chunk_data,chunk_size) ;
|
||||
|
||||
return s ;
|
||||
}
|
||||
|
||||
uint32_t RsTurtleFileMapItem::serial_size() const
|
||||
{
|
||||
uint32_t s = 0 ;
|
||||
|
||||
s += 8 ; // header
|
||||
s += 4 ; // tunnel id
|
||||
s += 4 ; // direction
|
||||
s += 4 ; // compressed_map.size()
|
||||
|
||||
s += 4 * compressed_map._map.size() ;
|
||||
|
||||
return s ;
|
||||
}
|
||||
|
||||
uint32_t RsTurtleChunkCrcItem::serial_size() const
|
||||
{
|
||||
uint32_t s = 0 ;
|
||||
|
||||
s += 8 ; // header
|
||||
s += 4 ; // tunnel id
|
||||
s += 4 ; // chunk number
|
||||
s += check_sum.serial_size() ; // check_sum
|
||||
|
||||
return s ;
|
||||
}
|
||||
uint32_t RsTurtleChunkCrcRequestItem::serial_size() const
|
||||
{
|
||||
uint32_t s = 0 ;
|
||||
|
||||
s += 8 ; // header
|
||||
s += 4 ; // tunnel id
|
||||
s += 4 ; // chunk number
|
||||
|
||||
return s ;
|
||||
}
|
||||
bool RsTurtleFileMapRequestItem::serialize(void *data,uint32_t& pktsize) const
|
||||
{
|
||||
uint32_t tlvsize = serial_size();
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data,tlvsize,PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, tunnel_id);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, direction);
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileConfigSerialiser::serialiseTransfer() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool RsTurtleFileMapItem::serialize(void *data,uint32_t& pktsize) const
|
||||
{
|
||||
uint32_t tlvsize = serial_size();
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data,tlvsize,PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, tunnel_id);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, direction);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, compressed_map._map.size());
|
||||
|
||||
for(uint32_t i=0;i<compressed_map._map.size() && ok;++i)
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, compressed_map._map[i]);
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileConfigSerialiser::serialiseTransfer() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool RsTurtleChunkCrcRequestItem::serialize(void *data,uint32_t& pktsize) const
|
||||
{
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << "RsTurtleChunkCrcRequestItem::serialize(): serializing packet:" << std::endl ;
|
||||
print(std::cerr,2) ;
|
||||
#endif
|
||||
uint32_t tlvsize = serial_size();
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data,tlvsize,PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, tunnel_id);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, chunk_number);
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
std::cerr << "RsFileConfigSerialiser::serialiseTransfer() Size Error! " << std::endl;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool RsTurtleChunkCrcItem::serialize(void *data,uint32_t& pktsize) const
|
||||
{
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << "RsTurtleChunkCrcRequestItem::serialize(): serializing packet:" << std::endl ;
|
||||
print(std::cerr,2) ;
|
||||
#endif
|
||||
uint32_t tlvsize = serial_size();
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data,tlvsize,PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, tunnel_id);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, chunk_number);
|
||||
ok &= check_sum.serialise(data, tlvsize, offset) ;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
std::cerr << "RsFileConfigSerialiser::serialiseTransfer() Size Error! " << std::endl;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
RsTurtleFileMapItem::RsTurtleFileMapItem(void *data,uint32_t pktsize)
|
||||
: RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_FILE_MAP)
|
||||
{
|
||||
setPriorityLevel(QOS_PRIORITY_RS_TURTLE_FILE_MAP) ;
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " type = file map item" << std::endl ;
|
||||
#endif
|
||||
uint32_t offset = 8; // skip the header
|
||||
|
||||
/* add mandatory parts first */
|
||||
|
||||
bool ok = true ;
|
||||
uint32_t s,d ;
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &tunnel_id);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &d);
|
||||
direction = d ;
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &s) ;
|
||||
|
||||
compressed_map._map.resize(s) ;
|
||||
|
||||
for(uint32_t i=0;i<s && ok;++i)
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &(compressed_map._map[i])) ;
|
||||
|
||||
#ifdef WINDOWS_SYS // No Exceptions in Windows compile. (drbobs).
|
||||
#else
|
||||
if (offset != pktsize)
|
||||
throw std::runtime_error("Size error while deserializing.") ;
|
||||
if (!ok)
|
||||
throw std::runtime_error("Unknown error while deserializing.") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
RsTurtleFileMapRequestItem::RsTurtleFileMapRequestItem(void *data,uint32_t pktsize)
|
||||
: RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_FILE_MAP_REQUEST)
|
||||
{
|
||||
setPriorityLevel(QOS_PRIORITY_RS_TURTLE_FILE_MAP_REQUEST) ;
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " type = file map request item" << std::endl ;
|
||||
#endif
|
||||
uint32_t offset = 8; // skip the header
|
||||
|
||||
/* add mandatory parts first */
|
||||
|
||||
bool ok = true ;
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &tunnel_id);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &direction);
|
||||
|
||||
#ifdef WINDOWS_SYS // No Exceptions in Windows compile. (drbobs).
|
||||
#else
|
||||
if (offset != pktsize)
|
||||
throw std::runtime_error("Size error while deserializing.") ;
|
||||
if (!ok)
|
||||
throw std::runtime_error("Unknown error while deserializing.") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
RsTurtleChunkCrcItem::RsTurtleChunkCrcItem(void *data,uint32_t pktsize)
|
||||
: RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_CHUNK_CRC)
|
||||
{
|
||||
setPriorityLevel(QOS_PRIORITY_RS_TURTLE_CHUNK_CRC) ;
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " type = file map item" << std::endl ;
|
||||
#endif
|
||||
uint32_t offset = 8; // skip the header
|
||||
|
||||
/* add mandatory parts first */
|
||||
|
||||
bool ok = true ;
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &tunnel_id) ;
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &chunk_number) ;
|
||||
ok &= check_sum.deserialise(data, pktsize, offset) ;
|
||||
|
||||
#ifdef WINDOWS_SYS // No Exceptions in Windows compile. (drbobs).
|
||||
#else
|
||||
if (offset != pktsize)
|
||||
throw std::runtime_error("Size error while deserializing.") ;
|
||||
if (!ok)
|
||||
throw std::runtime_error("Unknown error while deserializing.") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
RsTurtleChunkCrcRequestItem::RsTurtleChunkCrcRequestItem(void *data,uint32_t pktsize)
|
||||
: RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_CHUNK_CRC_REQUEST)
|
||||
{
|
||||
setPriorityLevel(QOS_PRIORITY_RS_TURTLE_CHUNK_CRC_REQUEST) ;
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " type = file map item" << std::endl ;
|
||||
#endif
|
||||
uint32_t offset = 8; // skip the header
|
||||
|
||||
/* add mandatory parts first */
|
||||
|
||||
bool ok = true ;
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &tunnel_id) ;
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &chunk_number) ;
|
||||
|
||||
#ifdef WINDOWS_SYS // No Exceptions in Windows compile. (drbobs).
|
||||
#else
|
||||
if (offset != pktsize)
|
||||
throw std::runtime_error("Size error while deserializing.") ;
|
||||
if (!ok)
|
||||
throw std::runtime_error("Unknown error while deserializing.") ;
|
||||
#endif
|
||||
}
|
||||
bool RsTurtleFileRequestItem::serialize(void *data,uint32_t& pktsize) const
|
||||
{
|
||||
uint32_t tlvsize = serial_size();
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data,tlvsize,PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, tunnel_id) ;
|
||||
ok &= setRawUInt64(data, tlvsize, &offset, chunk_offset);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, chunk_size);
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsTurtleTunnelOkItem::serialiseTransfer() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
RsTurtleFileRequestItem::RsTurtleFileRequestItem(void *data,uint32_t pktsize)
|
||||
: RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_FILE_REQUEST)
|
||||
{
|
||||
setPriorityLevel(QOS_PRIORITY_RS_TURTLE_FILE_REQUEST) ;
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " type = file request" << std::endl ;
|
||||
#endif
|
||||
uint32_t offset = 8; // skip the header
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
|
||||
/* add mandatory parts first */
|
||||
|
||||
bool ok = true ;
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &tunnel_id) ;
|
||||
ok &= getRawUInt64(data, pktsize, &offset, &chunk_offset);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &chunk_size);
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " tunnel_id=" << (void*)tunnel_id << ", chunk_offset=" << chunk_offset << ", chunk_size=" << chunk_size << std::endl ;
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWS_SYS // No Exceptions in Windows compile. (drbobs).
|
||||
UNREFERENCED_LOCAL_VARIABLE(rssize);
|
||||
#else
|
||||
if (offset != rssize)
|
||||
throw std::runtime_error("RsTurtleTunnelOkItem::() error while deserializing.") ;
|
||||
if (!ok)
|
||||
throw std::runtime_error("RsTurtleTunnelOkItem::() unknown error while deserializing.") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
RsTurtleFileDataItem::~RsTurtleFileDataItem()
|
||||
{
|
||||
free(chunk_data) ;
|
||||
}
|
||||
RsTurtleFileDataItem::RsTurtleFileDataItem(void *data,uint32_t pktsize)
|
||||
: RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_FILE_DATA)
|
||||
{
|
||||
setPriorityLevel(QOS_PRIORITY_RS_TURTLE_FILE_DATA) ;
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " type = file request" << std::endl ;
|
||||
#endif
|
||||
uint32_t offset = 8; // skip the header
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
|
||||
bool ok = true ;
|
||||
|
||||
if(rssize > pktsize)
|
||||
ok = false ;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &tunnel_id) ;
|
||||
ok &= getRawUInt64(data, pktsize, &offset, &chunk_offset);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &chunk_size);
|
||||
|
||||
if(chunk_size > rssize || rssize - chunk_size < offset)
|
||||
throw std::runtime_error("RsTurtleFileDataItem::() error while deserializing.") ;
|
||||
|
||||
chunk_data = (void*)rs_malloc(chunk_size) ;
|
||||
|
||||
if(chunk_data == NULL)
|
||||
throw std::runtime_error("RsTurtleFileDataItem::() cannot allocate memory.") ;
|
||||
|
||||
memcpy(chunk_data,(void*)((unsigned char*)data+offset),chunk_size) ;
|
||||
|
||||
offset += chunk_size ;
|
||||
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " tunnel_id=" << (void*)tunnel_id << ", chunk_offset=" << chunk_offset << ", chunk_size=" << chunk_size << std::endl ;
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWS_SYS // No Exceptions in Windows compile. (drbobs).
|
||||
UNREFERENCED_LOCAL_VARIABLE(rssize);
|
||||
#else
|
||||
if (offset != rssize)
|
||||
throw std::runtime_error("RsTurtleFileDataItem::() error while deserializing.") ;
|
||||
if (!ok)
|
||||
throw std::runtime_error("RsTurtleFileDataItem::() unknown error while deserializing.") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RsTurtleFileDataItem::serialize(void *data,uint32_t& pktsize) const
|
||||
{
|
||||
uint32_t tlvsize = serial_size();
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data,tlvsize,PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, tunnel_id) ;
|
||||
ok &= setRawUInt64(data, tlvsize, &offset, chunk_offset);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, chunk_size);
|
||||
|
||||
memcpy((void*)((unsigned char*)data+offset),chunk_data,chunk_size) ;
|
||||
offset += chunk_size ;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsTurtleTunnelOkItem::serialiseTransfer() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
std::ostream& RsTurtleFileRequestItem::print(std::ostream& o, uint16_t)
|
||||
{
|
||||
o << "File request item:" << std::endl ;
|
||||
|
||||
o << " tunnel id : " << std::hex << tunnel_id << std::dec << std::endl ;
|
||||
o << " offset : " << chunk_offset << std::endl ;
|
||||
o << " chunk size: " << chunk_size << std::endl ;
|
||||
|
||||
return o ;
|
||||
}
|
||||
|
||||
std::ostream& RsTurtleFileDataItem::print(std::ostream& o, uint16_t)
|
||||
{
|
||||
o << "File request item:" << std::endl ;
|
||||
|
||||
o << " tunnel id : " << std::hex << tunnel_id << std::dec << std::endl ;
|
||||
o << " offset : " << chunk_offset << std::endl ;
|
||||
o << " chunk size: " << chunk_size << std::endl ;
|
||||
o << " data : " << std::hex << chunk_data << std::dec << std::endl ;
|
||||
|
||||
return o ;
|
||||
}
|
||||
|
||||
std::ostream& RsTurtleFileMapItem::print(std::ostream& o, uint16_t)
|
||||
{
|
||||
o << "File map item:" << std::endl ;
|
||||
|
||||
o << " tunnel id : " << std::hex << tunnel_id << std::dec << std::endl ;
|
||||
o << " direction : " << direction << std::endl ;
|
||||
o << " map : " ;
|
||||
|
||||
for(uint32_t i=0;i<compressed_map._map.size();++i)
|
||||
o << std::hex << compressed_map._map[i] << std::dec << std::endl ;
|
||||
|
||||
return o ;
|
||||
}
|
||||
|
||||
std::ostream& RsTurtleFileMapRequestItem::print(std::ostream& o, uint16_t)
|
||||
{
|
||||
o << "File map request item:" << std::endl ;
|
||||
|
||||
o << " tunnel id : " << std::hex << tunnel_id << std::dec << std::endl ;
|
||||
o << " direction : " << direction << std::endl ;
|
||||
|
||||
return o ;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& RsTurtleChunkCrcRequestItem::print(std::ostream& o, uint16_t)
|
||||
{
|
||||
o << "Chunk CRC request item:" << std::endl ;
|
||||
|
||||
o << " tunnel id : " << std::hex << tunnel_id << std::dec << std::endl ;
|
||||
o << " chunk num : " << chunk_number << std::endl ;
|
||||
|
||||
return o ;
|
||||
}
|
||||
std::ostream& RsTurtleChunkCrcItem::print(std::ostream& o, uint16_t)
|
||||
{
|
||||
o << "Chunk CRC item:" << std::endl ;
|
||||
|
||||
o << " tunnel id : " << std::hex << tunnel_id << std::dec << std::endl ;
|
||||
o << " chunk num : " << chunk_number << std::endl ;
|
||||
o << " sha1 sum : " << check_sum.toStdString() << std::endl ;
|
||||
|
||||
return o ;
|
||||
RsTypeSerializer::serial_process(j,ctx,prox,"chunk_data") ;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@ class RsTurtleFileRequestItem: public RsTurtleGenericTunnelItem
|
||||
{
|
||||
public:
|
||||
RsTurtleFileRequestItem() : RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_FILE_REQUEST) { setPriorityLevel(QOS_PRIORITY_RS_TURTLE_FILE_REQUEST);}
|
||||
RsTurtleFileRequestItem(void *data,uint32_t size) ; // deserialization
|
||||
|
||||
virtual bool shouldStampTunnel() const { return false ; }
|
||||
virtual Direction travelingDirection() const { return DIRECTION_SERVER ; }
|
||||
@ -42,51 +41,50 @@ class RsTurtleFileRequestItem: public RsTurtleGenericTunnelItem
|
||||
uint64_t chunk_offset ;
|
||||
uint32_t chunk_size ;
|
||||
|
||||
virtual std::ostream& print(std::ostream& o, uint16_t) ;
|
||||
void clear() {}
|
||||
protected:
|
||||
virtual bool serialize(void *data,uint32_t& size) const;
|
||||
virtual uint32_t serial_size() const;
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
};
|
||||
|
||||
class RsTurtleFileDataItem: public RsTurtleGenericTunnelItem
|
||||
{
|
||||
public:
|
||||
RsTurtleFileDataItem() : RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_FILE_DATA) { setPriorityLevel(QOS_PRIORITY_RS_TURTLE_FILE_DATA) ;}
|
||||
~RsTurtleFileDataItem() ;
|
||||
RsTurtleFileDataItem(void *data,uint32_t size) ; // deserialization
|
||||
~RsTurtleFileDataItem() { clear() ; }
|
||||
|
||||
virtual bool shouldStampTunnel() const { return true ; }
|
||||
virtual Direction travelingDirection() const { return DIRECTION_CLIENT ; }
|
||||
|
||||
void clear()
|
||||
{
|
||||
free(chunk_data);
|
||||
chunk_data = NULL ;
|
||||
chunk_size = 0 ;
|
||||
chunk_offset = 0 ;
|
||||
}
|
||||
|
||||
uint64_t chunk_offset ; // offset in the file
|
||||
uint32_t chunk_size ; // size of the file chunk
|
||||
void *chunk_data ; // actual data.
|
||||
|
||||
virtual std::ostream& print(std::ostream& o, uint16_t) ;
|
||||
|
||||
virtual bool serialize(void *data,uint32_t& size) const;
|
||||
virtual uint32_t serial_size() const;
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
};
|
||||
|
||||
class RsTurtleFileMapRequestItem: public RsTurtleGenericTunnelItem
|
||||
{
|
||||
public:
|
||||
RsTurtleFileMapRequestItem() : RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_FILE_MAP_REQUEST) { setPriorityLevel(QOS_PRIORITY_RS_TURTLE_FILE_MAP_REQUEST) ;}
|
||||
RsTurtleFileMapRequestItem(void *data,uint32_t size) ; // deserialization
|
||||
|
||||
virtual bool shouldStampTunnel() const { return false ; }
|
||||
|
||||
virtual std::ostream& print(std::ostream& o, uint16_t) ;
|
||||
|
||||
virtual bool serialize(void *data,uint32_t& size) const;
|
||||
virtual uint32_t serial_size() const;
|
||||
void clear() {}
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
};
|
||||
|
||||
class RsTurtleFileMapItem: public RsTurtleGenericTunnelItem
|
||||
{
|
||||
public:
|
||||
RsTurtleFileMapItem() : RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_FILE_MAP) { setPriorityLevel(QOS_PRIORITY_RS_TURTLE_FILE_MAP) ;}
|
||||
RsTurtleFileMapItem(void *data,uint32_t size) ; // deserialization
|
||||
|
||||
virtual bool shouldStampTunnel() const { return false ; }
|
||||
|
||||
@ -94,34 +92,28 @@ class RsTurtleFileMapItem: public RsTurtleGenericTunnelItem
|
||||
// by default, we suppose the peer has all the chunks. This info will thus be and-ed
|
||||
// with the default file map for this source.
|
||||
|
||||
virtual std::ostream& print(std::ostream& o, uint16_t) ;
|
||||
|
||||
virtual bool serialize(void *data,uint32_t& size) const;
|
||||
virtual uint32_t serial_size() const;
|
||||
void clear() { compressed_map._map.clear() ;}
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
};
|
||||
|
||||
class RsTurtleChunkCrcRequestItem: public RsTurtleGenericTunnelItem
|
||||
{
|
||||
public:
|
||||
RsTurtleChunkCrcRequestItem() : RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_CHUNK_CRC_REQUEST) { setPriorityLevel(QOS_PRIORITY_RS_CHUNK_CRC_REQUEST);}
|
||||
RsTurtleChunkCrcRequestItem(void *data,uint32_t size) ; // deserialization
|
||||
|
||||
virtual bool shouldStampTunnel() const { return false ; }
|
||||
virtual Direction travelingDirection() const { return DIRECTION_SERVER ; }
|
||||
|
||||
uint32_t chunk_number ; // id of the chunk to CRC.
|
||||
|
||||
virtual std::ostream& print(std::ostream& o, uint16_t) ;
|
||||
|
||||
virtual bool serialize(void *data,uint32_t& size) const;
|
||||
virtual uint32_t serial_size() const;
|
||||
void clear() {}
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
};
|
||||
|
||||
class RsTurtleChunkCrcItem: public RsTurtleGenericTunnelItem
|
||||
{
|
||||
public:
|
||||
RsTurtleChunkCrcItem() : RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_CHUNK_CRC) { setPriorityLevel(QOS_PRIORITY_RS_CHUNK_CRC);}
|
||||
RsTurtleChunkCrcItem(void *data,uint32_t size) ; // deserialization
|
||||
|
||||
virtual bool shouldStampTunnel() const { return true ; }
|
||||
virtual Direction travelingDirection() const { return DIRECTION_CLIENT ; }
|
||||
@ -129,7 +121,6 @@ class RsTurtleChunkCrcItem: public RsTurtleGenericTunnelItem
|
||||
uint32_t chunk_number ;
|
||||
Sha1CheckSum check_sum ;
|
||||
|
||||
virtual std::ostream& print(std::ostream& o, uint16_t) ;
|
||||
virtual bool serialize(void *data,uint32_t& size) const;
|
||||
virtual uint32_t serial_size() const;
|
||||
void clear() { check_sum.clear() ;}
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,7 @@
|
||||
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rstlvkeys.h"
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "rsitems/rsserviceids.h"
|
||||
#include "retroshare/rstypes.h"
|
||||
|
||||
#include "retroshare/rsgrouter.h"
|
||||
@ -63,14 +63,7 @@ class RsGRouterItem: public RsItem
|
||||
|
||||
virtual ~RsGRouterItem() {}
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const = 0 ;
|
||||
virtual uint32_t serial_size() const = 0 ;
|
||||
|
||||
virtual void clear() = 0 ;
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) = 0;
|
||||
|
||||
protected:
|
||||
bool serialise_header(void *data, uint32_t& pktsize, uint32_t& tlvsize, uint32_t& offset) const;
|
||||
};
|
||||
|
||||
/***********************************************************************************/
|
||||
@ -100,14 +93,11 @@ public:
|
||||
RsGRouterAbstractMsgItem(uint8_t pkt_subtype) : RsGRouterItem(pkt_subtype) {}
|
||||
virtual ~RsGRouterAbstractMsgItem() {}
|
||||
|
||||
virtual uint32_t signed_data_size() const = 0 ;
|
||||
virtual bool serialise_signed_data(void *data,uint32_t size) const = 0 ;
|
||||
|
||||
GRouterMsgPropagationId routing_id ;
|
||||
GRouterKeyId destination_key ;
|
||||
GRouterServiceId service_id ;
|
||||
RsTlvKeySignature signature ; // signs mid+destination_key+state
|
||||
uint32_t flags ; // packet was delivered, not delivered, bounced, etc
|
||||
uint32_t flags ; // packet was delivered, not delivered, bounced, etc
|
||||
};
|
||||
|
||||
class RsGRouterGenericDataItem: public RsGRouterAbstractMsgItem, public RsGRouterNonCopyableObject
|
||||
@ -116,15 +106,13 @@ class RsGRouterGenericDataItem: public RsGRouterAbstractMsgItem, public RsGRoute
|
||||
RsGRouterGenericDataItem() : RsGRouterAbstractMsgItem(RS_PKT_SUBTYPE_GROUTER_DATA) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; }
|
||||
virtual ~RsGRouterGenericDataItem() { clear() ; }
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const ;
|
||||
virtual uint32_t serial_size() const ;
|
||||
|
||||
virtual void clear()
|
||||
{
|
||||
free(data_bytes);
|
||||
data_bytes=NULL;
|
||||
}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) ;
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
RsGRouterGenericDataItem *duplicate() const ;
|
||||
|
||||
@ -132,35 +120,23 @@ class RsGRouterGenericDataItem: public RsGRouterAbstractMsgItem, public RsGRoute
|
||||
//
|
||||
uint32_t data_size ;
|
||||
uint8_t *data_bytes;
|
||||
|
||||
uint32_t duplication_factor ; // number of duplicates allowed. Should be capped at each de-serialise operation!
|
||||
|
||||
// utility methods for signing data
|
||||
virtual uint32_t signed_data_size() const ;
|
||||
virtual bool serialise_signed_data(void *data, uint32_t size) const ;
|
||||
};
|
||||
|
||||
class RsGRouterSignedReceiptItem: public RsGRouterAbstractMsgItem
|
||||
{
|
||||
public:
|
||||
RsGRouterSignedReceiptItem() : RsGRouterAbstractMsgItem(RS_PKT_SUBTYPE_GROUTER_SIGNED_RECEIPT) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; }
|
||||
virtual ~RsGRouterSignedReceiptItem() {}
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const ;
|
||||
virtual uint32_t serial_size() const ;
|
||||
virtual ~RsGRouterSignedReceiptItem() {}
|
||||
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) ;
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
RsGRouterSignedReceiptItem *duplicate() const ;
|
||||
|
||||
// packet data
|
||||
//
|
||||
Sha1CheckSum data_hash ; // avoids an attacker to re-use a given signed receipt. This is the hash of the enceypted data.
|
||||
|
||||
// utility methods for signing data
|
||||
virtual uint32_t signed_data_size() const ;
|
||||
virtual bool serialise_signed_data(void *data, uint32_t size) const ;
|
||||
Sha1CheckSum data_hash ; // avoids an attacker to re-use a given signed receipt. This is the hash of the enceypted data.
|
||||
};
|
||||
|
||||
// Low-level data items
|
||||
@ -170,62 +146,55 @@ class RsGRouterTransactionItem: public RsGRouterItem
|
||||
public:
|
||||
RsGRouterTransactionItem(uint8_t pkt_subtype) : RsGRouterItem(pkt_subtype) {}
|
||||
|
||||
virtual ~RsGRouterTransactionItem() {}
|
||||
virtual ~RsGRouterTransactionItem() {}
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const =0;
|
||||
virtual uint32_t serial_size() const =0;
|
||||
virtual void clear() =0;
|
||||
|
||||
virtual RsGRouterTransactionItem *duplicate() const = 0 ;
|
||||
virtual RsGRouterTransactionItem *duplicate() const = 0 ;
|
||||
};
|
||||
|
||||
class RsGRouterTransactionChunkItem: public RsGRouterTransactionItem, public RsGRouterNonCopyableObject
|
||||
{
|
||||
public:
|
||||
RsGRouterTransactionChunkItem() : RsGRouterTransactionItem(RS_PKT_SUBTYPE_GROUTER_TRANSACTION_CHUNK) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; }
|
||||
public:
|
||||
RsGRouterTransactionChunkItem() : RsGRouterTransactionItem(RS_PKT_SUBTYPE_GROUTER_TRANSACTION_CHUNK) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; }
|
||||
|
||||
virtual ~RsGRouterTransactionChunkItem() { free(chunk_data) ; }
|
||||
virtual ~RsGRouterTransactionChunkItem() { free(chunk_data) ; }
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const ;
|
||||
virtual uint32_t serial_size() const ;
|
||||
virtual void clear() {}
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) ;
|
||||
virtual RsGRouterTransactionItem *duplicate() const
|
||||
{
|
||||
RsGRouterTransactionChunkItem *item = new RsGRouterTransactionChunkItem ;
|
||||
*item = *this ; // copy all fields
|
||||
item->chunk_data = (uint8_t*)rs_malloc(chunk_size) ; // deep copy memory chunk
|
||||
|
||||
virtual RsGRouterTransactionItem *duplicate() const
|
||||
{
|
||||
RsGRouterTransactionChunkItem *item = new RsGRouterTransactionChunkItem ;
|
||||
*item = *this ; // copy all fields
|
||||
item->chunk_data = (uint8_t*)rs_malloc(chunk_size) ; // deep copy memory chunk
|
||||
|
||||
if(item->chunk_data == NULL)
|
||||
return NULL ;
|
||||
|
||||
memcpy(item->chunk_data,chunk_data,chunk_size) ;
|
||||
return item ;
|
||||
}
|
||||
if(item->chunk_data == NULL)
|
||||
return NULL ;
|
||||
|
||||
GRouterMsgPropagationId propagation_id ;
|
||||
uint32_t chunk_start ;
|
||||
uint32_t chunk_size ;
|
||||
uint32_t total_size ;
|
||||
uint8_t *chunk_data ;
|
||||
memcpy(item->chunk_data,chunk_data,chunk_size) ;
|
||||
return item ;
|
||||
}
|
||||
|
||||
GRouterMsgPropagationId propagation_id ;
|
||||
uint32_t chunk_start ;
|
||||
uint32_t chunk_size ;
|
||||
uint32_t total_size ;
|
||||
uint8_t *chunk_data ;
|
||||
};
|
||||
class RsGRouterTransactionAcknItem: public RsGRouterTransactionItem
|
||||
{
|
||||
public:
|
||||
RsGRouterTransactionAcknItem() : RsGRouterTransactionItem(RS_PKT_SUBTYPE_GROUTER_TRANSACTION_ACKN) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; }
|
||||
virtual ~RsGRouterTransactionAcknItem() {}
|
||||
public:
|
||||
RsGRouterTransactionAcknItem() : RsGRouterTransactionItem(RS_PKT_SUBTYPE_GROUTER_TRANSACTION_ACKN) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; }
|
||||
virtual ~RsGRouterTransactionAcknItem() {}
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const ;
|
||||
virtual uint32_t serial_size() const ;
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) ;
|
||||
virtual void clear() {}
|
||||
|
||||
virtual RsGRouterTransactionItem *duplicate() const { return new RsGRouterTransactionAcknItem(*this) ; }
|
||||
virtual RsGRouterTransactionItem *duplicate() const { return new RsGRouterTransactionAcknItem(*this) ; }
|
||||
|
||||
GRouterMsgPropagationId propagation_id ;
|
||||
GRouterMsgPropagationId propagation_id ;
|
||||
};
|
||||
|
||||
// Items for saving the routing matrix information.
|
||||
@ -236,11 +205,8 @@ class RsGRouterMatrixCluesItem: public RsGRouterItem
|
||||
RsGRouterMatrixCluesItem() : RsGRouterItem(RS_PKT_SUBTYPE_GROUTER_MATRIX_CLUES)
|
||||
{ setPriorityLevel(0) ; } // this item is never sent through the network
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const ;
|
||||
virtual uint32_t serial_size() const ;
|
||||
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) ;
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
// packet data
|
||||
//
|
||||
@ -254,17 +220,15 @@ class RsGRouterMatrixTrackItem: public RsGRouterItem
|
||||
RsGRouterMatrixTrackItem() : RsGRouterItem(RS_PKT_SUBTYPE_GROUTER_MATRIX_TRACK)
|
||||
{ setPriorityLevel(0) ; } // this item is never sent through the network
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const ;
|
||||
virtual uint32_t serial_size() const ;
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) ;
|
||||
|
||||
// packet data
|
||||
//
|
||||
RsGxsMessageId message_id ;
|
||||
RsPeerId provider_id ;
|
||||
time_t time_stamp ;
|
||||
RsPeerId provider_id ;
|
||||
time_t time_stamp ;
|
||||
};
|
||||
class RsGRouterMatrixFriendListItem: public RsGRouterItem
|
||||
{
|
||||
@ -272,11 +236,8 @@ class RsGRouterMatrixFriendListItem: public RsGRouterItem
|
||||
RsGRouterMatrixFriendListItem() : RsGRouterItem(RS_PKT_SUBTYPE_GROUTER_FRIENDS_LIST)
|
||||
{ setPriorityLevel(0) ; } // this item is never sent through the network
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const ;
|
||||
virtual uint32_t serial_size() const ;
|
||||
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) ;
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
virtual void clear() {}
|
||||
|
||||
// packet data
|
||||
//
|
||||
@ -291,8 +252,7 @@ class RsGRouterRoutingInfoItem: public RsGRouterItem, public GRouterRoutingInfo,
|
||||
|
||||
virtual ~RsGRouterRoutingInfoItem() { clear() ; }
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const ;
|
||||
virtual uint32_t serial_size() const ;
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
virtual void clear()
|
||||
{
|
||||
@ -302,47 +262,18 @@ class RsGRouterRoutingInfoItem: public RsGRouterItem, public GRouterRoutingInfo,
|
||||
data_item = NULL ;
|
||||
receipt_item = NULL ;
|
||||
}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) ;
|
||||
};
|
||||
|
||||
/***********************************************************************************/
|
||||
/* Serialisation */
|
||||
/***********************************************************************************/
|
||||
|
||||
class RsGRouterSerialiser: public RsSerialType
|
||||
class RsGRouterSerialiser: public RsServiceSerializer
|
||||
{
|
||||
public:
|
||||
RsGRouterSerialiser() : RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_GROUTER) {}
|
||||
RsGRouterSerialiser(SerializationFlags flags = SERIALIZATION_FLAG_NONE) : RsServiceSerializer(RS_SERVICE_TYPE_GROUTER,RsGenericSerializer::FORMAT_BINARY,flags) {}
|
||||
|
||||
virtual uint32_t size (RsItem *item)
|
||||
{
|
||||
RsGRouterItem *gitem = dynamic_cast<RsGRouterItem *>(item);
|
||||
if (!gitem)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return gitem->serial_size() ;
|
||||
}
|
||||
virtual bool serialise(RsItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
RsGRouterItem *gitem = dynamic_cast<RsGRouterItem *>(item);
|
||||
if (!gitem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return gitem->serialise(data,*size) ;
|
||||
}
|
||||
virtual RsItem *deserialise (void *data, uint32_t *size) ;
|
||||
|
||||
private:
|
||||
RsGRouterGenericDataItem *deserialise_RsGRouterGenericDataItem(void *data,uint32_t size) const ;
|
||||
RsGRouterTransactionChunkItem *deserialise_RsGRouterTransactionChunkItem(void *data,uint32_t size) const ;
|
||||
RsGRouterTransactionAcknItem *deserialise_RsGRouterTransactionAcknItem(void *data,uint32_t size) const ;
|
||||
RsGRouterSignedReceiptItem *deserialise_RsGRouterSignedReceiptItem(void *data,uint32_t size) const ;
|
||||
RsGRouterMatrixCluesItem *deserialise_RsGRouterMatrixCluesItem(void *data,uint32_t size) const ;
|
||||
RsGRouterMatrixTrackItem *deserialise_RsGRouterMatrixTrackItem(void *data,uint32_t size) const ;
|
||||
RsGRouterMatrixFriendListItem *deserialise_RsGRouterMatrixFriendListItem(void *data,uint32_t size) const ;
|
||||
RsGRouterRoutingInfoItem *deserialise_RsGRouterRoutingInfoItem(void *data,uint32_t size) const ;
|
||||
virtual RsItem *create_item(uint16_t service,uint8_t subtype) const ;
|
||||
};
|
||||
|
||||
|
||||
|
@ -186,7 +186,7 @@
|
||||
#include "util/rsrandom.h"
|
||||
#include "util/rsprint.h"
|
||||
#include "util/rsmemory.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
#include "services/p3idservice.h"
|
||||
#include "turtle/p3turtle.h"
|
||||
#include "gxs/rsgixs.h"
|
||||
@ -1263,13 +1263,13 @@ bool p3GRouter::locked_sendTransactionData(const RsPeerId& pid,const RsGRouterTr
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " sending to tunnel vpid " << pid << std::endl;
|
||||
#endif
|
||||
uint32_t turtle_data_size = trans_item.serial_size() ;
|
||||
uint32_t turtle_data_size = RsGRouterSerialiser().size(const_cast<RsGRouterTransactionItem*>(&trans_item)) ;
|
||||
uint8_t *turtle_data = (uint8_t*)rs_malloc(turtle_data_size) ;
|
||||
|
||||
if(turtle_data == NULL)
|
||||
return false ;
|
||||
|
||||
if(!trans_item.serialise(turtle_data,turtle_data_size))
|
||||
if(!RsGRouterSerialiser().serialise(const_cast<RsGRouterTransactionItem*>(&trans_item),turtle_data,&turtle_data_size))
|
||||
{
|
||||
std::cerr << " ERROR: cannot serialise RsGRouterTransactionChunkItem." << std::endl;
|
||||
|
||||
@ -1428,7 +1428,7 @@ bool p3GRouter::sliceDataItem(RsGRouterAbstractMsgItem *item,std::list<RsGRouter
|
||||
item->print(std::cerr, 2) ;
|
||||
#endif
|
||||
|
||||
uint32_t size = item->serial_size();
|
||||
uint32_t size = RsGRouterSerialiser().size(item);
|
||||
|
||||
RsTemporaryMemory data(size) ; // data will be freed on return, whatever the route taken.
|
||||
|
||||
@ -1438,7 +1438,7 @@ bool p3GRouter::sliceDataItem(RsGRouterAbstractMsgItem *item,std::list<RsGRouter
|
||||
throw ;
|
||||
}
|
||||
|
||||
if(!item->serialise(data,size))
|
||||
if(!RsGRouterSerialiser().serialise(item,data,&size))
|
||||
{
|
||||
std::cerr << " ERROR: cannot serialise." << std::endl;
|
||||
throw ;
|
||||
@ -1617,12 +1617,15 @@ void p3GRouter::handleIncomingReceiptItem(RsGRouterSignedReceiptItem *receipt_it
|
||||
|
||||
Sha1CheckSum p3GRouter::computeDataItemHash(RsGRouterGenericDataItem *data_item)
|
||||
{
|
||||
uint32_t total_size = data_item->signed_data_size() + data_item->signature.TlvSize() ;
|
||||
RsGRouterSerialiser signature_serializer(RsGenericSerializer::SERIALIZATION_FLAG_SIGNATURE | RsGenericSerializer::SERIALIZATION_FLAG_SKIP_HEADER);
|
||||
|
||||
uint32_t signed_data_size = signature_serializer.size(data_item);
|
||||
uint32_t total_size = signed_data_size + data_item->signature.TlvSize() ;
|
||||
RsTemporaryMemory mem(total_size) ;
|
||||
|
||||
uint32_t offset = 0 ;
|
||||
data_item->serialise_signed_data(mem,total_size) ;
|
||||
offset += data_item->signed_data_size() ;
|
||||
signature_serializer.serialise(data_item,mem,&total_size) ;
|
||||
offset += signed_data_size ;
|
||||
|
||||
data_item->signature.SetTlv(mem, total_size,&offset) ;
|
||||
|
||||
@ -1952,28 +1955,45 @@ bool p3GRouter::signDataItem(RsGRouterAbstractMsgItem *item,const RsGxsId& signi
|
||||
{
|
||||
try
|
||||
{
|
||||
#ifdef GROUTER_DEBUG
|
||||
//#ifdef GROUTER_DEBUG
|
||||
std::cerr << "p3GRouter::signDataItem()" << std::endl;
|
||||
std::cerr << " Key ID = " << signing_id << std::endl;
|
||||
std::cerr << " Getting key material..." << std::endl;
|
||||
#endif
|
||||
uint32_t data_size = item->signed_data_size() ;
|
||||
RsTemporaryMemory data(data_size) ;
|
||||
//#endif
|
||||
RsGRouterSerialiser signature_serializer(RsGenericSerializer::SERIALIZATION_FLAG_SIGNATURE | RsGenericSerializer::SERIALIZATION_FLAG_SKIP_HEADER) ;
|
||||
uint32_t data_size = signature_serializer.size(item) ;
|
||||
RsTemporaryMemory data(data_size) ;
|
||||
|
||||
if(data == NULL)
|
||||
throw std::runtime_error("Cannot allocate memory for signing data.") ;
|
||||
|
||||
if(!item->serialise_signed_data(data,data_size))
|
||||
if(!signature_serializer.serialise(item,data,&data_size))
|
||||
throw std::runtime_error("Cannot serialise signed data.") ;
|
||||
|
||||
uint32_t error_status ;
|
||||
uint32_t error_status ;
|
||||
|
||||
if(!mGixs->signData(data,data_size,signing_id,item->signature,error_status))
|
||||
throw std::runtime_error("Cannot sign for id " + signing_id.toStdString() + ". Signature call failed.") ;
|
||||
std::cerr << "GRouter::signing data" << std::endl;
|
||||
std::cerr << " size: " << data_size << std::endl;
|
||||
std::cerr << " data: " << RsUtil::BinToHex(data,data_size) << std::endl;
|
||||
|
||||
#ifdef GROUTER_DEBUG
|
||||
if(!mGixs->signData(data,data_size,signing_id,item->signature,error_status))
|
||||
throw std::runtime_error("Cannot sign for id " + signing_id.toStdString() + ". Signature call failed.") ;
|
||||
|
||||
//#ifdef GROUTER_DEBUG
|
||||
std::cerr << "Created signature for data hash: " << RsDirUtil::sha1sum(data,data_size) << " and key id=" << signing_id << std::endl;
|
||||
#endif
|
||||
//#endif
|
||||
// Check signature
|
||||
RsIdentityUsage::UsageCode info;
|
||||
uint32_t error;
|
||||
|
||||
if(verifySignedDataItem(item,info,error))
|
||||
std::cerr << "Signature checks." << std::endl;
|
||||
else
|
||||
{
|
||||
std::cerr << "(EE) Cannot verify own signed item. Something's wrong." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
catch(std::exception& e)
|
||||
@ -1993,15 +2013,16 @@ bool p3GRouter::verifySignedDataItem(RsGRouterAbstractMsgItem *item,const RsIden
|
||||
std::cerr << "(WW) received global router message from banned identity " << item->signature.keyId << ". Rejecting the message." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
RsGRouterSerialiser signature_serializer(RsGenericSerializer::SERIALIZATION_FLAG_SIGNATURE | RsGenericSerializer::SERIALIZATION_FLAG_SKIP_HEADER);
|
||||
|
||||
uint32_t data_size = item->signed_data_size() ;
|
||||
RsTemporaryMemory data(data_size) ;
|
||||
uint32_t data_size = signature_serializer.size(item) ;
|
||||
RsTemporaryMemory data(data_size) ;
|
||||
|
||||
if(data == NULL)
|
||||
throw std::runtime_error("Cannot allocate data.") ;
|
||||
if(data == NULL)
|
||||
throw std::runtime_error("Cannot allocate data.") ;
|
||||
|
||||
if(!item->serialise_signed_data(data,data_size))
|
||||
throw std::runtime_error("Cannot serialise signed data.") ;
|
||||
if(!signature_serializer.serialise(item,data,&data_size))
|
||||
throw std::runtime_error("Cannot serialise signed data.") ;
|
||||
|
||||
RsIdentityUsage use(RS_SERVICE_TYPE_GROUTER,info) ;
|
||||
|
||||
@ -2188,26 +2209,6 @@ Sha1CheckSum p3GRouter::makeTunnelHash(const RsGxsId& destination,const GRouterS
|
||||
|
||||
return RsDirUtil::sha1sum(bytes,20) ;
|
||||
}
|
||||
#ifdef TO_REMOVE
|
||||
bool p3GRouter::locked_getGxsOwnIdAndClientIdFromHash(const TurtleFileHash& sum,RsGxsId& gxs_id,GRouterServiceId& client_id)
|
||||
{
|
||||
assert( gxs_id.SIZE_IN_BYTES == 16) ;
|
||||
assert(Sha1CheckSum::SIZE_IN_BYTES == 20) ;
|
||||
|
||||
//gxs_id = RsGxsId(sum.toByteArray());// takes the first 16 bytes
|
||||
//client_id = sum.toByteArray()[19] + (sum.toByteArray()[18] << 8) ;
|
||||
|
||||
std::map<Sha1CheckSum, GRouterPublishedKeyInfo>::const_iterator it = _owned_key_ids.find(sum);
|
||||
|
||||
if(it == _owned_key_ids.end())
|
||||
return false ;
|
||||
|
||||
gxs_id = it->second.authentication_key ;
|
||||
client_id = it->second.service_id ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
#endif
|
||||
bool p3GRouter::loadList(std::list<RsItem*>& items)
|
||||
{
|
||||
{
|
||||
|
@ -459,8 +459,12 @@ bool GxsSecurity::validateNxsMsg(const RsNxsMsg& msg, const RsTlvKeySignature& s
|
||||
msgMeta.signSet.TlvClear();
|
||||
|
||||
RsGxsMessageId msgId = msgMeta.mMsgId, origMsgId = msgMeta.mOrigMsgId;
|
||||
msgMeta.mOrigMsgId.clear();
|
||||
|
||||
if(msgMeta.mOrigMsgId == msgMeta.mMsgId) // message is not versionned, then the signature was made with mOrigMsgId==NULL
|
||||
msgMeta.mOrigMsgId.clear();
|
||||
|
||||
msgMeta.mMsgId.clear();
|
||||
|
||||
int signOk = 0 ;
|
||||
|
||||
{
|
||||
|
@ -28,7 +28,8 @@
|
||||
*/
|
||||
|
||||
#include "serialiser/rstlvkeys.h"
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
|
||||
#include "rsitems/rsnxsitems.h"
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/evp.h>
|
||||
|
@ -32,8 +32,8 @@
|
||||
|
||||
#include "inttypes.h"
|
||||
|
||||
#include "serialiser/rsgxsitems.h"
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
#include "rsitems/rsgxsitems.h"
|
||||
#include "rsitems/rsnxsitems.h"
|
||||
#include "gxs/rsgxsdata.h"
|
||||
#include "rsgxs.h"
|
||||
#include "util/contentvalue.h"
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "retroshare/rsgrouter.h"
|
||||
#include "retroshare/rsidentity.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "rsitems/rsnxsitems.h"
|
||||
#include "rsgixs.h"
|
||||
#include "rsgxsutil.h"
|
||||
#include "rsserver/p3face.h"
|
||||
@ -1270,6 +1271,58 @@ bool RsGenExchange::getMsgRelatedMeta(const uint32_t &token, GxsMsgRelatedMetaMa
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getSerializedGroupData(const uint32_t &token, RsGxsGroupId& id,unsigned char *& data,uint32_t& size)
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
std::list<RsNxsGrp*> nxsGrps;
|
||||
|
||||
if(!mDataAccess->getGroupData(token, nxsGrps))
|
||||
return false ;
|
||||
|
||||
if(nxsGrps.size() != 1)
|
||||
{
|
||||
std::cerr << "(EE) getSerializedGroupData() got multiple groups in single request. This is unexpected." << std::endl;
|
||||
|
||||
for(std::list<RsNxsGrp*>::const_iterator it(nxsGrps.begin());it!=nxsGrps.end();++it)
|
||||
delete *it ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
RsNxsGrp *nxs_grp = *(nxsGrps.begin());
|
||||
|
||||
size = RsNxsSerialiser(mServType).size(nxs_grp);
|
||||
id = nxs_grp->metaData->mGroupId ;
|
||||
|
||||
if(size > 1024*1024 || NULL==(data = (unsigned char *)rs_malloc(size)))
|
||||
{
|
||||
std::cerr << "(EE) getSerializedGroupData() cannot allocate mem chunk of size " << size << ". Too big, or no room." << std::endl;
|
||||
delete nxs_grp ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return RsNxsSerialiser(mServType).serialise(nxs_grp,data,&size) ;
|
||||
}
|
||||
|
||||
bool RsGenExchange::deserializeGroupData(unsigned char *data,uint32_t size)
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
RsItem *item = RsNxsSerialiser(mServType).deserialise(data, &size);
|
||||
|
||||
RsNxsGrp *nxs_grp = dynamic_cast<RsNxsGrp*>(item) ;
|
||||
|
||||
if(item == NULL)
|
||||
{
|
||||
std::cerr << "(EE) RsGenExchange::deserializeGroupData(): cannot deserialise this data. Something's wrong." << std::endl;
|
||||
delete item ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
mReceivedGrps.push_back( GxsPendingItem<RsNxsGrp*, RsGxsGroupId>(nxs_grp, nxs_grp->grpId,time(NULL)) );
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem *>& grpItem)
|
||||
{
|
||||
@ -1320,7 +1373,8 @@ bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem
|
||||
}
|
||||
}
|
||||
else if(data.bin_len > 0)
|
||||
std::cerr << "(EE) RsGenExchange::getGroupData() Item type is probably not handled. Data is: " << RsUtil::BinToHex((unsigned char*)data.bin_data,std::min(50u,data.bin_len)) << ((data.bin_len>50)?"...":"") << std::endl;
|
||||
//std::cerr << "(EE) RsGenExchange::getGroupData() Item type is probably not handled. Data is: " << RsUtil::BinToHex((unsigned char*)data.bin_data,std::min(50u,data.bin_len)) << ((data.bin_len>50)?"...":"") << std::endl;
|
||||
std::cerr << "(EE) RsGenExchange::getGroupData() Item type is probably not handled. Data is: " << RsUtil::BinToHex((unsigned char*)data.bin_data,data.bin_len) << std::endl;
|
||||
|
||||
delete *lit;
|
||||
}
|
||||
@ -2135,7 +2189,9 @@ void RsGenExchange::publishMsgs()
|
||||
if(createOk && validSize)
|
||||
{
|
||||
// empty orig msg id means this is the original
|
||||
// msg
|
||||
// msg.
|
||||
// (csoler) Why are we doing this???
|
||||
|
||||
if(msg->metaData->mOrigMsgId.isNull())
|
||||
{
|
||||
msg->metaData->mOrigMsgId = msg->metaData->mMsgId;
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "rsgxsdataaccess.h"
|
||||
#include "rsnxsobserver.h"
|
||||
#include "retroshare/rsgxsservice.h"
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
#include "rsitems/rsnxsitems.h"
|
||||
#include "rsgxsutil.h"
|
||||
|
||||
template<class GxsItem, typename Identity = std::string>
|
||||
@ -288,6 +288,20 @@ protected:
|
||||
*/
|
||||
bool getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem*>& grpItem);
|
||||
|
||||
/*!
|
||||
* \brief getSerializedGroupData
|
||||
* Retrieves the complete group data serialized into a chunk of memory. This can be useful to
|
||||
* transfer a full group from one machine to another.
|
||||
*
|
||||
* \param token token previously obtained from cache request
|
||||
* \param data memory chunk allocated (using malloc)
|
||||
* \param size size of the memory chunk.
|
||||
* \return
|
||||
*/
|
||||
|
||||
bool getSerializedGroupData(const uint32_t &token, RsGxsGroupId &id, unsigned char *& data, uint32_t& size);
|
||||
bool deserializeGroupData(unsigned char *data, uint32_t size);
|
||||
|
||||
template<class GrpType>
|
||||
bool getGroupDataT(const uint32_t &token, std::vector<GrpType*>& grpItem)
|
||||
{
|
||||
|
@ -239,17 +239,21 @@ void RsGxsMsgMetaData::clear()
|
||||
mMsgId.clear();
|
||||
mThreadId.clear();
|
||||
mParentId.clear();
|
||||
mAuthorId.clear();
|
||||
mOrigMsgId.clear();
|
||||
mMsgName.clear();
|
||||
mServiceString.clear();
|
||||
mAuthorId.clear();
|
||||
|
||||
signSet.TlvClear();
|
||||
mMsgName.clear();
|
||||
mPublishTs = 0;
|
||||
mMsgFlags = 0;
|
||||
|
||||
mServiceString.clear();
|
||||
mMsgStatus = 0;
|
||||
mMsgSize = 0;
|
||||
mChildTs = 0;
|
||||
recvTS = 0;
|
||||
mHash.clear();
|
||||
validated = false;
|
||||
}
|
||||
|
||||
bool RsGxsMsgMetaData::serialise(void *data, uint32_t *size)
|
||||
|
@ -29,13 +29,12 @@
|
||||
#include <string>
|
||||
|
||||
#include <retroshare/rstypes.h>
|
||||
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rstlvkeys.h"
|
||||
#include "serialiser/rsgxsitems.h"
|
||||
|
||||
class RsGroupMetaData;
|
||||
class RsMsgMetaData;
|
||||
#include "rsitems/rsgxsitems.h"
|
||||
|
||||
struct RsGroupMetaData;
|
||||
struct RsMsgMetaData;
|
||||
|
||||
static const uint32_t RS_GXS_GRP_META_DATA_VERSION_ID_0001 = 0x0000 ; // change this, and keep old values if the content changes
|
||||
static const uint32_t RS_GXS_GRP_META_DATA_VERSION_ID_0002 = 0xaf01 ; // current API
|
||||
@ -56,22 +55,22 @@ public:
|
||||
void clear();
|
||||
void operator =(const RsGroupMetaData& rMeta);
|
||||
|
||||
//Sort data in same order than serialiser and deserializer
|
||||
//Sort data in same order than serialiser and deserializer
|
||||
RsGxsGroupId mGroupId;
|
||||
RsGxsGroupId mOrigGrpId;
|
||||
RsGxsGroupId mParentGrpId;
|
||||
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 mCircleType;
|
||||
uint32_t mAuthenFlags;
|
||||
uint32_t mCircleType;
|
||||
uint32_t mAuthenFlags;
|
||||
RsGxsId mAuthorId;
|
||||
std::string mServiceString;
|
||||
std::string mServiceString;
|
||||
RsGxsCircleId mCircleId;
|
||||
RsTlvKeySignatureSet signSet;
|
||||
RsTlvSecurityKeySet keys;
|
||||
|
||||
uint32_t mSignFlags;
|
||||
uint32_t mSignFlags;
|
||||
|
||||
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
|
||||
|
||||
@ -103,9 +102,9 @@ public:
|
||||
void clear();
|
||||
void operator =(const RsMsgMetaData& rMeta);
|
||||
|
||||
static int refcount;
|
||||
|
||||
//Sort data in same order than serialiser and deserializer
|
||||
static int refcount;
|
||||
|
||||
//Sort data in same order than serialiser and deserializer
|
||||
RsGxsGroupId mGroupId;
|
||||
RsGxsMessageId mMsgId;
|
||||
RsGxsMessageId mThreadId;
|
||||
@ -121,7 +120,7 @@ public:
|
||||
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
|
||||
// normally READ / UNREAD flags. LOCAL Data.
|
||||
|
||||
std::string mServiceString;
|
||||
std::string mServiceString;
|
||||
uint32_t mMsgStatus;
|
||||
uint32_t mMsgSize;
|
||||
time_t mChildTs;
|
||||
|
@ -75,6 +75,12 @@ bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const
|
||||
gir->mGroupIds = groupIds;
|
||||
req = gir;
|
||||
}
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_SERIALIZED_DATA)
|
||||
{
|
||||
GroupSerializedDataReq* gir = new GroupSerializedDataReq();
|
||||
gir->mGroupIds = groupIds;
|
||||
req = gir;
|
||||
}
|
||||
|
||||
if(req == NULL)
|
||||
{
|
||||
@ -103,34 +109,25 @@ bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const
|
||||
uint32_t reqType = opts.mReqType;
|
||||
|
||||
if(reqType & GXS_REQUEST_TYPE_GROUP_META)
|
||||
{
|
||||
GroupMetaReq* gmr = new GroupMetaReq();
|
||||
req = gmr;
|
||||
}
|
||||
req = new GroupMetaReq();
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_DATA)
|
||||
{
|
||||
GroupDataReq* gdr = new GroupDataReq();
|
||||
req = gdr;
|
||||
}
|
||||
req = new GroupDataReq();
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_IDS)
|
||||
{
|
||||
GroupIdReq* gir = new GroupIdReq();
|
||||
req = gir;
|
||||
}
|
||||
|
||||
if(req == NULL)
|
||||
req = new GroupIdReq();
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_SERIALIZED_DATA)
|
||||
req = new GroupSerializedDataReq();
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() request type not recognised, type "
|
||||
<< reqType << std::endl;
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
generateToken(token);
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() gets Token: " << token << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
generateToken(token);
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() gets Token: " << token << std::endl;
|
||||
#endif
|
||||
|
||||
setReq(req, token, ansType, opts);
|
||||
storeRequest(req);
|
||||
|
||||
@ -430,7 +427,16 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list<RsNxsGrp*>&
|
||||
else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
{
|
||||
GroupDataReq* gmreq = dynamic_cast<GroupDataReq*>(req);
|
||||
if(gmreq)
|
||||
GroupSerializedDataReq* gsreq = dynamic_cast<GroupSerializedDataReq*>(req);
|
||||
|
||||
if(gsreq)
|
||||
{
|
||||
grpData.swap(gsreq->mGroupData);
|
||||
gsreq->mGroupData.clear();
|
||||
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
else if(gmreq)
|
||||
{
|
||||
grpData.swap(gmreq->mGroupData);
|
||||
gmreq->mGroupData.clear();
|
||||
@ -804,6 +810,7 @@ void RsGxsDataAccess::processRequests()
|
||||
MsgIdReq* mir;
|
||||
MsgRelatedInfoReq* mri;
|
||||
GroupStatisticRequest* gsr;
|
||||
GroupSerializedDataReq* grr;
|
||||
ServiceStatisticRequest* ssr;
|
||||
|
||||
#ifdef DATA_DEBUG
|
||||
@ -851,6 +858,11 @@ void RsGxsDataAccess::processRequests()
|
||||
{
|
||||
ok = getServiceStatistic(ssr);
|
||||
}
|
||||
else if((grr = dynamic_cast<GroupSerializedDataReq*>(req)) != NULL)
|
||||
{
|
||||
ok = getGroupSerializedData(grr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::processRequests() Failed to process request, token: "
|
||||
@ -929,7 +941,30 @@ bool RsGxsDataAccess::getServiceStatistic(const uint32_t &token, GxsServiceStati
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RsGxsDataAccess::getGroupSerializedData(GroupSerializedDataReq* req)
|
||||
{
|
||||
std::map<RsGxsGroupId, RsNxsGrp*> grpData;
|
||||
std::list<RsGxsGroupId> grpIdsOut;
|
||||
|
||||
getGroupList(req->mGroupIds, req->Options, grpIdsOut);
|
||||
|
||||
if(grpIdsOut.empty())
|
||||
return true;
|
||||
|
||||
|
||||
for(std::list<RsGxsGroupId>::iterator lit = grpIdsOut.begin();lit != grpIdsOut.end();++lit)
|
||||
grpData[*lit] = NULL;
|
||||
|
||||
bool ok = mDataStore->retrieveNxsGrps(grpData, true, true);
|
||||
req->mGroupData.clear();
|
||||
|
||||
std::map<RsGxsGroupId, RsNxsGrp*>::iterator mit = grpData.begin();
|
||||
|
||||
for(; mit != grpData.end(); ++mit)
|
||||
req->mGroupData.push_back(mit->second) ;
|
||||
|
||||
return ok;
|
||||
}
|
||||
bool RsGxsDataAccess::getGroupData(GroupDataReq* req)
|
||||
{
|
||||
std::map<RsGxsGroupId, RsNxsGrp*> grpData;
|
||||
|
@ -418,6 +418,13 @@ private:
|
||||
*/
|
||||
bool getGroupStatistic(GroupStatisticRequest* req);
|
||||
|
||||
/*!
|
||||
*
|
||||
* Attempts to retrieve group data in serialized format
|
||||
* @param req Request object to satisfy
|
||||
*/
|
||||
bool getGroupSerializedData(GroupSerializedDataReq* req);
|
||||
|
||||
/*!
|
||||
*
|
||||
* Attempts to service statistic
|
||||
|
@ -328,6 +328,23 @@ RsGxsNetService::RsGxsNetService(uint16_t servType, RsGeneralDataService *gds,
|
||||
mUpdateCounter = 0;
|
||||
}
|
||||
|
||||
void RsGxsNetService::getItemNames(std::map<uint8_t,std::string>& names) const
|
||||
{
|
||||
names.clear();
|
||||
|
||||
names[RS_PKT_SUBTYPE_NXS_SYNC_GRP_REQ_ITEM ] = "Group Sync Request" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_SYNC_GRP_ITEM ] = "Group Sync" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_SYNC_GRP_STATS_ITEM ] = "Group Stats" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_GRP_ITEM ] = "Group Data" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_ENCRYPTED_DATA_ITEM ] = "Encrypted data" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_SESSION_KEY_ITEM ] = "Session Key" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_SYNC_MSG_ITEM ] = "Message Sync" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_SYNC_MSG_REQ_ITEM ] = "Message Sync Request" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_MSG_ITEM ] = "Message Data" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_TRANSAC_ITEM ] = "Transaction" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_GRP_PUBLISH_KEY_ITEM ] = "Publish key" ;
|
||||
}
|
||||
|
||||
RsGxsNetService::~RsGxsNetService()
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
@ -1972,7 +1989,7 @@ void RsGxsNetService::updateServerSyncTS()
|
||||
#endif
|
||||
|
||||
// I keep the creation, but the data is not used yet.
|
||||
#warning disabled this, but do we need it?
|
||||
#warning csoler 2016-12-12: Disabled this, but do we need it?
|
||||
// RsGxsServerMsgUpdate& msui(mServerMsgUpdateMap[grpId]) ;
|
||||
|
||||
// (cyril) I'm removing this, because the msgUpdateTS is updated when new messages are received by calling locked_stampMsgServerUpdateTS().
|
||||
@ -3000,7 +3017,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
||||
}
|
||||
// FIXTESTS global variable rsReputations not available in unittests!
|
||||
|
||||
#warning Update the code below to correctly send/recv dependign on reputation
|
||||
#warning csoler 2016-12-23: Update the code below to correctly send/recv dependign on reputation
|
||||
if(!grpSyncItem->authorId.isNull() && mReputations->overallReputationLevel(grpSyncItem->authorId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
@ -3500,10 +3517,10 @@ bool RsGxsNetService::encryptSingleNxsItem(RsNxsItem *item, const RsGxsCircleId&
|
||||
#ifdef NXS_NET_DEBUG_7
|
||||
GXSNETDEBUG_P_ (item->PeerId()) << " Encrypting..." << std::endl;
|
||||
#endif
|
||||
uint32_t size = item->serial_size() ;
|
||||
uint32_t size = RsNxsSerialiser(mServType).size(item) ;
|
||||
RsTemporaryMemory tempmem( size ) ;
|
||||
|
||||
if(!item->serialise(tempmem,size))
|
||||
if(!RsNxsSerialiser(mServType).serialise(item,tempmem,&size))
|
||||
{
|
||||
std::cerr << " (EE) Cannot serialise item. Something went wrong." << std::endl;
|
||||
status = RS_NXS_ITEM_ENCRYPTION_STATUS_SERIALISATION_ERROR ;
|
||||
@ -3530,7 +3547,7 @@ bool RsGxsNetService::encryptSingleNxsItem(RsNxsItem *item, const RsGxsCircleId&
|
||||
enc_item->transactionNumber = item->transactionNumber ;
|
||||
enc_item->PeerId(item->PeerId()) ;
|
||||
|
||||
encrypted_item = enc_item ;
|
||||
encrypted_item = enc_item ;
|
||||
#ifdef NXS_NET_DEBUG_7
|
||||
GXSNETDEBUG_P_(item->PeerId()) << " encrypted item of size " << encrypted_len << std::endl;
|
||||
#endif
|
||||
|
@ -33,8 +33,8 @@
|
||||
#include "rsgds.h"
|
||||
#include "rsnxsobserver.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
#include "serialiser/rsgxsupdateitems.h"
|
||||
#include "rsitems/rsnxsitems.h"
|
||||
#include "rsitems/rsgxsupdateitems.h"
|
||||
#include "rsgxsnetutils.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "rsgixs.h"
|
||||
@ -99,6 +99,7 @@ public:
|
||||
|
||||
virtual RsServiceInfo getServiceInfo() { return mServiceInfo; }
|
||||
|
||||
virtual void getItemNames(std::map<uint8_t,std::string>& names) const ;
|
||||
public:
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ bool AuthorPending::getAuthorRep(GixsReputation& rep, const RsGxsId& authorId, c
|
||||
rep.id = authorId ;
|
||||
rep.reputation_level = mRep->overallReputationLevel(authorId);
|
||||
|
||||
#warning can it happen that reputations do not have the info yet?
|
||||
#warning csoler 2017-01-10: Can it happen that reputations do not have the info yet?
|
||||
return true ;
|
||||
#ifdef TO_BE_REMOVED
|
||||
{
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "retroshare/rsgxsifacetypes.h"
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
#include "rsitems/rsnxsitems.h"
|
||||
#include "rsgixs.h"
|
||||
|
||||
class p3ServiceControl;
|
||||
|
@ -61,6 +61,12 @@ public:
|
||||
std::list<RsGxsGroupId> mGroupIds;
|
||||
std::list<RsGxsGroupId> mGroupIdResult;
|
||||
};
|
||||
class GroupSerializedDataReq : public GxsRequest
|
||||
{
|
||||
public:
|
||||
std::list<RsGxsGroupId> mGroupIds;
|
||||
std::list<RsNxsGrp*> mGroupData;
|
||||
};
|
||||
|
||||
class GroupDataReq : public GxsRequest
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
||||
#define GXSUTIL_H_
|
||||
|
||||
#include <vector>
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
#include "rsitems/rsnxsitems.h"
|
||||
#include "rsgds.h"
|
||||
|
||||
class RsGixs ;
|
||||
|
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <set>
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
#include "rsitems/rsnxsitems.h"
|
||||
|
||||
|
||||
class RsNxsObserver
|
||||
|
@ -1186,7 +1186,9 @@ bool p3GxsTunnelService::locked_sendClearTunnelData(RsGxsTunnelDHPublicKeyItem *
|
||||
//
|
||||
RsTurtleGenericDataItem *gitem = new RsTurtleGenericDataItem ;
|
||||
|
||||
uint32_t rssize = item->serial_size() ;
|
||||
RsGxsTunnelSerialiser ser ;
|
||||
|
||||
uint32_t rssize = ser.size(item);
|
||||
|
||||
gitem->data_size = rssize + 8 ;
|
||||
gitem->data_bytes = rs_malloc(rssize+8) ;
|
||||
@ -1194,12 +1196,12 @@ bool p3GxsTunnelService::locked_sendClearTunnelData(RsGxsTunnelDHPublicKeyItem *
|
||||
if(gitem->data_bytes == NULL)
|
||||
{
|
||||
delete gitem ;
|
||||
return NULL ;
|
||||
return false ;
|
||||
}
|
||||
// by convention, we use a IV of 0 for unencrypted data.
|
||||
memset(gitem->data_bytes,0,8) ;
|
||||
|
||||
if(!item->serialise(&((uint8_t*)gitem->data_bytes)[8],rssize))
|
||||
if(!ser.serialise(item,&((uint8_t*)gitem->data_bytes)[8],&rssize))
|
||||
{
|
||||
std::cerr << "(EE) Could not serialise item!!!" << std::endl;
|
||||
delete gitem ;
|
||||
@ -1221,10 +1223,12 @@ bool p3GxsTunnelService::locked_sendClearTunnelData(RsGxsTunnelDHPublicKeyItem *
|
||||
|
||||
bool p3GxsTunnelService::locked_sendEncryptedTunnelData(RsGxsTunnelItem *item)
|
||||
{
|
||||
uint32_t rssize = item->serial_size();
|
||||
RsGxsTunnelSerialiser ser;
|
||||
|
||||
uint32_t rssize = ser.size(item);
|
||||
RsTemporaryMemory buff(rssize) ;
|
||||
|
||||
if(!item->serialise(buff,rssize))
|
||||
if(!ser.serialise(item,buff,&rssize))
|
||||
{
|
||||
std::cerr << "(EE) GxsTunnelService::sendEncryptedTunnelData(): Could not serialise item!" << std::endl;
|
||||
return false;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <time.h>
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rstypeserializer.h"
|
||||
#include "util/rsprint.h"
|
||||
#include "util/rsmemory.h"
|
||||
|
||||
@ -35,459 +36,89 @@
|
||||
|
||||
//#define GXS_TUNNEL_ITEM_DEBUG 1
|
||||
|
||||
std::ostream& RsGxsTunnelDHPublicKeyItem::print(std::ostream &out, uint16_t indent)
|
||||
RsItem *RsGxsTunnelSerialiser::create_item(uint16_t service,uint8_t item_subtype) const
|
||||
{
|
||||
printRsItemBase(out, "RsGxsTunnelDHPublicKeyItem", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
if(service != RS_SERVICE_TYPE_GXS_TUNNEL)
|
||||
return NULL ;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << " Signature Key ID: " << signature.keyId << std::endl ;
|
||||
out << " Public Key ID: " << gxs_key.keyId << std::endl ;
|
||||
|
||||
printRsItemEnd(out, "RsGxsTunnelMsgItem", indent);
|
||||
return out;
|
||||
switch(item_subtype)
|
||||
{
|
||||
case RS_PKT_SUBTYPE_GXS_TUNNEL_DATA: return new RsGxsTunnelDataItem();
|
||||
case RS_PKT_SUBTYPE_GXS_TUNNEL_DATA_ACK: return new RsGxsTunnelDataAckItem();
|
||||
case RS_PKT_SUBTYPE_GXS_TUNNEL_DH_PUBLIC_KEY: return new RsGxsTunnelDHPublicKeyItem();
|
||||
case RS_PKT_SUBTYPE_GXS_TUNNEL_STATUS: return new RsGxsTunnelStatusItem();
|
||||
default:
|
||||
return NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& RsGxsTunnelDataItem::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsGxsTunnelDataItem", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << " message id : " << std::hex << unique_item_counter << std::dec << std::endl ;
|
||||
out << " service id : " << std::hex << service_id << std::dec << std::endl ;
|
||||
out << " flags : " << std::hex << flags << std::dec << std::endl ;
|
||||
out << " size : " << data_size << std::endl ;
|
||||
out << " data : " << RsUtil::BinToHex(data,std::min(50u,data_size)) << ((data_size>50u)?"...":"") << std::endl ;
|
||||
|
||||
printRsItemEnd(out, "RsGxsTunnelDataItem", indent);
|
||||
return out;
|
||||
}
|
||||
std::ostream& RsGxsTunnelDataAckItem::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsGxsTunnelDataItem", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << " message id : " << std::hex << unique_item_counter << std::dec << std::endl ;
|
||||
|
||||
printRsItemEnd(out, "RsGxsTunnelDataAckItem", indent);
|
||||
return out;
|
||||
}
|
||||
std::ostream& RsGxsTunnelStatusItem::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsGxsTunnelDataItem", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << " flags : " << std::hex << status << std::dec << std::endl ;
|
||||
|
||||
printRsItemEnd(out, "RsGxsTunnelStatusItem", indent);
|
||||
return out;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
RsGxsTunnelDHPublicKeyItem::~RsGxsTunnelDHPublicKeyItem()
|
||||
{
|
||||
BN_free(public_key) ;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
RsItem *RsGxsTunnelSerialiser::deserialise(void *data, uint32_t *pktsize)
|
||||
void RsGxsTunnelDHPublicKeyItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
|
||||
#ifdef GXS_TUNNEL_ITEM_DEBUG
|
||||
std::cerr << "deserializing packet..."<< std::endl ;
|
||||
#endif
|
||||
// look what we have...
|
||||
if (*pktsize < rssize) /* check size */
|
||||
{
|
||||
std::cerr << "GxsTunnel deserialisation: not enough size: pktsize=" << *pktsize << ", rssize=" << rssize << std::endl ;
|
||||
return NULL; /* not enough data */
|
||||
}
|
||||
|
||||
/* set the packet length */
|
||||
*pktsize = rssize;
|
||||
|
||||
/* ready to load */
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || (RS_SERVICE_TYPE_GXS_TUNNEL != getRsItemService(rstype)))
|
||||
{
|
||||
#ifdef GXS_TUNNEL_ITEM_DEBUG
|
||||
std::cerr << "GxsTunnel deserialisation: wrong type !" << std::endl ;
|
||||
#endif
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
switch(getRsItemSubType(rstype))
|
||||
{
|
||||
case RS_PKT_SUBTYPE_GXS_TUNNEL_DH_PUBLIC_KEY: return deserialise_RsGxsTunnelDHPublicKeyItem(data,*pktsize) ;
|
||||
case RS_PKT_SUBTYPE_GXS_TUNNEL_DATA: return deserialise_RsGxsTunnelDataItem (data,*pktsize) ;
|
||||
case RS_PKT_SUBTYPE_GXS_TUNNEL_DATA_ACK: return deserialise_RsGxsTunnelDataAckItem (data,*pktsize) ;
|
||||
case RS_PKT_SUBTYPE_GXS_TUNNEL_STATUS: return deserialise_RsGxsTunnelStatusItem (data,*pktsize) ;
|
||||
default:
|
||||
std::cerr << "Unknown packet type in chat!" << std::endl ;
|
||||
return NULL ;
|
||||
}
|
||||
RsTypeSerializer::serial_process (j,ctx,public_key,"public_key") ;
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,signature,"signature") ;
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,gxs_key,"gxs_key") ;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
uint32_t RsGxsTunnelDHPublicKeyItem::serial_size()
|
||||
template<> bool RsTypeSerializer::serialize(uint8_t data[], uint32_t size, uint32_t &offset, BIGNUM * const & member)
|
||||
{
|
||||
uint32_t s = 8 ; // header
|
||||
s += 4 ; // BN size
|
||||
s += BN_num_bytes(public_key) ; // public_key
|
||||
s += signature.TlvSize() ; // signature
|
||||
s += gxs_key.TlvSize() ; // gxs_key
|
||||
uint32_t s = BN_num_bytes(member) ;
|
||||
|
||||
return s ;
|
||||
}
|
||||
if(size < offset + 4 + s)
|
||||
return false ;
|
||||
|
||||
uint32_t RsGxsTunnelDataItem::serial_size()
|
||||
{
|
||||
uint32_t s = 8 ; // header
|
||||
s += 8 ; // counter
|
||||
s += 4 ; // flags
|
||||
s += 4 ; // service id
|
||||
s += 4 ; // data_size
|
||||
s += data_size; // data
|
||||
bool ok = true ;
|
||||
ok &= setRawUInt32(data, size, &offset, s);
|
||||
|
||||
return s ;
|
||||
}
|
||||
|
||||
uint32_t RsGxsTunnelDataAckItem::serial_size()
|
||||
{
|
||||
uint32_t s = 8 ; // header
|
||||
s += 8 ; // counter
|
||||
|
||||
return s ;
|
||||
}
|
||||
|
||||
uint32_t RsGxsTunnelStatusItem::serial_size()
|
||||
{
|
||||
uint32_t s = 8 ; // header
|
||||
s += 4 ; // flags
|
||||
|
||||
return s ;
|
||||
}
|
||||
/*************************************************************************/
|
||||
|
||||
bool RsGxsTunnelDHPublicKeyItem::serialise(void *data,uint32_t& pktsize)
|
||||
{
|
||||
uint32_t tlvsize = serial_size() ;
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
uint32_t s = BN_num_bytes(public_key) ;
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, s);
|
||||
|
||||
BN_bn2bin(public_key,&((unsigned char *)data)[offset]) ;
|
||||
BN_bn2bin(member,&((unsigned char *)data)[offset]) ;
|
||||
offset += s ;
|
||||
|
||||
ok &= signature.SetTlv(data, tlvsize, &offset);
|
||||
ok &= gxs_key.SetTlv(data, tlvsize, &offset);
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
std::cerr << "RsGxsTunnelDHPublicKeyItem::serialiseItem() Size Error! offset=" << offset << ", tlvsize=" << tlvsize << std::endl;
|
||||
}
|
||||
return ok ;
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool RsGxsTunnelStatusItem::serialise(void *data, uint32_t& pktsize)
|
||||
template<> bool RsTypeSerializer::deserialize(const uint8_t data[], uint32_t size, uint32_t &offset, BIGNUM *& member)
|
||||
{
|
||||
uint32_t tlvsize = serial_size() ;
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, PacketId(), tlvsize);
|
||||
|
||||
#ifdef GXS_TUNNEL_ITEM_DEBUG
|
||||
std::cerr << "RsGxsTunnelSerialiser serialising chat status item." << std::endl;
|
||||
std::cerr << "RsGxsTunnelSerialiser::serialiseItem() Header: " << ok << std::endl;
|
||||
std::cerr << "RsGxsTunnelSerialiser::serialiseItem() Size: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, status);
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
std::cerr << "RsGxsTunnelSerialiser::serialiseItem() Size Error! " << std::endl;
|
||||
}
|
||||
#ifdef GXS_TUNNEL_ITEM_DEBUG
|
||||
std::cerr << "computed size: " << 256*((unsigned char*)data)[6]+((unsigned char*)data)[7] << std::endl ;
|
||||
#endif
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool RsGxsTunnelDataItem::serialise(void *dt, uint32_t& pktsize)
|
||||
{
|
||||
uint32_t tlvsize = serial_size() ;
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(dt, tlvsize, PacketId(), tlvsize);
|
||||
|
||||
#ifdef GXS_TUNNEL_ITEM_DEBUG
|
||||
std::cerr << "RsGxsTunnelSerialiser serialising chat status item." << std::endl;
|
||||
std::cerr << "RsGxsTunnelSerialiser::serialiseItem() Header: " << ok << std::endl;
|
||||
std::cerr << "RsGxsTunnelSerialiser::serialiseItem() Size: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt64(dt, tlvsize, &offset, unique_item_counter);
|
||||
ok &= setRawUInt32(dt, tlvsize, &offset, flags);
|
||||
ok &= setRawUInt32(dt, tlvsize, &offset, service_id);
|
||||
ok &= setRawUInt32(dt, tlvsize, &offset, data_size);
|
||||
|
||||
if(offset + data_size <= tlvsize)
|
||||
{
|
||||
memcpy(&((uint8_t*)dt)[offset],data,data_size) ;
|
||||
offset += data_size ;
|
||||
}
|
||||
else
|
||||
ok = false ;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
std::cerr << "RsGxsTunnelSerialiser::serialiseItem() Size Error! " << std::endl;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
bool RsGxsTunnelDataAckItem::serialise(void *data, uint32_t& pktsize)
|
||||
{
|
||||
uint32_t tlvsize = serial_size() ;
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, PacketId(), tlvsize);
|
||||
|
||||
#ifdef GXS_TUNNEL_ITEM_DEBUG
|
||||
std::cerr << "RsGxsTunnelSerialiser serialising chat status item." << std::endl;
|
||||
std::cerr << "RsGxsTunnelSerialiser::serialiseItem() Header: " << ok << std::endl;
|
||||
std::cerr << "RsGxsTunnelSerialiser::serialiseItem() Size: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt64(data, tlvsize, &offset, unique_item_counter);
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
std::cerr << "RsGxsTunnelSerialiser::serialiseItem() Size Error! " << std::endl;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
RsGxsTunnelDHPublicKeyItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelDHPublicKeyItem(void *data,uint32_t /*size*/)
|
||||
{
|
||||
uint32_t offset = 8; // skip the header
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
uint32_t s=0 ;
|
||||
bool ok = true ;
|
||||
ok &= getRawUInt32(data, size, &offset, &s);
|
||||
|
||||
RsGxsTunnelDHPublicKeyItem *item = new RsGxsTunnelDHPublicKeyItem() ;
|
||||
if(s > size || size - s < offset)
|
||||
return false ;
|
||||
|
||||
uint32_t s=0 ;
|
||||
/* get mandatory parts first */
|
||||
ok &= getRawUInt32(data, rssize, &offset, &s);
|
||||
|
||||
if(s > rssize || rssize - s < offset)
|
||||
{
|
||||
std::cerr << "RsGxsTunnelDHPublicKeyItem::() Size error while deserializing." << std::endl ;
|
||||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
item->public_key = BN_bin2bn(&((unsigned char *)data)[offset],s,NULL) ;
|
||||
member = BN_bin2bn(&((unsigned char *)data)[offset],s,NULL) ;
|
||||
offset += s ;
|
||||
|
||||
ok &= item->signature.GetTlv(data, rssize, &offset) ;
|
||||
ok &= item->gxs_key.GetTlv(data, rssize, &offset) ;
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
std::cerr << "RsGxsTunnelDHPublicKeyItem::() Size error while deserializing." << std::endl ;
|
||||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
if (!ok)
|
||||
{
|
||||
std::cerr << "RsGxsTunnelDHPublicKeyItem::() Unknown error while deserializing." << std::endl ;
|
||||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
return item ;
|
||||
return ok;
|
||||
}
|
||||
|
||||
RsGxsTunnelDataItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelDataItem(void *dat,uint32_t size)
|
||||
template<> uint32_t RsTypeSerializer::serial_size(BIGNUM * const & member)
|
||||
{
|
||||
uint32_t offset = 8; // skip the header
|
||||
uint32_t rssize = getRsItemSize(dat);
|
||||
bool ok = true ;
|
||||
|
||||
if(rssize > size)
|
||||
{
|
||||
std::cerr << "RsGxsTunnelDataItem::() Size error while deserializing." << std::endl ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
RsGxsTunnelDataItem *item = new RsGxsTunnelDataItem();
|
||||
|
||||
/* get mandatory parts first */
|
||||
|
||||
ok &= getRawUInt64(dat, rssize, &offset, &item->unique_item_counter);
|
||||
ok &= getRawUInt32(dat, rssize, &offset, &item->flags);
|
||||
ok &= getRawUInt32(dat, rssize, &offset, &item->service_id);
|
||||
ok &= getRawUInt32(dat, rssize, &offset, &item->data_size);
|
||||
|
||||
if(item->data_size > rssize || rssize < offset + item->data_size)
|
||||
{
|
||||
std::cerr << "RsGxsTunnelDataItem::() Size error while deserializing." << std::endl ;
|
||||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
item->data = (unsigned char*)rs_malloc(item->data_size) ;
|
||||
|
||||
if(item->data == NULL)
|
||||
{
|
||||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
memcpy(item->data,&((uint8_t*)dat)[offset],item->data_size) ;
|
||||
offset += item->data_size ;
|
||||
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
std::cerr << "RsGxsTunnelDHPublicKeyItem::() Size error while deserializing." << std::endl ;
|
||||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
if (!ok)
|
||||
{
|
||||
std::cerr << "RsGxsTunnelDHPublicKeyItem::() Unknown error while deserializing." << std::endl ;
|
||||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
return item ;
|
||||
return 4 + BN_num_bytes(member) ;
|
||||
}
|
||||
|
||||
RsGxsTunnelDataAckItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelDataAckItem(void *dat,uint32_t /* size */)
|
||||
template<> void RsTypeSerializer::print_data(const std::string& name,BIGNUM * const & /* member */)
|
||||
{
|
||||
uint32_t offset = 8; // skip the header
|
||||
uint32_t rssize = getRsItemSize(dat);
|
||||
bool ok = true ;
|
||||
|
||||
RsGxsTunnelDataAckItem *item = new RsGxsTunnelDataAckItem();
|
||||
|
||||
/* get mandatory parts first */
|
||||
|
||||
ok &= getRawUInt64(dat, rssize, &offset, &item->unique_item_counter);
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
std::cerr << "RsGxsTunnelDHPublicKeyItem::() Size error while deserializing." << std::endl ;
|
||||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
if (!ok)
|
||||
{
|
||||
std::cerr << "RsGxsTunnelDHPublicKeyItem::() Unknown error while deserializing." << std::endl ;
|
||||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
return item ;
|
||||
std::cerr << "[BIGNUM] : " << name << std::endl;
|
||||
}
|
||||
|
||||
RsGxsTunnelStatusItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelStatusItem(void *dat, uint32_t size)
|
||||
void RsGxsTunnelStatusItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
uint32_t offset = 8; // skip the header
|
||||
uint32_t rssize = getRsItemSize(dat);
|
||||
bool ok = true ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,status,"status") ;
|
||||
}
|
||||
|
||||
if(rssize > size)
|
||||
{
|
||||
std::cerr << "RsGxsTunnelStatusItem::() Size error while deserializing." << std::endl ;
|
||||
return NULL ;
|
||||
}
|
||||
void RsGxsTunnelDataItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process<uint64_t>(j,ctx,unique_item_counter,"unique_item_counter") ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,flags ,"flags") ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,service_id ,"service_id") ;
|
||||
|
||||
RsGxsTunnelStatusItem *item = new RsGxsTunnelStatusItem();
|
||||
|
||||
/* get mandatory parts first */
|
||||
|
||||
ok &= getRawUInt32(dat, rssize, &offset, &item->status);
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
std::cerr << "RsGxsTunnelStatusItem::() Size error while deserializing." << std::endl ;
|
||||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
if (!ok)
|
||||
{
|
||||
std::cerr << "RsGxsTunnelStatusItem::() Unknown error while deserializing." << std::endl ;
|
||||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
return item ;
|
||||
RsTypeSerializer::TlvMemBlock_proxy mem(data,data_size) ;
|
||||
RsTypeSerializer::serial_process(j,ctx,mem,"data") ;
|
||||
}
|
||||
void RsGxsTunnelDataAckItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process<uint64_t>(j,ctx,unique_item_counter,"unique_item_counter") ;
|
||||
}
|
||||
|
||||
|
||||
@ -505,3 +136,4 @@ RsGxsTunnelStatusItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelStatusItem(
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -27,9 +27,12 @@
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#include "rsitems/rsserviceids.h"
|
||||
#include "rsitems/itempriorities.h"
|
||||
#include "rsitems/rsitem.h"
|
||||
|
||||
#include "retroshare/rstypes.h"
|
||||
#include "serialiser/rstlvkeys.h"
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
|
||||
#include "serialiser/rstlvidset.h"
|
||||
@ -57,10 +60,6 @@ class RsGxsTunnelItem: public RsItem
|
||||
|
||||
virtual ~RsGxsTunnelItem() {}
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) = 0 ;
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) = 0 ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() = 0 ; // deserialise is handled using a constructor
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -78,10 +77,8 @@ public:
|
||||
|
||||
virtual ~RsGxsTunnelDataItem() {}
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
uint64_t unique_item_counter; // this allows to make the item unique
|
||||
uint32_t flags; // mainly NEEDS_HACK?
|
||||
@ -100,10 +97,8 @@ class RsGxsTunnelStatusItem: public RsGxsTunnelItem
|
||||
RsGxsTunnelStatusItem(void *data,uint32_t size) ; // deserialization
|
||||
|
||||
virtual ~RsGxsTunnelStatusItem() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
uint32_t status ;
|
||||
};
|
||||
@ -117,12 +112,10 @@ class RsGxsTunnelDataAckItem: public RsGxsTunnelItem
|
||||
RsGxsTunnelDataAckItem(void *data,uint32_t size) ; // deserialization
|
||||
|
||||
virtual ~RsGxsTunnelDataAckItem() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
uint64_t unique_item_counter ; // unique identifier for that item
|
||||
uint64_t unique_item_counter ; // unique identifier for that item
|
||||
};
|
||||
|
||||
|
||||
@ -136,10 +129,8 @@ class RsGxsTunnelDHPublicKeyItem: public RsGxsTunnelItem
|
||||
RsGxsTunnelDHPublicKeyItem(void *data,uint32_t size) ; // deserialization
|
||||
|
||||
virtual ~RsGxsTunnelDHPublicKeyItem() ;
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
// Private data to DH public key item
|
||||
//
|
||||
@ -154,24 +145,11 @@ class RsGxsTunnelDHPublicKeyItem: public RsGxsTunnelItem
|
||||
const RsGxsTunnelDHPublicKeyItem& operator=(const RsGxsTunnelDHPublicKeyItem&) { return *this ;}
|
||||
};
|
||||
|
||||
class RsGxsTunnelSerialiser: public RsSerialType
|
||||
class RsGxsTunnelSerialiser: public RsServiceSerializer
|
||||
{
|
||||
public:
|
||||
RsGxsTunnelSerialiser() :RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_GXS_TUNNEL) {}
|
||||
RsGxsTunnelSerialiser() :RsServiceSerializer(RS_SERVICE_TYPE_GXS_TUNNEL) {}
|
||||
|
||||
virtual uint32_t size (RsItem *item)
|
||||
{
|
||||
return static_cast<RsGxsTunnelItem *>(item)->serial_size() ;
|
||||
}
|
||||
virtual bool serialise(RsItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
return static_cast<RsGxsTunnelItem *>(item)->serialise(data,*size) ;
|
||||
}
|
||||
RsItem *deserialise(void *data, uint32_t *pktsize);
|
||||
private:
|
||||
static RsGxsTunnelDataAckItem *deserialise_RsGxsTunnelDataAckItem (void *data, uint32_t size) ;
|
||||
static RsGxsTunnelDataItem *deserialise_RsGxsTunnelDataItem (void *data, uint32_t size) ;
|
||||
static RsGxsTunnelStatusItem *deserialise_RsGxsTunnelStatusItem (void *data, uint32_t size) ;
|
||||
static RsGxsTunnelDHPublicKeyItem *deserialise_RsGxsTunnelDHPublicKeyItem(void *data, uint32_t size) ;
|
||||
virtual RsItem *create_item(uint16_t service,uint8_t item_subtype) const ;
|
||||
};
|
||||
|
||||
|
@ -61,14 +61,14 @@ file_lists {
|
||||
|
||||
dsdv {
|
||||
DEFINES *= SERVICES_DSDV
|
||||
HEADERS += services/p3dsdv.h \
|
||||
serialiser/rstlvdsdv.h \
|
||||
serialiser/rsdsdvitems.h \
|
||||
retroshare/rsdsdv.h
|
||||
HEADERS += unused/p3dsdv.h \
|
||||
unused/rstlvdsdv.h \
|
||||
unused/rsdsdvitems.h \
|
||||
unused/rsdsdv.h
|
||||
|
||||
SOURCES *= serialiser/rstlvdsdv.cc \
|
||||
serialiser/rsdsdvitems.cc \
|
||||
services/p3dsdv.cc
|
||||
SOURCES *= unused/rstlvdsdv.cc \
|
||||
unused/rsdsdvitems.cc \
|
||||
unused/p3dsdv.cc
|
||||
}
|
||||
bitdht {
|
||||
|
||||
@ -143,7 +143,7 @@ PUBLIC_HEADERS = retroshare/rsdisc.h \
|
||||
|
||||
HEADERS += plugins/pluginmanager.h \
|
||||
plugins/dlfcn_win32.h \
|
||||
serialiser/rspluginitems.h \
|
||||
rsitems/rspluginitems.h \
|
||||
util/rsinitedptr.h
|
||||
|
||||
HEADERS += $$PUBLIC_HEADERS
|
||||
@ -279,7 +279,12 @@ win32 {
|
||||
|
||||
CONFIG += upnp_miniupnpc
|
||||
|
||||
LIBS += -lsqlcipher
|
||||
no_sqlcipher {
|
||||
PKGCONFIG *= sqlite3
|
||||
LIBS += -lsqlite3
|
||||
} else {
|
||||
LIBS += -lsqlcipher
|
||||
}
|
||||
|
||||
DEPENDPATH += . $$INC_DIR
|
||||
INCLUDEPATH += . $$INC_DIR
|
||||
@ -452,17 +457,17 @@ HEADERS += grouter/groutercache.h \
|
||||
grouter/groutertypes.h \
|
||||
grouter/rsgrouterclient.h
|
||||
|
||||
HEADERS += serialiser/itempriorities.h \
|
||||
HEADERS += rsitems/rsitem.h \
|
||||
rsitems/itempriorities.h \
|
||||
serialiser/rsbaseserial.h \
|
||||
serialiser/rsfiletransferitems.h \
|
||||
serialiser/rsserviceserialiser.h \
|
||||
serialiser/rsconfigitems.h \
|
||||
serialiser/rshistoryitems.h \
|
||||
serialiser/rsmsgitems.h \
|
||||
rsitems/rsfiletransferitems.h \
|
||||
rsitems/rsconfigitems.h \
|
||||
rsitems/rshistoryitems.h \
|
||||
rsitems/rsmsgitems.h \
|
||||
serialiser/rsserial.h \
|
||||
serialiser/rsserviceids.h \
|
||||
rsitems/rsserviceids.h \
|
||||
serialiser/rsserviceitems.h \
|
||||
serialiser/rsstatusitems.h \
|
||||
rsitems/rsstatusitems.h \
|
||||
serialiser/rstlvaddrs.h \
|
||||
serialiser/rstlvbase.h \
|
||||
serialiser/rstlvitem.h \
|
||||
@ -479,14 +484,14 @@ HEADERS += serialiser/itempriorities.h \
|
||||
serialiser/rstlvlist.h \
|
||||
serialiser/rstlvmaps.h \
|
||||
serialiser/rstlvbanlist.h \
|
||||
serialiser/rsbanlistitems.h \
|
||||
serialiser/rsbwctrlitems.h \
|
||||
serialiser/rsdiscovery2items.h \
|
||||
serialiser/rsheartbeatitems.h \
|
||||
serialiser/rsrttitems.h \
|
||||
serialiser/rsgxsrecognitems.h \
|
||||
serialiser/rsgxsupdateitems.h \
|
||||
serialiser/rsserviceinfoitems.h \
|
||||
rsitems/rsbanlistitems.h \
|
||||
rsitems/rsbwctrlitems.h \
|
||||
rsitems/rsdiscovery2items.h \
|
||||
rsitems/rsheartbeatitems.h \
|
||||
rsitems/rsrttitems.h \
|
||||
rsitems/rsgxsrecognitems.h \
|
||||
rsitems/rsgxsupdateitems.h \
|
||||
rsitems/rsserviceinfoitems.h \
|
||||
|
||||
HEADERS += services/p3msgservice.h \
|
||||
services/p3service.h \
|
||||
@ -604,17 +609,14 @@ SOURCES += grouter/p3grouter.cc \
|
||||
grouter/groutermatrix.cc
|
||||
|
||||
SOURCES += plugins/pluginmanager.cc \
|
||||
plugins/dlfcn_win32.cc \
|
||||
serialiser/rspluginitems.cc
|
||||
plugins/dlfcn_win32.cc
|
||||
|
||||
SOURCES += serialiser/rsbaseserial.cc \
|
||||
serialiser/rsfiletransferitems.cc \
|
||||
serialiser/rsserviceserialiser.cc \
|
||||
serialiser/rsconfigitems.cc \
|
||||
serialiser/rshistoryitems.cc \
|
||||
serialiser/rsmsgitems.cc \
|
||||
rsitems/rsfiletransferitems.cc \
|
||||
rsitems/rsconfigitems.cc \
|
||||
rsitems/rshistoryitems.cc \
|
||||
rsitems/rsmsgitems.cc \
|
||||
serialiser/rsserial.cc \
|
||||
serialiser/rsstatusitems.cc \
|
||||
serialiser/rstlvaddrs.cc \
|
||||
serialiser/rstlvbase.cc \
|
||||
serialiser/rstlvitem.cc \
|
||||
@ -627,14 +629,13 @@ SOURCES += serialiser/rsbaseserial.cc \
|
||||
serialiser/rstlvkeyvalue.cc \
|
||||
serialiser/rstlvgenericparam.cc \
|
||||
serialiser/rstlvbanlist.cc \
|
||||
serialiser/rsbanlistitems.cc \
|
||||
serialiser/rsbwctrlitems.cc \
|
||||
serialiser/rsdiscovery2items.cc \
|
||||
serialiser/rsheartbeatitems.cc \
|
||||
serialiser/rsrttitems.cc \
|
||||
serialiser/rsgxsrecognitems.cc \
|
||||
serialiser/rsgxsupdateitems.cc \
|
||||
serialiser/rsserviceinfoitems.cc \
|
||||
rsitems/rsbanlistitems.cc \
|
||||
rsitems/rsbwctrlitems.cc \
|
||||
rsitems/rsdiscovery2items.cc \
|
||||
rsitems/rsrttitems.cc \
|
||||
rsitems/rsgxsrecognitems.cc \
|
||||
rsitems/rsgxsupdateitems.cc \
|
||||
rsitems/rsserviceinfoitems.cc \
|
||||
|
||||
SOURCES += services/p3msgservice.cc \
|
||||
services/p3service.cc \
|
||||
@ -721,7 +722,7 @@ SOURCES += zeroconf/p3zcnatassist.cc \
|
||||
DEFINES *= SQLITE_HAS_CODEC
|
||||
DEFINES *= GXS_ENABLE_SYNC_MSGS
|
||||
|
||||
HEADERS += serialiser/rsnxsitems.h \
|
||||
HEADERS += rsitems/rsnxsitems.h \
|
||||
gxs/rsgds.h \
|
||||
gxs/rsgxs.h \
|
||||
gxs/rsdataservice.h \
|
||||
@ -734,7 +735,7 @@ HEADERS += serialiser/rsnxsitems.h \
|
||||
retroshare/rstokenservice.h \
|
||||
gxs/rsgxsdataaccess.h \
|
||||
retroshare/rsgxsservice.h \
|
||||
serialiser/rsgxsitems.h \
|
||||
rsitems/rsgxsitems.h \
|
||||
util/retrodb.h \
|
||||
util/rsdbbind.h \
|
||||
gxs/rsgxsutil.h \
|
||||
@ -747,12 +748,12 @@ HEADERS += serialiser/rsnxsitems.h \
|
||||
gxs/rsgxsrequesttypes.h
|
||||
|
||||
|
||||
SOURCES += serialiser/rsnxsitems.cc \
|
||||
SOURCES += rsitems/rsnxsitems.cc \
|
||||
gxs/rsdataservice.cc \
|
||||
gxs/rsgenexchange.cc \
|
||||
gxs/rsgxsnetservice.cc \
|
||||
gxs/rsgxsdata.cc \
|
||||
serialiser/rsgxsitems.cc \
|
||||
rsitems/rsgxsitems.cc \
|
||||
gxs/rsgxsdataaccess.cc \
|
||||
util/retrodb.cc \
|
||||
util/contentvalue.cc \
|
||||
@ -771,85 +772,92 @@ HEADERS += gxstunnel/p3gxstunnel.h \
|
||||
SOURCES += gxstunnel/p3gxstunnel.cc \
|
||||
gxstunnel/rsgxstunnelitems.cc
|
||||
|
||||
# new serialization code
|
||||
HEADERS += serialiser/rsserializer.h \
|
||||
serialiser/rstypeserializer.h
|
||||
|
||||
SOURCES += serialiser/rsserializer.cc \
|
||||
serialiser/rstypeserializer.cc
|
||||
|
||||
# Identity Service
|
||||
HEADERS += retroshare/rsidentity.h \
|
||||
gxs/rsgixs.h \
|
||||
services/p3idservice.h \
|
||||
serialiser/rsgxsiditems.h \
|
||||
rsitems/rsgxsiditems.h \
|
||||
services/p3gxsreputation.h \
|
||||
serialiser/rsgxsreputationitems.h \
|
||||
rsitems/rsgxsreputationitems.h \
|
||||
|
||||
SOURCES += services/p3idservice.cc \
|
||||
serialiser/rsgxsiditems.cc \
|
||||
rsitems/rsgxsiditems.cc \
|
||||
services/p3gxsreputation.cc \
|
||||
serialiser/rsgxsreputationitems.cc \
|
||||
rsitems/rsgxsreputationitems.cc \
|
||||
|
||||
# GxsCircles Service
|
||||
HEADERS += services/p3gxscircles.h \
|
||||
serialiser/rsgxscircleitems.h \
|
||||
rsitems/rsgxscircleitems.h \
|
||||
retroshare/rsgxscircles.h \
|
||||
|
||||
SOURCES += services/p3gxscircles.cc \
|
||||
serialiser/rsgxscircleitems.cc \
|
||||
rsitems/rsgxscircleitems.cc \
|
||||
|
||||
# GxsForums Service
|
||||
HEADERS += retroshare/rsgxsforums.h \
|
||||
services/p3gxsforums.h \
|
||||
serialiser/rsgxsforumitems.h
|
||||
rsitems/rsgxsforumitems.h
|
||||
|
||||
SOURCES += services/p3gxsforums.cc \
|
||||
serialiser/rsgxsforumitems.cc \
|
||||
rsitems/rsgxsforumitems.cc \
|
||||
|
||||
# GxsChannels Service
|
||||
HEADERS += retroshare/rsgxschannels.h \
|
||||
services/p3gxschannels.h \
|
||||
services/p3gxscommon.h \
|
||||
serialiser/rsgxscommentitems.h \
|
||||
serialiser/rsgxschannelitems.h \
|
||||
rsitems/rsgxscommentitems.h \
|
||||
rsitems/rsgxschannelitems.h \
|
||||
|
||||
SOURCES += services/p3gxschannels.cc \
|
||||
services/p3gxscommon.cc \
|
||||
serialiser/rsgxscommentitems.cc \
|
||||
serialiser/rsgxschannelitems.cc \
|
||||
rsitems/rsgxscommentitems.cc \
|
||||
rsitems/rsgxschannelitems.cc \
|
||||
|
||||
wikipoos {
|
||||
# Wiki Service
|
||||
HEADERS += retroshare/rswiki.h \
|
||||
services/p3wiki.h \
|
||||
serialiser/rswikiitems.h
|
||||
rsitems/rswikiitems.h
|
||||
|
||||
SOURCES += services/p3wiki.cc \
|
||||
serialiser/rswikiitems.cc \
|
||||
rsitems/rswikiitems.cc \
|
||||
}
|
||||
|
||||
gxsthewire {
|
||||
# Wire Service
|
||||
HEADERS += retroshare/rswire.h \
|
||||
services/p3wire.h \
|
||||
serialiser/rswireitems.h
|
||||
rsitems/rswireitems.h
|
||||
|
||||
SOURCES += services/p3wire.cc \
|
||||
serialiser/rswireitems.cc \
|
||||
rsitems/rswireitems.cc \
|
||||
}
|
||||
|
||||
# Posted Service
|
||||
HEADERS += services/p3postbase.h \
|
||||
services/p3posted.h \
|
||||
retroshare/rsposted.h \
|
||||
serialiser/rsposteditems.h
|
||||
rsitems/rsposteditems.h
|
||||
|
||||
SOURCES += services/p3postbase.cc \
|
||||
services/p3posted.cc \
|
||||
serialiser/rsposteditems.cc
|
||||
rsitems/rsposteditems.cc
|
||||
|
||||
gxsphotoshare {
|
||||
#Photo Service
|
||||
HEADERS += services/p3photoservice.h \
|
||||
retroshare/rsphoto.h \
|
||||
serialiser/rsphotoitems.h \
|
||||
rsitems/rsphotoitems.h \
|
||||
|
||||
SOURCES += services/p3photoservice.cc \
|
||||
serialiser/rsphotoitems.cc \
|
||||
rsitems/rsphotoitems.cc \
|
||||
}
|
||||
|
||||
rs_gxs_trans {
|
||||
|
@ -9,8 +9,7 @@
|
||||
#include <serialiser/rstlvtypes.h>
|
||||
#endif
|
||||
|
||||
#include <serialiser/rspluginitems.h>
|
||||
|
||||
#include <rsitems/rspluginitems.h>
|
||||
|
||||
#include <rsserver/p3face.h>
|
||||
#include <util/rsdir.h>
|
||||
@ -34,7 +33,7 @@
|
||||
|
||||
std::string RsPluginManager::_plugin_entry_symbol = "RETROSHARE_PLUGIN_provide" ;
|
||||
std::string RsPluginManager::_plugin_revision_symbol = "RETROSHARE_PLUGIN_revision" ;
|
||||
std::string RsPluginManager::_plugin_API_symbol = "RETROSHARE_PLUGIN_api" ;
|
||||
std::string RsPluginManager::_plugin_API_symbol = "RETROSHARE_PLUGIN_api" ;
|
||||
|
||||
std::string RsPluginManager::_local_cache_dir ;
|
||||
std::string RsPluginManager::_remote_cache_dir ;
|
||||
@ -51,9 +50,14 @@ RsPluginManager::RsPluginManager(const RsFileHash &hash)
|
||||
_allow_all_plugins = false ;
|
||||
}
|
||||
|
||||
bool RsPluginManager::loadConfiguration(RsFileHash &loadHash)
|
||||
{
|
||||
return p3Config::loadConfiguration(loadHash);
|
||||
}
|
||||
|
||||
void RsPluginManager::loadConfiguration()
|
||||
{
|
||||
RsFileHash dummyHash ;
|
||||
RsFileHash dummyHash;
|
||||
p3Config::loadConfiguration(dummyHash);
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,7 @@ class RsPluginManager: public RsPluginHandler, public p3Config
|
||||
// -------------------- Own members -------------------------//
|
||||
//
|
||||
virtual void addConfigurations(p3ConfigMgr *cfgMgr) ;
|
||||
virtual bool loadConfiguration(RsFileHash &loadHash) ;
|
||||
virtual void loadConfiguration() ;
|
||||
|
||||
/*!
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
|
||||
#define LIMIT_CERTIFICATE_SIZE 1
|
||||
#define MAX_CERTIFICATE_SIZE 10000
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
#include "pqinetwork.h"
|
||||
#include "authgpg.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <util/rsdiscspace.h>
|
||||
#include "util/rsstring.h"
|
||||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
|
||||
/*
|
||||
#define CONFIG_DEBUG 1
|
||||
|
@ -92,7 +92,7 @@ dhtPeerEntry::dhtPeerEntry()
|
||||
return;
|
||||
}
|
||||
|
||||
p3DhtMgr::p3DhtMgr(std::string id, pqiConnectCb *cb)
|
||||
p3DhtMgr::p3DhtMgr(RsPeerId id, pqiConnectCb *cb)
|
||||
:pqiNetAssistConnect(id, cb), dhtMtx("p3DhtMgr"), mStunRequired(true)
|
||||
{
|
||||
/* setup own entry */
|
||||
@ -237,13 +237,13 @@ bool p3DhtMgr::setExternalInterface(
|
||||
|
||||
|
||||
/* add / remove peers */
|
||||
bool p3DhtMgr::findPeer(std::string id)
|
||||
bool p3DhtMgr::findPeer(const RsPeerId& id)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
|
||||
|
||||
mDhtModifications = true;
|
||||
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
it = peers.find(id);
|
||||
if (it != peers.end())
|
||||
{
|
||||
@ -281,14 +281,14 @@ bool p3DhtMgr::findPeer(std::string id)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3DhtMgr::dropPeer(std::string id)
|
||||
bool p3DhtMgr::dropPeer(const RsPeerId& id)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
|
||||
|
||||
mDhtModifications = true;
|
||||
|
||||
/* once we are connected ... don't worry about them anymore */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
it = peers.find(id);
|
||||
if (it == peers.end())
|
||||
{
|
||||
@ -302,14 +302,14 @@ bool p3DhtMgr::dropPeer(std::string id)
|
||||
}
|
||||
|
||||
/* post DHT key saying we should connect */
|
||||
bool p3DhtMgr::notifyPeer(std::string id)
|
||||
bool p3DhtMgr::notifyPeer(const RsPeerId& id)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::notifyPeer() " << id << std::endl;
|
||||
std::cerr << "p3DhtMgr::notifyPeer() " << id.toStdString() << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
it = peers.find(id);
|
||||
if (it == peers.end())
|
||||
{
|
||||
@ -333,7 +333,7 @@ bool p3DhtMgr::notifyPeer(std::string id)
|
||||
#ifdef DHT_LOGS
|
||||
{
|
||||
/* Log */
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id + " TO SOON - DROPPING");
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id.toStdString() + " TO SOON - DROPPING");
|
||||
|
||||
}
|
||||
#endif
|
||||
@ -352,7 +352,7 @@ bool p3DhtMgr::notifyPeer(std::string id)
|
||||
#ifdef DHT_LOGS
|
||||
{
|
||||
/* Log */
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id + " PEER NOT FOUND - Trigger Search");
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id.toStdString() + " PEER NOT FOUND - Trigger Search");
|
||||
}
|
||||
#endif
|
||||
it->second.lastTS = 0;
|
||||
@ -364,14 +364,14 @@ bool p3DhtMgr::notifyPeer(std::string id)
|
||||
}
|
||||
|
||||
/* extract current peer status */
|
||||
bool p3DhtMgr::getPeerStatus(std::string id,
|
||||
struct sockaddr_in &laddr,
|
||||
struct sockaddr_in &raddr,
|
||||
bool p3DhtMgr::getPeerStatus(const RsPeerId &id,
|
||||
struct sockaddr_in &laddr,
|
||||
struct sockaddr_in &raddr,
|
||||
uint32_t &type, uint32_t &state)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /* LOCK MUTEX */
|
||||
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
it = peers.find(id);
|
||||
|
||||
/* ignore OFF peers */
|
||||
@ -776,7 +776,7 @@ int p3DhtMgr::checkPeerDHTKeys()
|
||||
dhtMtx.lock(); /* LOCK MUTEX */
|
||||
|
||||
/* iterate through and find min time and suitable candidate */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it,pit;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it,pit;
|
||||
time_t now = time(NULL);
|
||||
uint32_t period = 0;
|
||||
uint32_t repeatPeriod = 6000;
|
||||
@ -802,7 +802,7 @@ int p3DhtMgr::checkPeerDHTKeys()
|
||||
period = DHT_CHECK_PERIOD;
|
||||
}
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::checkPeerDHTKeys() Peer: " << it->second.id;
|
||||
std::cerr << "p3DhtMgr::checkPeerDHTKeys() Peer: " << it->second.id.toStdString();
|
||||
std::cerr << " Period: " << period;
|
||||
std::cerr << " Delta: " << delta;
|
||||
std::cerr << std::endl;
|
||||
@ -865,7 +865,7 @@ int p3DhtMgr::checkNotifyDHT()
|
||||
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
|
||||
|
||||
/* iterate through and find min time and suitable candidate */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
time_t now = time(NULL);
|
||||
int repeatPeriod = DHT_DEFAULT_PERIOD;
|
||||
|
||||
@ -1015,7 +1015,7 @@ int p3DhtMgr::checkStunState()
|
||||
if (mDhtState == DHT_STATE_CHECK_PEERS)
|
||||
{
|
||||
/* check that they have all be searched for */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
for(it = peers.begin(); it != peers.end(); it++)
|
||||
{
|
||||
if (it->second.state == DHT_PEER_INIT)
|
||||
@ -1287,7 +1287,7 @@ int p3DhtMgr::status(std::ostream &out)
|
||||
out << "OWN DETAILS END----------------------------------------" << std::endl;
|
||||
|
||||
/* now peers states */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
out << "PEER DETAILS ------------------------------------------" << std::endl;
|
||||
for(it = peers.begin(); it != peers.end(); it++)
|
||||
{
|
||||
@ -1622,15 +1622,13 @@ bool p3DhtMgr::dhtResultNotify(std::string idhash)
|
||||
std::cerr << "p3DhtMgr::dhtResultNotify() from idhash: ";
|
||||
std::cerr << RsUtil::BinToHex(idhash) << std::endl;
|
||||
#endif
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
time_t now = time(NULL);
|
||||
|
||||
/* if notify - we must match on the second hash */
|
||||
for(it = peers.begin(); (it != peers.end()) && ((it->second).hash2 != idhash); it++) ;
|
||||
|
||||
/* update data */
|
||||
std::string peerid;
|
||||
|
||||
/* ignore OFF peers */
|
||||
if ((it != peers.end()) && (it->second.state != DHT_PEER_OFF))
|
||||
{
|
||||
@ -1677,7 +1675,7 @@ bool p3DhtMgr::dhtResultSearch(std::string idhash,
|
||||
std::cerr << "p3DhtMgr::dhtResultSearch() for idhash: ";
|
||||
std::cerr << RsUtil::BinToHex(idhash) << std::endl;
|
||||
#endif
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
bool doCb = false;
|
||||
bool doStun = false;
|
||||
uint32_t stunFlags = 0;
|
||||
@ -1780,7 +1778,7 @@ bool p3DhtMgr::dhtResultSearch(std::string idhash,
|
||||
void printDhtPeerEntry(dhtPeerEntry *ent, std::ostream &out)
|
||||
{
|
||||
|
||||
out << "DhtEntry: ID: " << ent->id;
|
||||
out << "DhtEntry: ID: " << ent->id.toStdString();
|
||||
out << " State: " << ent->state;
|
||||
out << " lastTS: " << ent->lastTS;
|
||||
out << " notifyPending: " << ent->notifyPending;
|
||||
|
@ -78,7 +78,7 @@ class dhtPeerEntry
|
||||
public:
|
||||
dhtPeerEntry();
|
||||
|
||||
std::string id;
|
||||
RsPeerId id;
|
||||
uint32_t state;
|
||||
time_t lastTS;
|
||||
|
||||
@ -97,7 +97,7 @@ class p3DhtMgr: public pqiNetAssistConnect, public RsThread
|
||||
/*
|
||||
*/
|
||||
public:
|
||||
p3DhtMgr(std::string id, pqiConnectCb *cb);
|
||||
p3DhtMgr(RsPeerId id, pqiConnectCb *cb);
|
||||
|
||||
/********** External DHT Interface ************************
|
||||
* These Functions are the external interface
|
||||
@ -121,15 +121,15 @@ virtual bool setExternalInterface(struct sockaddr_in laddr,
|
||||
struct sockaddr_in raddr, uint32_t type);
|
||||
|
||||
/* add / remove peers */
|
||||
virtual bool findPeer(std::string id);
|
||||
virtual bool dropPeer(std::string id);
|
||||
virtual bool findPeer(const RsPeerId& id);
|
||||
virtual bool dropPeer(const RsPeerId& id);
|
||||
|
||||
/* post DHT key saying we should connect (callback when done) */
|
||||
virtual bool notifyPeer(std::string id);
|
||||
virtual bool notifyPeer(const RsPeerId& id);
|
||||
|
||||
/* extract current peer status */
|
||||
virtual bool getPeerStatus(std::string id,
|
||||
struct sockaddr_in &laddr, struct sockaddr_in &raddr,
|
||||
virtual bool getPeerStatus(const RsPeerId& id,
|
||||
struct sockaddr_in &laddr, struct sockaddr_in &raddr,
|
||||
uint32_t &type, uint32_t &mode);
|
||||
|
||||
/* stun */
|
||||
@ -154,17 +154,17 @@ virtual bool dhtResultBootstrap(std::string idhash);
|
||||
protected:
|
||||
|
||||
/* can block briefly (called only from thread) */
|
||||
virtual bool dhtPublish(std::string id,
|
||||
virtual bool dhtPublish(std::string idhash,
|
||||
struct sockaddr_in &laddr,
|
||||
struct sockaddr_in &raddr,
|
||||
uint32_t type, std::string sign);
|
||||
|
||||
virtual bool dhtNotify(std::string peerid, std::string ownId,
|
||||
virtual bool dhtNotify(std::string idhash, std::string ownIdHash,
|
||||
std::string sign);
|
||||
|
||||
virtual bool dhtSearch(std::string id, uint32_t mode);
|
||||
virtual bool dhtSearch(std::string idhash, uint32_t mode);
|
||||
|
||||
virtual bool dhtBootstrap(std::string storehash, std::string ownIdHash,
|
||||
virtual bool dhtBootstrap(std::string idhash, std::string ownIdHash,
|
||||
std::string sign); /* to publish bootstrap */
|
||||
|
||||
|
||||
@ -232,7 +232,7 @@ std::string randomBootstrapId();
|
||||
|
||||
dhtPeerEntry ownEntry;
|
||||
time_t ownNotifyTS;
|
||||
std::map<std::string, dhtPeerEntry> peers;
|
||||
std::map<RsPeerId, dhtPeerEntry> peers;
|
||||
|
||||
std::list<std::string> stunIds;
|
||||
bool mStunRequired;
|
||||
|
@ -26,11 +26,11 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "p3historymgr.h"
|
||||
#include "serialiser/rshistoryitems.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rshistoryitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "serialiser/rsmsgitems.h"
|
||||
#include "rsitems/rsmsgitems.h"
|
||||
#include "rsserver/p3face.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
#include "serialiser/rshistoryitems.h"
|
||||
#include "rsitems/rshistoryitems.h"
|
||||
#include "retroshare/rshistory.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
|
||||
|
@ -41,7 +41,8 @@
|
||||
#include "util/rsprint.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsstring.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
@ -42,7 +42,8 @@
|
||||
struct RsLog::logInfo p3netmgrzoneInfo = {RsLog::Default, "p3netmgr"};
|
||||
#define p3netmgrzone &p3netmgrzoneInfo
|
||||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rsconfig.h"
|
||||
#include "retroshare/rsbanlist.h"
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include "util/rsstring.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
|
||||
#include "retroshare/rsiface.h" // Needed for rsicontrol (should remove this dependancy)
|
||||
#include "retroshare/rspeers.h" // Needed for Group Parameters.
|
||||
@ -2295,43 +2295,6 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
continue;
|
||||
}
|
||||
|
||||
RsPeerGroupItem_deprecated *gitem = dynamic_cast<RsPeerGroupItem_deprecated *>(*it) ;
|
||||
|
||||
if (gitem)
|
||||
{
|
||||
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 ginfo ;
|
||||
ginfo.flag = gitem->flag ;
|
||||
ginfo.name = gitem->name ;
|
||||
ginfo.peerIds = gitem->pgpList.ids ;
|
||||
|
||||
do { ginfo.id = RsNodeGroupId::random(); } while(groupList.find(ginfo.id) != groupList.end()) ;
|
||||
|
||||
// Ensure backward compatibility when loading the group in old format. The id must matchthe standard default id.
|
||||
|
||||
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)
|
||||
|
@ -397,7 +397,7 @@ private:
|
||||
std::map<RsPeerId,sockaddr_storage> mReportedOwnAddresses ;
|
||||
|
||||
std::map<RsNodeGroupId,RsGroupInfo> groupList;
|
||||
uint32_t lastGroupId;
|
||||
//uint32_t lastGroupId;
|
||||
|
||||
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
|
||||
|
||||
|
@ -26,10 +26,12 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "p3servicecontrol.h"
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "rsitems/rsserviceids.h"
|
||||
#include "rsitems/rsitem.h"
|
||||
#include "serialiser/rstypeserializer.h"
|
||||
#include "rsitems/rsnxsitems.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "pqi/pqiservice.h"
|
||||
|
||||
/*******************************/
|
||||
// #define SERVICECONTROL_DEBUG 1
|
||||
@ -41,184 +43,40 @@ class RsServiceControlItem: public RsItem
|
||||
{
|
||||
public:
|
||||
RsServiceControlItem(uint8_t item_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_SERVICE_CONTROL,item_subtype) {}
|
||||
|
||||
virtual uint32_t serial_size() const =0;
|
||||
virtual bool serialise(uint8_t *data,uint32_t size) const =0;
|
||||
|
||||
bool serialise_header(void *data,uint32_t& pktsize,uint32_t& tlvsize, uint32_t& offset) const
|
||||
{
|
||||
tlvsize = serial_size() ;
|
||||
offset = 0;
|
||||
|
||||
if (pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
if(!setRsItemHeader(data, tlvsize, PacketId(), tlvsize))
|
||||
{
|
||||
std::cerr << "RsFileTransferItem::serialise_header(): ERROR. Not enough size!" << std::endl;
|
||||
return false ;
|
||||
}
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileItemSerialiser::serialiseData() Header: " << ok << std::endl;
|
||||
#endif
|
||||
offset += 8;
|
||||
|
||||
return true ;
|
||||
}
|
||||
};
|
||||
|
||||
class RsServicePermissionItem: public RsServiceControlItem, public RsServicePermissions
|
||||
{
|
||||
public:
|
||||
RsServicePermissionItem()
|
||||
: RsServiceControlItem(RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS) {}
|
||||
RsServicePermissionItem(const RsServicePermissions& perms)
|
||||
: RsServiceControlItem(RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS),
|
||||
RsServicePermissions(perms) {}
|
||||
RsServicePermissionItem(): RsServiceControlItem(RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS) {}
|
||||
RsServicePermissionItem(const RsServicePermissions& perms) : RsServiceControlItem(RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS), RsServicePermissions(perms) {}
|
||||
|
||||
virtual uint32_t serial_size() const
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
uint32_t s = 8 ; // header
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,mServiceId,"mServiceId") ;
|
||||
RsTypeSerializer::serial_process (j,ctx,TLV_TYPE_STR_NAME,mServiceName,"mServiceName") ;
|
||||
RsTypeSerializer::serial_process<bool> (j,ctx,mDefaultAllowed,"mDefaultAllowed") ;
|
||||
|
||||
s += 4 ; // mServiceId
|
||||
s += GetTlvStringSize(mServiceName) ;
|
||||
s += 1 ; // mDefaultAllowed
|
||||
s += 4 ; // mPeersAllowed.size()
|
||||
s += mPeersAllowed.size() * RsPeerId::serial_size() ;
|
||||
s += 4 ; // mPeersAllowed.size()
|
||||
s += mPeersDenied.size() * RsPeerId::serial_size() ;
|
||||
|
||||
return s ;
|
||||
}
|
||||
virtual bool serialise(uint8_t *data,uint32_t size) const
|
||||
{
|
||||
uint32_t tlvsize,offset=0;
|
||||
bool ok = true;
|
||||
|
||||
if(!serialise_header(data,size,tlvsize,offset))
|
||||
return false ;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mServiceId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, mServiceName);
|
||||
ok &= setRawUInt8(data, tlvsize, &offset, mDefaultAllowed);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mPeersAllowed.size());
|
||||
|
||||
for(std::set<RsPeerId>::const_iterator it(mPeersAllowed.begin());it!=mPeersAllowed.end();++it)
|
||||
(*it).serialise(data,tlvsize,offset) ;
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mPeersDenied.size());
|
||||
|
||||
for(std::set<RsPeerId>::const_iterator it(mPeersDenied.begin());it!=mPeersDenied.end();++it)
|
||||
(*it).serialise(data,tlvsize,offset) ;
|
||||
|
||||
if(offset != tlvsize)
|
||||
{
|
||||
std::cerr << "RsGxsChannelSerialiser::serialiseGxsChannelGroupItem() FAIL Size Error! " << std::endl;
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
std::cerr << "RsGxsChannelSerialiser::serialiseGxsChannelGroupItem() NOK" << std::endl;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static RsServicePermissionItem *deserialise(uint8_t *data, uint32_t size)
|
||||
{
|
||||
RsServicePermissionItem *item = new RsServicePermissionItem ;
|
||||
|
||||
uint32_t offset = 8; // skip the header
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
bool ok = true ;
|
||||
|
||||
if(rssize > size)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": error while deserialising! Item will be dropped." << std::endl;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= getRawUInt32(data, rssize, &offset, &item->mServiceId);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->mServiceName);
|
||||
|
||||
uint8_t v;
|
||||
ok &= getRawUInt8(data, rssize, &offset, &v) ;
|
||||
|
||||
if (v != 0 && v != 1)
|
||||
ok = false;
|
||||
else
|
||||
item->mDefaultAllowed = (bool)v ;
|
||||
|
||||
uint32_t tmp ;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &tmp);
|
||||
|
||||
for(uint32_t i=0;i<tmp && offset < rssize;++i)
|
||||
{
|
||||
RsPeerId peer_id ;
|
||||
ok &= peer_id.deserialise(data,rssize,offset) ;
|
||||
item->mPeersAllowed.insert(peer_id) ;
|
||||
}
|
||||
|
||||
ok &= getRawUInt32(data, rssize, &offset, &tmp);
|
||||
|
||||
for(uint32_t i=0;i<tmp && offset < rssize;++i)
|
||||
{
|
||||
RsPeerId peer_id ;
|
||||
ok &= peer_id.deserialise(data,rssize,offset) ;
|
||||
item->mPeersDenied.insert(peer_id) ;
|
||||
}
|
||||
if (offset != rssize || !ok)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": error while deserialising! Item will be dropped." << std::endl;
|
||||
delete(item);
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
return item;
|
||||
RsTypeSerializer::serial_process (j,ctx,mPeersAllowed,"mPeersAllowed");
|
||||
RsTypeSerializer::serial_process (j,ctx,mPeersDenied ,"mPeersDenied");
|
||||
}
|
||||
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream& out,uint16_t)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": not implemented!" << std::endl;
|
||||
return out ;
|
||||
}
|
||||
};
|
||||
|
||||
class ServiceControlSerialiser: public RsSerialType
|
||||
class ServiceControlSerialiser: public RsServiceSerializer
|
||||
{
|
||||
public:
|
||||
ServiceControlSerialiser() : RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_SERVICE_CONTROL) {}
|
||||
ServiceControlSerialiser() : RsServiceSerializer(RS_SERVICE_TYPE_SERVICE_CONTROL) {}
|
||||
|
||||
virtual uint32_t size (RsItem *item)
|
||||
virtual RsItem *create_item(uint16_t service,uint8_t item_subtype) const
|
||||
{
|
||||
RsServiceControlItem *scitem = dynamic_cast<RsServiceControlItem *>(item);
|
||||
if (!scitem)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return scitem->serial_size() ;
|
||||
}
|
||||
virtual bool serialise(RsItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
RsServiceControlItem *scitem = dynamic_cast<RsServiceControlItem *>(item);
|
||||
if (!scitem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return scitem->serialise((uint8_t*)data,*size) ;
|
||||
}
|
||||
virtual RsItem *deserialise (void *data, uint32_t *size)
|
||||
{
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
if(RS_SERVICE_TYPE_SERVICE_CONTROL != service)
|
||||
return NULL;
|
||||
|
||||
if(RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype) || RS_SERVICE_TYPE_SERVICE_CONTROL != getRsItemService(rstype)) { return NULL; /* wrong type */ }
|
||||
|
||||
switch(getRsItemSubType(rstype))
|
||||
switch(item_subtype)
|
||||
{
|
||||
case RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS:return RsServicePermissionItem::deserialise((uint8_t*)data, *size);
|
||||
case RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS: return new RsServicePermissionItem();
|
||||
default:
|
||||
return NULL ;
|
||||
}
|
||||
@ -248,6 +106,13 @@ const RsPeerId& p3ServiceControl::getOwnId()
|
||||
return mOwnPeerId;
|
||||
}
|
||||
|
||||
bool p3ServiceControl::getServiceItemNames(uint32_t serviceId,std::map<uint8_t,std::string>& names)
|
||||
{
|
||||
if(mServiceServer != NULL)
|
||||
return mServiceServer->getServiceItemNames(serviceId,names) ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
/* Interface for Services */
|
||||
bool p3ServiceControl::registerService(const RsServiceInfo &info, bool defaultOn)
|
||||
@ -537,7 +402,7 @@ bool p3ServiceControl::updateServicePermissions(uint32_t serviceId, const RsServ
|
||||
{
|
||||
for(pit = onlinePeers.begin(); pit != onlinePeers.end(); ++pit)
|
||||
{
|
||||
if (it->second.peerHasPermission(*pit) !=
|
||||
if (it->second.peerHasPermission(*pit) !=
|
||||
permissions.peerHasPermission(*pit))
|
||||
{
|
||||
mUpdatedSet.insert(*pit);
|
||||
@ -597,7 +462,7 @@ bool p3ServiceControl::checkFilter(uint32_t serviceId, const RsPeerId &peerId)
|
||||
#endif
|
||||
|
||||
// must allow ServiceInfo through, or we have nothing!
|
||||
#define FULLID_SERVICEINFO ((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + ((RS_SERVICE_TYPE_SERVICEINFO) << 8))
|
||||
#define FULLID_SERVICEINFO ((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + ((RS_SERVICE_TYPE_SERVICEINFO) << 8))
|
||||
|
||||
//if (serviceId == RS_SERVICE_TYPE_SERVICEINFO)
|
||||
if (serviceId == FULLID_SERVICEINFO)
|
||||
@ -691,21 +556,21 @@ bool ServiceInfoCompatible(const RsServiceInfo &info1, const RsServiceInfo &info
|
||||
}
|
||||
|
||||
// ensure that info1 meets minimum requirements for info2
|
||||
if (!versionOkay(info1.mVersionMajor, info1.mVersionMinor,
|
||||
if (!versionOkay(info1.mVersionMajor, info1.mVersionMinor,
|
||||
info2.mMinVersionMajor, info2.mMinVersionMinor))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ensure that info2 meets minimum requirements for info1
|
||||
if (!versionOkay(info2.mVersionMajor, info2.mVersionMinor,
|
||||
if (!versionOkay(info2.mVersionMajor, info2.mVersionMinor,
|
||||
info1.mMinVersionMajor, info1.mMinVersionMinor))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool p3ServiceControl::updateFilterByPeer(const RsPeerId &peerId)
|
||||
{
|
||||
@ -790,8 +655,8 @@ bool p3ServiceControl::updateFilterByPeer_locked(const RsPeerId &peerId)
|
||||
std::cerr << "p3ServiceControl::updateFilterByPeer_locked() Empty ... Clearing";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
// empty, remove...
|
||||
|
||||
// empty, remove...
|
||||
recordFilterChanges_locked(peerId, originalFilter, peerFilter);
|
||||
if (fit != mPeerFilterMap.end())
|
||||
{
|
||||
@ -882,7 +747,7 @@ bool p3ServiceControl::updateFilterByPeer_locked(const RsPeerId &peerId)
|
||||
std::cerr << "p3ServiceControl::updateFilterByPeer_locked() Empty(2) ... Clearing";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
if (fit != mPeerFilterMap.end())
|
||||
{
|
||||
mPeerFilterMap.erase(fit);
|
||||
@ -900,7 +765,7 @@ bool p3ServiceControl::updateFilterByPeer_locked(const RsPeerId &peerId)
|
||||
return true;
|
||||
}
|
||||
|
||||
void p3ServiceControl::recordFilterChanges_locked(const RsPeerId &peerId,
|
||||
void p3ServiceControl::recordFilterChanges_locked(const RsPeerId &peerId,
|
||||
ServicePeerFilter &originalFilter, ServicePeerFilter &updatedFilter)
|
||||
{
|
||||
#ifdef SERVICECONTROL_DEBUG
|
||||
@ -1202,7 +1067,7 @@ bool p3ServiceControl::loadList(std::list<RsItem *>& loadList)
|
||||
|
||||
if(item != NULL)
|
||||
mServicePermissionMap[item->mServiceId] = *item ;
|
||||
|
||||
|
||||
delete *it ;
|
||||
}
|
||||
|
||||
@ -1396,49 +1261,49 @@ void p3ServiceControl::notifyServices()
|
||||
std::cerr << "p3ServiceControl::notifyServices(): Noone Monitoring ... skipping";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
std::list<pqiServicePeer> peers;
|
||||
std::set<RsPeerId>::const_iterator pit;
|
||||
for(pit = it->second.mAdded.begin();
|
||||
for(pit = it->second.mAdded.begin();
|
||||
pit != it->second.mAdded.end(); ++pit)
|
||||
{
|
||||
pqiServicePeer peer;
|
||||
peer.id = *pit;
|
||||
peer.actions = RS_SERVICE_PEER_CONNECTED;
|
||||
|
||||
|
||||
peers.push_back(peer);
|
||||
|
||||
|
||||
#ifdef SERVICECONTROL_DEBUG
|
||||
std::cerr << "p3ServiceControl::notifyServices(): Peer: " << *pit << " CONNECTED";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
for(pit = it->second.mRemoved.begin();
|
||||
|
||||
for(pit = it->second.mRemoved.begin();
|
||||
pit != it->second.mRemoved.end(); ++pit)
|
||||
{
|
||||
pqiServicePeer peer;
|
||||
peer.id = *pit;
|
||||
peer.actions = RS_SERVICE_PEER_DISCONNECTED;
|
||||
|
||||
|
||||
peers.push_back(peer);
|
||||
|
||||
|
||||
#ifdef SERVICECONTROL_DEBUG
|
||||
std::cerr << "p3ServiceControl::notifyServices(): Peer: " << *pit << " DISCONNECTED";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
for(; sit != eit; ++sit)
|
||||
{
|
||||
#ifdef SERVICECONTROL_DEBUG
|
||||
std::cerr << "p3ServiceControl::notifyServices(): Sending to Monitoring Service";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
sit->second->statusChange(peers);
|
||||
}
|
||||
}
|
||||
@ -1500,17 +1365,17 @@ void RsServicePermissions::resetPermission(const RsPeerId& peerId)
|
||||
}
|
||||
|
||||
RsServiceInfo::RsServiceInfo(
|
||||
const uint16_t service_type,
|
||||
const std::string service_name,
|
||||
const uint16_t service_type,
|
||||
const std::string service_name,
|
||||
const uint16_t version_major,
|
||||
const uint16_t version_minor,
|
||||
const uint16_t min_version_major,
|
||||
const uint16_t min_version_minor)
|
||||
:mServiceName(service_name),
|
||||
mServiceType((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) service_type) << 8)),
|
||||
mVersionMajor(version_major),
|
||||
:mServiceName(service_name),
|
||||
mServiceType((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) service_type) << 8)),
|
||||
mVersionMajor(version_major),
|
||||
mVersionMinor(version_minor),
|
||||
mMinVersionMajor(min_version_major),
|
||||
mMinVersionMajor(min_version_major),
|
||||
mMinVersionMinor(min_version_minor)
|
||||
{
|
||||
return;
|
||||
@ -1518,7 +1383,7 @@ RsServiceInfo::RsServiceInfo(
|
||||
|
||||
|
||||
RsServiceInfo::RsServiceInfo()
|
||||
:mServiceName("unknown"),
|
||||
:mServiceName("unknown"),
|
||||
mServiceType(0),
|
||||
mVersionMajor(0),
|
||||
mVersionMinor(0),
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
|
||||
class p3ServiceServer ;
|
||||
|
||||
class ServiceNotifications
|
||||
{
|
||||
public:
|
||||
@ -101,6 +103,9 @@ virtual bool updateServicePermissions(uint32_t serviceId, const RsServicePermiss
|
||||
virtual void getPeersConnected(const uint32_t serviceId, std::set<RsPeerId> &peerSet);
|
||||
virtual bool isPeerConnected(const uint32_t serviceId, const RsPeerId &peerId);
|
||||
|
||||
// Gets the list of items used by that service
|
||||
virtual bool getServiceItemNames(uint32_t serviceId,std::map<uint8_t,std::string>& names) ;
|
||||
|
||||
/**
|
||||
* Registration for all Services.
|
||||
*/
|
||||
@ -132,6 +137,8 @@ virtual bool updateServicesProvided(const RsPeerId &peerId, const RsPeerServiceI
|
||||
// pqiMonitor.
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
|
||||
virtual void setServiceServer(p3ServiceServer *p) { mServiceServer = p ; }
|
||||
|
||||
protected:
|
||||
// configuration.
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
|
||||
@ -196,6 +203,7 @@ bool peerHasPermissionForService_locked(const RsPeerId &peerId, uint32_t service
|
||||
// Below here is saved in Configuration.
|
||||
std::map<uint32_t, RsServicePermissions> mServicePermissionMap;
|
||||
|
||||
p3ServiceServer *mServiceServer ;
|
||||
};
|
||||
|
||||
|
||||
|
@ -27,8 +27,7 @@
|
||||
#ifndef PQI_TOP_HEADER
|
||||
#define PQI_TOP_HEADER
|
||||
|
||||
#include "serialiser/rsserial.h"
|
||||
|
||||
#include "rsitems/rsitem.h"
|
||||
|
||||
class P3Interface
|
||||
{
|
||||
|
@ -61,14 +61,20 @@ void pqiConnectCbDummy::peerStatus(const RsPeerId& id, const pqiIpAddrSet &ad
|
||||
std::cerr << out << std::endl;
|
||||
}
|
||||
|
||||
void pqiConnectCbDummy::peerConnectRequest(const RsPeerId& id,
|
||||
const struct sockaddr_storage &raddr, uint32_t source)
|
||||
void pqiConnectCbDummy::peerConnectRequest(const RsPeerId &id, const sockaddr_storage &raddr
|
||||
, const sockaddr_storage &proxyaddr, const sockaddr_storage &srcaddr
|
||||
, uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth)
|
||||
{
|
||||
std::cerr << "pqiConnectCbDummy::peerConnectRequest()";
|
||||
std::cerr << " id: " << id;
|
||||
std::cerr << " raddr: " << sockaddr_storage_tostring(raddr);
|
||||
std::cerr << " proxyaddr: " << sockaddr_storage_tostring(proxyaddr);
|
||||
std::cerr << " srcaddr: " << sockaddr_storage_tostring(srcaddr);
|
||||
std::cerr << " source: " << source;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << " flags: " << flags;
|
||||
std::cerr << " delay: " << delay;
|
||||
std::cerr << " bandwidth: " << bandwidth;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
void pqiMonitor::disconnectPeer(const RsPeerId &/*peer*/)
|
||||
|
@ -179,8 +179,9 @@ virtual ~pqiConnectCbDummy();
|
||||
virtual void peerStatus(const RsPeerId& id, const pqiIpAddrSet &addrs,
|
||||
uint32_t type, uint32_t mode, uint32_t source);
|
||||
|
||||
virtual void peerConnectRequest(const RsPeerId& id,
|
||||
const struct sockaddr_storage &raddr, uint32_t source);
|
||||
virtual void peerConnectRequest(const RsPeerId& id, const struct sockaddr_storage &raddr,
|
||||
const struct sockaddr_storage &proxyaddr, const struct sockaddr_storage &srcaddr,
|
||||
uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth);
|
||||
|
||||
//virtual void stunStatus(std::string id, const struct sockaddr_storage &raddr, uint32_t type, uint32_t flags);
|
||||
};
|
||||
|
@ -40,7 +40,7 @@ static struct RsLog::logInfo pqipersonzoneInfo = {RsLog::Default, "pqiperson"};
|
||||
|
||||
pqiperson::pqiperson(const RsPeerId& id, pqipersongrp *pg) :
|
||||
PQInterface(id), mNotifyMtx("pqiperson-notify"), mPersonMtx("pqiperson"),
|
||||
active(false), activepqi(NULL), inConnectAttempt(false), waittimes(0),
|
||||
active(false), activepqi(NULL), inConnectAttempt(false),// waittimes(0),
|
||||
pqipg(pg) {} // TODO: must check id!
|
||||
|
||||
pqiperson::~pqiperson()
|
||||
|
@ -29,6 +29,7 @@
|
||||
#define MRK_PQI_PERSON_HEADER
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "pqi/pqi.h"
|
||||
#include "util/rsnet.h"
|
||||
|
||||
@ -66,7 +67,7 @@ public:
|
||||
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_parameter(uint32_t type, const 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); }
|
||||
virtual int getConnectAddress(struct sockaddr_storage &raddr){ return ni->getConnectAddress(raddr); }
|
||||
|
||||
@ -171,7 +172,7 @@ private:
|
||||
bool active;
|
||||
pqiconnect *activepqi;
|
||||
bool inConnectAttempt;
|
||||
int waittimes;
|
||||
//int waittimes;
|
||||
time_t lastHeartbeatReceived; // use to track connection failure
|
||||
pqipersongrp *pqipg; /* parent for callback */
|
||||
};
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsprint.h"
|
||||
#include "serialiser/rsserviceserialiser.h"
|
||||
#include "serialiser/rsserializer.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -699,7 +699,7 @@ pqiperson * pqipersongrpDummy::locked_createPerson(const RsPeerId& id, pqilisten
|
||||
NetBinDummy *d1 = new NetBinDummy(pqip, id, PQI_CONNECT_TCP);
|
||||
|
||||
RsSerialiser *rss = new RsSerialiser();
|
||||
rss->addSerialType(new RsServiceSerialiser());
|
||||
rss->addSerialType(new RsRawSerialiser());
|
||||
|
||||
pqiconnect *pqic = new pqiconnect(pqip, rss, d1);
|
||||
|
||||
@ -709,7 +709,7 @@ pqiperson * pqipersongrpDummy::locked_createPerson(const RsPeerId& id, pqilisten
|
||||
NetBinDummy *d2 = new NetBinDummy(pqip, id, PQI_CONNECT_UDP);
|
||||
|
||||
RsSerialiser *rss2 = new RsSerialiser();
|
||||
rss2->addSerialType(new RsServiceSerialiser());
|
||||
rss2->addSerialType(new RsRawSerialiser());
|
||||
|
||||
pqiconnect *pqic2 = new pqiconnect(pqip, rss2, d2);
|
||||
|
||||
|
@ -11,7 +11,9 @@ const uint32_t pqiQoS::MAX_PACKET_COUNTER_VALUE = (1 << 24) ;
|
||||
pqiQoS::pqiQoS(uint32_t nb_levels,float alpha)
|
||||
: _item_queues(nb_levels),_alpha(alpha)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(pow(alpha,nb_levels) < 1e+20) ;
|
||||
#endif
|
||||
|
||||
float c = 1.0f ;
|
||||
float inc = alpha ;
|
||||
@ -110,7 +112,9 @@ void *pqiQoS::out_rsItem(uint32_t max_slice_size, uint32_t& size, bool& starts,
|
||||
|
||||
if(last >= 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(_nb_items > 0) ;
|
||||
#endif
|
||||
|
||||
// now chop a slice of this item
|
||||
|
||||
|
@ -79,11 +79,26 @@ int p3ServiceServer::addService(pqiService *ts, bool defaultOn)
|
||||
services[info.mServiceType] = ts;
|
||||
|
||||
// This doesn't need to be in Mutex.
|
||||
mServiceControl->registerService(info, defaultOn);
|
||||
mServiceControl->registerService(info,defaultOn);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool p3ServiceServer::getServiceItemNames(uint32_t service_type,std::map<uint8_t,std::string>& names)
|
||||
{
|
||||
RsStackMutex stack(srvMtx); /********* LOCKED *********/
|
||||
|
||||
std::map<uint32_t, pqiService *>::iterator it=services.find(service_type) ;
|
||||
|
||||
if(it != services.end())
|
||||
{
|
||||
it->second->getItemNames(names) ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
int p3ServiceServer::removeService(pqiService *ts)
|
||||
{
|
||||
RsStackMutex stack(srvMtx); /********* LOCKED *********/
|
||||
|
@ -60,24 +60,26 @@ class p3ServiceServerIface;
|
||||
|
||||
class pqiService
|
||||
{
|
||||
protected:
|
||||
protected:
|
||||
|
||||
pqiService() // our type of packets.
|
||||
:mServiceServer(NULL) { return; }
|
||||
:mServiceServer(NULL) { return; }
|
||||
|
||||
virtual ~pqiService() { return; }
|
||||
virtual ~pqiService() { return; }
|
||||
|
||||
public:
|
||||
void setServiceServer(p3ServiceServerIface *server);
|
||||
//
|
||||
virtual bool recv(RsRawItem *) = 0;
|
||||
virtual bool send(RsRawItem *item);
|
||||
public:
|
||||
void setServiceServer(p3ServiceServerIface *server);
|
||||
//
|
||||
virtual bool recv(RsRawItem *) = 0;
|
||||
virtual bool send(RsRawItem *item);
|
||||
|
||||
virtual RsServiceInfo getServiceInfo() = 0;
|
||||
virtual RsServiceInfo getServiceInfo() = 0;
|
||||
|
||||
virtual int tick() { return 0; }
|
||||
virtual int tick() { return 0; }
|
||||
|
||||
private:
|
||||
virtual void getItemNames(std::map<uint8_t,std::string>& /*names*/) const {} // This does nothing by default. Service should derive it in order to give info for the UI
|
||||
|
||||
private:
|
||||
p3ServiceServerIface *mServiceServer; // const, no need for mutex.
|
||||
};
|
||||
|
||||
@ -97,10 +99,10 @@ public:
|
||||
virtual ~p3ServiceServerIface() {}
|
||||
|
||||
|
||||
virtual bool recvItem(RsRawItem *) = 0;
|
||||
virtual bool sendItem(RsRawItem *) = 0;
|
||||
|
||||
virtual bool recvItem(RsRawItem *) = 0;
|
||||
virtual bool sendItem(RsRawItem *) = 0;
|
||||
|
||||
virtual bool getServiceItemNames(uint32_t service_type,std::map<uint8_t,std::string>& names) =0;
|
||||
};
|
||||
|
||||
class p3ServiceServer : public p3ServiceServerIface
|
||||
@ -108,13 +110,15 @@ class p3ServiceServer : public p3ServiceServerIface
|
||||
public:
|
||||
p3ServiceServer(pqiPublisher *pub, p3ServiceControl *ctrl);
|
||||
|
||||
int addService(pqiService *, bool defaultOn);
|
||||
int removeService(pqiService *);
|
||||
int addService(pqiService *, bool defaultOn);
|
||||
int removeService(pqiService *);
|
||||
|
||||
bool recvItem(RsRawItem *);
|
||||
bool sendItem(RsRawItem *);
|
||||
bool recvItem(RsRawItem *);
|
||||
bool sendItem(RsRawItem *);
|
||||
|
||||
int tick();
|
||||
bool getServiceItemNames(uint32_t service_type, std::map<uint8_t,std::string>& names) ;
|
||||
|
||||
int tick();
|
||||
public:
|
||||
|
||||
private:
|
||||
@ -122,7 +126,7 @@ private:
|
||||
pqiPublisher *mPublisher; // constant no need for mutex.
|
||||
p3ServiceControl *mServiceControl;
|
||||
|
||||
RsMutex srvMtx;
|
||||
RsMutex srvMtx;
|
||||
std::map<uint32_t, pqiService *> services;
|
||||
|
||||
};
|
||||
|
@ -1009,7 +1009,7 @@ int pqissl::Basic_Connection_Complete()
|
||||
|
||||
return -1;
|
||||
}
|
||||
else if ((err == ECONNREFUSED))
|
||||
else if (err == ECONNREFUSED)
|
||||
{
|
||||
rslog(RSL_WARNING, pqisslzone, "pqissl::Basic_Connection_Complete() ECONNREFUSED: cert: " + PeerId().toStdString());
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "serialiser/rsserviceserialiser.h"
|
||||
#include "serialiser/rsserializer.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
#include "pqi/pqisslpersongrp.h"
|
||||
@ -87,7 +87,7 @@ pqiperson * pqisslpersongrp::locked_createPerson(const RsPeerId& id, pqilistener
|
||||
|
||||
|
||||
RsSerialiser *rss = new RsSerialiser();
|
||||
rss->addSerialType(new RsServiceSerialiser());
|
||||
rss->addSerialType(new RsRawSerialiser());
|
||||
|
||||
pqiconnect *pqisc = new pqiconnect(pqip, rss, pqis);
|
||||
|
||||
@ -141,7 +141,7 @@ pqiperson * pqisslpersongrp::locked_createPerson(const RsPeerId& id, pqilistener
|
||||
ssl_tunnels[id] = pqis ; // keeps for getting crypt info per peer.
|
||||
|
||||
RsSerialiser *rss = new RsSerialiser();
|
||||
rss->addSerialType(new RsServiceSerialiser());
|
||||
rss->addSerialType(new RsRawSerialiser());
|
||||
|
||||
pqiconnect *pqisc = new pqiconnect(pqip, rss, pqis);
|
||||
|
||||
@ -151,7 +151,7 @@ pqiperson * pqisslpersongrp::locked_createPerson(const RsPeerId& id, pqilistener
|
||||
pqissludp *pqius = new pqissludp(pqip, mLinkMgr);
|
||||
|
||||
RsSerialiser *rss2 = new RsSerialiser();
|
||||
rss2->addSerialType(new RsServiceSerialiser());
|
||||
rss2->addSerialType(new RsRawSerialiser());
|
||||
|
||||
pqiconnect *pqiusc = new pqiconnect(pqip, rss2, pqius);
|
||||
|
||||
|
@ -53,7 +53,7 @@ static const uint32_t PQI_SSLUDP_DEF_CONN_PERIOD = 300; /* 5 minutes? */
|
||||
/********** PQI SSL UDP STUFF **************************************/
|
||||
|
||||
pqissludp::pqissludp(PQInterface *parent, p3LinkMgr *lm) :
|
||||
pqissl(NULL, parent, lm), tou_bio(NULL), listen_checktime(0),
|
||||
pqissl(NULL, parent, lm), tou_bio(NULL),// listen_checktime(0),
|
||||
mConnectPeriod(PQI_SSLUDP_DEF_CONN_PERIOD), mConnectFlags(0),
|
||||
mConnectBandwidth(0)
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ private:
|
||||
|
||||
BIO *tou_bio; // specific to ssludp.
|
||||
|
||||
long listen_checktime;
|
||||
//long listen_checktime;
|
||||
|
||||
uint32_t mConnectPeriod;
|
||||
uint32_t mConnectFlags;
|
||||
|
@ -40,6 +40,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "rsitems/rsitem.h"
|
||||
#include "pqi/pqistore.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
#include <iostream>
|
||||
@ -309,24 +310,25 @@ int pqistore::readPkt(RsItem **item_out)
|
||||
}
|
||||
|
||||
// workout how much more to read.
|
||||
int extralen = getRsItemSize(block) - blen;
|
||||
int totallen = extralen+blen;
|
||||
|
||||
// make sure that totallen is not a crazy number. If so, we drop the entire stream that might be corrupted.
|
||||
|
||||
if(totallen > 1024*1024)
|
||||
int blocklength = getRsItemSize(block);
|
||||
|
||||
// make sure that blocklength is not a crazy number. If so, we drop the entire stream that might be corrupted.
|
||||
|
||||
if(blocklength < blen || blocklength > 1024*1024*10)
|
||||
{
|
||||
std::cerr << "pqistore: ERROR: trying to realloc memory for packet of length" << totallen <<", which exceeds the allowed limit (1MB)" << std::endl ;
|
||||
std::cerr << "pqistore: ERROR: trying to realloc memory for packet of length" << blocklength <<", which is either too small, or exceeds the safety limit (10 MB)" << std::endl ;
|
||||
free(block) ;
|
||||
bStopReading=true;
|
||||
return 0 ;
|
||||
}
|
||||
void *tmp = realloc(block, totallen);
|
||||
int extralen = blocklength - blen;
|
||||
|
||||
void *tmp = realloc(block, blocklength);
|
||||
|
||||
if (tmp == NULL)
|
||||
{
|
||||
free(block);
|
||||
std::cerr << "pqistore: ERROR: trying to realloc memory for packet of length" << totallen << std::endl ;
|
||||
std::cerr << "pqistore: ERROR: trying to realloc memory for packet of length" << blocklength << std::endl ;
|
||||
std::cerr << "Have you got enought memory?" << std::endl ;
|
||||
bStopReading=true;
|
||||
return 0 ;
|
||||
@ -520,17 +522,18 @@ int pqiSSLstore::readPkt(RsItem **item_out)
|
||||
}
|
||||
|
||||
// workout how much more to read.
|
||||
int extralen = getRsItemSize(block) - blen;
|
||||
int totallen = extralen+blen;
|
||||
int blocklength = getRsItemSize(block);
|
||||
|
||||
if(totallen > 1024*1024)
|
||||
if(blocklength < blen || blocklength > 1024*1024*10)
|
||||
{
|
||||
free(block);
|
||||
std::cerr << "pqiSSLstore: ERROR: trying to realloc memory for packet of length" << totallen << ", that exceeds the limit of 1MB" << std::endl ;
|
||||
std::cerr << "pqiSSLstore: ERROR: block length has invalid value " << blocklength << " (either too small, or exceeds the safety limit of 10 MB)" << std::endl ;
|
||||
bStopReading=true;
|
||||
return 0 ;
|
||||
}
|
||||
void *tmp = realloc(block, totallen);
|
||||
int extralen = blocklength - blen;
|
||||
|
||||
void *tmp = realloc(block, blocklength);
|
||||
|
||||
if (tmp == NULL)
|
||||
{
|
||||
|
@ -627,7 +627,7 @@ bool getX509id(X509 *x509, RsPeerId& xid)
|
||||
* more randomness
|
||||
*/
|
||||
|
||||
#warning this is cryptographically horrible. We should do a hash of the public key here!!!
|
||||
#warning csoler 2017-02-19: This is cryptographically horrible. We should do a hash of the public key here!!!
|
||||
|
||||
xid = RsPeerId(&signdata[signlen - CERTSIGNLEN]) ;
|
||||
|
||||
|
@ -59,11 +59,12 @@ template<int n> class t_RsFlags32
|
||||
uint32_t _bits ;
|
||||
};
|
||||
|
||||
#define FLAGS_TAG_TRANSFER_REQS 0x4228af
|
||||
#define FLAGS_TAG_TRANSFER_REQS 0x4228af
|
||||
#define FLAGS_TAG_FILE_STORAGE 0x184738
|
||||
#define FLAGS_TAG_FILE_SEARCH 0xf29ba5
|
||||
#define FLAGS_TAG_FILE_SEARCH 0xf29ba5
|
||||
#define FLAGS_TAG_SERVICE_PERM 0x380912
|
||||
#define FLAGS_TAG_SERVICE_CHAT 0x839042
|
||||
#define FLAGS_TAG_SERIALIZER 0xa0338d
|
||||
|
||||
// Flags for requesting transfers, ask for turtle, cache, speed, etc.
|
||||
//
|
||||
@ -85,3 +86,7 @@ typedef t_RsFlags32<FLAGS_TAG_SERVICE_PERM > ServicePermissionFlags ;
|
||||
//
|
||||
typedef t_RsFlags32<FLAGS_TAG_SERVICE_CHAT > ChatLobbyFlags ;
|
||||
|
||||
// Flags for serializer
|
||||
//
|
||||
typedef t_RsFlags32<FLAGS_TAG_SERIALIZER > SerializationFlags ;
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <retroshare/rstypes.h>
|
||||
#include <retroshare/rsids.h>
|
||||
|
||||
typedef GXSGroupId RsGxsGroupId;
|
||||
typedef Sha1CheckSum RsGxsMessageId;
|
||||
@ -25,7 +26,7 @@ typedef std::pair<RsGxsGroupId, RsGxsMessageId> RsGxsGrpMsgIdPair;
|
||||
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMessageId> > MsgRelatedIdResult;
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq;
|
||||
|
||||
class RsMsgMetaData;
|
||||
struct RsMsgMetaData;
|
||||
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > MsgMetaResult;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "retroshare/rsgxsifacetypes.h"
|
||||
#include "retroshare/rstokenservice.h"
|
||||
|
||||
class RsMsgMetaData ;
|
||||
struct RsMsgMetaData ;
|
||||
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > GxsMsgMetaMap;
|
||||
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsMsgMetaData> > GxsMsgRelatedMetaMap;
|
||||
|
@ -305,6 +305,9 @@ public:
|
||||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
|
||||
virtual bool isARegularContact(const RsGxsId& id) = 0 ;
|
||||
|
||||
virtual bool serialiseIdentityToMemory(const RsGxsId& id,std::string& radix_string)=0;
|
||||
virtual bool deserialiseIdentityFromMemory(const std::string& radix_string)=0;
|
||||
|
||||
/*!
|
||||
* \brief overallReputationLevel
|
||||
* Returns the overall reputation level of the supplied identity. See rsreputations.h
|
||||
@ -319,6 +322,7 @@ public:
|
||||
*/
|
||||
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups) = 0;
|
||||
virtual bool getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups)=0;
|
||||
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions) = 0;
|
||||
|
||||
};
|
||||
|
@ -136,7 +136,7 @@ template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> c
|
||||
offset += SIZE_IN_BYTES ;
|
||||
return true ;
|
||||
}
|
||||
bool deserialise(void *data,uint32_t pktsize,uint32_t& offset)
|
||||
bool deserialise(const void *data,uint32_t pktsize,uint32_t& offset)
|
||||
{
|
||||
if(offset + SIZE_IN_BYTES > pktsize)
|
||||
return false ;
|
||||
|
@ -78,15 +78,16 @@ const uint32_t RS_FEED_TYPE_SECURITY = 0x0800;
|
||||
const uint32_t RS_FEED_TYPE_POSTED = 0x1000;
|
||||
const uint32_t RS_FEED_TYPE_SECURITY_IP = 0x2000;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_PEER_CONNECT = RS_FEED_TYPE_PEER | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_PEER_DISCONNECT = RS_FEED_TYPE_PEER | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_PEER_HELLO = RS_FEED_TYPE_PEER | 0x0003;
|
||||
const uint32_t RS_FEED_ITEM_PEER_NEW = RS_FEED_TYPE_PEER | 0x0004;
|
||||
const uint32_t RS_FEED_ITEM_PEER_CONNECT = RS_FEED_TYPE_PEER | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_PEER_DISCONNECT = RS_FEED_TYPE_PEER | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_PEER_HELLO = RS_FEED_TYPE_PEER | 0x0003;
|
||||
const uint32_t RS_FEED_ITEM_PEER_NEW = RS_FEED_TYPE_PEER | 0x0004;
|
||||
const uint32_t RS_FEED_ITEM_PEER_OFFSET = RS_FEED_TYPE_PEER | 0x0005;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_SEC_CONNECT_ATTEMPT = RS_FEED_TYPE_SECURITY | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_SEC_AUTH_DENIED = RS_FEED_TYPE_SECURITY | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_IN = RS_FEED_TYPE_SECURITY | 0x0003;
|
||||
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_OUT = RS_FEED_TYPE_SECURITY | 0x0004;
|
||||
const uint32_t RS_FEED_ITEM_SEC_CONNECT_ATTEMPT = RS_FEED_TYPE_SECURITY | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_SEC_AUTH_DENIED = RS_FEED_TYPE_SECURITY | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_IN = RS_FEED_TYPE_SECURITY | 0x0003;
|
||||
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_OUT = RS_FEED_TYPE_SECURITY | 0x0004;
|
||||
const uint32_t RS_FEED_ITEM_SEC_WRONG_SIGNATURE = RS_FEED_TYPE_SECURITY | 0x0005;
|
||||
const uint32_t RS_FEED_ITEM_SEC_BAD_CERTIFICATE = RS_FEED_TYPE_SECURITY | 0x0006;
|
||||
const uint32_t RS_FEED_ITEM_SEC_INTERNAL_ERROR = RS_FEED_TYPE_SECURITY | 0x0007;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user