├── .gitattributes ├── .gitignore ├── .gitlab-ci.yml ├── .reuse └── dep5 ├── CMakeLists.txt ├── COPYING ├── LICENSES ├── AGPL-3.0-only.txt ├── AGPL-3.0-or-later.txt ├── Apache-2.0.txt ├── CC-BY-SA-4.0.txt ├── CC0-1.0.txt ├── GPL-3.0-or-later.txt ├── LGPL-3.0-or-later.txt └── MIT.txt ├── README.asciidoc ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── misc └── Android │ ├── Dockerfile │ ├── GitlabCI_images_prepare.sh │ ├── README.asciidoc │ ├── generate_gdb_init_commands.sh │ ├── prepare-toolchain-clang.sh │ ├── proguard-keep-libretroshare-java-classes.pro │ ├── pull_sysroot.sh │ └── start_gdbserver.sh ├── settings.gradle ├── src ├── CMakeLists.txt ├── Doxyfile ├── chat │ ├── distantchat.cc │ ├── distantchat.h │ ├── distributedchat.cc │ ├── distributedchat.h │ ├── p3chatservice.cc │ ├── p3chatservice.h │ ├── rschatitems.cc │ └── rschatitems.h ├── crypto │ ├── chacha20.cpp │ ├── chacha20.h │ ├── hashstream.cc │ ├── hashstream.h │ ├── rsaes.cc │ ├── rsaes.h │ ├── rscrypto.cpp │ └── rscrypto.h ├── deep_search │ ├── channelsindex.cpp │ ├── channelsindex.hpp │ ├── commonutils.cpp │ ├── commonutils.hpp │ ├── filesflacindexer.hpp │ ├── filesindex.cpp │ ├── filesindex.hpp │ ├── filesoggindexer.hpp │ ├── filestaglibindexer.hpp │ ├── forumsindex.cpp │ └── forumsindex.hpp ├── dht │ ├── connectstatebox.cc │ ├── connectstatebox.h │ ├── p3bitdht.cc │ ├── p3bitdht.h │ ├── p3bitdht_interface.cc │ ├── p3bitdht_peernet.cc │ ├── p3bitdht_peers.cc │ ├── p3bitdht_relay.cc │ └── stunaddrassist.h ├── file_sharing │ ├── README.txt │ ├── dir_hierarchy.cc │ ├── dir_hierarchy.h │ ├── directory_list.h │ ├── directory_storage.cc │ ├── directory_storage.h │ ├── directory_updater.cc │ ├── directory_updater.h │ ├── file_sharing_defaults.h │ ├── file_tree.cc │ ├── filelist_io.cc │ ├── filelist_io.h │ ├── hash_cache.cc │ ├── hash_cache.h │ ├── p3filelists.cc │ ├── p3filelists.h │ ├── rsfilelistitems.cc │ └── rsfilelistitems.h ├── friend_server │ ├── fsclient.cc │ ├── fsclient.h │ ├── fsitem.h │ ├── fsmanager.cc │ └── fsmanager.h ├── ft │ ├── ftchunkmap.cc │ ├── ftchunkmap.h │ ├── ftcontroller.cc │ ├── ftcontroller.h │ ├── ftdata.h │ ├── ftdatamultiplex.cc │ ├── ftdatamultiplex.h │ ├── ftextralist.cc │ ├── ftextralist.h │ ├── ftfilecreator.cc │ ├── ftfilecreator.h │ ├── ftfileprovider.cc │ ├── ftfileprovider.h │ ├── ftfilesearch.cc │ ├── ftfilesearch.h │ ├── ftsearch.h │ ├── ftserver.cc │ ├── ftserver.h │ ├── fttransfermodule.cc │ ├── fttransfermodule.h │ ├── ftturtlefiletransferitem.cc │ └── ftturtlefiletransferitem.h ├── gossipdiscovery │ ├── gossipdiscoveryitems.cc │ ├── gossipdiscoveryitems.h │ ├── p3gossipdiscovery.cc │ └── p3gossipdiscovery.h ├── grouter │ ├── groutercache.h │ ├── grouterclientservice.h │ ├── grouteritems.cc │ ├── grouteritems.h │ ├── groutermatrix.cc │ ├── groutermatrix.h │ ├── groutertypes.h │ ├── p3grouter.cc │ └── p3grouter.h ├── gxs │ ├── UseCases.txt │ ├── gxssecurity.cc │ ├── gxssecurity.h │ ├── gxstokenqueue.cc │ ├── gxstokenqueue.h │ ├── rsdataservice.cc │ ├── rsdataservice.h │ ├── rsgds.h │ ├── rsgenexchange.cc │ ├── rsgenexchange.h │ ├── rsgixs.h │ ├── rsgroups.h │ ├── rsgxs.h │ ├── rsgxsdata.cc │ ├── rsgxsdata.h │ ├── rsgxsdataaccess.cc │ ├── rsgxsdataaccess.h │ ├── rsgxsnetservice.cc │ ├── rsgxsnetservice.h │ ├── rsgxsnettunnel.cc │ ├── rsgxsnettunnel.h │ ├── rsgxsnetutils.cc │ ├── rsgxsnetutils.h │ ├── rsgxsnotify.h │ ├── rsgxsrequesttypes.cc │ ├── rsgxsrequesttypes.h │ ├── rsgxsutil.cc │ ├── rsgxsutil.h │ ├── rsnxs.h │ ├── rsnxsobserver.cpp │ └── rsnxsobserver.h ├── gxstrans │ ├── p3gxstrans.cc │ ├── p3gxstrans.h │ ├── p3gxstransitems.cc │ └── p3gxstransitems.h ├── gxstunnel │ ├── p3gxstunnel.cc │ ├── p3gxstunnel.h │ ├── rsgxstunnelitems.cc │ └── rsgxstunnelitems.h ├── jsonapi │ ├── README.adoc │ ├── async-method-wrapper-template.cpp.tmpl │ ├── jsonapi-generator-doxygen.conf │ ├── jsonapi-generator.py │ ├── jsonapi.cpp │ ├── jsonapi.h │ ├── jsonapiitems.h │ ├── method-wrapper-template.cpp.tmpl │ ├── p3webui.cc │ └── p3webui.h ├── libretroshare.pro ├── pgp │ ├── openpgpsdkhandler.cc │ ├── openpgpsdkhandler.h │ ├── pgpauxutils.cc │ ├── pgpauxutils.h │ ├── pgphandler.cc │ ├── pgphandler.h │ ├── pgpkeyutil.cc │ ├── pgpkeyutil.h │ ├── rnppgphandler.cc │ ├── rnppgphandler.h │ ├── rscertificate.cc │ └── rscertificate.h ├── plugins │ ├── dlfcn_win32.cc │ ├── dlfcn_win32.h │ ├── pluginmanager.cc │ ├── pluginmanager.h │ ├── rscacheservice.h │ └── rspqiservice.h ├── pqi │ ├── authgpg.cc │ ├── authgpg.h │ ├── authssl.cc │ ├── authssl.h │ ├── p3cfgmgr.cc │ ├── p3cfgmgr.h │ ├── p3historymgr.cc │ ├── p3historymgr.h │ ├── p3linkmgr.cc │ ├── p3linkmgr.h │ ├── p3netmgr.cc │ ├── p3netmgr.h │ ├── p3notify.cc │ ├── p3notify.h │ ├── p3peermgr.cc │ ├── p3peermgr.h │ ├── p3servicecontrol.cc │ ├── p3servicecontrol.h │ ├── p3upnpmgr.h │ ├── pqi.h │ ├── pqi_base.h │ ├── pqiassist.h │ ├── pqibin.cc │ ├── pqibin.h │ ├── pqifdbin.cc │ ├── pqifdbin.h │ ├── pqihandler.cc │ ├── pqihandler.h │ ├── pqihash.h │ ├── pqiindic.h │ ├── pqiipset.cc │ ├── pqiipset.h │ ├── pqilistener.h │ ├── pqiloopback.cc │ ├── pqiloopback.h │ ├── pqimonitor.cc │ ├── pqimonitor.h │ ├── pqinetstatebox.cc │ ├── pqinetstatebox.h │ ├── pqinetwork.cc │ ├── pqinetwork.h │ ├── pqiperson.cc │ ├── pqiperson.h │ ├── pqipersongrp.cc │ ├── pqipersongrp.h │ ├── pqiproxy.cc │ ├── pqiproxy.h │ ├── pqiqos.cc │ ├── pqiqos.h │ ├── pqiqosstreamer.cc │ ├── pqiqosstreamer.h │ ├── pqiservice.cc │ ├── pqiservice.h │ ├── pqiservicemonitor.h │ ├── pqissl.cc │ ├── pqissl.h │ ├── pqissli2psam3.cpp │ ├── pqissli2psam3.h │ ├── pqissllistener.cc │ ├── pqissllistener.h │ ├── pqisslpersongrp.cc │ ├── pqisslpersongrp.h │ ├── pqisslproxy.cc │ ├── pqisslproxy.h │ ├── pqissludp.cc │ ├── pqissludp.h │ ├── pqistore.cc │ ├── pqistore.h │ ├── pqistreamer.cc │ ├── pqistreamer.h │ ├── pqithreadstreamer.cc │ ├── pqithreadstreamer.h │ ├── rstcpsocket.cc │ ├── rstcpsocket.h │ ├── sslfns.cc │ └── sslfns.h ├── retroshare │ ├── rsbanlist.h │ ├── rsbroadcastdiscovery.h │ ├── rsconfig.h │ ├── rsdht.h │ ├── rsdisc.h │ ├── rsevents.h │ ├── rsexpr.h │ ├── rsfiles.h │ ├── rsflags.h │ ├── rsfriendserver.h │ ├── rsgossipdiscovery.h │ ├── rsgrouter.h │ ├── rsgxschannels.h │ ├── rsgxscircles.h │ ├── rsgxscommon.h │ ├── rsgxsdistsync.h │ ├── rsgxsflags.h │ ├── rsgxsforums.h │ ├── rsgxsiface.h │ ├── rsgxsifacehelper.h │ ├── rsgxsifacetypes.h │ ├── rsgxsservice.h │ ├── rsgxstrans.h │ ├── rsgxstunnel.h │ ├── rshistory.h │ ├── rsidentity.h │ ├── rsids.h │ ├── rsiface.h │ ├── rsinit.h │ ├── rsjsonapi.h │ ├── rsmsgs.h │ ├── rsnotify.h │ ├── rspeers.h │ ├── rsphoto.h │ ├── rsplugin.h │ ├── rsposted.h │ ├── rsreputations.h │ ├── rsrtt.h │ ├── rsservicecontrol.h │ ├── rsstatus.h │ ├── rstokenservice.h │ ├── rstor.h │ ├── rsturtle.h │ ├── rstypes.h │ ├── rsversion.h │ ├── rswebui.h │ ├── rswiki.h │ └── rswire.h ├── rs_android │ ├── AndroidManifest.xml │ ├── LocalArray.h │ ├── README-ifaddrs-android.adoc │ ├── ScopedFd.h │ ├── androidcoutcerrcatcher.hpp │ ├── errorconditionwrap.cpp │ ├── ifaddrs-android.h │ ├── org │ │ └── retroshare │ │ │ └── service │ │ │ ├── AssetHelper.java │ │ │ ├── ErrorConditionWrap.java │ │ │ └── RetroShareServiceAndroid.java │ ├── retroshareserviceandroid.cpp │ ├── retroshareserviceandroid.hpp │ ├── rsjni.cpp │ └── rsjni.hpp ├── rs_upnp │ ├── UPnPBase.cpp │ ├── UPnPBase.h │ ├── upnp18_retrocompat.h │ ├── upnphandler_libupnp.cc │ ├── upnphandler_libupnp.h │ ├── upnphandler_miniupnp.cc │ ├── upnphandler_miniupnp.h │ ├── upnptest.cc │ ├── upnputil.cc │ └── upnputil.h ├── rsitems │ ├── itempriorities.h │ ├── rsbanlistitems.cc │ ├── rsbanlistitems.h │ ├── rsbwctrlitems.cc │ ├── rsbwctrlitems.h │ ├── rsconfigitems.cc │ ├── rsconfigitems.h │ ├── rsfiletransferitems.cc │ ├── rsfiletransferitems.h │ ├── rsgxschannelitems.cc │ ├── rsgxschannelitems.h │ ├── rsgxscircleitems.cc │ ├── rsgxscircleitems.h │ ├── rsgxscommentitems.cc │ ├── rsgxscommentitems.h │ ├── rsgxsforumitems.cc │ ├── rsgxsforumitems.h │ ├── rsgxsiditems.cc │ ├── rsgxsiditems.h │ ├── rsgxsitems.cc │ ├── rsgxsitems.h │ ├── rsgxsrecognitems.cc │ ├── rsgxsrecognitems.h │ ├── rsgxsreputationitems.cc │ ├── rsgxsreputationitems.h │ ├── rsgxsupdateitems.cc │ ├── rsgxsupdateitems.h │ ├── rsheartbeatitems.h │ ├── rshistoryitems.cc │ ├── rshistoryitems.h │ ├── rsitem.h │ ├── rsmsgitems.cc │ ├── rsmsgitems.h │ ├── rsnxsitems.cc │ ├── rsnxsitems.h │ ├── rsphotoitems.cc │ ├── rsphotoitems.h │ ├── rspluginitems.h │ ├── rsposteditems.cc │ ├── rsposteditems.h │ ├── rsrttitems.cc │ ├── rsrttitems.h │ ├── rsserviceids.h │ ├── rsserviceinfoitems.cc │ ├── rsserviceinfoitems.h │ ├── rsstatusitems.h │ ├── rswikiitems.cc │ ├── rswikiitems.h │ ├── rswireitems.cc │ └── rswireitems.h ├── rsserver │ ├── p3face-config.cc │ ├── p3face-info.cc │ ├── p3face-server.cc │ ├── p3face.h │ ├── p3history.cc │ ├── p3history.h │ ├── p3msgs.cc │ ├── p3msgs.h │ ├── p3peers.cc │ ├── p3peers.h │ ├── p3serverconfig.cc │ ├── p3serverconfig.h │ ├── p3status.cc │ ├── p3status.h │ ├── rsaccounts.cc │ ├── rsaccounts.h │ ├── rsinit.cc │ ├── rsloginhandler.cc │ └── rsloginhandler.h ├── serialiser │ ├── rsbaseserial.cc │ ├── rsbaseserial.h │ ├── rsserial.cc │ ├── rsserial.h │ ├── rsserializable.cc │ ├── rsserializable.h │ ├── rsserializer.cc │ ├── rsserializer.h │ ├── rstlvaddrs.cc │ ├── rstlvaddrs.h │ ├── rstlvbanlist.cc │ ├── rstlvbanlist.h │ ├── rstlvbase.cc │ ├── rstlvbase.h │ ├── rstlvbinary.cc │ ├── rstlvbinary.h │ ├── rstlvfileitem.cc │ ├── rstlvfileitem.h │ ├── rstlvgenericmap.h │ ├── rstlvgenericmap.inl │ ├── rstlvgenericparam.cc │ ├── rstlvgenericparam.h │ ├── rstlvidset.cc │ ├── rstlvidset.h │ ├── rstlvimage.cc │ ├── rstlvimage.h │ ├── rstlvitem.cc │ ├── rstlvitem.h │ ├── rstlvkeys.cc │ ├── rstlvkeys.h │ ├── rstlvkeyvalue.cc │ ├── rstlvkeyvalue.h │ ├── rstlvlist.h │ ├── rstlvmaps.h │ ├── rstlvstring.cc │ ├── rstlvstring.h │ ├── rstypeserializer.cc │ └── rstypeserializer.h ├── services │ ├── autoproxy │ │ ├── p3i2psam3.cpp │ │ ├── p3i2psam3.h │ │ ├── rsautoproxymonitor.cc │ │ └── rsautoproxymonitor.h │ ├── broadcastdiscoveryservice.cc │ ├── broadcastdiscoveryservice.h │ ├── p3banlist.cc │ ├── p3banlist.h │ ├── p3bwctrl.cc │ ├── p3bwctrl.h │ ├── p3gxschannels.cc │ ├── p3gxschannels.h │ ├── p3gxscircles.cc │ ├── p3gxscircles.h │ ├── p3gxscommon.cc │ ├── p3gxscommon.h │ ├── p3gxsforums.cc │ ├── p3gxsforums.h │ ├── p3gxsreputation.cc │ ├── p3gxsreputation.h │ ├── p3heartbeat.cc │ ├── p3heartbeat.h │ ├── p3idservice.cc │ ├── p3idservice.h │ ├── p3msgservice.cc │ ├── p3msgservice.h │ ├── p3photoservice.cc │ ├── p3photoservice.h │ ├── p3postbase.cc │ ├── p3postbase.h │ ├── p3posted.cc │ ├── p3posted.h │ ├── p3rtt.cc │ ├── p3rtt.h │ ├── p3service.cc │ ├── p3service.h │ ├── p3serviceinfo.cc │ ├── p3serviceinfo.h │ ├── p3statusservice.cc │ ├── p3statusservice.h │ ├── p3wiki.cc │ ├── p3wiki.h │ ├── p3wire.cc │ ├── p3wire.h │ ├── rseventsservice.cc │ └── rseventsservice.h ├── tcponudp │ ├── bio_tou.h │ ├── bss_tou.cc │ ├── rsudpstack.h │ ├── tcppacket.cc │ ├── tcppacket.h │ ├── tcpstream.cc │ ├── tcpstream.h │ ├── tou.cc │ ├── tou.h │ ├── udppeer.cc │ ├── udppeer.h │ ├── udprelay.cc │ ├── udprelay.h │ ├── udpstunner.cc │ └── udpstunner.h ├── tests │ ├── TestNotes.txt │ ├── common │ │ └── testutils.h │ ├── dbase │ │ ├── ficachetest.cc │ │ ├── fimontest.cc │ │ ├── fisavetest.cc │ │ ├── fitest2.cc │ │ └── searchtest.cc │ ├── ft │ │ ├── TestNotes.txt │ │ ├── ftcontrollertest.cc │ │ ├── ftcontrollertest.sh │ │ ├── ftcrc32test.cc │ │ ├── ftcrossprovidercreatortest.cc │ │ ├── ftdata_dummy.cc │ │ ├── ftdata_dummy.h │ │ ├── ftdataplextest.cc │ │ ├── ftextralisttest.cc │ │ ├── ftfilecreatortest.cc │ │ ├── ftfilemappertest.cc │ │ ├── ftfileprovidertest.cc │ │ ├── ftsearch_dummy.cc │ │ ├── ftsearch_dummy.h │ │ ├── ftserver1test.cc │ │ ├── ftserver1test.sh │ │ ├── ftserver2test.cc │ │ ├── ftserver2test.sh │ │ ├── ftserver3test.cc │ │ ├── ftserver3test.sh │ │ ├── fttransfermoduletest.cc │ │ ├── pqitestor.cc │ │ └── pqitestor.h │ ├── general │ │ ├── memory_management_test.cc │ │ ├── netsetup_test.cc │ │ ├── pgpkey_test.cc │ │ └── random_test.cc │ ├── gxs │ │ ├── common │ │ │ ├── data_support.cc │ │ │ ├── data_support.h │ │ │ ├── support.cc │ │ │ └── support.h │ │ ├── data_service │ │ │ ├── nxs_tests.pro │ │ │ ├── rsdataservice_test.cc │ │ │ ├── rsdataservice_test.h │ │ │ └── rsgxsdata_test.cc │ │ ├── gen_exchange │ │ │ ├── genexchange_test.pro │ │ │ ├── genexchangetester.cpp │ │ │ ├── genexchangetester.h │ │ │ ├── genexchangetestservice.cpp │ │ │ ├── genexchangetestservice.h │ │ │ ├── gxsmsgrelatedtest.cpp │ │ │ ├── gxsmsgrelatedtest.h │ │ │ ├── gxspublishgrouptest.cc │ │ │ ├── gxspublishgrouptest.h │ │ │ ├── gxspublishmsgtest.cc │ │ │ ├── gxspublishmsgtest.h │ │ │ ├── rsdummyservices.cc │ │ │ ├── rsdummyservices.h │ │ │ └── rsgenexchange_test.cc │ │ └── nxs_test │ │ │ ├── nxs_tests.pro │ │ │ ├── nxstesthub.cc │ │ │ ├── nxstesthub.h │ │ │ ├── nxstestscenario.cc │ │ │ ├── nxstestscenario.h │ │ │ └── rsgxsnetservice_test.cc │ ├── network_simulator │ │ ├── README.txt │ │ ├── gui │ │ │ ├── GlobalRouterStatistics.cpp │ │ │ ├── GlobalRouterStatistics.h │ │ │ ├── GlobalRouterStatistics.ui │ │ │ ├── NetworkSimulatorGUI.cpp │ │ │ ├── NetworkSimulatorGUI.h │ │ │ ├── NetworkSimulatorGUI.ui │ │ │ ├── NetworkViewer.cpp │ │ │ ├── NetworkViewer.h │ │ │ ├── RsAutoUpdatePage.cpp │ │ │ ├── RsAutoUpdatePage.h │ │ │ ├── TurtleRouterStatistics.cpp │ │ │ ├── TurtleRouterStatistics.h │ │ │ ├── TurtleRouterStatistics.ui │ │ │ ├── gui.pro │ │ │ └── main.cpp │ │ ├── network_simulator.pro │ │ └── nscore │ │ │ ├── FakeComponents.h │ │ │ ├── MainLoop.cpp │ │ │ ├── MonitoredGRouterClient.cpp │ │ │ ├── MonitoredGRouterClient.h │ │ │ ├── MonitoredRsPeers.cpp │ │ │ ├── MonitoredRsPeers.h │ │ │ ├── MonitoredTurtleClient.cpp │ │ │ ├── MonitoredTurtleClient.h │ │ │ ├── Network.cpp │ │ │ ├── Network.h │ │ │ ├── PeerNode.cpp │ │ │ ├── PeerNode.h │ │ │ └── nscore.pro │ ├── perform_all_auto_tests.sh │ ├── pgp │ │ ├── test_certificate.cc │ │ ├── test_certificate.newformat.rsc │ │ ├── test_certificate.oldformat.rsc │ │ ├── test_certificate.sh │ │ ├── test_identity_import.c │ │ ├── test_key_parsing.cc │ │ ├── test_key_parsing.sh │ │ ├── test_pgp_handler.cc │ │ ├── test_pgp_handler.sh │ │ ├── test_pgp_signature_parsing.cc │ │ └── test_pubring.gpg │ ├── pqi │ │ ├── TestNotes.txt │ │ ├── conn_harness.cc │ │ ├── conn_harness.h │ │ ├── conn_test.cc │ │ ├── dht_test.cc │ │ ├── dnsresolver_test.cc │ │ ├── extaddrfinder_test.cc │ │ ├── gpgme_tst.c │ │ ├── net_test.cc │ │ ├── net_test1.cc │ │ ├── p3connmgr_connect_test.cc │ │ ├── p3connmgr_reset_test.cc │ │ ├── pkt_test.cc │ │ ├── pkt_test.h │ │ ├── ppg_harness.cc │ │ ├── ppg_harness.h │ │ ├── pqiarchive_test.cc │ │ ├── pqiipset_test.cc │ │ ├── pqiperson_test.cc │ │ ├── pqipersongrp_test.cc │ │ ├── pqiqos_test.cc │ │ ├── testconnect.cc │ │ └── testconnect.h │ ├── printcache │ │ ├── main.cpp │ │ ├── main_extended.cpp │ │ └── printcache.pro │ ├── scripts │ │ ├── checks.mk │ │ ├── config-cygwin.mk │ │ ├── config-linux.mk │ │ ├── config-macosx.mk │ │ ├── config-mingw.mk │ │ ├── config.mk │ │ ├── regress.mk │ │ └── rules.mk │ ├── serialiser │ │ ├── TestNotes.txt │ │ ├── distribitem_test.cc │ │ ├── distribitem_test.h │ │ ├── perform_auto_tests.sh │ │ ├── rsbaseitem_test.cc │ │ ├── rsconfigitem_test.cc │ │ ├── rsconfigitem_test.h │ │ ├── rsgrouteritem_test.cc │ │ ├── rsgrouteritem_test.h │ │ ├── rsgxsupdateitem_test.cc │ │ ├── rsgxsupdateitem_test.h │ │ ├── rsmsgitem_test.cc │ │ ├── rsmsgitem_test.h │ │ ├── rsnxsitems_test.cc │ │ ├── rsnxsitems_test.h │ │ ├── rsphotoitem_test.cc │ │ ├── rsphotoitem_test.h │ │ ├── rsserial_test.cc │ │ ├── rsstatusitem_test.cc │ │ ├── rsstatusitem_test.h │ │ ├── rstlvutil.cc │ │ ├── rstlvutil.h │ │ ├── rstlvwidetest.cc │ │ ├── rstunnelitem_test.cc │ │ ├── rsturtleitem_test.cc │ │ ├── support.cc │ │ ├── support.h │ │ ├── tlvbase_test.cc │ │ ├── tlvbase_test2.cc │ │ ├── tlvitems_test.cc │ │ ├── tlvkey_test.cc │ │ ├── tlvrandom_test.cc │ │ ├── tlvstack_test.cc │ │ ├── tlvtypes_test.cc │ │ └── valgrind_all.sh │ ├── services │ │ ├── chatservicetest.cc │ │ ├── chatservicetest.h │ │ ├── chattest.cc │ │ ├── distribtest.cc │ │ ├── forumservicetest.cc │ │ ├── forumservicetest.h │ │ ├── servicetest.cc │ │ └── servicetest.h │ ├── tcponudp │ │ ├── bidir_tou.cc │ │ ├── bidir_tou.sh │ │ ├── internal_tou.cc │ │ ├── largefile_tou.cc │ │ ├── pair_tou.cc │ │ ├── reset_tou.cc │ │ ├── stacks_tou.cc │ │ ├── stacks_tou.sh │ │ ├── test_tou.cc │ │ ├── test_tou.sh │ │ ├── timed_tou.cc │ │ ├── timed_tou.sh │ │ ├── udp_server.cc │ │ ├── udp_server.sh │ │ ├── udpsock_test.cc │ │ ├── udpsock_test.sh │ │ ├── udpsort_test.cc │ │ ├── udpsort_test.sh │ │ ├── udptestfn.cc │ │ └── udptestfn.h │ ├── upnp │ │ └── upnpforward.cc │ ├── utest.h │ └── util │ │ ├── aes_test.cc │ │ ├── compress_test.cc │ │ ├── dir2test.cc │ │ ├── dirtest.cc │ │ ├── sha1_test.cc │ │ ├── test_fifo.cpp │ │ ├── testcontentvalue.cpp │ │ ├── testretrocursor.cpp │ │ └── testretrodb.cpp ├── tor │ ├── AddOnionCommand.cpp │ ├── AddOnionCommand.h │ ├── AuthenticateCommand.cpp │ ├── AuthenticateCommand.h │ ├── CryptoKey.cpp │ ├── CryptoKey.h │ ├── GetConfCommand.cpp │ ├── GetConfCommand.h │ ├── HiddenService.cpp │ ├── HiddenService.h │ ├── PendingOperation.cpp │ ├── PendingOperation.h │ ├── ProtocolInfoCommand.cpp │ ├── ProtocolInfoCommand.h │ ├── SetConfCommand.cpp │ ├── SetConfCommand.h │ ├── StrUtil.cpp │ ├── StrUtil.h │ ├── TorControl.cpp │ ├── TorControl.h │ ├── TorControlCommand.cpp │ ├── TorControlCommand.h │ ├── TorControlSocket.cpp │ ├── TorControlSocket.h │ ├── TorManager.cpp │ ├── TorManager.h │ ├── TorProcess.cpp │ ├── TorProcess.h │ ├── TorTypes.h │ ├── Useful.h │ └── bytearray.h ├── turtle │ ├── p3turtle.cc │ ├── p3turtle.h │ ├── rsturtleitem.cc │ ├── rsturtleitem.h │ ├── turtleclientservice.h │ ├── turtlestatistics.h │ └── turtletypes.h ├── unfinished │ ├── db_acadeeb.h │ ├── db_wire.h │ ├── mail │ │ ├── directmailservice.cc │ │ ├── directmailservice.h │ │ ├── mailtransport.cc │ │ └── mailtransport.h │ ├── p3portservice.cc │ ├── p3portservice.h │ ├── p3tunnel.cc │ ├── p3tunnel.h │ ├── rstlvdsdv.cc │ └── rstlvdsdv.h ├── unused │ ├── p3dsdv.cc │ ├── p3dsdv.h │ ├── pqiarchive.cc │ ├── pqiarchive.h │ ├── rscompress.cc │ ├── rscompress.h │ ├── rsdsdv.h │ ├── rsdsdvitems.cc │ └── rsdsdvitems.h ├── use_libretroshare.pri └── util │ ├── argstream.h │ ├── contentvalue.cc │ ├── contentvalue.h │ ├── cxx11retrocompat.h │ ├── cxx14retrocompat.h │ ├── cxx17retrocompat.h │ ├── cxx23retrocompat.h │ ├── dnsresolver.cc │ ├── dnsresolver.h │ ├── extaddrfinder.cc │ ├── extaddrfinder.h │ ├── folderiterator.cc │ ├── folderiterator.h │ ├── i2pcommon.cpp │ ├── i2pcommon.h │ ├── largefile_retrocompat.hpp │ ├── radix32.h │ ├── radix64.h │ ├── retrodb.cc │ ├── retrodb.h │ ├── rsbase64.cc │ ├── rsbase64.h │ ├── rsdbbind.cc │ ├── rsdbbind.h │ ├── rsdebug.cc │ ├── rsdebug.h │ ├── rsdebuglevel0.h │ ├── rsdebuglevel1.h │ ├── rsdebuglevel2.h │ ├── rsdebuglevel3.h │ ├── rsdebuglevel4.h │ ├── rsdeprecate.h │ ├── rsdir.cc │ ├── rsdir.h │ ├── rsdiscspace.cc │ ├── rsdiscspace.h │ ├── rsdnsutils.cc │ ├── rsendian.h │ ├── rserrorbubbleorexit.h │ ├── rsexpr.cc │ ├── rsfile.cc │ ├── rsfile.h │ ├── rsinitedptr.h │ ├── rsjson.cc │ ├── rsjson.h │ ├── rskbdinput.cc │ ├── rskbdinput.h │ ├── rslikelyunlikely.h │ ├── rsmacrosugar.hpp │ ├── rsmemcache.h │ ├── rsmemory.h │ ├── rsnet.cc │ ├── rsnet.h │ ├── rsnet_ss.cc │ ├── rsprint.cc │ ├── rsprint.h │ ├── rsrandom.cc │ ├── rsrandom.h │ ├── rsrecogn.cc │ ├── rsrecogn.h │ ├── rsstacktrace.cc │ ├── rsstd.h │ ├── rsstring.cc │ ├── rsstring.h │ ├── rsthreads.cc │ ├── rsthreads.h │ ├── rstickevent.cc │ ├── rstickevent.h │ ├── rstime.cc │ ├── rstime.h │ ├── rsurl.cc │ ├── rsurl.h │ ├── rswin.h │ ├── smallobject.cc │ ├── smallobject.h │ └── stacktrace.h └── tests ├── librssimulator ├── librssimulator.pro ├── peer │ ├── FakeLinkMgr.h │ ├── FakeNetMgr.h │ ├── FakeNxsNetMgr.h │ ├── FakePeerMgr.h │ ├── FakePublisher.h │ ├── FakeServiceControl.h │ ├── PeerNode.cc │ └── PeerNode.h └── testing │ ├── IsolatedServiceTester.cc │ ├── IsolatedServiceTester.h │ ├── SetFilter.cc │ ├── SetFilter.h │ ├── SetPacket.h │ ├── SetServiceTester.cc │ └── SetServiceTester.h ├── test_JSON_API_DirDetails_handle_correct_64bit_integer_type.sh └── unittests ├── libretroshare ├── crypto │ └── chacha20_test.cc ├── dbase │ ├── ficachetest.cc │ ├── fimontest.cc │ ├── fisavetest.cc │ ├── fitest2.cc │ └── searchtest.cc ├── gxs │ ├── common │ │ ├── data_support.cc │ │ └── data_support.h │ ├── data_service │ │ ├── rsdataservice_test.cc │ │ ├── rsdataservice_test.h │ │ └── rsgxsdata_test.cc │ ├── gen_exchange │ │ ├── genexchange_test.pro │ │ ├── genexchangetester.cc │ │ ├── genexchangetester.h │ │ ├── genexchangetestservice.cc │ │ ├── genexchangetestservice.h │ │ ├── gxsmsgrelatedtest.cc │ │ ├── gxsmsgrelatedtest.h │ │ ├── gxspublishgrouptest.cc │ │ ├── gxspublishgrouptest.h │ │ ├── gxspublishmsgtest.cc │ │ ├── gxspublishmsgtest.h │ │ ├── gxsteststats.cpp │ │ ├── gxsteststats.h │ │ ├── rsdummyservices.cc │ │ ├── rsdummyservices.h │ │ └── rsgenexchange_test.cc │ ├── nxs_test │ │ ├── nxsdummyservices.cc │ │ ├── nxsdummyservices.h │ │ ├── nxsgrpsync_test.cc │ │ ├── nxsgrpsync_test.h │ │ ├── nxsgrpsyncdelayed.cc │ │ ├── nxsgrpsyncdelayed.h │ │ ├── nxsgrptestscenario.cc │ │ ├── nxsgrptestscenario.h │ │ ├── nxsmsgsync_test.cc │ │ ├── nxsmsgsync_test.h │ │ ├── nxsmsgtestscenario.cc │ │ ├── nxsmsgtestscenario.h │ │ ├── nxstesthub.cc │ │ ├── nxstesthub.h │ │ ├── nxstestscenario.h │ │ ├── rsgxsnetservice_test.cc │ │ └── rssharedptr.h │ └── security │ │ └── gxssecurity_test.cc ├── serialiser │ ├── rsbaseitem_test.cc │ ├── rsconfigitem_test.cc │ ├── rsgrouteritem_test.cc │ ├── rsgxsiditem_test.cc │ ├── rsgxsupdateitem_test.cc │ ├── rsmsgitem_test.cc │ ├── rsnxsitems_test.cc │ ├── rsphotoitem_test.cc │ ├── rsstatusitem_test.cc │ ├── rstlvutil.cc │ ├── rstlvutil.h │ ├── rsturtleitem_test.cc │ ├── support.cc │ ├── support.h │ ├── tlvbase_test.cc │ ├── tlvbase_test2.cc │ ├── tlvitems_test.cc │ ├── tlvkey_test.cc │ ├── tlvrandom_test.cc │ ├── tlvstack_test.cc │ └── tlvtypes_test.cc └── services │ ├── gxs │ ├── FakePgpAuxUtils.cc │ ├── FakePgpAuxUtils.h │ ├── GxsIsolatedServiceTester.cc │ ├── GxsIsolatedServiceTester.h │ ├── GxsPairServiceTester.cc │ ├── GxsPairServiceTester.h │ ├── GxsPeerNode.cc │ ├── GxsPeerNode.h │ ├── RsGxsNetServiceTester.cc │ ├── RsGxsNetServiceTester.h │ ├── gxscircle_mintest.cc │ ├── gxscircle_tests.cc │ ├── gxstestservice.cc │ ├── gxstestservice.h │ ├── nxsbasic_test.cc │ ├── nxspair_tests.cc │ ├── rsgxstestitems.cc │ └── rsgxstestitems.h │ └── status │ └── status_test.cc ├── run_tests.sh ├── unittests.cc └── unittests.pro /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | 7 | # Ignore Gradle local options 8 | local.properties 9 | 10 | # Ignore Qt Creator local CMake configuration 11 | CMakeLists.txt.user 12 | 13 | # Build artifacts 14 | Makefile.libretroshare 15 | *.a 16 | *.o 17 | -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: RetroShare 3 | Upstream-Contact: RetroShare Team 4 | 5 | Files: * 6 | Copyright: 2004-2022, Retroshare Team 7 | License: AGPL-3.0-only 8 | 9 | Files: src/* 10 | Copyright: 2004-2022, Retroshare Team 11 | License: LGPL-3.0-or-later 12 | 13 | Files: src/deep_search/* 14 | Copyright: 2018-2022, Gioacchino Mazzurco 15 | 2019-2022, Asociación Civil Altermundi 16 | License: AGPL-3.0-only 17 | 18 | Files: src/jsonapi/* 19 | Copyright: 2018-2022, Gioacchino Mazzurco 20 | 2019-2022, Asociación Civil Altermundi 21 | License: AGPL-3.0-or-later 22 | 23 | Files: src/tor/* 24 | Copyright: 2014, John Brooks 25 | 2017-2022, Retroshare Team 26 | License: BSD-3-Clause 27 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | .reuse/dep5 -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License Copyright (c) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice (including the next 11 | paragraph) shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 17 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 19 | OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.asciidoc: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Retroshare Team 2 | // SPDX-FileCopyrightText: 2022 Gioacchino Mazzurco 3 | // SPDX-FileCopyrightText: 2022 Asociación Civil Altermundi 4 | // SPDX-License-Identifier: CC-BY-SA-4.0 5 | 6 | = RetroShare library 7 | 8 | RetroShare is a decentralized, private, secure, cross-platform, communication 9 | software. 10 | 11 | RetroShare functionalities (file sharing, chat, messages, forums, channels...) 12 | are implemented under the hood by libretroshare which offer a documented C++ and 13 | JSON API. 14 | 15 | While RetroShare is an application on it's own, libretroshare is meant to be 16 | used as part of other programs, some of them are 17 | https://retroshare.cc[RetroShare-gui], 18 | https://retroshare.cc[RetroShare-service], 19 | https://elrepo.io/[elRepo.io] 20 | (let us know if there are more). 21 | 22 | 23 | === Continuous integration 24 | 25 | image:https://gitlab.com/RetroShare/libretroshare/badges/master/pipeline.svg[link="https://gitlab.com/RetroShare/libretroshare/-/commits/master",title="pipeline status"] 26 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RetroShare/libretroshare/ac83e00ea7a26cd6cf57cefef745d6dcfd07e5da/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /misc/Android/proguard-keep-libretroshare-java-classes.pro: -------------------------------------------------------------------------------- 1 | # Keep libretroshare Java classes 2 | -keep class org.retroshare.service.** { *; } 3 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.1.1/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'libretroshare' 11 | -------------------------------------------------------------------------------- /src/file_sharing/directory_list.h: -------------------------------------------------------------------------------- 1 | // This class keeps a shared directory. It's quite the equivalent of the old "FileIndex" class 2 | // The main difference is that it is 3 | // - extensible 4 | // - fast to search (at least for hashes). Should provide possibly multiple search handles for 5 | // the same file, e.g. if connexion is encrypted. 6 | // - abstracts the browsing in a same manner. 7 | // 8 | class SharedDirectoryList 9 | { 10 | public: 11 | 12 | DirEntry mRoot ; 13 | }; 14 | -------------------------------------------------------------------------------- /src/gxs/rsnxsobserver.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * RetroShare General eXchange System * 3 | * * 4 | * Copyright (C) 2021 Gioacchino Mazzurco * 5 | * Copyright (C) 2021 Asociación Civil Altermundi * 6 | * * 7 | * This program is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU Lesser General Public License as * 9 | * published by the Free Software Foundation, either version 3 of the * 10 | * License, or (at your option) any later version. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU Lesser General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU Lesser General Public License * 18 | * along with this program. If not, see . * 19 | * * 20 | *******************************************************************************/ 21 | 22 | #include "gxs/rsnxsobserver.h" 23 | 24 | const RsNxsObserverErrorCategory RsNxsObserverErrorCategory::instance; 25 | 26 | std::error_condition RsNxsObserverErrorCategory::default_error_condition(int ev) 27 | const noexcept 28 | { 29 | switch(static_cast(ev)) 30 | { 31 | case RsNxsObserverErrorNum::NOT_OVERRIDDEN_BY_OBSERVER: 32 | return std::errc::operation_not_supported; 33 | default: 34 | return std::error_condition(ev, *this); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/jsonapi/p3webui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RetroShare Web User Interface 3 | * 4 | * Copyright (C) 2019 Cyril Soler 5 | * Copyright (C) 2022 Gioacchino Mazzurco 6 | * Copyright (C) 2022 Asociación Civil Altermundi 7 | * 8 | * This program is free software: you can redistribute it and/or modify it under 9 | * the terms of the GNU Affero General Public License as published by the 10 | * Free Software Foundation, version 3. 11 | * 12 | * This program is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | * FOR A PARTICULAR PURPOSE. 15 | * See the GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see 19 | * 20 | * SPDX-FileCopyrightText: 2004-2019 RetroShare Team 21 | * SPDX-License-Identifier: AGPL-3.0-only 22 | */ 23 | 24 | #pragma once 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "retroshare/rswebui.h" 31 | #include "jsonapi/jsonapi.h" 32 | 33 | class p3WebUI: public RsWebUi /*, public p3Config */, public JsonApiResourceProvider 34 | { 35 | public: 36 | ~p3WebUI() override = default; 37 | 38 | /// implements RsWebUI 39 | virtual std::error_condition setHtmlFilesDirectory( const std::string& html_dir ) override; 40 | virtual std::string htmlFilesDirectory() const override; 41 | virtual std::error_condition setUserPassword( const std::string& passwd ) override; 42 | 43 | virtual std::error_condition restart() override; 44 | virtual std::error_condition stop() override; 45 | 46 | bool isRunning() const override; 47 | 48 | /// implements JsonApiResourceProvider 49 | virtual std::vector > getResources() const override; 50 | virtual std::string getName() const override { return "Web interface" ; }; 51 | 52 | protected: 53 | 54 | }; 55 | -------------------------------------------------------------------------------- /src/plugins/rscacheservice.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "plugins/pluginmanager.h" 4 | 5 | // This code needs to be re-written to work with GXS. For now it is obsolete. 6 | // 7 | 8 | // The following class abstracts the construction of a cache service. The user only has to 9 | // supply RS with a type ID. If the ID is already in use, RS will complain. 10 | // 11 | class RsCacheService: /* public CacheSource, public CacheStore, */ public p3Config 12 | { 13 | public: 14 | RsCacheService(uint16_t type,uint32_t tick_delay_in_seconds, RsPluginHandler* pgHandler) ; 15 | 16 | uint32_t tickDelay() const { return _tick_delay_in_seconds ; } 17 | virtual void tick() {} 18 | 19 | // Functions from p3config 20 | // 21 | virtual RsSerialiser *setupSerialiser() { return NULL ; } 22 | virtual bool saveList(bool&, std::list&) =0; 23 | virtual bool loadList(std::list&) =0; 24 | 25 | private: 26 | uint32_t _tick_delay_in_seconds ; 27 | }; 28 | -------------------------------------------------------------------------------- /src/plugins/rspqiservice.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "services/p3service.h" 4 | #include "plugins/pluginmanager.h" 5 | 6 | // The following class abstracts the construction of a peer-to-peer service. The user only has to 7 | // supply RS with a type ID. If the ID is already in use, RS will complain. 8 | // 9 | class RsPQIService: public p3Service, public p3Config 10 | { 11 | public: 12 | RsPQIService(uint16_t type,uint32_t tick_delay_in_seconds, RsPluginHandler* pgHandler) ; 13 | 14 | uint32_t tickDelay() const { return _tick_delay_in_seconds ; } 15 | virtual int tick() = 0 ; 16 | 17 | // Functions from p3config 18 | // 19 | virtual RsSerialiser *setupSerialiser() { return NULL ; } 20 | virtual bool saveList(bool&, std::list&) =0 ; 21 | virtual bool loadList(std::list&) =0 ; 22 | 23 | private: 24 | uint32_t _tick_delay_in_seconds ; 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /src/pqi/pqilistener.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * libretroshare/src/pqi: pqilistener.h * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright 2004-2008 by Robert Fernie * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Lesser General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | *******************************************************************************/ 22 | #ifndef MRK_PQI_GENERIC_LISTEN_HEADER 23 | #define MRK_PQI_GENERIC_LISTEN_HEADER 24 | 25 | // operating system specific network header. 26 | #include "pqi/pqinetwork.h" 27 | 28 | class pqilistener 29 | { 30 | public: 31 | pqilistener() {} 32 | virtual ~pqilistener() {} 33 | virtual int tick() { return 1; } 34 | virtual int status() { return 1; } 35 | virtual int setListenAddr(const sockaddr_storage & /*addr*/) { return 1; } 36 | virtual int setuplisten() { return 1; } 37 | virtual int resetlisten() { return 1; } 38 | }; 39 | 40 | 41 | #endif // MRK_PQI_GENERIC_LISTEN_HEADER 42 | -------------------------------------------------------------------------------- /src/pqi/pqissli2psam3.h: -------------------------------------------------------------------------------- 1 | #ifndef PQISSLI2PSAM3_H 2 | #define PQISSLI2PSAM3_H 3 | 4 | #include "pqi/pqissl.h" 5 | #include "services/autoproxy/rsautoproxymonitor.h" 6 | #include "services/autoproxy/p3i2psam3.h" 7 | 8 | // Use a state machine as the whole pqi code is designed around them and some operation (like lookup) might be blocking 9 | enum class pqisslSam3State : uint8_t { 10 | NONE = 0, 11 | DO_LOOKUP, 12 | WAIT_LOOKUP, 13 | DO_CONNECT, 14 | WAIT_CONNECT, 15 | DONE 16 | }; 17 | 18 | class pqissli2psam3 : public pqissl, public autoProxyCallback 19 | { 20 | public: 21 | pqissli2psam3(pqissllistener *l, PQInterface *parent, p3LinkMgr *lm); 22 | 23 | // NetInterface interface 24 | public: 25 | bool connect_parameter(uint32_t type, const std::string &value); 26 | 27 | // pqissl interface 28 | protected: 29 | int Initiate_Connection(); 30 | int net_internal_close(int fd); 31 | 32 | // autoProxyCallback interface 33 | public: 34 | void taskFinished(taskTicket *&ticket); 35 | 36 | private: 37 | bool setupSocket(); 38 | 39 | private: 40 | pqisslSam3State mState; 41 | std::string mI2pAddrB32; 42 | std::string mI2pAddrLong; 43 | 44 | Sam3Connection *mConn; 45 | }; 46 | 47 | #endif // PQISSLI2PSAM3_H 48 | -------------------------------------------------------------------------------- /src/pqi/rstcpsocket.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "util/rsthreads.h" 3 | #include "pqi/pqifdbin.h" 4 | 5 | class RsTcpSocket: public RsFdBinInterface 6 | { 7 | public: 8 | RsTcpSocket(const std::string& tcp_address,uint16_t tcp_port); 9 | RsTcpSocket(); 10 | virtual ~RsTcpSocket()=default; 11 | 12 | enum State: uint8_t { 13 | UNKNOWN = 0x00, 14 | DISCONNECTED = 0x01, 15 | CONNECTED = 0x02 16 | }; 17 | 18 | // Return true when OK, false otherwise. 19 | bool connect(); 20 | 21 | bool connect(const std::string& tcp_address,uint16_t tcp_port); 22 | 23 | // Returns 1 when OK, 0 otherwise. 24 | int close(); 25 | 26 | State connectionState() const { return mState; } 27 | const std::string& connectAddress() const { return mConnectAddress ; } 28 | uint16_t connectPort() const { return mConnectPort ; } 29 | 30 | private: 31 | State mState; 32 | std::string mConnectAddress; 33 | uint16_t mConnectPort; 34 | int mSocket; 35 | }; 36 | 37 | class RsThreadedTcpSocket: public RsTcpSocket, public RsThread 38 | { 39 | public: 40 | RsThreadedTcpSocket(const std::string& tcp_address,uint16_t tcp_port); 41 | RsThreadedTcpSocket(); 42 | virtual ~RsThreadedTcpSocket(); 43 | 44 | virtual void run() override; 45 | }; 46 | 47 | -------------------------------------------------------------------------------- /src/retroshare/rsdisc.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * RetroShare gossip discovery - discovery2 retro-compatibility include * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright (C) 2019 Gioacchino Mazzurco * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Lesser General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | *******************************************************************************/ 22 | #pragma once 23 | 24 | #include "retroshare/rsgossipdiscovery.h" 25 | #include "util/rsdeprecate.h" 26 | 27 | #warning "Including retroshare/rsdisc.h is deprecated, \ 28 | use retroshare/rsgossipdiscovery.h instead" 29 | 30 | using RsDisc RS_DEPRECATED_FOR("RsGossipDiscovery") = RsGossipDiscovery; 31 | 32 | #define rsDisc rsGossipDiscovery.get() 33 | -------------------------------------------------------------------------------- /src/retroshare/rsgxsservice.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * libretroshare/src/retroshare: rsgxsservice.h * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright (C) 2015 Retroshare Team * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Lesser General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | *******************************************************************************/ 22 | #ifndef RSGXSSERVICE_H 23 | #define RSGXSSERVICE_H 24 | 25 | 26 | #include "retroshare/rsgxsifacetypes.h" 27 | #include "retroshare/rstokenservice.h" 28 | 29 | struct RsMsgMetaData ; 30 | typedef uint32_t TurtleRequestId; 31 | 32 | typedef std::map > GxsMsgMetaMap; 33 | typedef std::map > GxsMsgRelatedMetaMap; 34 | 35 | 36 | 37 | #endif // RSGXSSERVICE_H 38 | -------------------------------------------------------------------------------- /src/rs_android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/rs_android/README-ifaddrs-android.adoc: -------------------------------------------------------------------------------- 1 | = README Android ifaddrs 2 | 3 | Android API level < 24 doesn't provide `getifaddrs` and related functions, we 4 | have tested multiple ways to overcome this issue. 5 | 6 | 7 | == Non Weorking alternative implementations 8 | 9 | https://github.com/kmackay/android-ifaddrs 10 | https://github.com/morristech/android-ifaddrs 11 | https://www.openhub.net/p/android-ifaddrs/ 12 | 13 | Compiles but then segfault at runtime. 14 | 15 | 16 | == Qt implementation 17 | 18 | Using `QNetworkInterface::allAddresses()` provided by Qt works but at time of 19 | writing (Q4 2021) on newer Android the log is flooded by warnings as we reported 20 | here 21 | https://bugreports.qt.io/browse/QTBUG-78659 22 | plus depending on Qt networking module just for this is frustrating. 23 | 24 | Update: the warning flood seems have been fixed in later Qt versions 25 | https://bugreports.qt.io/browse/QTBUG-86394 26 | 27 | This solution was the first working we implemented in our code it has been 28 | removed to avoid dependency on Qt, as lighter alternatives are possible. 29 | 30 | 31 | == Code copied from Android Gingerbread release 32 | 33 | As explained here 34 | https://stackoverflow.com/a/57112520 35 | 36 | even older Android have `getifaddrs` implementations but doesn't make them 37 | accessible in the API, in particular the one included in Android Gingerbread 38 | 39 | https://android.googlesource.com/platform/libcore/+/refs/heads/gingerbread-release/luni/src/main/native/ifaddrs-android.h 40 | https://android.googlesource.com/platform/libcore/+/refs/heads/gingerbread-release/ 41 | 42 | is particularly easy to include in our code base and compile. 43 | 44 | This solution seems the best fitting and doesn't introduce dependency on Qt. 45 | Newer Android releases (expecially 11) have introduced multiple restrictions 46 | on network information access so we suggest you to prepare different APK for 47 | different API level in order to use the `getifaddrs` provided by Android NDK 48 | which deal gracefully with those restrictions as soon as available. 49 | 50 | -------------------------------------------------------------------------------- /src/rs_android/ScopedFd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SCOPED_FD_H_included 18 | #define SCOPED_FD_H_included 19 | 20 | #include 21 | 22 | // A smart pointer that closes the given fd on going out of scope. 23 | // Use this when the fd is incidental to the purpose of your function, 24 | // but needs to be cleaned up on exit. 25 | class ScopedFd { 26 | public: 27 | explicit ScopedFd(int fd) : fd(fd) { 28 | } 29 | 30 | ~ScopedFd() { 31 | close(fd); 32 | } 33 | 34 | int get() const { 35 | return fd; 36 | } 37 | 38 | private: 39 | int fd; 40 | 41 | // Disallow copy and assignment. 42 | ScopedFd(const ScopedFd&); 43 | void operator=(const ScopedFd&); 44 | }; 45 | 46 | #endif // SCOPED_FD_H_included 47 | -------------------------------------------------------------------------------- /src/rs_android/org/retroshare/service/ErrorConditionWrap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * RetroShare 3 | * Copyright (C) 2021 Gioacchino Mazzurco 4 | * Copyright (C) 2021 Asociación Civil Altermundi 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | * 19 | * SPDX-FileCopyrightText: Retroshare Team 20 | * SPDX-License-Identifier: AGPL-3.0-or-later 21 | */ 22 | 23 | package org.retroshare.service; 24 | 25 | public class ErrorConditionWrap 26 | { 27 | public ErrorConditionWrap( 28 | int value, String message, String categoryName ) 29 | { 30 | mValue = value; 31 | mMessage = message; 32 | mCategoryName = categoryName; 33 | } 34 | 35 | public int value() { return mValue; } 36 | public String message() { return mMessage; } 37 | public String categoryName() { return mCategoryName; } 38 | 39 | public boolean toBool() { return mValue != 0; } 40 | 41 | @Override 42 | public String toString() 43 | { return String.format("%d", mValue)+" "+mMessage+" [" + mCategoryName+ "]"; } 44 | 45 | private int mValue = 0; 46 | private String mMessage; 47 | private String mCategoryName; 48 | } 49 | -------------------------------------------------------------------------------- /src/rs_upnp/upnptest.cc: -------------------------------------------------------------------------------- 1 | //this file use miniupnp 2 | 3 | #include 4 | 5 | 6 | int main(int argc, char **argv) 7 | { 8 | 9 | int id = argc % 3; 10 | 11 | /********* 12 | char *fhash1 = "3509426505463458576487"; 13 | char *hash2 = "1549879882341985914515"; 14 | char *hash3 = "8743598543269526505434"; 15 | 16 | int port1 = 8754; 17 | int port2 = 2355; 18 | int port3 = 6621; 19 | **********/ 20 | 21 | std::cerr << "Starting dhttest Id: " << id << std::endl; 22 | /******************************** WINDOWS/UNIX SPECIFIC PART ******************/ 23 | #ifndef WINDOWS_SYS 24 | /********************************** WINDOWS/UNIX SPECIFIC PART ******************/ 25 | #else 26 | // Windows Networking Init. 27 | WORD wVerReq = MAKEWORD(2,2); 28 | WSADATA wsaData; 29 | 30 | if (0 != WSAStartup(wVerReq, &wsaData)) 31 | { 32 | std::cerr << "Failed to Startup Windows Networking"; 33 | std::cerr << std::endl; 34 | } 35 | else 36 | { 37 | std::cerr << "Started Windows Networking"; 38 | std::cerr << std::endl; 39 | } 40 | 41 | #endif 42 | /********************************** WINDOWS/UNIX SPECIFIC PART ******************/ 43 | 44 | #ifdef PTW32_STATIC_LIB 45 | pthread_win32_process_attach_np(); 46 | #endif 47 | 48 | 49 | upnphandler upnp; 50 | 51 | upnp.setInternalPort(12122); 52 | 53 | for(int i = 0; 1; i++) 54 | { 55 | 56 | /********************************** WINDOWS/UNIX SPECIFIC PART ******************/ 57 | #ifndef WINDOWS_SYS 58 | sleep(1); 59 | #else 60 | 61 | Sleep(1000); 62 | #endif 63 | /********************************** WINDOWS/UNIX SPECIFIC PART ******************/ 64 | 65 | if (i % 120 == 10) 66 | { 67 | /* start up a forward */ 68 | upnp.enable(true); 69 | 70 | } 71 | 72 | if (i % 120 == 60) 73 | { 74 | /* shutdown a forward */ 75 | upnp.restart(); 76 | } 77 | 78 | if (i % 120 == 100) 79 | { 80 | /* shutdown a forward */ 81 | upnp.shutdown(); 82 | } 83 | 84 | } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/serialiser/rsserializable.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * libretroshare: retroshare core library * 3 | * * 4 | * Copyright (C) 2018 Gioacchino Mazzurco * 5 | * * 6 | * This program is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU Lesser General Public License as * 8 | * published by the Free Software Foundation, either version 3 of the * 9 | * License, or (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU Lesser General Public License * 17 | * along with this program. If not, see . * 18 | * * 19 | *******************************************************************************/ 20 | 21 | #include "serialiser/rsserializable.h" 22 | 23 | #include 24 | 25 | std::ostream& operator<<(std::ostream& out, const RsSerializable& serializable) 26 | { 27 | RsGenericSerializer::SerializeContext ctx; 28 | const_cast(serializable) // safe with TO_JSON 29 | .serial_process(RsGenericSerializer::TO_JSON, ctx); 30 | return out << ctx.mJson; 31 | } 32 | -------------------------------------------------------------------------------- /src/serialiser/rstlvmaps.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * libretroshare/src/serialiser: rstlvmaps.h * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright 2014 by Robert Fernie * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Lesser General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | *******************************************************************************/ 22 | #ifndef RS_TLV_MAPS_H 23 | #define RS_TLV_MAPS_H 24 | 25 | class RsTlvOpinionMapRef: public RsTlvGenericMapRef 26 | { 27 | public: 28 | RsTlvOpinionMapRef(std::map &refmap) 29 | :RsTlvGenericMapRef(OPINION, STRING_INT_PAIR, refmap) { return; } 30 | }; 31 | 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /src/tcponudp/bio_tou.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * libretroshare/src/tcponudp: bio_tou.h * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright 2004-2006 by Robert Fernie * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Lesser General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | *******************************************************************************/ 22 | 23 | #ifndef BIO_TCPONUDP_H 24 | #define BIO_TCPONUDP_H 25 | 26 | #include 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | 33 | int BIO_tou_socket_should_retry(int s, int e); 34 | int BIO_tou_socket_non_fatal_error(int error); 35 | 36 | #define BIO_TYPE_TOU_SOCKET (30|0x0400|0x0100) /* NEW rmfern type */ 37 | 38 | BIO_METHOD *BIO_s_tou_socket(void); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | #endif 44 | -------------------------------------------------------------------------------- /src/tests/TestNotes.txt: -------------------------------------------------------------------------------- 1 | 2 | This file documents the high-level status of the regression cases. 3 | -----------+----------------------+------------------------------------------------- 4 | DIRECTORY | STATUS | TODO 5 | -----------+----------------------+------------------------------------------------- 6 | services | NO TESTS | write test framework for services. 7 | turtle | NO TESTS | write tests 8 | rsserver | NO TESTS | write tests 9 | upnp | automatic tests | [--S] 10 | pgp | automatic tests | [---] 11 | util | automatic tests | [---] 12 | dbase | automatic tests | [--S] 13 | pqi | automatic tests | [C--] 14 | ft | automatic tests | [-FS] (ftcontrollertest, ftserver2test, fttransfermoduletest) 15 | tcponudp | automatic tests | [-F-] Takes 15 mins. test_tou,bidir_tou,stacks_tou fail 16 | dht | NO TESTS | write tests 17 | serialiser | automatic tests | [-F-] (tlvrandom_test) 18 | -----------+----------------------+------------------------------------------------- 19 | 20 | Legend: 21 | [---] : nothing to do. All work perfectly. 22 | [ S] : needs scripts 23 | [ F ] : some tests fail 24 | [C ] : some tests don't compile 25 | [E ] : some test execution fail 26 | 27 | Commands: 28 | - to launch tests in a directory: 29 | > \rm *.tstout 30 | > make regress 31 | 32 | - to use parameters: 33 | * create a script [testname].sh where [testname] is the name of the 34 | executable test. It will be used automatically by the above command. 35 | * in the script, use a single command, or if necessary put all commands 36 | on one line using &&. 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/tests/ft/TestNotes.txt: -------------------------------------------------------------------------------- 1 | 2 | Features that need to be tested, and which test checks it. 3 | ----------------------------------------------------------- 4 | 5 | (*) Transfer Related 6 | 7 | (*) Search Related 8 | 9 | (*) ExtraList Related 10 | 11 | (*) Cache Related 12 | 13 | (*) Config / Storage. 14 | Change Config Directory works dynamically. (no restart required). 15 | 16 | 17 | (*) Miscelleous 18 | 19 | 20 | 21 | ----------------------------------------------------------- 22 | ----------------------------------------------------------- 23 | Actual Tests, and what they check. 24 | ----------------------------------------------------------- 25 | 26 | ftserver1test.cc 27 | ================== 28 | 29 | Used to develop test framework. 30 | Tests. 31 | 1) Test Framework. OK 32 | 2) File Indexing. OK 33 | 3) Cache Packet Exchange. OK 34 | 4) Cache downloads (including loopback). FAILS 35 | 5) FileIndex Store loading. 36 | 6) Basic Search. 37 | 38 | ftserver2test.cc 39 | ================== 40 | 41 | Test out the ExtraList functions. 42 | Demonstrates the use of libretroshare/src/util/utest.h 43 | 44 | Tests. 45 | 1) Load ExtraList path OK 46 | 2) Hashing of ExtraList File OK 47 | 3) ExtraHashDone. OK 48 | 4) Local Search for ExtraList Data. OK 49 | 5) Remote Search of ExtraList (should Fail) OK 50 | 6) Transfer of ExtraList File (Local) TODO 51 | 7) Transfer of ExtraList File (Remote) TODO 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/tests/ft/ftcontrollertest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./ftcontrollertest -p 8cb3a1677872c9e8248fd5ddeac84000 -p 8cb3a1677872c9e8248fd5ddeac84001 -p 8cb3a1677872c9e8248fd5ddeac84002 -e ftcontrollertest . 4 | -------------------------------------------------------------------------------- /src/tests/ft/ftsearch_dummy.cc: -------------------------------------------------------------------------------- 1 | #include "ftsearch_dummy.h" 2 | 3 | bool ftSearchDummy::search(const std::string& /*hash*/, FileSearchFlags hintflags, FileInfo &/*info*/) const 4 | { 5 | /* remove unused parameter warnings */ 6 | (void) hintflags; 7 | 8 | #ifdef DEBUG_SEARCH 9 | std::cerr << "ftSearchDummy::search(" << hash ; 10 | std::cerr << ", " << hintflags << ");"; 11 | std::cerr << std::endl; 12 | #endif 13 | return false; 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/tests/ft/ftsearch_dummy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libretroshare/src/ft: ftsearch.h 3 | * 4 | * File Transfer for RetroShare. 5 | * 6 | * Copyright 2008 by Robert Fernie. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License Version 2 as published by the Free Software Foundation. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Library General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Library General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA. 21 | * 22 | * Please report all bugs and problems to "retroshare@lunamutt.com". 23 | * 24 | */ 25 | 26 | #pragma once 27 | 28 | #include "ft/ftsearch.h" 29 | 30 | class ftSearchDummy: public ftSearch 31 | { 32 | public: 33 | 34 | ftSearchDummy() { return; } 35 | virtual ~ftSearchDummy() { return; } 36 | virtual bool search(const std::string& hash, FileSearchFlags hintflags, FileInfo &info) const; 37 | }; 38 | 39 | -------------------------------------------------------------------------------- /src/tests/ft/ftserver1test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./ftserver1test -p 8cb3a1677872c9e8248fd5ddeac84000 -p 8cb3a1677872c9e8248fd5ddeac84001 -p 8cb3a1677872c9e8248fd5ddeac84002 . 4 | -------------------------------------------------------------------------------- /src/tests/ft/ftserver2test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./ftserver2test -p 8cb3a1677872c9e8248fd5ddeac84000 -p 8cb3a1677872c9e8248fd5ddeac84001 -p 8cb3a1677872c9e8248fd5ddeac84002 . -e ftserver1test ftcontrollertest 4 | -------------------------------------------------------------------------------- /src/tests/ft/ftserver3test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./ftserver3test -p 8cb3a1677872c9e8248fd5ddeac84000 -p 8cb3a1677872c9e8248fd5ddeac84001 -p 8cb3a1677872c9e8248fd5ddeac84002 . ftserver3test 3 | -------------------------------------------------------------------------------- /src/tests/general/memory_management_test.cc: -------------------------------------------------------------------------------- 1 | #ifdef LINUX 2 | #include 3 | #endif 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "util/utest.h" 9 | #include "serialiser/rsserial.h" 10 | 11 | INITTEST(); 12 | 13 | // Make a fake class of size n. 14 | // 15 | template class RsTestItem: public RsItem 16 | { 17 | public: 18 | unsigned char buff[n] ; 19 | 20 | RsTestItem(uint32_t s) : RsItem(s) {} 21 | virtual void clear() {} 22 | virtual std::ostream& print(std::ostream& o, uint16_t) { return o ; } 23 | }; 24 | 25 | int main(int argc, char **argv) 26 | { 27 | #ifdef LINUX 28 | feenableexcept(FE_INVALID) ; 29 | feenableexcept(FE_DIVBYZERO) ; 30 | #endif 31 | typedef RsTestItem<17> Test17 ; 32 | typedef RsTestItem<31> Test31 ; 33 | 34 | std::vector v; 35 | 36 | for(int i=0;i<300;++i) 37 | v.push_back(new Test17(0)) ; 38 | for(int i=0;i<700;++i) 39 | v.push_back(new Test31(0)) ; 40 | 41 | RsMemoryManagement::printStatistics() ; 42 | 43 | // Now delete objects randomly. 44 | // 45 | for(int i=0;i<1000;++i) 46 | { 47 | int indx = lrand48()%(int)v.size() ; 48 | 49 | delete v[indx] ; 50 | v[indx] = v.back() ; 51 | v.pop_back() ; 52 | } 53 | 54 | std::cerr << "After memory free: " << std::endl; 55 | 56 | RsMemoryManagement::printStatistics() ; 57 | 58 | FINALREPORT("memory_management_test"); 59 | exit(TESTRESULT()); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /src/tests/general/pgpkey_test.cc: -------------------------------------------------------------------------------- 1 | #ifdef LINUX 2 | #include 3 | #endif 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "util/utest.h" 10 | #include "pgp/pgpkeyutil.h" 11 | 12 | INITTEST(); 13 | 14 | int main(int argc, char **argv) 15 | { 16 | #ifdef LINUX 17 | feenableexcept(FE_INVALID) ; 18 | feenableexcept(FE_DIVBYZERO) ; 19 | #endif 20 | try 21 | { 22 | if(argc < 2) 23 | { 24 | std::cerr << argv[0] << ": test gpg certificate cleaning method. " << std::endl; 25 | std::cerr << " Usage: " << argv[0] << " certificate.asc" << std::endl; 26 | return 0 ; 27 | } 28 | 29 | FILE *f = fopen(argv[1],"r") ; 30 | 31 | if(f == NULL) 32 | throw std::runtime_error(std::string("Could not open file ") + argv[1]) ; 33 | 34 | std::string cert ; 35 | int c ; 36 | 37 | while((c = getc(f) ) != EOF) 38 | cert += (char)c ; 39 | 40 | std::cerr << "got this certificate: " << std::endl; 41 | std::cerr << cert << std::endl; 42 | 43 | std::cerr << "Calling cert simplification code..." << std::endl; 44 | std::string cleaned_key ; 45 | 46 | PGPKeyManagement::createMinimalKey(cert,cleaned_key) ; 47 | 48 | std::cerr << "Minimal key produced: " << std::endl; 49 | std::cerr << cleaned_key << std::endl; 50 | FINALREPORT("pgpkey_test"); 51 | exit(TESTRESULT()); 52 | } 53 | catch(std::exception& e) 54 | { 55 | std::cerr << "Exception never handled: " << e.what() << std::endl ; 56 | return 1 ; 57 | } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /src/tests/gxs/common/data_support.h: -------------------------------------------------------------------------------- 1 | #ifndef DATA_SUPPORT_H 2 | #define DATA_SUPPORT_H 3 | 4 | #include "serialiser/rsnxsitems.h" 5 | #include "gxs/rsgxsdata.h" 6 | 7 | bool operator==(const RsNxsGrp&, const RsNxsGrp&); 8 | bool operator==(const RsNxsMsg&, const RsNxsMsg&); 9 | 10 | void init_item(RsNxsGrp& nxg); 11 | void init_item(RsNxsMsg& nxm); 12 | void init_item(RsGxsGrpMetaData* metaGrp); 13 | void init_item(RsGxsMsgMetaData* metaMsg); 14 | 15 | #endif // DATA_SUPPORT_H 16 | -------------------------------------------------------------------------------- /src/tests/gxs/data_service/rsdataservice_test.h: -------------------------------------------------------------------------------- 1 | #ifndef RSDATASERVICE_TEST_H 2 | #define RSDATASERVICE_TEST_H 3 | 4 | #include "util/rsthreads.h" 5 | #include "serialiser/rsnxsitems.h" 6 | #include "gxs/rsgds.h" 7 | 8 | void test_messageStoresAndRetrieve(); 9 | 10 | void test_groupStoreAndRetrieve(); 11 | 12 | void test_storeAndDeleteGroup(); 13 | void test_storeAndDeleteMessage(); 14 | 15 | void test_searchMsg(); 16 | void test_searchGrp(); 17 | 18 | bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r); 19 | bool operator ==(const RsGxsMsgMetaData& l, const RsGxsMsgMetaData& r); 20 | 21 | void test_multiThreaded(); 22 | 23 | class DataReadWrite : RsThread 24 | { 25 | 26 | 27 | 28 | }; 29 | 30 | void test_cacheSize(); 31 | 32 | 33 | #endif // RSDATASERVICE_TEST_H 34 | -------------------------------------------------------------------------------- /src/tests/gxs/gen_exchange/gxsmsgrelatedtest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * gxsmsgrelatedtest.cpp 3 | * 4 | * Created on: 27 Apr 2013 5 | * Author: crispy 6 | */ 7 | 8 | #include "gxsmsgrelatedtest.h" 9 | 10 | GxsMsgRelatedTest::GxsMsgRelatedTest() { 11 | // TODO Auto-generated constructor stub 12 | 13 | } 14 | 15 | GxsMsgRelatedTest::~GxsMsgRelatedTest() { 16 | // TODO Auto-generated destructor stub 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/tests/gxs/gen_exchange/gxsmsgrelatedtest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gxsmsgrelatedtest.h 3 | * 4 | * Created on: 27 Apr 2013 5 | * Author: crispy 6 | */ 7 | 8 | #ifndef GXSMSGRELATEDTEST_H_ 9 | #define GXSMSGRELATEDTEST_H_ 10 | 11 | #include "genexchangetester.h" 12 | 13 | class GxsMsgRelatedTest: public GenExchangeTest { 14 | public: 15 | GxsMsgRelatedTest(); 16 | virtual ~GxsMsgRelatedTest(); 17 | 18 | // request msg related tests 19 | bool testMsgRelatedChildIdRetrieval(); 20 | bool testMsgRelatedChildDataRetrieval(); 21 | bool testMsgRelatedChildDataRetrieval_Multi(); 22 | bool testMsgAllVersions(); 23 | }; 24 | 25 | #endif /* GXSMSGRELATEDTEST_H_ */ 26 | -------------------------------------------------------------------------------- /src/tests/gxs/gen_exchange/gxspublishgrouptest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gxspublishgrouptest.h 3 | * 4 | * Created on: 27 Apr 2013 5 | * Author: crispy 6 | */ 7 | 8 | #ifndef GXSPUBLISHGROUPTEST_H_ 9 | #define GXSPUBLISHGROUPTEST_H_ 10 | 11 | #include "genexchangetester.h" 12 | 13 | class GxsPublishGroupTest : public GenExchangeTest { 14 | public: 15 | 16 | GxsPublishGroupTest(GenExchangeTestService* const testService, 17 | RsGeneralDataService* dataService); 18 | virtual ~GxsPublishGroupTest(); 19 | 20 | void runTests(); 21 | 22 | private: 23 | 24 | // group tests 25 | bool testGrpSubmissionRetrieval(); 26 | bool testSpecificGrpRetrieval(); 27 | bool testGrpIdRetrieval(); 28 | bool testGrpMetaRetrieval(); 29 | bool testUpdateGroup(); 30 | 31 | 32 | private: 33 | 34 | }; 35 | 36 | #endif /* GXSPUBLISHGROUPTEST_H_ */ 37 | -------------------------------------------------------------------------------- /src/tests/gxs/gen_exchange/gxspublishmsgtest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * gxspublishmsgtest.cpp 3 | * 4 | * Created on: 27 Apr 2013 5 | * Author: crispy 6 | */ 7 | 8 | #include "gxspublishmsgtest.h" 9 | #include "util/utest.h" 10 | 11 | #define POLLING_TIME_OUT 5 12 | 13 | GxsPublishMsgTest::GxsPublishMsgTest(GenExchangeTestService* const testService, 14 | RsGeneralDataService* dataService) 15 | : GenExchangeTest(testService, dataService, POLLING_TIME_OUT) 16 | { 17 | } 18 | 19 | GxsPublishMsgTest::~GxsPublishMsgTest() 20 | { 21 | } 22 | 23 | void GxsPublishMsgTest::runTests() 24 | { 25 | CHECK(testMsgSubmissionRetrieval()); 26 | } 27 | 28 | bool GxsPublishMsgTest::testMsgSubmissionRetrieval() 29 | { 30 | // start up 31 | setUp(); 32 | std::list grpIds; 33 | createGrps(4, grpIds); 34 | 35 | /********************/ 36 | 37 | RsDummyMsg* msg = new RsDummyMsg(); 38 | init(*msg); 39 | 40 | msg->meta.mGroupId = grpIds.front(); 41 | uint32_t token; 42 | RsDummyMsg* msgOut = new RsDummyMsg(); 43 | *msgOut = *msg; 44 | getTestService()->publishDummyMsg(token, msg); 45 | 46 | 47 | RsGxsGrpMsgIdPair msgId; 48 | pollForMsgAcknowledgement(token, msgId); 49 | msgOut->meta.mMsgId = msgId.second; 50 | 51 | DummyMsgMap msgMap; 52 | std::vector msgV; 53 | msgV.push_back(msgOut); 54 | msgMap[msgOut->meta.mGroupId] = msgV; 55 | storeToMsgDataOutMaps(msgMap); 56 | 57 | 58 | RsTokReqOptions opts; 59 | opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; 60 | 61 | getTokenService()->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds); 62 | 63 | // poll again 64 | pollForToken(token, opts, true); 65 | 66 | bool ok = compareMsgDataMaps(); 67 | 68 | // complete 69 | breakDown(); 70 | 71 | return ok; 72 | } 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/tests/gxs/gen_exchange/gxspublishmsgtest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gxspublishmsgtest.h 3 | * 4 | * Created on: 27 Apr 2013 5 | * Author: crispy 6 | */ 7 | 8 | #ifndef GXSPUBLISHMSGTEST_H_ 9 | #define GXSPUBLISHMSGTEST_H_ 10 | 11 | #include "genexchangetester.h" 12 | 13 | class GxsPublishMsgTest: public GenExchangeTest { 14 | public: 15 | GxsPublishMsgTest(GenExchangeTestService* const testService, 16 | RsGeneralDataService* dataService); 17 | virtual ~GxsPublishMsgTest(); 18 | 19 | void runTests(); 20 | 21 | // message tests 22 | bool testMsgSubmissionRetrieval(); 23 | // bool testMsgIdRetrieval(); 24 | // bool testMsgIdRetrieval_OptParents(); 25 | // bool testMsgIdRetrieval_OptOrigMsgId(); 26 | // bool testMsgIdRetrieval_OptLatest(); 27 | // bool testSpecificMsgMetaRetrieval(); 28 | 29 | 30 | }; 31 | 32 | #endif /* GXSPUBLISHMSGTEST_H_ */ 33 | -------------------------------------------------------------------------------- /src/tests/gxs/gen_exchange/rsgenexchange_test.cc: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "genexchangetester.h" 4 | #include "gxspublishgrouptest.h" 5 | #include "gxspublishmsgtest.h" 6 | #include "util/utest.h" 7 | #include "gxs/rsdataservice.h" 8 | #include "rsdummyservices.h" 9 | 10 | 11 | /*! 12 | * It always hard to say exactly what coverage of a test would 13 | * be ahead of time. Partly because its difficult to create the 14 | * actual conditions of a test or the permutations of different request 15 | * options to a module is extremely large (and there are probably ways to deal with this) 16 | * In so far as the genexchange test is concerned we are primarily interested that it 17 | * retrieves and stores data correctly 18 | * The auxillary (and important) requirement is authentication and ensuring the authentication 19 | * rules are respected. This auxillary requirement is of the "hard" situation to create as 20 | * genexchange depends on an external module (rsidentity) for satisfying a significant sum 21 | * of its authentication. This difficulty is solved with a dummy identity service. 22 | * Which passes all authentications (In this respect authentication) is reserved for "online" 23 | * testing and is relatively straight forward. 24 | * 25 | */ 26 | 27 | INITTEST(); 28 | 29 | 30 | int main() 31 | { 32 | 33 | RsGeneralDataService* dataStore = new RsDataService("./", "testServiceDb", RS_SERVICE_TYPE_DUMMY, NULL, ""); 34 | 35 | // we want to use default authentication which is NO authentication :) 36 | GenExchangeTestService testService(dataStore, NULL, NULL); 37 | 38 | GxsPublishGroupTest testGrpPublishing(&testService, dataStore); 39 | testGrpPublishing.runTests(); 40 | 41 | //GxsPublishMsgTest testMsgPublishing(&testService, dataStore); 42 | //testMsgPublishing.runTests(); 43 | 44 | FINALREPORT("RsGenExchangeTest"); 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /src/tests/gxs/nxs_test/rsgxsnetservice_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * rsgxsnetservice_test.cc 3 | * 4 | * Created on: 11 Jul 2012 5 | * Author: crispy 6 | */ 7 | 8 | #include "util/utest.h" 9 | #include "nxstesthub.h" 10 | #include "nxstestscenario.h" 11 | 12 | INITTEST(); 13 | 14 | 15 | int main() 16 | { 17 | 18 | // first setup 19 | NxsMessageTest msgTest(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); 20 | std::set peers; 21 | peers.insert("PeerA"); 22 | peers.insert("PeerB"); 23 | NxsTestHub hub(&msgTest, peers); 24 | 25 | // now get things started 26 | createThread(hub); 27 | 28 | double timeDelta = 50; 29 | 30 | // put this thread to sleep for 10 secs 31 | // make thread sleep for a bit 32 | #ifndef WINDOWS_SYS 33 | usleep((int) (timeDelta * 1000000)); 34 | #else 35 | Sleep((int) (timeDelta * 1000)); 36 | #endif 37 | 38 | hub.join(); 39 | CHECK(hub.testsPassed()); 40 | 41 | hub.cleanUp(); 42 | 43 | FINALREPORT("RsGxsNetService Tests"); 44 | 45 | return TESTRESULT(); 46 | } 47 | -------------------------------------------------------------------------------- /src/tests/network_simulator/gui/GlobalRouterStatistics.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * RetroShare is distributed under the following license: 3 | * 4 | * Copyright (C) 20011, RetroShare Team 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 | * Boston, MA 02110-1301, USA. 20 | ****************************************************************/ 21 | 22 | #pragma once 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "RsAutoUpdatePage.h" 29 | #include "ui_GlobalRouterStatistics.h" 30 | 31 | class GlobalRouterStatisticsWidget ; 32 | class p3GRouter ; 33 | 34 | class GlobalRouterStatistics: public RsAutoUpdatePage, public Ui::GlobalRouterStatistics 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | GlobalRouterStatistics(QWidget *parent = NULL) ; 40 | ~GlobalRouterStatistics(); 41 | 42 | // Cache for peer names. 43 | static QString getPeerName(const RsPeerId& peer_id) ; 44 | 45 | void setGlobalRouter(const RsGRouter *grouter) ; 46 | virtual void updateDisplay() ; 47 | 48 | private: 49 | 50 | 51 | GlobalRouterStatisticsWidget *_tst_CW ; 52 | RsGRouter *_grouter ; 53 | } ; 54 | 55 | class GlobalRouterStatisticsWidget: public QWidget 56 | { 57 | Q_OBJECT 58 | 59 | public: 60 | GlobalRouterStatisticsWidget(QWidget *parent = NULL) ; 61 | 62 | virtual void paintEvent(QPaintEvent *event) ; 63 | virtual void resizeEvent(QResizeEvent *event); 64 | 65 | void updateContent(RsGRouter *grouter) ; 66 | private: 67 | static QString speedString(float f) ; 68 | 69 | QPixmap pixmap ; 70 | int maxWidth,maxHeight ; 71 | }; 72 | 73 | -------------------------------------------------------------------------------- /src/tests/network_simulator/gui/GlobalRouterStatistics.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | GlobalRouterStatistics 4 | 5 | 6 | 7 | 0 8 | 0 9 | 611 10 | 408 11 | 12 | 13 | 14 | Router Statistics 15 | 16 | 17 | 18 | :/images/rstray3.png:/images/rstray3.png 19 | 20 | 21 | 22 | 23 | 24 | Qt::Vertical 25 | 26 | 27 | 28 | QFrame::NoFrame 29 | 30 | 31 | Qt::ScrollBarAlwaysOff 32 | 33 | 34 | true 35 | 36 | 37 | 38 | 39 | 0 40 | 0 41 | 593 42 | 390 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/tests/network_simulator/gui/NetworkSimulatorGUI.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "NetworkSimulatorGUI.h" 5 | #include "NetworkViewer.h" 6 | #include "TurtleRouterStatistics.h" 7 | #include "GlobalRouterStatistics.h" 8 | 9 | NetworkSimulatorGUI::NetworkSimulatorGUI(Network& net) 10 | { 11 | setupUi(this) ; 12 | tickTimerId = 0 ; 13 | 14 | QVBoxLayout *layout = new QVBoxLayout(networkViewFrame) ; 15 | layout->addWidget(_viewer = new NetworkViewer(networkViewFrame,net)) ; 16 | 17 | QObject::connect(_viewer,SIGNAL(nodeSelected(int)),this,SLOT(updateSelectedNode(int))) ; 18 | QObject::connect(flow_CB,SIGNAL(toggled(bool)),this,SLOT(toggleNetworkTraffic(bool))) ; 19 | 20 | QVBoxLayout *layout2 = new QVBoxLayout(inspectorFrame) ; 21 | QTabWidget *tabwidget = new QTabWidget() ; 22 | 23 | layout2->addWidget(tabwidget) ; 24 | 25 | tabwidget->addTab(_turtle_router_statistics = new TurtleRouterStatistics(),"Turtle router" ) ; 26 | tabwidget->addTab(_global_router_statistics = new GlobalRouterStatistics(),"Global router" ) ; 27 | } 28 | 29 | void NetworkSimulatorGUI::updateSelectedNode(int node_id) 30 | { 31 | const RsTurtle *turtle = _viewer->network().node(node_id).turtle_service() ; 32 | const RsGRouter *grouter = _viewer->network().node(node_id).global_router_service() ; 33 | 34 | _turtle_router_statistics->setTurtleRouter( turtle ) ; 35 | _global_router_statistics->setGlobalRouter( grouter ) ; 36 | 37 | // make only the selected node to display grouter info 38 | 39 | for(uint32_t i=0;i<_viewer->network().n_nodes();++i) 40 | _viewer->network().node(i).global_router_service()->setDebugEnabled(i==node_id) ; 41 | 42 | std::cerr << "Selected objects: turtle=" << std::hex << turtle << ", grouter=" << grouter << std::dec << std::endl; 43 | } 44 | 45 | void NetworkSimulatorGUI::toggleNetworkTraffic(bool b) 46 | { 47 | if(!b && tickTimerId > 0) 48 | { 49 | killTimer(tickTimerId) ; 50 | tickTimerId = 0 ; 51 | return ; 52 | } 53 | 54 | if(b && tickTimerId == 0) 55 | { 56 | tickTimerId = startTimer(1000) ; 57 | return ; 58 | } 59 | 60 | std::cerr << "ERROR !!" << std::endl; 61 | } 62 | 63 | void NetworkSimulatorGUI::timerEvent(QTimerEvent *event) 64 | { 65 | Q_UNUSED(event) ; 66 | 67 | //std::cerr << "timer event!" << std::endl; 68 | 69 | _viewer->network().tick() ; 70 | 71 | } 72 | 73 | -------------------------------------------------------------------------------- /src/tests/network_simulator/gui/NetworkSimulatorGUI.h: -------------------------------------------------------------------------------- 1 | #include "ui_NetworkSimulatorGUI.h" 2 | 3 | class TurtleRouterStatistics ; 4 | class GlobalRouterStatistics ; 5 | class NetworkViewer ; 6 | class Network ; 7 | 8 | class NetworkSimulatorGUI: public QMainWindow, public Ui::NetworkSimulatorGUI 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | NetworkSimulatorGUI(Network& net) ; 14 | 15 | public slots: 16 | void updateSelectedNode(int) ; 17 | void toggleNetworkTraffic(bool) ; 18 | 19 | virtual void timerEvent(QTimerEvent *e) ; 20 | 21 | private: 22 | NetworkViewer *_viewer ; 23 | TurtleRouterStatistics *_turtle_router_statistics ; 24 | GlobalRouterStatistics *_global_router_statistics ; 25 | 26 | int tickTimerId ; 27 | }; 28 | 29 | -------------------------------------------------------------------------------- /src/tests/network_simulator/gui/RsAutoUpdatePage.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "RsAutoUpdatePage.h" 3 | 4 | bool RsAutoUpdatePage::_locked = false ; 5 | 6 | RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period, QWidget *parent, Qt::WindowFlags flags) 7 | : QWidget(parent, flags) 8 | { 9 | _timer = new QTimer ; 10 | _timer->setInterval(ms_update_period); 11 | _timer->setSingleShot(true); 12 | 13 | QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(timerUpdate())) ; 14 | 15 | _timer->start() ; 16 | } 17 | 18 | RsAutoUpdatePage::~RsAutoUpdatePage() 19 | { 20 | if(_timer != NULL) 21 | delete _timer ; 22 | 23 | _timer = NULL ; 24 | } 25 | 26 | void RsAutoUpdatePage::showEvent(QShowEvent */*event*/) 27 | { 28 | //std::cout << "RsAutoUpdatePage::showEvent() In show event !!" << std::endl ; 29 | if(!_locked) 30 | updateDisplay(); 31 | } 32 | 33 | void RsAutoUpdatePage::timerUpdate() 34 | { 35 | // only update when the widget is visible. 36 | // 37 | if(_locked == false && isVisible()) { 38 | updateDisplay(); 39 | update() ; // Qt flush 40 | } 41 | 42 | _timer->start() ; 43 | } 44 | 45 | void RsAutoUpdatePage::lockAllEvents() { _locked = true ; } 46 | void RsAutoUpdatePage::unlockAllEvents() { _locked = false ; } 47 | bool RsAutoUpdatePage::eventsLocked() { return _locked ; } 48 | -------------------------------------------------------------------------------- /src/tests/network_simulator/gui/RsAutoUpdatePage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | // This class implement a basic RS functionality which is that widgets displayign info 7 | // should update regularly. They also should update only when visible, to save CPU time. 8 | // 9 | // Using this class simply needs to derive your widget from RsAutoUpdateWidget 10 | // and oveload the update() function with the actual code that updates the 11 | // widget. 12 | // 13 | class QTimer ; 14 | 15 | class RsAutoUpdatePage: public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | RsAutoUpdatePage(int ms_update_period = 1000, QWidget *parent = NULL, Qt::WindowFlags flags = 0) ; 21 | virtual ~RsAutoUpdatePage() ; 22 | 23 | virtual void updateDisplay() {} 24 | 25 | static void lockAllEvents() ; 26 | static void unlockAllEvents() ; 27 | static bool eventsLocked() ; 28 | 29 | protected: 30 | virtual void showEvent(QShowEvent *e) ; 31 | 32 | private slots: 33 | void timerUpdate() ; 34 | 35 | private: 36 | QTimer *_timer ; 37 | 38 | static bool _locked ; 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /src/tests/network_simulator/gui/TurtleRouterStatistics.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | TurtleRouterStatistics 4 | 5 | 6 | 7 | 0 8 | 0 9 | 611 10 | 408 11 | 12 | 13 | 14 | Router Statistics 15 | 16 | 17 | 18 | :/images/rstray3.png:/images/rstray3.png 19 | 20 | 21 | 22 | 23 | 24 | Qt::Vertical 25 | 26 | 27 | 28 | QFrame::NoFrame 29 | 30 | 31 | Qt::ScrollBarAlwaysOff 32 | 33 | 34 | true 35 | 36 | 37 | 38 | 39 | 0 40 | 0 41 | 593 42 | 390 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/tests/network_simulator/gui/gui.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | CONFIG *= qt qglviewer uic 4 | QT *= xml opengl 5 | 6 | INCLUDEPATH *= ../../.. .. 7 | 8 | TARGET = NetworkSim 9 | DESTDIR = ../bin 10 | 11 | PRE_TARGETDEPS = ../nscore/nscore.pro 12 | 13 | SOURCES = main.cpp NetworkViewer.cpp NetworkSimulatorGUI.cpp \ 14 | TurtleRouterStatistics.cpp RsAutoUpdatePage.cpp GlobalRouterStatistics.cpp 15 | 16 | HEADERS = NetworkViewer.h NetworkSimulatorGUI.h \ 17 | TurtleRouterStatistics.h RsAutoUpdatePage.h GlobalRouterStatistics.h 18 | 19 | FORMS = NetworkSimulatorGUI.ui TurtleRouterStatistics.ui GlobalRouterStatistics.ui 20 | 21 | LIBS *= ../../../lib/libretroshare.a \ 22 | ../../../../../libbitdht/src/lib/libbitdht.a \ 23 | ../../../../../openpgpsdk/src/lib/libops.a \ 24 | ../lib/libnscore.a \ 25 | -lsqlcipher -lgnome-keyring -lupnp -lssl -lcrypto -lbz2 -lixml 26 | -------------------------------------------------------------------------------- /src/tests/network_simulator/gui/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "nscore/Network.h" 5 | #include "nscore/MonitoredRsPeers.h" 6 | 7 | #include 8 | 9 | #include "NetworkSimulatorGUI.h" 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | feenableexcept(FE_INVALID) ; 14 | feenableexcept(FE_DIVBYZERO) ; 15 | 16 | #ifndef DEBUG 17 | try 18 | { 19 | #endif 20 | argstream as(argc,argv) ; 21 | bool show_gui = false; 22 | int nb_nodes = 20 ; 23 | float connexion_probability = 0.2 ; 24 | 25 | as >> option('i',"gui",show_gui,"show gui (vs. do the pipeline automatically)") 26 | >> parameter('n',"nodes",nb_nodes,"number of nodes in the network",false) 27 | >> parameter('p',"connexion probability",connexion_probability,"probability that two nodes are connected (exponential law)",false) 28 | >> help() ; 29 | 30 | as.defaultErrorHandling() ; 31 | 32 | // 2 - call the full pipeline 33 | 34 | Network network ; 35 | 36 | network.initRandom(nb_nodes,connexion_probability) ; 37 | 38 | rsPeers = new MonitoredRsPeers(network) ; 39 | 40 | if(show_gui) 41 | { 42 | QApplication app(argc,argv) ; 43 | 44 | NetworkSimulatorGUI pgui(network); 45 | pgui.show() ; 46 | 47 | return app.exec() ; 48 | } 49 | 50 | return 0 ; 51 | #ifndef DEBUG 52 | } 53 | catch(std::exception& e) 54 | { 55 | std::cerr << "Unhandled exception: " << e.what() << std::endl; 56 | return 1 ; 57 | } 58 | #endif 59 | } 60 | 61 | -------------------------------------------------------------------------------- /src/tests/network_simulator/network_simulator.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = nscore gui 3 | -------------------------------------------------------------------------------- /src/tests/network_simulator/nscore/MainLoop.cpp: -------------------------------------------------------------------------------- 1 | 2 | void NetworkLoop() 3 | { 4 | while(true) 5 | { 6 | std::cerr<< "network loop: tick()" << std::endl; 7 | 8 | // Get items for each components and send them to their destination. 9 | // 10 | for(int i=0;in_nodes();++i) 11 | { 12 | RsRawItem *item ; 13 | 14 | while(item = network->node(i).outgoing()) 15 | { 16 | PeerNode& node = network->node_by_id(item->peerId()) 17 | item->peerId(network->node(i)->id()) ; 18 | 19 | node.received(item) ; 20 | } 21 | } 22 | usleep(500000) ; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/tests/network_simulator/nscore/MonitoredGRouterClient.cpp: -------------------------------------------------------------------------------- 1 | #include "MonitoredGRouterClient.h" 2 | 3 | const uint32_t MonitoredGRouterClient::GROUTER_CLIENT_SERVICE_ID_00 = 0x0111 ; 4 | 5 | void MonitoredGRouterClient::receiveGRouterData(const GRouterKeyId& destination_key,const RsGRouterGenericDataItem *item) 6 | { 7 | std::cerr << "received one global grouter item for key " << destination_key << std::endl; 8 | } 9 | 10 | void MonitoredGRouterClient::provideKey(const GRouterKeyId& key_id) 11 | { 12 | _grouter->registerKey(key_id,GROUTER_CLIENT_SERVICE_ID_00,"test grouter address") ; 13 | 14 | std::cerr << "Registered new key " << key_id << " for service " << std::hex << GROUTER_CLIENT_SERVICE_ID_00 << std::dec << std::endl; 15 | } 16 | 17 | void MonitoredGRouterClient::sendMessage(const GRouterKeyId& destination_key_id) const 18 | { 19 | RsGRouterGenericDataItem *item = new RsGRouterGenericDataItem ; 20 | item->data_size = 1000 + (RSRandom::random_u32()%1000) ; 21 | item->data_bytes = (unsigned char *)malloc(item->data_size) ; 22 | 23 | RSRandom::random_bytes(item->data_bytes,item->data_size) ; 24 | GRouterMsgPropagationId propagation_id ; 25 | 26 | _grouter->sendData(destination_key_id,GROUTER_CLIENT_SERVICE_ID_00,item,propagation_id) ; 27 | } 28 | -------------------------------------------------------------------------------- /src/tests/network_simulator/nscore/MonitoredGRouterClient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class MonitoredGRouterClient: public GRouterClientService 6 | { 7 | public: 8 | static const uint32_t GROUTER_CLIENT_SERVICE_ID_00 ; 9 | 10 | // Derived from grouterclientservice.h 11 | // 12 | virtual void connectToGlobalRouter(p3GRouter *p) { _grouter = p ; p->registerClientService(GROUTER_CLIENT_SERVICE_ID_00,this) ; } 13 | virtual void receiveGRouterData(const GRouterKeyId& destination_key,const RsGRouterGenericDataItem *item); 14 | 15 | // Own functionality 16 | // 17 | void sendMessage(const GRouterKeyId& destination_key) const ; 18 | void provideKey(const GRouterKeyId& key) ; 19 | 20 | private: 21 | p3GRouter *_grouter ; 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /src/tests/network_simulator/nscore/MonitoredRsPeers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "MonitoredRsPeers.h" 3 | 4 | MonitoredRsPeers::MonitoredRsPeers(const Network& net) 5 | : p3Peers(NULL,NULL,NULL),_network(net) 6 | { 7 | } 8 | 9 | bool MonitoredRsPeers::getPeerDetails(const std::string& str,RsPeerDetails& details) 10 | { 11 | std::cerr << __PRETTY_FUNCTION__ << " called" << std::endl; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/network_simulator/nscore/MonitoredRsPeers.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Network ; 4 | 5 | class MonitoredRsPeers: public p3Peers 6 | { 7 | public: 8 | MonitoredRsPeers(const Network& net) ; 9 | 10 | virtual bool getPeerDetails(const std::string& peer_id,RsPeerDetails& details) ; 11 | 12 | private: 13 | const Network& _network ; 14 | }; 15 | -------------------------------------------------------------------------------- /src/tests/network_simulator/nscore/MonitoredTurtleClient.cpp: -------------------------------------------------------------------------------- 1 | #include "MonitoredTurtleClient.h" 2 | 3 | bool MonitoredTurtleClient::handleTunnelRequest(const TurtleFileHash& hash,const RsPeerId& peer_id) 4 | { 5 | std::map::const_iterator it( _local_files.find(hash) ) ; 6 | 7 | return (it != _local_files.end() ) ; 8 | } 9 | 10 | void MonitoredTurtleClient::provideFileHash(const RsFileHash& hash) 11 | { 12 | FileInfo& info( _local_files[hash] ) ; 13 | 14 | info.fname = "File 1" ; 15 | info.size = 100000 ; 16 | info.hash = hash ; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/tests/network_simulator/nscore/MonitoredTurtleClient.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class MonitoredTurtleClient: public RsTurtleClientService 4 | { 5 | public: 6 | virtual void addVirtualPeer(const TurtleFileHash& hash,const TurtleVirtualPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction dir) {} 7 | virtual void removeVirtualPeer(const TurtleFileHash& hash,const TurtleVirtualPeerId& virtual_peer_id) {} 8 | virtual void connectToTurtleRouter(p3turtle*p) { p->registerTunnelService(this) ; } 9 | 10 | bool handleTunnelRequest(const TurtleFileHash& hash,const RsPeerId& peer_id); 11 | void provideFileHash(const RsFileHash& hash); 12 | void requestFileHash(const RsFileHash& hash) ; 13 | 14 | private: 15 | std::map _local_files ; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /src/tests/network_simulator/nscore/Network.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "PeerNode.h" 10 | 11 | template class Graph 12 | { 13 | public: 14 | typedef uint32_t NodeId ; 15 | 16 | void symmetric_connect(uint32_t n1,uint32_t n2) ; 17 | const std::set& neighbors(const NodeId& n) const { return _neighbors[n] ; } 18 | 19 | // number of nodes. 20 | // 21 | uint32_t n_nodes() const { return _nodes.size() ;} 22 | const NODE_TYPE& node(int i) const { return *_nodes[i] ; } 23 | NODE_TYPE& node(int i) { return *_nodes[i] ; } 24 | 25 | protected: 26 | 27 | std::vector _nodes ; 28 | std::vector > _neighbors ; 29 | }; 30 | 31 | class Network: public Graph 32 | { 33 | public: 34 | // inits the graph as random. Returns true if connected, false otherwise. 35 | // 36 | bool initRandom(uint32_t n_nodes, float connexion_probability) ; 37 | 38 | // ticks all services of all nodes. 39 | // 40 | void tick() ; 41 | 42 | PeerNode& node_by_id(const RsPeerId& node_id) ; 43 | 44 | private: 45 | std::map _node_ids ; 46 | }; 47 | 48 | -------------------------------------------------------------------------------- /src/tests/network_simulator/nscore/PeerNode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class MonitoredTurtleClient ; 8 | class MonitoredGRouterClient ; 9 | class RsTurtle ; 10 | class p3turtle ; 11 | class p3GRouter ; 12 | class pqiPublisher ; 13 | class RsRawItem ; 14 | class p3ServiceServer ; 15 | 16 | class PeerNode 17 | { 18 | public: 19 | struct NodeTrafficInfo 20 | { 21 | std::map local_src ; // peer id., tunnel id 22 | std::map local_dst ; 23 | }; 24 | 25 | PeerNode(const RsPeerId& id,const std::list& friends) ; 26 | ~PeerNode() ; 27 | 28 | RsRawItem *outgoing() ; 29 | void incoming(RsRawItem *) ; 30 | 31 | const RsPeerId& id() const { return _id ;} 32 | 33 | void tick() ; 34 | 35 | // Turtle-related methods 36 | // 37 | const RsTurtle *turtle_service() const { return _turtle ; } 38 | p3GRouter *global_router_service() const { return _grouter ; } 39 | 40 | void manageFileHash(const RsFileHash& hash) ; 41 | void provideFileHash(const RsFileHash& hash) ; 42 | 43 | const std::set& providedHashes() const { return _provided_hashes; } 44 | const std::set& managedHashes() const { return _managed_hashes; } 45 | 46 | void getTrafficInfo(NodeTrafficInfo& trinfo) ; // 47 | 48 | // GRouter-related methods 49 | // 50 | void provideGRKey(const GRouterKeyId& key_id) ; 51 | void sendToGRKey(const GRouterKeyId& key_id) ; 52 | 53 | const std::set& providedGRKeys() const { return _provided_keys; } 54 | 55 | private: 56 | p3ServiceServer *_service_server ; 57 | pqiPublisher *_publisher ; 58 | RsPeerId _id ; 59 | 60 | // turtle stuff 61 | // 62 | p3turtle *_turtle ; 63 | MonitoredTurtleClient *_turtle_client ; 64 | 65 | // grouter stuff 66 | // 67 | p3GRouter *_grouter ; 68 | MonitoredGRouterClient *_grouter_client ; 69 | 70 | std::set _provided_hashes ; 71 | std::set _managed_hashes ; 72 | std::set _provided_keys ; 73 | }; 74 | 75 | -------------------------------------------------------------------------------- /src/tests/network_simulator/nscore/nscore.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = lib 2 | CONFIG *= staticlib 3 | 4 | INCLUDEPATH *= ../../.. .. 5 | 6 | TARGET = nscore 7 | 8 | SOURCES = Network.cpp \ 9 | PeerNode.cpp \ 10 | MonitoredRsPeers.cpp \ 11 | MonitoredTurtleClient.cpp \ 12 | MonitoredGRouterClient.cpp 13 | 14 | HEADERS = Network.h \ 15 | PeerNode.h \ 16 | MonitoredRsPeers.h \ 17 | MonitoredTurtleClient.h \ 18 | MonitoredGRouterClient.h 19 | 20 | DESTDIR = ../lib 21 | -------------------------------------------------------------------------------- /src/tests/perform_all_auto_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This is the main script for performing all tests automatically. 4 | # - in order to add new directories, just list them in the $subdirs variable below 5 | 6 | echo "****************************************" 7 | echo "*** RetroShare automatic test suite. ***" 8 | echo "****************************************" 9 | echo "Performing all tests on subdirs." 10 | echo "(Some tests take a few minutes. Be patient) " 11 | echo 12 | echo 13 | 14 | subdirs="util serialiser dbase upnp general pgp tcponudp" 15 | 16 | for dir in $subdirs; do 17 | echo Tests for directory: $dir 18 | cd $dir 19 | ./perform_auto_tests.sh 20 | cd .. 21 | done 22 | 23 | -------------------------------------------------------------------------------- /src/tests/pgp/test_certificate.newformat.rsc: -------------------------------------------------------------------------------- 1 | Af8AAAKHmQENBEyoe/MBCAC9rKm/ehp9Iv1XrOiKIyj1X5nJzQ660+OhmQf4lbJv 2 | krcnvdrdcmlfZQfupWMXHo7A3+27lOpfTvA1xpO8Gze0bRbLsbpx2dARjLUzXJAI 3 | FNCYzH5xlIixxOwgX3tinKfoP3WvZv+nYBac/HeAPUW8BVqx6Y6V/gM3c71XNf9u 4 | hPgArN0jvLOeqAJY+lACJZYlAIw6Jt2FzarC+orWndkvrsgrWmdxkorfZKBfdNwd 5 | f1YYrpUmGaf51x4DkrMWpfHxS8b6cgOmSN3LeAC8LCm5oEXPfNgaRehN9LKrSmcp 6 | cPS2jvDipgGBx+nL7gytCREMJkJoxppXQpVt1whaFDJVABEBAAG0OkN5cmlsLXRl 7 | c3QgKGdlbmVyYXRlZCBieSBSZXRyb3NoYXJlKSA8Y3lyaWwuc29sZXJAaW1hZy5m 8 | cj6JATgEEwECACIFAkyoe/MCGy8GCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJ 9 | EGYPt3FyfOKG+h0H/A+vvryYmGcGFl82D4M0mAPAlbjZFkGCB8qJJSFuor55GJ3V 10 | 8pBb4UK7jnLhQhqsdXxAawT9R5RzTDITWHkS4KVaFalOYLxQ8x4s31FWXUiprAvJ 11 | AIVw9gnBC7kDLro2irCljZB5ro8fsg0SJ0ZFc4cZMPZxnMKm5ovC6WggbblyaHrR 12 | rV8jhHFIR+RG9/nnw0PgvGOmV9f4Q0a/7E18AxdBXYMZSp7p/mwbQdkqgm7p73bg 13 | 7E2Zz/Fhg1/PguwjlDal+HyUEPDvcPG41NAKwpMeL78qVJTQcBzzo1Irqj5f5UFJ 14 | p4/H7QDlEsz/ZGxXXq3PdAP5BICwiOD44G9dIUECBlLktZUcsQMGwKgAZxyxBAAG 15 | BmxhcHRvcAUQXVLApuPC+s1X/RPnFumDgQ== 16 | -------------------------------------------------------------------------------- /src/tests/pgp/test_certificate.oldformat.rsc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Version: OpenPGP:SDK v0.9 3 | 4 | mQENBEyoe/MBCAC9rKm/ehp9Iv1XrOiKIyj1X5nJzQ660+OhmQf4lbJvkrcnvdrd 5 | cmlfZQfupWMXHo7A3+27lOpfTvA1xpO8Gze0bRbLsbpx2dARjLUzXJAIFNCYzH5x 6 | lIixxOwgX3tinKfoP3WvZv+nYBac/HeAPUW8BVqx6Y6V/gM3c71XNf9uhPgArN0j 7 | vLOeqAJY+lACJZYlAIw6Jt2FzarC+orWndkvrsgrWmdxkorfZKBfdNwdf1YYrpUm 8 | Gaf51x4DkrMWpfHxS8b6cgOmSN3LeAC8LCm5oEXPfNgaRehN9LKrSmcpcPS2jvDi 9 | pgGBx+nL7gytCREMJkJoxppXQpVt1whaFDJVABEBAAG0OkN5cmlsLXRlc3QgKGdl 10 | bmVyYXRlZCBieSBSZXRyb3NoYXJlKSA8Y3lyaWwuc29sZXJAaW1hZy5mcj6JATgE 11 | EwECACIFAkyoe/MCGy8GCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEGYPt3Fy 12 | fOKG+h0H/A+vvryYmGcGFl82D4M0mAPAlbjZFkGCB8qJJSFuor55GJ3V8pBb4UK7 13 | jnLhQhqsdXxAawT9R5RzTDITWHkS4KVaFalOYLxQ8x4s31FWXUiprAvJAIVw9gnB 14 | C7kDLro2irCljZB5ro8fsg0SJ0ZFc4cZMPZxnMKm5ovC6WggbblyaHrRrV8jhHFI 15 | R+RG9/nnw0PgvGOmV9f4Q0a/7E18AxdBXYMZSp7p/mwbQdkqgm7p73bg7E2Zz/Fh 16 | g1/PguwjlDal+HyUEPDvcPG41NAKwpMeL78qVJTQcBzzo1Irqj5f5UFJp4/H7QDl 17 | Esz/ZGxXXq3PdAP5BICwiOD44G9dIUE= 18 | =BWkb 19 | -----END PGP PUBLIC KEY BLOCK----- 20 | --SSLID--5d52c0a6e3c2facd57fd13e716e98381;--LOCATION--laptop; 21 | --LOCAL--192.168.0.103:7345;--EXT--82.228.181.149:7345; 22 | -------------------------------------------------------------------------------- /src/tests/pgp/test_certificate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./test_certificate -i test_certificate.oldformat.rsc && ./test_certificate -i test_certificate.newformat.rsc 4 | -------------------------------------------------------------------------------- /src/tests/pgp/test_identity_import.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | //#include 7 | #include 8 | #include 9 | #include 10 | 11 | INITTEST() ; 12 | 13 | static std::string pgp_pwd_cb(void * /*hook*/, const char *uid_hint, const char * /*passphrase_info*/, int prev_was_bad) 14 | { 15 | #define GPG_DEBUG2 16 | #ifdef GPG_DEBUG2 17 | fprintf(stderr, "pgp_pwd_callback() called.\n"); 18 | #endif 19 | std::string password; 20 | 21 | std::cerr << "SHould not be called!" << std::endl; 22 | return password ; 23 | } 24 | 25 | int main(int argc,char *argv[]) 26 | { 27 | try 28 | { 29 | argstream as(argc,argv) ; 30 | std::string idfile ; 31 | bool clean_cert = false ; 32 | 33 | as >> parameter('i',"input",idfile,"input retroshare identity file, ascii format",true) 34 | >> help() ; 35 | 36 | as.defaultErrorHandling() ; 37 | 38 | PGPHandler handler("toto1","toto2","toto3","toto4") ; 39 | 40 | PGPIdType imported_key_id ; 41 | std::string import_error_string ; 42 | 43 | bool res = handler.importGPGKeyPair(idfile,imported_key_id,import_error_string) ; 44 | 45 | handler.syncDatabase() ; 46 | 47 | if(!res) 48 | std::cerr << "Identity Import error: " << import_error_string << std::endl; 49 | 50 | CHECK(res) ; 51 | } 52 | catch(std::exception& e) 53 | { 54 | std::cerr << "Exception never handled: " << e.what() << std::endl; 55 | return 1 ; 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/tests/pgp/test_key_parsing.cc: -------------------------------------------------------------------------------- 1 | // COMPILE_LINE: g++ -o test_key_parsing test_key_parsing.cc -g -I../../../openpgpsdk/include -I../ -L../lib ../../../openpgpsdk/src/lib/libops.a -lssl -lcrypto -lbz2 2 | // 3 | #include 4 | #include 5 | 6 | extern "C" 7 | { 8 | #include 9 | #include 10 | #include 11 | } 12 | 13 | #include 14 | #include 15 | 16 | INITTEST() ; 17 | 18 | int main(int argc,char *argv[]) 19 | { 20 | try 21 | { 22 | // test PGPHandler 23 | // 24 | // 0 - init 25 | 26 | bool armoured = false ; 27 | std::string keyfile ; 28 | 29 | argstream as(argc,argv) ; 30 | 31 | as >> parameter('i',"input-key",keyfile,"input key file.",true) 32 | >> option('a',"armoured",armoured,"input is armoured") 33 | >> help() ; 34 | 35 | as.defaultErrorHandling() ; 36 | 37 | ops_keyring_t *kr = (ops_keyring_t*)malloc(sizeof(ops_keyring_t)) ; 38 | kr->nkeys = 0 ; 39 | kr->nkeys_allocated = 0 ; 40 | kr->keys = 0 ; 41 | 42 | CHECK(ops_false != ops_keyring_read_from_file(kr,armoured, keyfile.c_str())) ; 43 | 44 | for(int i=0;inkeys;++i) 45 | { 46 | ops_print_public_keydata(&kr->keys[i]) ; 47 | ops_print_public_keydata_verbose(&kr->keys[i]) ; 48 | ops_print_public_key(&kr->keys[i].key.pkey) ; 49 | } 50 | 51 | ops_list_packets(const_cast(keyfile.c_str()),armoured,kr,NULL) ; 52 | 53 | FINALREPORT("Test key parsing") ; 54 | 55 | return TESTRESULT() ; 56 | } 57 | catch(std::exception& e) 58 | { 59 | std::cerr << "Caught exception: " << e.what() << std::endl; 60 | return 1 ; 61 | } 62 | } 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/tests/pgp/test_key_parsing.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./test_key_parsing -i test_pubring.gpg 3 | -------------------------------------------------------------------------------- /src/tests/pgp/test_pgp_handler.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./test_pgp_handler -F 4 | 5 | -------------------------------------------------------------------------------- /src/tests/pgp/test_pgp_signature_parsing.cc: -------------------------------------------------------------------------------- 1 | // COMPILE_LINE: g++ -o test_pgp_signature_parsing test_pgp_signature_parsing.cc -g -I../../../openpgpsdk/include -I../ -L../lib -lretroshare ../../../libbitdht/src/lib/libbitdht.a ../../../openpgpsdk/lib/libops.a -lgnome-keyring -lupnp -lssl -lcrypto -lbz2 2 | // 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | INITTEST() ; 10 | 11 | static std::string passphrase_callback(void *data,const char *uid_info,const char *what,int prev_was_bad) 12 | { 13 | return std::string(getpass(what)) ; 14 | } 15 | 16 | static std::string stringFromBytes(unsigned char *bytes,size_t len) 17 | { 18 | static const char out[16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' } ; 19 | 20 | std::string res ; 21 | 22 | for(int j = 0; j < len; j++) 23 | { 24 | res += out[ (bytes[j]>>4) ] ; 25 | res += out[ bytes[j] & 0xf ] ; 26 | } 27 | 28 | return res ; 29 | } 30 | 31 | int main(int argc,char *argv[]) 32 | { 33 | // test pgp ids. 34 | // 35 | PGPIdType id("3e5b22140ef56abb") ; 36 | 37 | std::cerr << "Id st : " << id.toStdString() << std::endl; 38 | 39 | // test PGPHandler 40 | // 41 | // 0 - init 42 | 43 | static const std::string pubring = "pubring.gpg" ; 44 | static const std::string secring = "secring.gpg" ; 45 | static const std::string trustdb = "trustdb.gpg" ; 46 | static const std::string lockfil = "lock" ; 47 | 48 | PGPHandler::setPassphraseCallback(&passphrase_callback) ; 49 | PGPHandler pgph(pubring,secring,trustdb,lockfil) ; 50 | 51 | pgph.printKeys() ; 52 | 53 | FINALREPORT("Signature parsing") ; 54 | 55 | return TESTRESULT() ; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /src/tests/pgp/test_pubring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RetroShare/libretroshare/ac83e00ea7a26cd6cf57cefef745d6dcfd07e5da/src/tests/pgp/test_pubring.gpg -------------------------------------------------------------------------------- /src/tests/pqi/extaddrfinder_test.cc: -------------------------------------------------------------------------------- 1 | #include "util/utest.h" 2 | 3 | #include 4 | #include "pqi/pqinetwork.h" 5 | 6 | #include 7 | #include 8 | 9 | INITTEST(); 10 | 11 | int main() 12 | { 13 | std::cerr << "Testing the ext address finder service. This might take up to 10 secs..." << std::endl ; 14 | 15 | ExtAddrFinder fnd ; 16 | in_addr addr ; 17 | uint32_t tries = 0 ; 18 | 19 | while(! fnd.hasValidIP( &addr )) 20 | { 21 | sleep(1) ; 22 | 23 | if(++tries > 20) 24 | { 25 | std::cerr << "Failed !" << std::endl ; 26 | CHECK(false) ; 27 | } 28 | } 29 | 30 | std::cerr << "Found the following IP: " << inet_ntoa(addr) << std::endl ; 31 | 32 | FINALREPORT("extaddrfinder_test"); 33 | 34 | return TESTRESULT() ; 35 | } 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/tests/pqi/gpgme_tst.c: -------------------------------------------------------------------------------- 1 | 2 | #include "pqi/authgpg.h" 3 | 4 | const std::string key_path("./tmp/privkey.pem"); 5 | const std::string passwd("8764"); 6 | const std::string gpg_passwd("aaaa"); 7 | const std::string name("Test X509"); 8 | const std::string email("test@email.com"); 9 | const std::string org("Org"); 10 | const std::string loc("Loc"); 11 | const std::string state("State"); 12 | const std::string country("GB"); 13 | 14 | int main() 15 | { 16 | /* Init the auth manager */ 17 | 18 | GPGAuthMgr mgr; 19 | 20 | 21 | /* Select which GPG Keys we use */ 22 | 23 | /* print all keys */ 24 | mgr.printKeys(); 25 | 26 | std::list idList; 27 | mgr.availablePGPCertificates(idList); 28 | 29 | if (idList.size() < 1) 30 | { 31 | fprintf(stderr, "No GPG Certificate to use!\n"); 32 | exit(1); 33 | } 34 | std::string id = idList.front(); 35 | fprintf(stderr, "Using GPG Certificate:%s \n", id.c_str()); 36 | 37 | std::string noname; 38 | mgr.GPGInit(id); 39 | mgr.LoadGPGPassword(gpg_passwd); 40 | 41 | /* Init SSL library */ 42 | mgr.InitAuth(NULL, NULL, NULL); 43 | 44 | /* then try to generate and sign a X509 certificate */ 45 | int nbits_in = 2048; 46 | std::string errString; 47 | 48 | /* Generate a Certificate Request */ 49 | X509_REQ *req = GenerateX509Req(key_path, passwd, name, email, org, 50 | loc, state, country, nbits_in, errString); 51 | 52 | // setup output. 53 | BIO *bio_out = NULL; 54 | bio_out = BIO_new(BIO_s_file()); 55 | BIO_set_fp(bio_out,stdout,BIO_NOCLOSE); 56 | 57 | /* Print it out */ 58 | int nmflag = 0; 59 | int reqflag = 0; 60 | 61 | X509_REQ_print_ex(bio_out, req, nmflag, reqflag); 62 | 63 | X509 *x509 = mgr.SignX509Req(req, 100, gpg_passwd); 64 | 65 | X509_print_ex(bio_out, x509, nmflag, reqflag); 66 | 67 | BIO_flush(bio_out); 68 | BIO_free(bio_out); 69 | 70 | /* now try to validate it */ 71 | mgr.AuthX509(x509); 72 | 73 | //sleep(10); 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/tests/pqi/pkt_test.h: -------------------------------------------------------------------------------- 1 | #ifndef RS_TEST_PACKETS 2 | #define RS_TEST_PACKETS 3 | /* 4 | * libretroshare/src/tests/pqi pkt_tst.cc 5 | * 6 | * 3P/PQI network interface for RetroShare. 7 | * 8 | * Copyright 2009-2010 by Robert Fernie. 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Library General Public 12 | * License Version 2 as published by the Free Software Foundation. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Library General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Library General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 22 | * USA. 23 | * 24 | * Please report all bugs and problems to "retroshare@lunamutt.com". 25 | * 26 | */ 27 | 28 | /****** 29 | * pkt_tst. 30 | * 31 | * This is not testing serialisation.... so we only need 1 type of packet. 32 | * using FileData packets - as these can have arbitary size. 33 | */ 34 | 35 | #include "serialiser/rsbaseitems.h" 36 | 37 | #define TEST_PKT_SIZE 1234567 38 | #define TEST_PKT_HASH "HASHTESTHASH" 39 | #define TEST_PKT_OFFSET 1234 40 | 41 | #define TEST_DATA_LEN (1024 * 1024) // MB 42 | 43 | void generate_test_data(); 44 | bool check_data(void *data_in, int len); 45 | 46 | RsFileData *gen_packet(int datasize, std::string pid); 47 | bool check_packet(RsFileData *pkt); 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/tests/pqi/ppg_harness.h: -------------------------------------------------------------------------------- 1 | #ifndef PPG_HARNESS_TEST_H 2 | #define PPG_HARNESS_TEST_H 3 | 4 | /* 5 | * libretroshare/src/test/pqi ppg_harness.cc 6 | * 7 | * 3P/PQI network interface for RetroShare. 8 | * 9 | * Copyright 2007-2008 by Robert Fernie. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Library General Public 13 | * License Version 2 as published by the Free Software Foundation. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Library General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Library General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 23 | * USA. 24 | * 25 | * Please report all bugs and problems to "retroshare@lunamutt.com". 26 | * 27 | */ 28 | 29 | /****** 30 | * test harness for pqipersongrp / pqihandler. 31 | */ 32 | 33 | #include "pqi/pqiperson.h" 34 | #include "pqi/pqipersongrp.h" 35 | 36 | /******************************************************* 37 | * 38 | * Test structure 39 | *****************/ 40 | 41 | void setupPqiPersonGrpTH(); 42 | void tickPqiPersonGrpTH(); 43 | 44 | class pqipersongrpTestHarness; 45 | extern pqipersongrpTestHarness *mPqiPersonGrpTH; 46 | 47 | class pqipersongrpTestHarness: public pqipersongrp 48 | { 49 | public: 50 | pqipersongrpTestHarness(SecurityPolicy *pol, unsigned long flags); 51 | 52 | protected: 53 | 54 | /********* FUNCTIONS to OVERLOAD for specialisation ********/ 55 | virtual pqilistener *createListener(struct sockaddr_in laddr); 56 | virtual pqiperson *createPerson(std::string id, pqilistener *listener); 57 | 58 | /********* FUNCTIONS to OVERLOAD for specialisation ********/ 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/tests/printcache/printcache.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | CONFIG = debug 3 | 4 | #SOURCES = main.cpp 5 | SOURCES = main_extended.cpp 6 | 7 | LIBS += ../../lib/libretroshare.a ../../../../libbitdht/src/lib/libbitdht.a ../../../../openpgpsdk/src/lib/libops.a 8 | LIBS += -lssl -lcrypto -lupnp -lgnome-keyring -lixml -lbz2 9 | 10 | INCLUDEPATH *= ../.. .. 11 | linux { 12 | #LIBS = -lstdc++ -lm 13 | } 14 | macx { 15 | # ENABLE THIS OPTION FOR Univeral Binary BUILD. 16 | # CONFIG += ppc x86 17 | # QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 18 | # CONFIG -= uitools 19 | 20 | LIBS += ../../lib/libretroshare.a 21 | LIBS += -lssl -lcrypto -lz -lgpgme -lgpg-error -lassuan 22 | LIBS += ../../../../../miniupnpc-1.0/libminiupnpc.a 23 | LIBS += ../../../../libbitdht/src/lib/libbitdht.a 24 | LIBS += -framework CoreFoundation 25 | LIBS += -framework Security 26 | 27 | # LIBS += -framework CoreServices 28 | 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/tests/scripts/checks.mk: -------------------------------------------------------------------------------- 1 | #Basic checks 2 | 3 | ifndef RS_TOP_DIR 4 | dummy: 5 | echo "RS_TOP_DIR is not defined in your makefile" 6 | endif 7 | 8 | #ifndef SSL_DIR 9 | #dummy: 10 | # echo "you must define SSL_DIR before you can compile" 11 | # 12 | #endif 13 | 14 | ifneq ($(OS),Linux) 15 | ifneq ($(OS),MacOSX) 16 | ifndef PTHREADS_DIR 17 | dummy: 18 | echo "you must define PTHREADS_DIR before you can compile" 19 | 20 | endif 21 | endif 22 | endif 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/tests/scripts/config.mk: -------------------------------------------------------------------------------- 1 | 2 | # determine which operating system 3 | # 4 | ########################################################################### 5 | #Define OS. 6 | # 7 | OS = Linux 8 | #OS = MacOSX 9 | #OS = Cygwin 10 | #OS = Win # MinGw. 11 | ########################################################################### 12 | 13 | ifeq ($(OS),Linux) 14 | include $(RS_TOP_DIR)/tests/scripts/config-linux.mk 15 | else 16 | ifeq ($(OS),MacOSX) 17 | include $(RS_TOP_DIR)/tests/scripts/config-macosx.mk 18 | else 19 | ifeq ($(OS),Cygwin) 20 | include $(RS_TOP_DIR)/tests/scripts/config-cygwin.mk 21 | else 22 | include $(RS_TOP_DIR)/tests/scripts/config-mingw.mk 23 | endif 24 | endif 25 | endif 26 | 27 | ########################################################################### 28 | -------------------------------------------------------------------------------- /src/tests/scripts/regress.mk: -------------------------------------------------------------------------------- 1 | 2 | testoutputfiles = $(foreach tt,$(1),$(tt).tstout) 3 | 4 | %.tstout : %.sh % 5 | -sh ./$< > $@ 2>&1 6 | 7 | %.tstout : % 8 | -./$< > $@ 2>&1 9 | 10 | TESTOUT = $(call testoutputfiles,$(TESTS)) 11 | 12 | .phony : tests regress retest clobber 13 | 14 | tests: $(TESTS) 15 | 16 | regress: $(TESTOUT) 17 | @-echo "--------------- SUCCESS (count):" 18 | @-grep -c SUCCESS $(TESTOUT) 19 | @-echo "--------------- FAILURE REPORTS:" 20 | @-grep FAILURE $(TESTOUT) || echo no failures 21 | @-echo "--------------- end" 22 | 23 | retest: 24 | -/bin/rm $(TESTOUT) 25 | 26 | -------------------------------------------------------------------------------- /src/tests/scripts/rules.mk: -------------------------------------------------------------------------------- 1 | 2 | # defines required / used. 3 | # 4 | # CFLAGS 5 | # 6 | # 7 | 8 | librs: $(RSOBJ) 9 | $(AR) r $(LIBRS) $(RSOBJ) 10 | $(RANLIB) $(LIBRS) 11 | 12 | .cc.o: 13 | $(CC) $(CFLAGS) -c $< 14 | 15 | clean: 16 | -/bin/rm -f $(RSOBJ) $(EXECOBJ) $(TESTOBJ) *.gcno *.gcda \ 17 | *.gcov *.tstout $(TESTS) 18 | 19 | clobber: clean retest 20 | -/bin/rm $(EXEC) $(TESTS) 21 | 22 | 23 | include $(RS_TOP_DIR)/tests/scripts/regress.mk 24 | 25 | -------------------------------------------------------------------------------- /src/tests/serialiser/TestNotes.txt: -------------------------------------------------------------------------------- 1 | 2 | Few test still need to be done. Needs to be automated 3 | 4 | used support(.h/.cc) file for testing RsItems 5 | 6 | Components and Tests. 7 | ============================================================ 8 | ------------------------------------------------------------ 9 | Basic Items 10 | ------------------------------------------------------------ 11 | rsbaseitems.cc : needed 12 | rsbaseserial.cc : needed 13 | rsconfigitems.cc : needed 14 | rsserial.cc : needed 15 | 16 | 17 | 18 | 19 | ------------------------------------------------------------ 20 | Compound TLV Components 21 | ------------------------------------------------------------ 22 | 23 | rstlvaddrs.cc : needed 24 | rstlvbase.cc : not finished, tlvbase_test 25 | rstlvfileitem.cc : tlvtypes_test 26 | rstlvimage.cc : tlvtypes_test 27 | rstlvkeys.cc : tlvtypes_test 28 | rstlvkvwide.cc : rstlvwidetest 29 | rstlvtypes.cc : tlvtypes_test 30 | rstlvutil.cc : no need 31 | 32 | ------------------------------------------------------------ 33 | Service Components 34 | ------------------------------------------------------------ 35 | rstunnelitems.cc : rstunnelitem_test & rsturtleitem_test 36 | rsdistribitem.cc : distribitem_test 37 | rsmsgitem.cc : msgitem_test 38 | rsdiscitems.cc : needed 39 | rsrankitems.cc : needed 40 | rsblogitems.cc : distribitem_test 41 | rschannelitems.cc : distribitem_test 42 | rsforumitems.cc : distribitem_test 43 | rsstatusitems.cc : needed 44 | rsgameitems.cc : TBC 45 | rsphotoitems.cc : TBC 46 | 47 | ============================================================ 48 | Test Specifics 49 | ============================================================ 50 | 51 | ------------------------------------------------------------ 52 | Basic Components 53 | ------------------------------------------------------------ 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/tests/serialiser/distribitem_test.h: -------------------------------------------------------------------------------- 1 | #ifndef DISTRIBITEM_TEST_H_ 2 | #define DISTRIBITEM_TEST_H_ 3 | 4 | /* 5 | * libretroshare/src/serialiser: distribitem_test.h 6 | * 7 | * RetroShare Serialiser tests 8 | * 9 | * Copyright 2010 by Christopher Evi-Parker. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Library General Public 13 | * License Version 2 as published by the Free Software Foundation. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Library General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Library General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 23 | * USA. 24 | * 25 | * Please report all bugs and problems to "retroshare@lunamutt.com". 26 | * 27 | */ 28 | 29 | #include "serialiser/rsdistribitems.h" 30 | #include "serialiser/rschannelitems.h" 31 | #include "serialiser/rsforumitems.h" 32 | #include "serialiser/rsblogitems.h" 33 | 34 | 35 | 36 | RsSerialType* init_item(RsDistribGrp&); 37 | RsSerialType* init_item(RsDistribGrpKey&); 38 | RsSerialType* init_item(RsDistribSignedMsg&); 39 | RsSerialType* init_item(RsChannelMsg&); 40 | RsSerialType* init_item(RsForumMsg&); 41 | RsSerialType* init_item(RsForumReadStatus&); 42 | RsSerialType* init_item(RsBlogMsg&); 43 | 44 | bool operator==(const RsDistribGrp& , const RsDistribGrp& ); 45 | bool operator==(const RsDistribGrpKey& , const RsDistribGrpKey& ); 46 | bool operator==(const RsDistribSignedMsg& , const RsDistribSignedMsg& ); 47 | bool operator==(const RsChannelMsg& , const RsChannelMsg& ); 48 | bool operator==(const RsForumMsg& , const RsForumMsg& ); 49 | bool operator==(const RsForumReadStatus&, const RsForumReadStatus& ); 50 | bool operator==(const RsBlogMsg& , const RsBlogMsg& ); 51 | 52 | 53 | 54 | 55 | #endif /* DISTRIBITEM_TEST_H_ */ 56 | -------------------------------------------------------------------------------- /src/tests/serialiser/perform_auto_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printresult() { 4 | if test "$?" = "0"; then 5 | echo ' 'PASSED 6 | else 7 | echo *FAILED* 8 | fi 9 | } 10 | 11 | # Warning: printresult needs to be called before anything else because it contains the 12 | # result of the call to the test program, until the next command. 13 | 14 | exes="rsstatusitem_test \ 15 | tlvbase_test \ 16 | rsserial_test \ 17 | tlvtypes_test \ 18 | rsmsgitem_test \ 19 | rstunnelitem_test \ 20 | tlvrandom_test \ 21 | rstlvwidetest \ 22 | rsconfigitem_test \ 23 | rsturtleitem_test \ 24 | tlvitems_test \ 25 | distribitem_test \ 26 | tlvstack_test \ 27 | tlvbase_test2" 28 | 29 | for exe in $exes; do 30 | ./$exe > /dev/null 2>&1 ; result=`printresult`; echo "-- $exe \t test :" $result ; 31 | done 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/tests/serialiser/rsgrouteritem_test.h: -------------------------------------------------------------------------------- 1 | #ifndef MSGITEM_TEST_H_ 2 | #define MSGITEM_TEST_H_ 3 | 4 | /* 5 | * libretroshare/src/tests/serialiser: msgitem_test.cc 6 | * 7 | * RetroShare Serialiser. 8 | * 9 | * Copyright 2010 by Christopher Evi-Parker. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Library General Public 13 | * License Version 2 as published by the Free Software Foundation. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Library General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Library General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 23 | * USA. 24 | * 25 | * Please report all bugs and problems to "retroshare@lunamutt.com". 26 | * 27 | */ 28 | 29 | 30 | #include 31 | #include "serialiser/rsmsgitems.h" 32 | 33 | 34 | RsSerialType* init_item(RsChatMsgItem& ); 35 | RsSerialType* init_item(RsChatStatusItem& ); 36 | RsSerialType* init_item(RsChatAvatarItem& ); 37 | RsSerialType* init_item(RsMsgItem& ); 38 | RsSerialType* init_item(RsMsgTagType& ); 39 | RsSerialType* init_item(RsMsgTags& ); 40 | RsSerialType* init_item(RsMsgSrcId& ); 41 | 42 | bool operator ==(const RsChatMsgItem& ,const RsChatMsgItem& ); 43 | bool operator ==(const RsChatStatusItem& , const RsChatStatusItem& ); 44 | bool operator ==(const RsChatAvatarItem&, const RsChatAvatarItem& ); 45 | bool operator ==(const RsMsgTagType&, const RsMsgTagType& ); 46 | bool operator ==(const RsMsgTags&, const RsMsgTags& ); 47 | bool operator ==(const RsMsgItem&, const RsMsgItem& ); 48 | bool operator ==(const RsMsgSrcId&, const RsMsgSrcId& ); 49 | 50 | #endif /* MSGITEM_TEST_H_ */ 51 | -------------------------------------------------------------------------------- /src/tests/serialiser/rsgxsupdateitem_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rsgxsupdateitem_test.h 3 | * 4 | * Created on: 9 Dec 2013 5 | * Author: crispy 6 | */ 7 | 8 | #ifndef RSGXSUPDATEITEM_TEST_H_ 9 | #define RSGXSUPDATEITEM_TEST_H_ 10 | 11 | #include "serialiser/rsgxsupdateitems.h" 12 | #include "support.h" 13 | 14 | 15 | RsSerialType* init_item(RsGxsGrpUpdateItem& i); 16 | RsSerialType* init_item(RsGxsMsgUpdateItem& i); 17 | RsSerialType* init_item(RsGxsServerGrpUpdateItem& i); 18 | RsSerialType* init_item(RsGxsServerMsgUpdateItem& i); 19 | 20 | bool operator==(const RsGxsGrpUpdateItem& l, const RsGxsGrpUpdateItem& r); 21 | bool operator==(const RsGxsMsgUpdateItem& l, const RsGxsMsgUpdateItem& r); 22 | bool operator==(const RsGxsServerGrpUpdateItem& l, const RsGxsServerGrpUpdateItem& r); 23 | bool operator==(const RsGxsServerMsgUpdateItem& l, const RsGxsServerMsgUpdateItem& r); 24 | 25 | #endif /* RSGXSUPDATEITEM_TEST_H_ */ 26 | -------------------------------------------------------------------------------- /src/tests/serialiser/rsmsgitem_test.h: -------------------------------------------------------------------------------- 1 | #ifndef MSGITEM_TEST_H_ 2 | #define MSGITEM_TEST_H_ 3 | 4 | /* 5 | * libretroshare/src/tests/serialiser: msgitem_test.cc 6 | * 7 | * RetroShare Serialiser. 8 | * 9 | * Copyright 2010 by Christopher Evi-Parker. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Library General Public 13 | * License Version 2 as published by the Free Software Foundation. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Library General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Library General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 23 | * USA. 24 | * 25 | * Please report all bugs and problems to "retroshare@lunamutt.com". 26 | * 27 | */ 28 | 29 | 30 | #include 31 | #include "serialiser/rsmsgitems.h" 32 | 33 | 34 | RsSerialType* init_item(RsChatMsgItem& ); 35 | RsSerialType* init_item(RsChatStatusItem& ); 36 | RsSerialType* init_item(RsChatAvatarItem& ); 37 | RsSerialType* init_item(RsMsgItem& ); 38 | RsSerialType* init_item(RsMsgTagType& ); 39 | RsSerialType* init_item(RsMsgTags& ); 40 | RsSerialType* init_item(RsMsgSrcId& ); 41 | 42 | bool operator ==(const RsChatMsgItem& ,const RsChatMsgItem& ); 43 | bool operator ==(const RsChatStatusItem& , const RsChatStatusItem& ); 44 | bool operator ==(const RsChatAvatarItem&, const RsChatAvatarItem& ); 45 | bool operator ==(const RsMsgTagType&, const RsMsgTagType& ); 46 | bool operator ==(const RsMsgTags&, const RsMsgTags& ); 47 | bool operator ==(const RsMsgItem&, const RsMsgItem& ); 48 | bool operator ==(const RsMsgSrcId&, const RsMsgSrcId& ); 49 | 50 | #endif /* MSGITEM_TEST_H_ */ 51 | -------------------------------------------------------------------------------- /src/tests/serialiser/rsnxsitems_test.h: -------------------------------------------------------------------------------- 1 | #ifndef RSNXSITEMS_TEST_H 2 | #define RSNXSITEMS_TEST_H 3 | 4 | #include "serialiser/rsnxsitems.h" 5 | 6 | 7 | RsSerialType* init_item(RsNxsGrp&); 8 | RsSerialType* init_item(RsNxsMsg&); 9 | RsSerialType* init_item(RsNxsSyncGrp&); 10 | RsSerialType* init_item(RsNxsSyncMsg&); 11 | RsSerialType* init_item(RsNxsSyncGrpItem&); 12 | RsSerialType* init_item(RsNxsSyncMsgItem&); 13 | RsSerialType* init_item(RsNxsTransac& ); 14 | 15 | bool operator==(const RsNxsGrp&, const RsNxsGrp&); 16 | bool operator==(const RsNxsMsg&, const RsNxsMsg&); 17 | bool operator==(const RsNxsSyncGrp&, const RsNxsSyncGrp&); 18 | bool operator==(const RsNxsSyncMsg&, const RsNxsSyncMsg&); 19 | bool operator==(const RsNxsSyncGrpItem&, const RsNxsSyncGrpItem&); 20 | bool operator==(const RsNxsSyncMsgItem&, const RsNxsSyncMsgItem&); 21 | bool operator==(const RsNxsTransac&, const RsNxsTransac& ); 22 | 23 | 24 | #endif // RSNXSITEMS_TEST_H 25 | -------------------------------------------------------------------------------- /src/tests/serialiser/rsphotoitem_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libretroshare/src/test rsphotoitem_test.h 3 | * 4 | * Test for photo item serialisation 5 | * 6 | * Copyright 2012-2012 by Christopher Evi-Parker 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License Version 2 as published by the Free Software Foundation. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Library General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Library General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA. 21 | * 22 | * Please report all bugs and problems to "retroshare@lunamutt.com". 23 | * 24 | */ 25 | 26 | #ifndef RSPHOTOITEM_TEST_H_ 27 | #define RSPHOTOITEM_TEST_H_ 28 | 29 | #include "serialiser/rsphotov2items.h" 30 | #include "support.h" 31 | 32 | 33 | 34 | RsSerialType* init_item(RsGxsPhotoAlbumItem& album); 35 | RsSerialType* init_item(RsGxsPhotoPhotoItem& photo); 36 | 37 | bool operator == (RsGxsPhotoAlbumItem& l, RsGxsPhotoAlbumItem& r); 38 | bool operator == (RsGxsPhotoPhotoItem& l, RsGxsPhotoPhotoItem& r); 39 | bool operator == (RsPhotoThumbnail& l, RsPhotoThumbnail& r); 40 | 41 | #endif /* RSPHOTOITEM_TEST_H_ */ 42 | -------------------------------------------------------------------------------- /src/tests/serialiser/rsstatusitem_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * libretroshare/src/tests/serialiser: rsstatusitem_test.cc 3 | * 4 | * RetroShare Serialiser. 5 | * 6 | * Copyright 2010 by Christopher Evi-Parker. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License Version 2 as published by the Free Software Foundation. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Library General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Library General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA. 21 | * 22 | * Please report all bugs and problems to "retroshare@lunamutt.com". 23 | * 24 | */ 25 | 26 | 27 | #include "support.h" 28 | #include "rsstatusitem_test.h" 29 | 30 | INITTEST(); 31 | 32 | RsSerialType* init_item(RsStatusItem& rsi) 33 | { 34 | 35 | rsi.sendTime = rand()%5353; 36 | rsi.status = rand()%2032; 37 | return new RsStatusSerialiser(); 38 | } 39 | 40 | bool operator ==(RsStatusItem& rsi1, RsStatusItem& rsi2) 41 | { 42 | // note: recv time is not serialised 43 | 44 | if(rsi1.sendTime != rsi2.sendTime) return false; 45 | if(rsi1.status != rsi2.status) return false; 46 | 47 | return true; 48 | } 49 | 50 | 51 | int main() 52 | { 53 | 54 | std::cerr << "RsStatusItem Tests" << std::endl; 55 | 56 | test_RsItem(); REPORT("Serialise/Deserialise RsStatusItem"); 57 | FINALREPORT("RsStatusItem Tests"); 58 | 59 | return TESTRESULT(); 60 | } 61 | -------------------------------------------------------------------------------- /src/tests/serialiser/rsstatusitem_test.h: -------------------------------------------------------------------------------- 1 | #ifndef RSSTATUS_TEST_H_ 2 | #define RSSTATUS_TEST_H_ 3 | 4 | /* 5 | * libretroshare/src/tests/serialiser: rsstatusitem_test.h 6 | * 7 | * RetroShare Serialiser. 8 | * 9 | * Copyright 2010 by Christopher Evi-Parker. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Library General Public 13 | * License Version 2 as published by the Free Software Foundation. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Library General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Library General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 23 | * USA. 24 | * 25 | * Please report all bugs and problems to "retroshare@lunamutt.com". 26 | * 27 | */ 28 | 29 | #include "serialiser/rsstatusitems.h" 30 | 31 | RsSerialType* init_item(RsStatusItem& ); 32 | 33 | bool operator ==(RsStatusItem& , RsStatusItem& ); 34 | 35 | #endif /* RSSTATUS_TEST_H_ */ 36 | -------------------------------------------------------------------------------- /src/tests/serialiser/rstlvutil.h: -------------------------------------------------------------------------------- 1 | #ifndef RS_TLV_UTIL_H 2 | #define RS_TLV_UTIL_H 3 | 4 | /* 5 | * libretroshare/src/serialiser: rstlvutil.h 6 | * 7 | * RetroShare Serialiser. 8 | * 9 | * Copyright 2007-2008 by Robert Fernie. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Library General Public 13 | * License Version 2 as published by the Free Software Foundation. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Library General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Library General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 23 | * USA. 24 | * 25 | * Please report all bugs and problems to "retroshare@lunamutt.com". 26 | * 27 | */ 28 | 29 | /* some utility functions mainly for debugging 30 | */ 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | class RsTlvItem; 37 | 38 | /* print out a packet */ 39 | void displayRawPacket(std::ostream &out, void *data, uint32_t size); 40 | int test_SerialiseTlvItem(std::ostream &str, RsTlvItem *in, RsTlvItem *out); 41 | 42 | 43 | bool test_StepThroughTlvStack(std::ostream &str, void *data, int size); 44 | int test_CreateTlvStack(std::ostream &str, 45 | std::vector items, void *data, int totalsize); 46 | int test_TlvSet(std::vector items, int maxsize); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/tests/serialiser/tlvitems_test.cc: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * libretroshare/src/serialiser: tlvitems_test.cc 4 | * 5 | * RetroShare Serialiser. 6 | * 7 | * Copyright 2007-2008 by Robert Fernie. 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Library General Public 11 | * License Version 2 as published by the Free Software Foundation. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Library General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Library General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 21 | * USA. 22 | * 23 | * Please report all bugs and problems to "retroshare@lunamutt.com". 24 | * 25 | */ 26 | 27 | /****************************************************************** 28 | * tlvfileitem test. 29 | * 30 | * 31 | */ 32 | 33 | #include 34 | #include 35 | #include "serialiser/rstlvbinary.h" 36 | #include "serialiser/rstlvutil.h" 37 | #include "util/utest.h" 38 | 39 | INITTEST(); 40 | 41 | static int test_RsTlvBinData(); 42 | static int test_RsTlvStepping(); 43 | 44 | int main() 45 | { 46 | std::cerr << "RsTlvItems Tests" << std::endl; 47 | 48 | test_RsTlvBinData(); 49 | 50 | FINALREPORT("RsTlvItems Tests"); 51 | 52 | return TESTRESULT(); 53 | } 54 | 55 | #define BIN_LEN 65536 /* bigger than 64k */ 56 | 57 | int test_RsTlvBinData() 58 | { 59 | RsTlvBinaryData d1(1023); 60 | RsTlvBinaryData d2(1023); 61 | 62 | char data[BIN_LEN] = {0}; 63 | int i, j; 64 | for(i = 0; i < BIN_LEN; i++) 65 | { 66 | data[i] = i%13; 67 | } 68 | 69 | for(j = 1; j < BIN_LEN; j *= 2) 70 | { 71 | d1.setBinData(data, j); 72 | CHECK(test_SerialiseTlvItem(std::cerr, &d1, &d2)); 73 | 74 | CHECK(d1.bin_len == d2.bin_len); 75 | CHECK(0 == memcmp(d1.bin_data, d2.bin_data, d1.bin_len)); 76 | } 77 | 78 | REPORT("Serialise/Deserialise RsTlvBinData"); 79 | 80 | return 1; 81 | } 82 | 83 | int test_RsTlvStepping() 84 | { 85 | 86 | 87 | return 1; 88 | } 89 | 90 | -------------------------------------------------------------------------------- /src/tests/serialiser/tlvkey_test.cc: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "support.h" 4 | #include "serialiser/rstlvkeys.h" 5 | 6 | INITTEST(); 7 | 8 | bool test_RsTlvKeySignatureSet(); 9 | 10 | int main() 11 | { 12 | test_RsTlvKeySignatureSet(); REPORT("test_RsTlvKeySignatureSet()"); 13 | 14 | FINALREPORT("RsTlvKey Test"); 15 | } 16 | 17 | 18 | 19 | bool test_RsTlvKeySignatureSet() 20 | { 21 | RsTlvKeySignatureSet set; 22 | 23 | init_item(set); 24 | 25 | char data[set.TlvSize()]; 26 | uint32_t offset = 0; 27 | set.SetTlv(data, set.TlvSize(), &offset); 28 | 29 | RsTlvKeySignatureSet setConfirm; 30 | 31 | offset = 0; 32 | setConfirm.GetTlv(data, set.TlvSize(), &offset); 33 | 34 | CHECK(setConfirm == set); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/tests/serialiser/valgrind_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo This script will call valgrind on all executables of the current directory and launch a debugger in case it finds an error. If the script terminate with non error, then the test passes. Press enter when ready... 4 | read tmp 5 | 6 | for i in `find . -executable -type f | grep -v valgrind`; do 7 | echo testing $i 8 | valgrind --tool=memcheck --db-attach=yes ./$i 9 | done 10 | -------------------------------------------------------------------------------- /src/tests/services/chatservicetest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * chatservicetest.cpp 3 | * 4 | * Created on: 17 Jun 2011 5 | * Author: greyfox 6 | */ 7 | 8 | #include "chatservicetest.h" 9 | 10 | chatServiceTest::chatServiceTest() 11 | : ServiceTest() { 12 | 13 | mChat = new p3ChatService(mConnMgr); 14 | } 15 | 16 | chatServiceTest::~chatServiceTest() { 17 | delete mChat; 18 | } 19 | 20 | void chatServiceTest::runTests(){ 21 | 22 | } 23 | 24 | void chatServiceTest::insertChatItems(){ 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/tests/services/chatservicetest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * chatservicetest.h 3 | * 4 | * Created on: 17 Jun 2011 5 | * Author: greyfox 6 | */ 7 | 8 | #ifndef CHATSERVICETEST_H_ 9 | #define CHATSERVICETEST_H_ 10 | 11 | #include "servicetest.h" 12 | #include "services/p3chatservice.h" 13 | #include "util/utest.h" 14 | 15 | class chatServiceTest: public ServiceTest { 16 | 17 | public: 18 | chatServiceTest(); 19 | virtual ~chatServiceTest(); 20 | 21 | public: 22 | void runTests(); 23 | 24 | void insertChatItems(); 25 | 26 | private: 27 | 28 | p3ChatService* mChat; 29 | 30 | }; 31 | 32 | #endif /* CHATSERVICETEST_H_ */ 33 | -------------------------------------------------------------------------------- /src/tests/services/chattest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * chattest.cc 3 | * 4 | * Created on: 17 Jun 2011 5 | * Author: greyfox 6 | */ 7 | 8 | #include "chatservicetest.h" 9 | 10 | // chat service is tested here 11 | int main(){ 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/tests/services/distribtest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * libretroshare/src/tests/services distrib_test_main.cc 3 | * 4 | * RetroShare Service Testing 5 | * 6 | * Copyright 2011 by Christopher Evi-Parker. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License Version 2 as published by the Free Software Foundation. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Library General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Library General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA. 21 | * 22 | * Please report all bugs and problems to "retroshare@lunamutt.com". 23 | * 24 | */ 25 | 26 | #include "forumservicetest.h" 27 | 28 | 29 | // distrib services are tested here 30 | int main() 31 | { 32 | forumServiceTest forumTest; 33 | forumTest.runTests(); 34 | REPORT("Forum Tests"); 35 | 36 | FINALREPORT("Distrib Test"); 37 | 38 | return TESTRESULT(); 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/services/forumservicetest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * libretroshare/src/tests/services distrib_services.cc 3 | * 4 | * RetroShare Service Testing 5 | * 6 | * Copyright 2010 by Chris Evi-Parker, Robert Fernie 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License Version 2 as published by the Free Software Foundation. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Library General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Library General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA. 21 | * 22 | * Please report all bugs and problems to "retroshare@lunamutt.com". 23 | * 24 | */ 25 | 26 | 27 | #include "forumservicetest.h" 28 | 29 | 30 | forumServiceTest::forumServiceTest() 31 | : ServiceTest() { 32 | 33 | mForums = NULL; 34 | 35 | } 36 | 37 | 38 | forumServiceTest::~forumServiceTest(){ 39 | if(mForums != NULL) 40 | delete mForums; 41 | } 42 | 43 | bool forumServiceTest::getForumMsgTest(){ 44 | return false; 45 | } 46 | 47 | bool forumServiceTest::setForumMsgTest(){ 48 | return false; 49 | } 50 | 51 | bool forumServiceTest::createGroupTests(){ 52 | return false; 53 | } 54 | 55 | void forumServiceTest::runTests(){ 56 | 57 | } 58 | 59 | void forumServiceTest::loadDummyData(){ 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/tests/services/forumservicetest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libretroshare/src/tests/services distrib_services.h 3 | * 4 | * RetroShare Service Testing 5 | * 6 | * Copyright 2010 by Chris Evi-Parker. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License Version 2 as published by the Free Software Foundation. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Library General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Library General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA. 21 | * 22 | * Please report all bugs and problems to "retroshare@lunamutt.com". 23 | * 24 | */ 25 | 26 | 27 | #ifndef DISTRIB_SERVICE_TEST_H_ 28 | #define DISTRIB_SERVICE_TEST_H_ 29 | 30 | #include "servicetest.h" 31 | #include "services/p3forums.h" 32 | #include "util/utest.h" 33 | 34 | INITTEST() 35 | 36 | class forumServiceTest : public ServiceTest { 37 | 38 | public: 39 | 40 | forumServiceTest(); 41 | ~forumServiceTest(); 42 | 43 | 44 | void runTests(); 45 | 46 | private: 47 | 48 | bool getForumMsgTest(); 49 | bool setForumMsgTest(); 50 | bool createGroupTests(); 51 | 52 | private: 53 | 54 | void loadDummyData(); 55 | 56 | private: 57 | 58 | p3Forums* mForums; 59 | 60 | }; 61 | 62 | 63 | #endif /* DISTRIB_SERVICE_TEST_H_ */ 64 | -------------------------------------------------------------------------------- /src/tests/services/servicetest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * libretroshare/src/tests/services Service_Test.cc 3 | * 4 | * RetroShare Service Testing 5 | * 6 | * Copyright 2010 by Chris Evi-Parker. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License Version 2 as published by the Free Software Foundation. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Library General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Library General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA. 21 | * 22 | * Please report all bugs and problems to "retroshare@lunamutt.com". 23 | * 24 | */ 25 | 26 | #include "servicetest.h" 27 | #include "pqi/pqisslpersongrp.h" 28 | 29 | 30 | ServiceTest::ServiceTest() 31 | { 32 | 33 | mConnMgr = new p3ConnectMgr(); 34 | #error secpolicy was removed, should remove it from tests too 35 | SecurityPolicy *none = secpolicy_create(); 36 | mPersonGrp = new pqisslpersongrp(none, NULL); 37 | mPeers = new p3Peers(mConnMgr); 38 | 39 | mConnMgr->addFriend(fakePeer); 40 | } 41 | 42 | ServiceTest::~ServiceTest() 43 | { 44 | // release resources 45 | delete mConnMgr; 46 | delete mPersonGrp; 47 | delete mPeers; 48 | } 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/tests/services/servicetest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libretroshare/src/tests/services Service_Test.h 3 | * 4 | * RetroShare Service Testing 5 | * 6 | * Copyright 2010 by Chris Evi-Parker. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License Version 2 as published by the Free Software Foundation. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Library General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Library General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA. 21 | * 22 | * Please report all bugs and problems to "retroshare@lunamutt.com". 23 | * 24 | */ 25 | 26 | 27 | #ifndef SERVICE_TEST_H_ 28 | #define SERVICE_TEST_H_ 29 | 30 | #include "pqi/p3connmgr.h" 31 | #include "rsserver/p3peers.h" 32 | #include "dbase/cachestrapper.h" 33 | #include "pqi/pqipersongrp.h" 34 | 35 | 36 | 37 | 38 | /*! 39 | * A convenience class from which tests derive from 40 | * This enables user to test in shallow manner the public methods 41 | * of a service 42 | */ 43 | class ServiceTest { 44 | 45 | public: 46 | ServiceTest(); 47 | virtual ~ServiceTest(); 48 | 49 | /*! 50 | * all tests of service should be implemented here 51 | */ 52 | virtual void runTests() = 0; 53 | 54 | /*! 55 | * use this to populate the service with messages 56 | */ 57 | void sendItem(RsItem* item); 58 | 59 | protected: 60 | 61 | 62 | p3ConnectMgr* mConnMgr; 63 | CacheStrapper *mCs; 64 | CacheTransfer *mCt; 65 | p3Peers* mPeers; 66 | pqipersongrp* mPersonGrp; 67 | 68 | std::string fakePeer; // ssl id of fake receiving peer 69 | 70 | }; 71 | 72 | 73 | 74 | #endif /* SERVICE_TEST_H_ */ 75 | -------------------------------------------------------------------------------- /src/tests/tcponudp/bidir_tou.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to Test the udp_server code. 3 | 4 | EXEC=./bidir_tou 5 | DATAFILE=../../lib/libretroshare.a 6 | 7 | TMPOUTPUT=tmpoutput$$ 8 | EXPECTEDPERIOD=10 9 | 10 | $EXEC 127.0.0.1 4401 127.0.0.1 4032 < $DATAFILE > $TMPOUTPUT 11 | 12 | if diff -s $DATAFILE $TMPOUTPUT 13 | then 14 | echo "SUCCESS" 15 | else 16 | echo "FAILURE to accurately transfer DATA" 17 | fi 18 | 19 | rm $TMPOUTPUT 20 | 21 | -------------------------------------------------------------------------------- /src/tests/tcponudp/stacks_tou.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to Test the udp_server code. 3 | 4 | EXEC=./stacks_tou 5 | DATAFILE=./stacks_tou 6 | 7 | TMPOUTPUT=tmpoutput$$ 8 | EXPECTEDPERIOD=10 9 | 10 | $EXEC 127.0.0.1 4401 127.0.0.1 4032 < $DATAFILE > $TMPOUTPUT 11 | 12 | if diff -s $DATAFILE $TMPOUTPUT 13 | then 14 | echo "SUCCESS" 15 | else 16 | echo "FAILURE to accurately transfer DATA" 17 | fi 18 | 19 | rm $TMPOUTPUT 20 | 21 | -------------------------------------------------------------------------------- /src/tests/tcponudp/test_tou.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to Test the udp_server code. 3 | 4 | EXEC=./test_tou 5 | TMPOUTPUT=tmpoutput$$ 6 | EXPECTEDPERIOD=10 7 | # launches one instance in server mode. 8 | $EXEC 127.0.0.1 4001 127.0.0.1 4002 > $TMPOUTPUT & 9 | #2> udp_server1.cerr & 10 | 11 | # launch a second in connect mode. 12 | $EXEC -c 127.0.0.1 4002 127.0.0.1 4001 < $EXEC 13 | # 2> udp_server2.cerr 14 | # pipe a bunch of data through. 15 | # make sure the data is the same. 16 | 17 | # print success / failure. 18 | sleep $EXPECTEDPERIOD 19 | killall $EXEC 20 | 21 | if diff -s $EXEC $TMPOUTPUT 22 | then 23 | echo "SUCCESS" 24 | else 25 | echo "FAILURE to accurately transfer DATA" 26 | fi 27 | 28 | #rm udp_server1.cerr 29 | #rm udp_server2.cerr 30 | rm $TMPOUTPUT 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/tests/tcponudp/timed_tou.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to Test the udp_server code. 3 | 4 | EXEC=./timed_tou 5 | DATAFILE=./timed_tou 6 | 7 | TMPOUTPUT=tmpoutput$$ 8 | EXPECTEDPERIOD=10 9 | 10 | $EXEC 127.0.0.1 4401 127.0.0.1 4032 < $DATAFILE > $TMPOUTPUT 11 | 12 | if diff -s $DATAFILE $TMPOUTPUT 13 | then 14 | echo "SUCCESS" 15 | else 16 | echo "FAILURE to accurately transfer DATA" 17 | fi 18 | 19 | rm $TMPOUTPUT 20 | 21 | -------------------------------------------------------------------------------- /src/tests/tcponudp/udp_server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to Test the udp_server code. 3 | 4 | EXEC=./udp_server 5 | TMPOUTPUT=tmpoutput$$ 6 | EXPECTEDPERIOD=10 7 | # launches one instance in server mode. 8 | $EXEC 127.0.0.1 4001 127.0.0.1 4002 > $TMPOUTPUT & 9 | #2> udp_server1.cerr & 10 | 11 | # launch a second in connect mode. 12 | $EXEC -c 127.0.0.1 4002 127.0.0.1 4001 < $EXEC 13 | # 2> udp_server2.cerr 14 | # pipe a bunch of data through. 15 | # make sure the data is the same. 16 | 17 | # print success / failure. 18 | sleep $EXPECTEDPERIOD 19 | killall $EXEC 20 | 21 | if diff -s $EXEC $TMPOUTPUT 22 | then 23 | echo "SUCCESS" 24 | else 25 | echo "FAILURE to accurately transfer DATA" 26 | fi 27 | 28 | #rm udp_server1.cerr 29 | #rm udp_server2.cerr 30 | rm $TMPOUTPUT 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/tests/tcponudp/udpsock_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to Test the udp_server code. 3 | 4 | EXEC=./udpsock_test 5 | TMPOUTPUT=tmpoutput$$ 6 | EXPECTEDPERIOD=10 7 | $EXEC 6001 6002 6003 6004 6005 & 8 | #2> udp_server1.cerr & 9 | 10 | $EXEC 6002 6001 6003 6004 6005 & 11 | $EXEC 6003 6002 6001 6004 6005 & 12 | $EXEC 6004 6002 6003 6001 6005 & 13 | $EXEC 6005 6002 6003 6004 6001 & 14 | 15 | ## print success / failure. 16 | sleep $EXPECTEDPERIOD 17 | killall $EXEC 18 | 19 | # 20 | #if diff -s $EXEC $TMPOUTPUT 21 | #then 22 | # echo "SUCCESS" 23 | #else 24 | # echo "FAILURE to accurately transfer DATA" 25 | #fi 26 | # 27 | ##rm udp_server1.cerr 28 | ##rm udp_server2.cerr 29 | #rm $TMPOUTPUT 30 | ## 31 | ### 32 | -------------------------------------------------------------------------------- /src/tests/tcponudp/udpsort_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to Test the udp_server code. 3 | 4 | EXEC=./udpsort_test 5 | TMPOUTPUT=tmpoutput$$ 6 | EXPECTEDPERIOD=10 7 | $EXEC 6001 6002 6003 6004 6005 & 8 | #2> udp_server1.cerr & 9 | 10 | $EXEC 6002 6001 6003 6004 6005 & 11 | $EXEC 6003 6002 6001 6004 6005 & 12 | $EXEC 6004 6002 6003 6001 6005 & 13 | $EXEC 6005 6002 6003 6004 6001 & 14 | 15 | ## print success / failure. 16 | sleep $EXPECTEDPERIOD 17 | killall $EXEC 18 | 19 | # 20 | #if diff -s $EXEC $TMPOUTPUT 21 | #then 22 | # echo "SUCCESS" 23 | #else 24 | # echo "FAILURE to accurately transfer DATA" 25 | #fi 26 | # 27 | ##rm udp_server1.cerr 28 | ##rm udp_server2.cerr 29 | #rm $TMPOUTPUT 30 | ## 31 | ### 32 | -------------------------------------------------------------------------------- /src/tests/tcponudp/udptestfn.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * libretroshare/src/tcponudp: udptestfn.cc 3 | * 4 | * TCP-on-UDP (tou) network interface for RetroShare. 5 | * 6 | * Copyright 2007-2008 by Robert Fernie. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License Version 2 as published by the Free Software Foundation. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Library General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Library General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA. 21 | * 22 | * Please report all bugs and problems to "retroshare@lunamutt.com". 23 | * 24 | */ 25 | 26 | #include "udptestfn.h" 27 | 28 | int UdpRecvTest::recvPkt(void *data, int size, struct sockaddr_in &from) 29 | { 30 | /* print packet information */ 31 | std::cerr << "UdpRecvTest::recvPkt(" << size << ") from: " << from; 32 | std::cerr << std::endl; 33 | return -1; 34 | } 35 | 36 | UdpPeerTest::UdpPeerTest(struct sockaddr_in &addr) 37 | :raddr(addr) 38 | { 39 | return; 40 | } 41 | 42 | void UdpPeerTest::recvPkt(void *data, int size) 43 | { 44 | /* print packet information */ 45 | std::cerr << "UdpPeerTest::recvPkt(" << size << ") from: " << raddr; 46 | std::cerr << std::endl; 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/tests/tcponudp/udptestfn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libretroshare/src/tcponudp: udptestfn.h 3 | * 4 | * TCP-on-UDP (tou) network interface for RetroShare. 5 | * 6 | * Copyright 2007-2008 by Robert Fernie. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License Version 2 as published by the Free Software Foundation. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Library General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Library General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA. 21 | * 22 | * Please report all bugs and problems to "retroshare@lunamutt.com". 23 | * 24 | */ 25 | 26 | #include "udp/udplayer.h" 27 | #include "udp/udpstack.h" 28 | #include "tcponudp/udppeer.h" 29 | 30 | //#include "udpsorter.h" 31 | 32 | #ifndef TOU_UDP_TEST_FN_H 33 | #define TOU_UDP_TEST_FN_H 34 | 35 | class UdpRecvTest: public UdpReceiver 36 | { 37 | public: 38 | virtual int recvPkt(void *data, int size, struct sockaddr_in &from); 39 | virtual int status(std::ostream&) { return 0; } 40 | }; 41 | 42 | 43 | class UdpPeerTest: public UdpPeer 44 | { 45 | public: 46 | UdpPeerTest(struct sockaddr_in &addr); 47 | virtual void recvPkt(void *data, int size); 48 | 49 | struct sockaddr_in raddr; 50 | }; 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/tests/utest.h: -------------------------------------------------------------------------------- 1 | #ifndef _UNIT_TEST_MACROS_H__ 2 | #define _UNIT_TEST_MACROS_H__ 3 | 4 | #include 5 | 6 | #define TFAILURE( s ) printf( "FAILURE: " __FILE__ ":%-4d %s\n", __LINE__, s ) 7 | #define TSUCCESS( s ) printf( "SUCCESS: " __FILE__ ":%-4d %s\n", __LINE__, s ) 8 | 9 | /* careful with this line (no protection) */ 10 | #define INITTEST() int ok = 1; int gok = 1; 11 | 12 | /* declare the variables */ 13 | extern int ok; 14 | extern int gok; 15 | 16 | #define CHECK( b ) do { if ( ! (b) ) { ok = 0; TFAILURE( #b ); } } while(0) 17 | #define FAILED( s ) do { ok = 0; TFAILURE( s ); } while(0) 18 | #define REPORT( s ) do { if ( ! (ok) ) { ok = 0; TFAILURE( s ); } else { TSUCCESS( s );} gok &= ok; ok = 1; } while(0) 19 | #define REPORT2( b, s ) do { if ( ! (b) ) { ok = 0; TFAILURE( s ); } else { TSUCCESS( s );} gok &= ok; ok = 1; } while(0) 20 | #define FINALREPORT( s ) do { gok &= ok; ok = 1; if ( ! (gok) ) { TFAILURE( s ); } else { TSUCCESS( s );} } while(0) 21 | #define TESTRESULT() (!gok) 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/tests/util/dir2test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * dirtest.cc 3 | * 4 | * RetroShare Test Program. 5 | * 6 | * Copyright 2004-2007 by Robert Fernie. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License Version 2 as published by the Free Software Foundation. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Library General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Library General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA. 21 | * 22 | * Please report all bugs and problems to "retroshare@lunamutt.com". 23 | * 24 | */ 25 | 26 | 27 | #include "util/rsdir.h" 28 | 29 | #include 30 | 31 | int processpath(std::string path); 32 | 33 | int main() 34 | { 35 | 36 | std::string path1 = "/home/tst1//test2///test3/"; 37 | std::string path2 = "home2/tst4//test5///test6"; 38 | std::string path3 = "//home3"; 39 | std::string path4 = "//"; 40 | std::string path5 = "/a/b/c/d/"; 41 | std::string path6 = "a//b/c//d"; 42 | 43 | processpath(path1); 44 | processpath(path2); 45 | processpath(path3); 46 | processpath(path4); 47 | processpath(path5); 48 | processpath(path6); 49 | 50 | return 1; 51 | } 52 | 53 | 54 | int processpath(std::string path) 55 | { 56 | std::string pathtogo = path; 57 | while(pathtogo != "") 58 | { 59 | std::string basedir = RsDirUtil::getRootDir(pathtogo); 60 | std::string rempath = RsDirUtil::removeRootDir(pathtogo); 61 | std::string topdir = RsDirUtil::getTopDir(pathtogo); 62 | std::string remtoppath = RsDirUtil::removeTopDir(pathtogo); 63 | 64 | std::cerr << "Processing: \"" << pathtogo << "\"" << std::endl; 65 | std::cerr << "\tRootDir : \"" << basedir << "\"" << std::endl; 66 | std::cerr << "\tRemaining: \"" << rempath << "\"" << std::endl; 67 | std::cerr << "\tTopDir : \"" << topdir << "\"" << std::endl; 68 | std::cerr << "\tRemaining(Top): \"" << remtoppath << "\"" << std::endl; 69 | std::cerr << std::endl; 70 | 71 | pathtogo = rempath; 72 | } 73 | return 1; 74 | } 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /src/tests/util/testretrodb.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RetroShare/libretroshare/ac83e00ea7a26cd6cf57cefef745d6dcfd07e5da/src/tests/util/testretrodb.cpp -------------------------------------------------------------------------------- /src/tor/StrUtil.h: -------------------------------------------------------------------------------- 1 | /* Ricochet - https://ricochet.im/ 2 | * Copyright (C) 2014, John Brooks 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above 12 | * copyright notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * * Neither the names of the copyright owners nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef STRINGUTIL_H 34 | #define STRINGUTIL_H 35 | 36 | #include 37 | 38 | #include "bytearray.h" 39 | 40 | ByteArray quotedString(const ByteArray &string); 41 | 42 | /* Return the unquoted contents of a string, either until an end quote or an unescaped separator character. */ 43 | ByteArray unquotedString(const ByteArray &string); 44 | 45 | std::list splitQuotedStrings(const ByteArray& input, char separator); 46 | 47 | #endif // STRINGUTIL_H 48 | -------------------------------------------------------------------------------- /src/turtle/turtlestatistics.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class TurtleTrafficStatisticsInfoOp: public TurtleTrafficStatisticsInfo 4 | { 5 | public: 6 | TurtleTrafficStatisticsInfoOp() 7 | { 8 | reset() ; 9 | } 10 | 11 | void reset() 12 | { 13 | unknown_updn_Bps = 0.0f ; 14 | data_up_Bps = 0.0f ; 15 | data_dn_Bps = 0.0f ; 16 | tr_up_Bps = 0.0f ; 17 | tr_dn_Bps = 0.0f ; 18 | total_up_Bps = 0.0f ; 19 | total_dn_Bps = 0.0f ; 20 | } 21 | 22 | TurtleTrafficStatisticsInfoOp operator*(float f) const 23 | { 24 | TurtleTrafficStatisticsInfoOp i(*this) ; 25 | 26 | i.unknown_updn_Bps *= f ; 27 | i.data_up_Bps *= f ; 28 | i.data_dn_Bps *= f ; 29 | i.tr_up_Bps *= f ; 30 | i.tr_dn_Bps *= f ; 31 | i.total_up_Bps *= f ; 32 | i.total_dn_Bps *= f ; 33 | 34 | return i ; 35 | } 36 | TurtleTrafficStatisticsInfoOp operator+(const TurtleTrafficStatisticsInfoOp& j) const 37 | { 38 | TurtleTrafficStatisticsInfoOp i(*this) ; 39 | 40 | i.unknown_updn_Bps += j.unknown_updn_Bps ; 41 | i.data_up_Bps += j.data_up_Bps ; 42 | i.data_dn_Bps += j.data_dn_Bps ; 43 | i.tr_up_Bps += j.tr_up_Bps ; 44 | i.tr_dn_Bps += j.tr_dn_Bps ; 45 | i.total_up_Bps += j.total_up_Bps ; 46 | i.total_dn_Bps += j.total_dn_Bps ; 47 | 48 | return i ; 49 | } 50 | }; 51 | 52 | -------------------------------------------------------------------------------- /src/turtle/turtletypes.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * libretroshare/src/turtle: rsturtletypes.h * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright 2013-2018 by Cyril Soler * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Lesser General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | *******************************************************************************/ 22 | #pragma once 23 | 24 | #include "retroshare/rsturtle.h" 25 | 26 | typedef RsPeerId TurtlePeerId ; 27 | typedef RsPeerId TurtleVirtualPeerId ; 28 | typedef RsFileHash TurtleFileHash ; 29 | typedef std::string TurtleFileName ; 30 | 31 | typedef TurtleRequestId TurtleSearchRequestId ; 32 | 33 | typedef uint32_t TurtleTunnelRequestId ; 34 | typedef uint32_t TurtleTunnelId ; 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/unfinished/db_wire.h: -------------------------------------------------------------------------------- 1 | 2 | #include "gxp_service.h" 3 | 4 | class db_wire 5 | { 6 | /* external interface for accessing the info */ 7 | 8 | /** Note this could get very busy with a large number of tweeters. 9 | * need some other method of getting data 10 | */ 11 | 12 | getTweeters(std::list &tweeterIds); 13 | { 14 | getGroups(); 15 | } 16 | 17 | getTweetRange(GxpTimeStamp, GxpTimeStamp, std::list &tweetIds); 18 | { 19 | getTimeRange(); 20 | } 21 | 22 | getTweetRangeSource(GxpTimeStamp, GxpTimeStamp, std::string tweeterId, std::list &tweetIds); 23 | { 24 | getGroupTimeRange(); 25 | } 26 | 27 | getTweet(std::string id, TweetData &tweet); 28 | { 29 | StackLock(); 30 | 31 | RsGxpItem *getMsg_locked(id); 32 | 33 | // translate message into TweetData. 34 | 35 | } 36 | 37 | // Default 38 | getProfile(std::string id, TweetData &tweet); 39 | 40 | /* returns a search code, which is used to id later delivery */ 41 | int searchTweets(GxpSearchCondition cond, std::list); 42 | 43 | /* returns a search code, which is used to id later delivery */ 44 | int fetchPendingSearchResults(int searchId, std::list); 45 | 46 | int cancelSearch(int searchId, std::list); 47 | 48 | }; 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/unfinished/mail/mailtransport.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * libretroshare/src/services/mail mailtransport.cc 3 | * 4 | * Services for RetroShare. 5 | * 6 | * Copyright 2014 by Robert Fernie. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License Version 2 as published by the Free Software Foundation. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Library General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Library General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA. 21 | * 22 | * Please report all bugs and problems to "retroshare@lunamutt.com". 23 | * 24 | */ 25 | 26 | #include "services/mail/mailtransport.h" 27 | 28 | using namespace Rs::Mail; 29 | 30 | MailTransport::MailTransport(uint32_t max_size, uint16_t transport_type) 31 | :mEnabled(true), mMaxSize(max_size), mTransportType(transport_type) 32 | { 33 | return; 34 | } 35 | 36 | bool MailTransport::isEnabled() 37 | { 38 | return mEnabled; 39 | } 40 | 41 | void MailTransport::setEnabled(bool enabled) 42 | { 43 | mEnabled = enabled; 44 | } 45 | 46 | uint32_t MailTransport::getMaxSize() 47 | { 48 | return mMaxSize; 49 | } 50 | 51 | uint16_t MailTransport::getTransportType() 52 | { 53 | return mTransportType; 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/unfinished/mail/mailtransport.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef RS_MAIL_TRANSPORT_HEADER 3 | #define RS_MAIL_TRANSPORT_HEADER 4 | /* 5 | * libretroshare/src/services/mail mailtransport.h 6 | * 7 | * Services for RetroShare. 8 | * 9 | * Copyright 2014 by Robert Fernie. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Library General Public 13 | * License Version 2 as published by the Free Software Foundation. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Library General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Library General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 23 | * USA. 24 | * 25 | * Please report all bugs and problems to "retroshare@lunamutt.com". 26 | * 27 | */ 28 | 29 | 30 | #include "serialiser/rsmailtransportitems.h" 31 | 32 | 33 | namespace Rs 34 | { 35 | namespace Mail 36 | { 37 | 38 | const uint32_t DEFAULT_MAX_MESSAGE_SIZE = (64 * 1024); 39 | 40 | // To decide how this will work! 41 | const uint32_t ADDRESS_TYPE_PEER_ID = 0x001; 42 | const uint32_t ADDRESS_TYPE_GXS_ID = 0x002; 43 | const uint32_t ADDRESS_TYPE_EMAIL_ID = 0x003; 44 | 45 | 46 | class MailTransport 47 | { 48 | public: 49 | MailTransport(uint32_t max_size, uint16_t transport_type); 50 | virtual ~MailTransport(); 51 | 52 | virtual bool CanSend(const RsTlvMailAddress &addr) = 0; 53 | virtual bool haveIncomingMail() = 0; 54 | 55 | virtual bool sendMail(RsMailChunkItem *msg) = 0; 56 | virtual RsMailChunkItem *recvMail() = 0; 57 | virtual bool sendMailAck(RsMailAckItem *ack) = 0; 58 | virtual RsMailAckItem *recvMailAck() = 0; 59 | 60 | virtual bool isEnabled(); 61 | virtual void setEnabled(bool enabled); 62 | 63 | uint32_t getMaxSize(); 64 | uint16_t getTransportType(); 65 | 66 | private: 67 | 68 | bool mEnabled; 69 | uint32_t mMaxSize; 70 | uint16_t mTransportType; 71 | }; 72 | 73 | 74 | } // namespace Mail 75 | } // namespace Rs 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/unused/rscompress.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * libretroshare/src/util: rscompress.h * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright 2013 Cyril Soler * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Lesser General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | *******************************************************************************/ 22 | #pragma once 23 | 24 | class RsCompress 25 | { 26 | public: 27 | static bool compress_memory_chunk(const uint8_t *input_mem,const uint32_t input_size,uint8_t *& output_mem,uint32_t& output_size) ; 28 | static bool uncompress_memory_chunk(const uint8_t *input_mem,const uint32_t input_size,uint8_t *& output_mem,uint32_t& output_size) ; 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /src/util/cxx11retrocompat.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * libretroshare/src/util: cxx11retrocompat.h * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright (C) 2017 Gioacchino Mazzurco * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Lesser General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | *******************************************************************************/ 22 | #pragma once 23 | 24 | #if defined(__GNUC__) && !defined(__clang__) 25 | # define GCC_VERSION (__GNUC__*10000+__GNUC_MINOR__*100+__GNUC_PATCHLEVEL__) 26 | # if GCC_VERSION < 40700 27 | # define override 28 | # define final 29 | # endif // GCC version < 40700 30 | # if GCC_VERSION < 40600 31 | # define nullptr NULL 32 | # endif // GCC_VERSION < 40600 33 | #endif // defined(__GNUC__) && !defined(__clang__) 34 | -------------------------------------------------------------------------------- /src/util/cxx14retrocompat.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * * 3 | * libretroshare < C++14 retro-compatibility helpers * 4 | * * 5 | * Copyright (C) 2020 Gioacchino Mazzurco * 6 | * Copyright (C) 2020 Asociación Civil Altermundi * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Lesser General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | *******************************************************************************/ 22 | #pragma once 23 | 24 | #if __cplusplus < 201402L 25 | 26 | #include 27 | 28 | namespace std 29 | { 30 | template using decay_t = typename decay::type; 31 | 32 | template 33 | using enable_if_t = typename enable_if::type; 34 | 35 | template 36 | using remove_const_t = typename remove_const::type; 37 | } 38 | #endif // __cplusplus < 201402L 39 | -------------------------------------------------------------------------------- /src/util/cxx17retrocompat.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * * 3 | * libretroshare C++17 compatibility helpers * 4 | * * 5 | * Copyright (C) 2019-2024 Gioacchino Mazzurco * 6 | * Copyright (C) 2024 Asociación Civil Altermundi * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Lesser General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | *******************************************************************************/ 22 | #pragma once 23 | 24 | #if __cplusplus < 201703L 25 | 26 | # include 27 | 28 | namespace std 29 | { 30 | using namespace std; 31 | template constexpr typename add_const::type& as_const(T& t) noexcept 32 | { return t; } 33 | template void as_const(const T&&) = delete; 34 | } 35 | 36 | # define RS_FALLTHROUGH 37 | 38 | #else // __cplusplus < 201703L 39 | 40 | # define RS_FALLTHROUGH [[fallthrough]] 41 | 42 | #endif // __cplusplus < 201703L 43 | -------------------------------------------------------------------------------- /src/util/cxx23retrocompat.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * RetroShare C++23 backwards compatibility utilities * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright (C) 2021-2022 Gioacchino Mazzurco * 7 | * Copyright (C) 2021-2022 Asociación Civil Altermundi * 8 | * * 9 | * This program is free software: you can redistribute it and/or modify * 10 | * it under the terms of the GNU Lesser General Public License as * 11 | * published by the Free Software Foundation, either version 3 of the * 12 | * License, or (at your option) any later version. * 13 | * * 14 | * This program is distributed in the hope that it will be useful, * 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 17 | * GNU Lesser General Public License for more details. * 18 | * * 19 | * You should have received a copy of the GNU Lesser General Public License * 20 | * along with this program. If not, see . * 21 | * * 22 | *******************************************************************************/ 23 | 24 | #pragma once 25 | 26 | #include 27 | 28 | #if !defined(__cpp_lib_to_underlying) 29 | # include 30 | namespace std 31 | { 32 | template 33 | constexpr underlying_type_t to_underlying(Enum e) noexcept 34 | { return static_cast>(e); } 35 | } 36 | #endif // !defined(__cpp_lib_to_underlying) 37 | -------------------------------------------------------------------------------- /src/util/rsdebuglevel0.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * RetroShare debugging level * 3 | * * 4 | * Copyright (C) 2020 Gioacchino Mazzurco * 5 | * Copyright (C) 2020 Asociación Civil Altermundi * 6 | * * 7 | * This program is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU Lesser General Public License as * 9 | * published by the Free Software Foundation, either version 3 of the * 10 | * License, or (at your option) any later version. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU Lesser General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU Lesser General Public License * 18 | * along with this program. If not, see . * 19 | * * 20 | *******************************************************************************/ 21 | 22 | // #pragma once // This is commented out on purpose! 23 | 24 | #include 25 | 26 | #undef RS_DEBUG_LEVEL 27 | #define RS_DEBUG_LEVEL 0 28 | 29 | #undef RS_DBG0 30 | #define RS_DBG0(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 31 | 32 | #undef RS_DBG1 33 | #define RS_DBG1(...) RsNoDbg("") 34 | 35 | #undef RS_DBG2 36 | #define RS_DBG2(...) RsNoDbg("") 37 | 38 | #undef RS_DBG3 39 | #define RS_DBG3(...) RsNoDbg("") 40 | 41 | #undef RS_DBG4 42 | #define RS_DBG4(...) RsNoDbg("") 43 | -------------------------------------------------------------------------------- /src/util/rsdebuglevel1.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * RetroShare debugging level * 3 | * * 4 | * Copyright (C) 2020 Gioacchino Mazzurco * 5 | * Copyright (C) 2020 Asociación Civil Altermundi * 6 | * * 7 | * This program is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU Lesser General Public License as * 9 | * published by the Free Software Foundation, either version 3 of the * 10 | * License, or (at your option) any later version. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU Lesser General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU Lesser General Public License * 18 | * along with this program. If not, see . * 19 | * * 20 | *******************************************************************************/ 21 | 22 | // #pragma once // This is commented out on purpose! 23 | 24 | #include 25 | 26 | #undef RS_DEBUG_LEVEL 27 | #define RS_DEBUG_LEVEL 1 28 | 29 | #undef RS_DBG0 30 | #define RS_DBG0(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 31 | 32 | #undef RS_DBG1 33 | #define RS_DBG1(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 34 | 35 | #undef RS_DBG2 36 | #define RS_DBG2(...) RsNoDbg() 37 | 38 | #undef RS_DBG3 39 | #define RS_DBG3(...) RsNoDbg() 40 | 41 | #undef RS_DBG4 42 | #define RS_DBG4(...) RsNoDbg() 43 | -------------------------------------------------------------------------------- /src/util/rsdebuglevel2.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * RetroShare debugging level * 3 | * * 4 | * Copyright (C) 2020 Gioacchino Mazzurco * 5 | * Copyright (C) 2020 Asociación Civil Altermundi * 6 | * * 7 | * This program is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU Lesser General Public License as * 9 | * published by the Free Software Foundation, either version 3 of the * 10 | * License, or (at your option) any later version. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU Lesser General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU Lesser General Public License * 18 | * along with this program. If not, see . * 19 | * * 20 | *******************************************************************************/ 21 | 22 | // #pragma once // This is commented out on purpose! 23 | 24 | #include 25 | 26 | #undef RS_DEBUG_LEVEL 27 | #define RS_DEBUG_LEVEL 2 28 | 29 | #undef RS_DBG0 30 | #define RS_DBG0(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 31 | 32 | #undef RS_DBG1 33 | #define RS_DBG1(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 34 | 35 | #undef RS_DBG2 36 | #define RS_DBG2(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 37 | 38 | #undef RS_DBG3 39 | #define RS_DBG3(...) RsNoDbg() 40 | 41 | #undef RS_DBG4 42 | #define RS_DBG4(...) RsNoDbg() 43 | -------------------------------------------------------------------------------- /src/util/rsdebuglevel3.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * RetroShare debugging level * 3 | * * 4 | * Copyright (C) 2020 Gioacchino Mazzurco * 5 | * Copyright (C) 2020 Asociación Civil Altermundi * 6 | * * 7 | * This program is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU Lesser General Public License as * 9 | * published by the Free Software Foundation, either version 3 of the * 10 | * License, or (at your option) any later version. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU Lesser General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU Lesser General Public License * 18 | * along with this program. If not, see . * 19 | * * 20 | *******************************************************************************/ 21 | 22 | // #pragma once // This is commented out on purpose! 23 | 24 | #include 25 | 26 | #undef RS_DEBUG_LEVEL 27 | #define RS_DEBUG_LEVEL 3 28 | 29 | #undef RS_DBG0 30 | #define RS_DBG0(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 31 | 32 | #undef RS_DBG1 33 | #define RS_DBG1(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 34 | 35 | #undef RS_DBG2 36 | #define RS_DBG2(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 37 | 38 | #undef RS_DBG3 39 | #define RS_DBG3(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 40 | 41 | #undef RS_DBG4 42 | #define RS_DBG4(...) RsNoDbg() 43 | -------------------------------------------------------------------------------- /src/util/rsdebuglevel4.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * RetroShare debugging level * 3 | * * 4 | * Copyright (C) 2020 Gioacchino Mazzurco * 5 | * Copyright (C) 2020 Asociación Civil Altermundi * 6 | * * 7 | * This program is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU Lesser General Public License as * 9 | * published by the Free Software Foundation, either version 3 of the * 10 | * License, or (at your option) any later version. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU Lesser General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU Lesser General Public License * 18 | * along with this program. If not, see . * 19 | * * 20 | *******************************************************************************/ 21 | 22 | // #pragma once // This is commented out on purpose! 23 | 24 | #include 25 | 26 | #undef RS_DEBUG_LEVEL 27 | #define RS_DEBUG_LEVEL 4 28 | 29 | #undef RS_DBG0 30 | #define RS_DBG0(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 31 | 32 | #undef RS_DBG1 33 | #define RS_DBG1(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 34 | 35 | #undef RS_DBG2 36 | #define RS_DBG2(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 37 | 38 | #undef RS_DBG3 39 | #define RS_DBG3(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 40 | 41 | #undef RS_DBG4 42 | #define RS_DBG4(...) RsDbg(__PRETTY_FUNCTION__, " ", __VA_ARGS__) 43 | -------------------------------------------------------------------------------- /src/util/rsfile.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * libretroshare/src/util: rsfile.h * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright (C) 2021 Retroshare Team * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Lesser General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | *******************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | #ifndef WINDOWS_SYS 28 | #include 29 | #include 30 | #endif 31 | 32 | namespace RsFileUtil { 33 | 34 | int set_fd_nonblock(int fd); 35 | ssize_t rs_getline(char **lineptr, size_t *n, FILE *stream); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/util/rskbdinput.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * libretroshare/src/retroshare/util/rskbdinput.h * 3 | * * 4 | * Copyright (C) 2019 Cyril Soler * 5 | * * 6 | * This program is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU Lesser General Public License as * 8 | * published by the Free Software Foundation, either version 3 of the * 9 | * License, or (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU Lesser General Public License * 17 | * along with this program. If not, see . * 18 | * * 19 | *******************************************************************************/ 20 | 21 | #include 22 | 23 | namespace RsUtil { 24 | 25 | std::string rs_getpass(const std::string& prompt,bool no_echo=true) ; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/util/rslikelyunlikely.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * RetroShare C++20 likely/unlikely backwards compatibility utilities * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright (C) 2023 Gioacchino Mazzurco * 7 | * Copyright (C) 2023 Asociación Civil Altermundi * 8 | * * 9 | * This program is free software: you can redistribute it and/or modify * 10 | * it under the terms of the GNU Lesser General Public License as * 11 | * published by the Free Software Foundation, either version 3 of the * 12 | * License, or (at your option) any later version. * 13 | * * 14 | * This program is distributed in the hope that it will be useful, * 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 17 | * GNU Lesser General Public License for more details. * 18 | * * 19 | * You should have received a copy of the GNU Lesser General Public License * 20 | * along with this program. If not, see . * 21 | * * 22 | *******************************************************************************/ 23 | 24 | #pragma once 25 | 26 | #if __cplusplus >= 202002L 27 | # define RS_LIKELY [[likely]] 28 | # define RS_UNLIKELY [[unlikely]] 29 | #else // __cplusplus >= 202002L 30 | # define RS_LIKELY 31 | # define RS_UNLIKELY 32 | #endif // __cplusplus >= 202002L 33 | -------------------------------------------------------------------------------- /src/util/rsstd.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * libretroshare/src/util: rsstd.h * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright (C) 2015 Retroshare Team * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Lesser General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | *******************************************************************************/ 22 | #ifndef RSSTD_H_ 23 | #define RSSTD_H_ 24 | 25 | namespace rsstd { 26 | 27 | template 28 | void delete_all(_IIter iter_begin, _IIter iter_end) 29 | { 30 | for (_IIter it = iter_begin; it != iter_end; ++it) { 31 | delete(*it); 32 | } 33 | } 34 | 35 | } 36 | 37 | #endif // RSSTD_H_ 38 | -------------------------------------------------------------------------------- /tests/librssimulator/peer/FakeNetMgr.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * librssimulator/peer/: FakeNetMgr.h * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright (C) 2018, Retroshare team * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Affero General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | ******************************************************************************/ 22 | #pragma once 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | class FakeNetMgr: public p3NetMgrIMPL 31 | { 32 | public: 33 | FakeNetMgr() 34 | : p3NetMgrIMPL() 35 | { 36 | return; 37 | } 38 | private: 39 | //RsPeerId mOwnId; 40 | }; 41 | 42 | 43 | -------------------------------------------------------------------------------- /tests/librssimulator/peer/FakeNxsNetMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "gxs/rsgxsnetservice.h" 4 | #include "FakeLinkMgr.h" 5 | 6 | class FakeNxsNetMgr : public RsNxsNetMgr 7 | { 8 | 9 | public: 10 | 11 | FakeNxsNetMgr(FakeLinkMgr *linkMgr) 12 | :mLinkMgr(linkMgr) { return; } 13 | 14 | const RsPeerId& getOwnId() 15 | { 16 | return mLinkMgr->getOwnId(); 17 | } 18 | 19 | void getOnlineList(uint32_t serviceId, std::set& ssl_peers) 20 | { 21 | (void) serviceId; 22 | 23 | std::list peerList; 24 | mLinkMgr->getOnlineList(peerList); 25 | 26 | std::list::const_iterator it; 27 | for(it = peerList.begin(); it != peerList.end(); it++) 28 | { 29 | ssl_peers.insert(*it); 30 | } 31 | } 32 | private: 33 | 34 | FakeLinkMgr *mLinkMgr; 35 | }; 36 | 37 | -------------------------------------------------------------------------------- /tests/librssimulator/testing/SetPacket.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * librssimulator/testing/: SetPacket.h * 3 | * * 4 | * libretroshare: retroshare core library * 5 | * * 6 | * Copyright (C) 2018, Retroshare team * 7 | * * 8 | * This program is free software: you can redistribute it and/or modify * 9 | * it under the terms of the GNU Affero General Public License as * 10 | * published by the Free Software Foundation, either version 3 of the * 11 | * License, or (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU Lesser General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU Lesser General Public License * 19 | * along with this program. If not, see . * 20 | * * 21 | ******************************************************************************/ 22 | #pragma once 23 | 24 | #include "pqi/p3linkmgr.h" // for RsPeerId ?? 25 | 26 | #include 27 | #include "retroshare/rsids.h" 28 | 29 | struct RsItem; 30 | 31 | class SetPacket 32 | { 33 | public: 34 | SetPacket(double t, const RsPeerId &srcId, 35 | const RsPeerId &destId, RsItem *item) 36 | :mTime(t), mSrcId(srcId), mDestId(destId), mItem(item) 37 | { 38 | return; 39 | } 40 | 41 | SetPacket() :mTime(), mItem(NULL) { return; } 42 | 43 | double mTime; // relative to test creation; 44 | RsPeerId mSrcId; 45 | RsPeerId mDestId; 46 | RsItem *mItem; 47 | }; 48 | 49 | -------------------------------------------------------------------------------- /tests/test_JSON_API_DirDetails_handle_correct_64bit_integer_type.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (C) 2021 Gioacchino Mazzurco 4 | # Copyright (C) 2021 Asociación Civil Altermundi 5 | # 6 | # This program is free software: you can redistribute it and/or modify it under 7 | # the terms of the GNU Affero General Public License as published by the 8 | # Free Software Foundation, version 3. 9 | # 10 | # This program is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | # FITNESS FOR A PARTICULAR PURPOSE. 13 | # See the GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License along 16 | # with this program. If not, see 17 | # 18 | # SPDX-FileCopyrightText: Retroshare Team 19 | # SPDX-License-Identifier: AGPL-3.0-only 20 | 21 | 22 | ## Define default value for variable, take two arguments, $1 variable name, 23 | ## $2 default variable value, if the variable is not already define define it 24 | ## with default value. 25 | function define_default_value() 26 | { 27 | VAR_NAME="${1}" 28 | DEFAULT_VALUE="${2}" 29 | 30 | [ -z "${!VAR_NAME}" ] && export ${VAR_NAME}="${DEFAULT_VALUE}" || true 31 | } 32 | 33 | define_default_value API_BASE_URL "http://127.0.0.1:9092" 34 | define_default_value API_TOKEN "0000:0000" 35 | 36 | function tLog() 37 | { 38 | local mCategory="$1" ; shift 39 | echo "$mCategory $(date) $@" >&2 40 | } 41 | 42 | mCmd="curl -u $API_TOKEN $API_BASE_URL/rsFiles/requestDirDetails" 43 | 44 | mReply="$($mCmd)" 45 | mCurlRet="$?" 46 | 47 | if [ "$mCurlRet" != 0 ]; then 48 | tLog E "$mCmd failed: $mCurlRet '$mReply'" 49 | exit -3 50 | fi 51 | 52 | [ "$(echo "$mReply" | jq '.retval')" == "true" ] || 53 | { 54 | tLog E "/rsFiles/requestDirDetails failed: '$mReply'" 55 | exit -1 56 | } 57 | 58 | [ "$(echo "$mReply" | jq '.details.handle')" != "0" ] || 59 | { 60 | tLog E ".details.handle has wrong type int: '$mReply'" 61 | exit -1 62 | } 63 | 64 | [ "$(echo "$mReply" | jq '.details.handle.xstr64')" == "\"0\"" ] && 65 | [ "$(echo "$mReply" | jq '.details.handle.xint64')" == "0" ] && 66 | { 67 | tLog I '.details.handle has correct type' 68 | exit 0 69 | } 70 | 71 | tLog E "Unkown error in test $0: '$mReply'" 72 | exit -2 73 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/crypto/chacha20_test.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * unittests/libretroshare/crypto/chacha20_test.cc * 3 | * * 4 | * Copyright (C) 2018, Retroshare team * 5 | * * 6 | * This program is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU Affero General Public License as * 8 | * published by the Free Software Foundation, either version 3 of the * 9 | * License, or (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU Lesser General Public License * 17 | * along with this program. If not, see . * 18 | * * 19 | ******************************************************************************/ 20 | 21 | #include 22 | 23 | // from libretroshare 24 | 25 | #include "crypto/chacha20.h" 26 | 27 | TEST(libretroshare_crypto, ChaCha20) 28 | { 29 | std::cerr << "Testing Chacha20" << std::endl; 30 | 31 | EXPECT_TRUE(librs::crypto::perform_tests()) ; 32 | } 33 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/gxs/gen_exchange/gxsmsgrelatedtest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * gxsmsgrelatedtest.cpp 3 | * 4 | * Created on: 27 Apr 2013 5 | * Author: crispy 6 | */ 7 | 8 | #include "gxsmsgrelatedtest.h" 9 | 10 | GxsMsgRelatedTest::GxsMsgRelatedTest() { 11 | // TODO Auto-generated constructor stub 12 | 13 | } 14 | 15 | GxsMsgRelatedTest::~GxsMsgRelatedTest() { 16 | // TODO Auto-generated destructor stub 17 | } 18 | 19 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/gxs/gen_exchange/gxsmsgrelatedtest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gxsmsgrelatedtest.h 3 | * 4 | * Created on: 27 Apr 2013 5 | * Author: crispy 6 | */ 7 | 8 | #ifndef GXSMSGRELATEDTEST_H_ 9 | #define GXSMSGRELATEDTEST_H_ 10 | 11 | #include "genexchangetester.h" 12 | 13 | class GxsMsgRelatedTest: public GenExchangeTest { 14 | public: 15 | GxsMsgRelatedTest(); 16 | virtual ~GxsMsgRelatedTest(); 17 | 18 | // request msg related tests 19 | bool testMsgRelatedChildIdRetrieval(); 20 | bool testMsgRelatedChildDataRetrieval(); 21 | bool testMsgRelatedChildDataRetrieval_Multi(); 22 | bool testMsgAllVersions(); 23 | }; 24 | 25 | #endif /* GXSMSGRELATEDTEST_H_ */ 26 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/gxs/gen_exchange/gxspublishgrouptest.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * unittests/libretroshare/gxs/gen_exchange/gxspublishgrouptest.h * 3 | * * 4 | * Copyright (C) 2013, Crispy * 5 | * * 6 | * This program is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU Affero General Public License as * 8 | * published by the Free Software Foundation, either version 3 of the * 9 | * License, or (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU Lesser General Public License * 17 | * along with this program. If not, see . * 18 | * * 19 | ******************************************************************************/ 20 | 21 | #ifndef GXSPUBLISHGROUPTEST_H_ 22 | #define GXSPUBLISHGROUPTEST_H_ 23 | 24 | #include "genexchangetester.h" 25 | 26 | class GxsPublishGroupTest : public GenExchangeTest { 27 | public: 28 | 29 | GxsPublishGroupTest(GenExchangeTestService* const testService, 30 | RsGeneralDataService* dataService); 31 | virtual ~GxsPublishGroupTest(); 32 | 33 | void runTests(); 34 | 35 | private: 36 | 37 | // group tests 38 | bool testGrpSubmissionRetrieval(); 39 | bool testSpecificGrpRetrieval(); 40 | bool testGrpIdRetrieval(); 41 | bool testGrpMetaRetrieval(); 42 | bool testUpdateGroup(); 43 | 44 | 45 | private: 46 | 47 | }; 48 | 49 | #endif /* GXSPUBLISHGROUPTEST_H_ */ 50 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/gxs/gen_exchange/gxspublishmsgtest.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * unittests/libretroshare/gxs/gen_exchange/gxspublishmsgtest.h * 3 | * * 4 | * Copyright (C) 2013, Crispy * 5 | * * 6 | * This program is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU Affero General Public License as * 8 | * published by the Free Software Foundation, either version 3 of the * 9 | * License, or (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU Lesser General Public License * 17 | * along with this program. If not, see . * 18 | * * 19 | ******************************************************************************/ 20 | 21 | #ifndef GXSPUBLISHMSGTEST_H_ 22 | #define GXSPUBLISHMSGTEST_H_ 23 | 24 | #include "genexchangetester.h" 25 | 26 | class GxsPublishMsgTest: public GenExchangeTest { 27 | public: 28 | GxsPublishMsgTest(GenExchangeTestService* const testService, 29 | RsGeneralDataService* dataService); 30 | virtual ~GxsPublishMsgTest(); 31 | 32 | void runTests(); 33 | 34 | // message tests 35 | bool testMsgSubmissionRetrieval(); 36 | // bool testMsgIdRetrieval(); 37 | // bool testMsgIdRetrieval_OptParents(); 38 | // bool testMsgIdRetrieval_OptOrigMsgId(); 39 | // bool testMsgIdRetrieval_OptLatest(); 40 | // bool testSpecificMsgMetaRetrieval(); 41 | 42 | 43 | }; 44 | 45 | #endif /* GXSPUBLISHMSGTEST_H_ */ 46 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/gxs/gen_exchange/gxsteststats.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * unittests/libretroshare/gxs/gen_exchange/gxsteststats.h * 3 | * * 4 | * Copyright (C) 2013, Crispy * 5 | * * 6 | * This program is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU Affero General Public License as * 8 | * published by the Free Software Foundation, either version 3 of the * 9 | * License, or (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU Lesser General Public License * 17 | * along with this program. If not, see . * 18 | * * 19 | ******************************************************************************/ 20 | 21 | #ifndef GXSTESTSTATS_H 22 | #define GXSTESTSTATS_H 23 | 24 | #include "genexchangetester.h" 25 | 26 | class GxsTestStats : public GenExchangeTest { 27 | public: 28 | 29 | GxsTestStats(GenExchangeTestService* const testService, 30 | RsGeneralDataService* dataService); 31 | virtual ~GxsTestStats(); 32 | 33 | void runTests(); 34 | private: 35 | 36 | void testGroupStatistics(); 37 | void testServiceStatistics(); 38 | }; 39 | 40 | #endif // GXSTESTSTATS_H 41 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsyncdelayed.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * unittests/libretroshare/gxs/nxs_test/nxsgrpsyncdelayed.cc * 3 | * * 4 | * Copyright (C) 2014, Crispy * 5 | * * 6 | * This program is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU Affero General Public License as * 8 | * published by the Free Software Foundation, either version 3 of the * 9 | * License, or (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU Lesser General Public License * 17 | * along with this program. If not, see . * 18 | * * 19 | ******************************************************************************/ 20 | 21 | #include "nxsgrpsyncdelayed.h" 22 | #include "nxsdummyservices.h" 23 | 24 | namespace rs_nxs_test { 25 | 26 | NxsGrpSyncDelayed::NxsGrpSyncDelayed() 27 | : NxsGrpSync(new rs_nxs_test::RsNxsDelayedDummyCircles(4), NULL) { 28 | 29 | 30 | } 31 | 32 | NxsGrpSyncDelayed::~NxsGrpSyncDelayed() { 33 | // TODO Auto-generated destructor stub 34 | } 35 | 36 | } /* namespace rs_nxs_test */ 37 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsyncdelayed.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * unittests/libretroshare/gxs/nxs_test/nxsgrpsyncdelayed.h * 3 | * * 4 | * Copyright (C) 2014, Crispy * 5 | * * 6 | * This program is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU Affero General Public License as * 8 | * published by the Free Software Foundation, either version 3 of the * 9 | * License, or (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU Lesser General Public License * 17 | * along with this program. If not, see . * 18 | * * 19 | ******************************************************************************/ 20 | 21 | #ifndef NXSGRPSYNCDELAYED_H_ 22 | #define NXSGRPSYNCDELAYED_H_ 23 | 24 | #include "nxsgrpsync_test.h" 25 | 26 | namespace rs_nxs_test { 27 | 28 | class NxsGrpSyncDelayed : public NxsGrpSync { 29 | public: 30 | NxsGrpSyncDelayed(); 31 | virtual ~NxsGrpSyncDelayed(); 32 | }; 33 | 34 | } /* namespace rs_nxs_test */ 35 | #endif /* NXSGRPSYNCDELAYED_H_ */ 36 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/gxs/nxs_test/nxstestscenario.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nxstestscenario.h 3 | * 4 | * Created on: 10 Jul 2012 5 | * Author: crispy 6 | */ 7 | 8 | #ifndef NXSTESTSCENARIO_H_ 9 | #define NXSTESTSCENARIO_H_ 10 | 11 | #include 12 | #include "retroshare/rstypes.h" 13 | #include "gxs/rsgxsnetutils.h" 14 | #include "gxs/rsdataservice.h" 15 | #include "gxs/rsnxsobserver.h" 16 | #include "util/rssharedptr.h" 17 | 18 | namespace rs_nxs_test 19 | { 20 | /*! 21 | * This scenario module provides data resources 22 | */ 23 | class NxsTestScenario 24 | { 25 | public: 26 | 27 | typedef RsSharedPtr pointer; 28 | 29 | virtual ~NxsTestScenario() {} 30 | 31 | virtual void getPeers(std::list& peerIds) = 0; 32 | virtual RsGeneralDataService* getDataService(const RsPeerId& peerId) = 0; 33 | virtual bool checkTestPassed() = 0; 34 | virtual bool checkDeepTestPassed() = 0; 35 | virtual RsNxsNetMgr* getDummyNetManager(const RsPeerId& peerId) = 0; 36 | virtual RsGcxs* getDummyCircles(const RsPeerId& peerId) = 0; 37 | virtual RsGixsReputation* getDummyReputations(const RsPeerId& peerId) = 0; 38 | virtual uint16_t getServiceType() = 0; 39 | virtual RsServiceInfo getServiceInfo() = 0; 40 | virtual PgpAuxUtils* getDummyPgpUtils() = 0; 41 | 42 | virtual void cleanTestScenario() = 0; 43 | 44 | 45 | }; 46 | } 47 | 48 | #endif /* NXSTESTSCENARIO_H_ */ 49 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/gxs/nxs_test/rssharedptr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rssharedptr.h 3 | * 4 | * Created on: 16 Apr 2014 5 | * Author: crispy 6 | */ 7 | 8 | #ifndef RSSHAREDPTR_H_ 9 | #define RSSHAREDPTR_H_ 10 | 11 | #include 12 | 13 | /*! 14 | * Not thread safe!! 15 | * And also has a memory leak. Do not use (csoler, 24 Jul 2017). 16 | */ 17 | template 18 | class RsSharedPtr 19 | { 20 | public: 21 | 22 | RsSharedPtr() : mShared(NULL), mCount(NULL), mSharedPtrMutex(NULL){} 23 | 24 | RsSharedPtr(T* shared) 25 | : mShared(shared), mCount(new int(0)), mSharedPtrMutex(new RsMutex("SharedMutex")) 26 | { 27 | mCount++; 28 | } 29 | 30 | RsSharedPtr(const RsSharedPtr& rsp) 31 | { 32 | rsp.lock(); 33 | mShared = rsp.mShared; 34 | mCount = rsp.mCount; 35 | mCount++; 36 | mSharedPtrMutex = rsp.mSharedPtrMutex; 37 | rsp.unlock(); 38 | 39 | } 40 | 41 | void operator=(const RsSharedPtr& rsp) 42 | { 43 | rsp.lock(); 44 | mSharedPtrMutex = rsp.mSharedPtrMutex; 45 | DecrementAndDeleteIfLast(); 46 | mShared = rsp.mShared; 47 | RepointAndIncrement(rsp.mCount); 48 | 49 | mSharedPtrMutex->unlock(); 50 | } 51 | 52 | T* release() { 53 | 54 | lock(); 55 | 56 | mCount--; T* temp = mShared; mShared = NULL; 57 | 58 | unlock(); 59 | 60 | return temp; 61 | } 62 | T* get() { return mShared; } 63 | 64 | T& operator*(){ return *mShared; } 65 | T* operator->(){ return mShared; } 66 | 67 | ~RsSharedPtr() 68 | { 69 | lock(); 70 | DecrementAndDeleteIfLast(); 71 | unlock(); 72 | } 73 | private: 74 | 75 | void DecrementAndDeleteIfLast() 76 | { 77 | mCount--; 78 | if(mCount == 0 && mShared != NULL) 79 | { 80 | delete mShared; 81 | delete mCount; 82 | } 83 | 84 | mShared = NULL; 85 | mCount = NULL; 86 | } 87 | 88 | void RepointAndIncrement(int* count) 89 | { 90 | mCount = count; 91 | mCount++; 92 | 93 | } 94 | 95 | void lock() const { mSharedPtrMutex->lock(); } 96 | void unlock() const { mSharedPtrMutex->unlock(); } 97 | 98 | private: 99 | 100 | T* mShared; 101 | int* mCount; 102 | RsMutex* mSharedPtrMutex; 103 | 104 | }; 105 | 106 | template 107 | RsSharedPtr rs_make_shared(T* ptr){ return RsSharedPtr(ptr); } 108 | 109 | #endif /* RSSHAREDPTR_H_ */ 110 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/serialiser/rsgxsiditem_test.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * unittests/libretroshare/serialiser/rsgxsiditem_test.cc * 3 | * * 4 | * Copyright 2007-2008 by Cyril Soler * 5 | * * 6 | * This program is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU Affero General Public License as * 8 | * published by the Free Software Foundation, either version 3 of the * 9 | * License, or (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU Lesser General Public License * 17 | * along with this program. If not, see . * 18 | * * 19 | ******************************************************************************/ 20 | 21 | #include 22 | 23 | #include "rsitems/rsgxsiditems.h" 24 | #include "support.h" 25 | 26 | 27 | bool operator==(const RsGxsIdGroupItem& it1,const RsGxsIdGroupItem& it2) 28 | { 29 | if(it1.mPgpIdSign != it2.mPgpIdSign) return false ; 30 | 31 | return true ; 32 | } 33 | void init_item(RsGxsIdGroupItem& item) 34 | { 35 | item.mPgpIdSign = "hello"; 36 | } 37 | 38 | 39 | TEST(libretroshare_serialiser, RsGxsIdItem) 40 | { 41 | for(uint32_t i=0;i<20;++i) 42 | { 43 | test_RsItem< RsGxsIdGroupItem,RsGxsIdSerialiser >(); 44 | } 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/serialiser/rsstatusitem_test.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * unittests/libretroshare/serialiser/rsstatusitem_test.cc * 3 | * * 4 | * Copyright 2010 by Christopher Evi-Parker * 5 | * * 6 | * This program is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU Affero General Public License as * 8 | * published by the Free Software Foundation, either version 3 of the * 9 | * License, or (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU Lesser General Public License * 17 | * along with this program. If not, see . * 18 | * * 19 | ******************************************************************************/ 20 | 21 | #include "support.h" 22 | #include "rsitems/rsstatusitems.h" 23 | 24 | void init_item(RsStatusItem& rsi) 25 | { 26 | 27 | rsi.sendTime = rand()%5353; 28 | rsi.status = rand()%2032; 29 | } 30 | 31 | bool operator ==(RsStatusItem& rsi1, RsStatusItem& rsi2) 32 | { 33 | // note: recv time is not serialised 34 | 35 | if(rsi1.sendTime != rsi2.sendTime) return false; 36 | if(rsi1.status != rsi2.status) return false; 37 | 38 | return true; 39 | } 40 | 41 | 42 | TEST(libretroshare_serialiser, test_RsStatusItem) 43 | { 44 | test_RsItem(); 45 | } 46 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/serialiser/rstlvutil.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * unittests/libretroshare/serialiser/rstlvutil.h * 3 | * * 4 | * Copyright 2007-2008 by Robert Fernie * 5 | * * 6 | * This program is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU Affero General Public License as * 8 | * published by the Free Software Foundation, either version 3 of the * 9 | * License, or (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU Lesser General Public License * 17 | * along with this program. If not, see . * 18 | * * 19 | ******************************************************************************/ 20 | #ifndef RS_TLV_UTIL_H 21 | #define RS_TLV_UTIL_H 22 | 23 | /* some utility functions mainly for debugging 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | class RsTlvItem; 31 | 32 | /* print out a packet */ 33 | void displayRawPacket(std::ostream &out, void *data, uint32_t size); 34 | int test_SerialiseTlvItem(std::ostream &str, RsTlvItem *in, RsTlvItem *out); 35 | 36 | 37 | bool test_StepThroughTlvStack(std::ostream &str, void *data, int size); 38 | int test_CreateTlvStack(std::ostream &str, 39 | std::vector items, void *data, int totalsize); 40 | int test_TlvSet(std::vector items, int maxsize); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/serialiser/tlvkey_test.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * unittests/libretroshare/serialiser/tlvkey_test.cc * 3 | * * 4 | * Copyright 2007-2008 by Robert Fernie * 5 | * * 6 | * This program is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU Affero General Public License as * 8 | * published by the Free Software Foundation, either version 3 of the * 9 | * License, or (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU Lesser General Public License * 17 | * along with this program. If not, see . * 18 | * * 19 | ******************************************************************************/ 20 | 21 | 22 | #include 23 | 24 | #include "support.h" 25 | #include "serialiser/rstlvkeys.h" 26 | 27 | TEST(libretroshare_serialiser, test_RsTlvKeySignatureSet) 28 | { 29 | RsTlvKeySignatureSet set; 30 | 31 | init_item(set); 32 | 33 | char data[set.TlvSize()]; 34 | uint32_t offset = 0; 35 | set.SetTlv(data, set.TlvSize(), &offset); 36 | 37 | RsTlvKeySignatureSet setConfirm; 38 | 39 | offset = 0; 40 | setConfirm.GetTlv(data, set.TlvSize(), &offset); 41 | 42 | EXPECT_TRUE(setConfirm == set); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /tests/unittests/libretroshare/services/gxs/RsGxsNetServiceTester.h: -------------------------------------------------------------------------------- 1 | 2 | #include "gxs/rsgxsnetservice.h" 3 | 4 | /* This is a wrapper class used to allow testing 5 | * of internal functions 6 | */ 7 | 8 | class RsGxsNetServiceTester: public RsGxsNetService 9 | { 10 | public: 11 | 12 | RsGxsNetServiceTester( 13 | uint16_t servType, RsGeneralDataService *gds, 14 | RsNxsNetMgr *netMgr, 15 | RsNxsObserver *nxsObs, // used to be = NULL. 16 | const RsServiceInfo serviceInfo, 17 | RsGixsReputation* reputations = NULL, RsGcxs* circles = NULL, 18 | PgpAuxUtils *pgpUtils = NULL, 19 | bool grpAutoSync = true); 20 | 21 | 22 | bool fetchAllowedGroups(const RsPeerId &peerId, std::vector &groups); 23 | 24 | }; 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /tests/unittests/run_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | GTESTFILTER='--gtest_filter=libretroshare_services.*' 4 | #GTESTFILTER='--gtest_filter=libretroshare_services.GXS_nxs_basic*' 5 | #GTESTOUTPUT='--gtest_output "xml:test_results.xml"' 6 | 7 | echo ./unittests $GTESTOUTPUT $GTESTFILTER 8 | ./unittests $GTESTOUTPUT $GTESTFILTER 9 | -------------------------------------------------------------------------------- /tests/unittests/unittests.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * unittests/unittests.cc * 3 | * * 4 | * Copyright (C) 2018, Retroshare team * 5 | * * 6 | * This program is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU Affero General Public License as * 8 | * published by the Free Software Foundation, either version 3 of the * 9 | * License, or (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU Lesser General Public License * 17 | * along with this program. If not, see . * 18 | * * 19 | ******************************************************************************/ 20 | 21 | #include 22 | 23 | int main(int argc, char **argv) { 24 | ::testing::InitGoogleTest(&argc, argv); 25 | return RUN_ALL_TESTS(); 26 | } 27 | 28 | 29 | --------------------------------------------------------------------------------