mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05:00
manual merge before creating a conflict-free PR
This commit is contained in:
commit
71c8dfdc58
@ -7,7 +7,7 @@ before_install:
|
||||
- echo $LANG
|
||||
- echo $LC_ALL
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install build-essential checkinstall cmake g++ git libavcodec-dev libavformat-dev libbz2-dev libcurl4-openssl-dev libdc1394-22-dev libglib2.0-dev libcv-dev libopencv-highgui-dev libhighgui-dev
|
||||
- sudo apt-get install build-essential checkinstall cmake g++ git libavutil-dev libavcodec-dev libavformat-dev libbz2-dev libcurl4-openssl-dev libdc1394-22-dev libglib2.0-dev libcv-dev libopencv-highgui-dev libhighgui-dev
|
||||
- sudo apt-get install libgnome-keyring-dev libgstreamer-plugins-base0.10-dev libgstreamer0.10-dev libjasper-dev libjpeg-dev libmicrohttpd-dev libopencv-dev libprotobuf-dev libqt4-dev
|
||||
- sudo apt-get install libspeex-dev libspeexdsp-dev libsqlite3-dev libssl-dev libswscale-dev
|
||||
- sudo apt-get install libtbb-dev libtiff4-dev libupnp-dev libv4l-dev libxine-dev libxslt1-dev libxss-dev make pkg-config protobuf-compiler python-dev python-numpy subversion git yasm qtmobility-dev
|
||||
|
@ -7,7 +7,6 @@ SUBDIRS += \
|
||||
libbitdht \
|
||||
libretroshare \
|
||||
libresapi \
|
||||
pegmarkdown \
|
||||
retroshare_gui \
|
||||
retroshare_nogui \
|
||||
plugins
|
||||
@ -22,10 +21,8 @@ libretroshare.depends = openpgpsdk libbitdht
|
||||
libresapi.file = libresapi/src/libresapi.pro
|
||||
libresapi.depends = libretroshare
|
||||
|
||||
pegmarkdown.file = supportlibs/pegmarkdown/pegmarkdown.pro
|
||||
|
||||
retroshare_gui.file = retroshare-gui/src/retroshare-gui.pro
|
||||
retroshare_gui.depends = libretroshare libresapi pegmarkdown
|
||||
retroshare_gui.depends = libretroshare libresapi
|
||||
retroshare_gui.target = retroshare-gui
|
||||
|
||||
retroshare_nogui.file = retroshare-nogui/src/retroshare-nogui.pro
|
||||
@ -35,3 +32,9 @@ retroshare_nogui.target = retroshare-nogui
|
||||
plugins.file = plugins/plugins.pro
|
||||
plugins.depends = retroshare_gui
|
||||
plugins.target = plugins
|
||||
|
||||
wikipoos {
|
||||
SUBDIRS += pegmarkdown
|
||||
pegmarkdown.file = supportlibs/pegmarkdown/pegmarkdown.pro
|
||||
retroshare_gui.depends += pegmarkdown
|
||||
}
|
||||
|
@ -1,5 +1,69 @@
|
||||
retroshare06 (0.6.0-1.XXXXXX~YYYYYY) YYYYYY; urgency=low
|
||||
|
||||
1d54630 thunder2 17 Sep 2015 10:05:31 +0200 Fixed Windows compile.
|
||||
66691d4 Cyril Soler 16 Sep 2015 20:01:39 -0400 Merge pull request #108 from sehraf/i2p
|
||||
04abfad sehraf 16 Sep 2015 17:01:20 +0200 manually reverted changes by Qt Creator
|
||||
7c7e4f8 sehraf 16 Sep 2015 12:13:54 +0200 added ip addr. field to the add certificate dialog
|
||||
6202e83 sehraf 16 Sep 2015 11:48:32 +0200 add default case to gui instead of falling back to tor labeling
|
||||
d3d184f sehraf 16 Sep 2015 11:09:04 +0200 added simple step-by-step guide to add a I2P server tunnel
|
||||
e54358a sehraf 16 Sep 2015 10:55:33 +0200 added simple step-by-step guide to add a I2P client tunnel
|
||||
1dd3375 sehraf 15 Sep 2015 17:14:55 +0200 hide debug output
|
||||
d24b281 sehraf 15 Sep 2015 17:10:48 +0200 optimizations * reduced calls to mPeermgr * use switch convenience * small fixes
|
||||
bfcf43f sehraf 15 Sep 2015 16:18:46 +0200 fixed connection type detection and other small things
|
||||
8725aab sehraf 14 Sep 2015 15:14:39 +0200 gui fixes
|
||||
6b87c38 sehraf 14 Sep 2015 14:56:14 +0200 small fixes
|
||||
6ec1919 sehraf 14 Sep 2015 12:39:46 +0200 gui changes
|
||||
b0251e3 sehraf 14 Sep 2015 12:12:28 +0200 generalized tooltips
|
||||
4b19e73 sehraf 14 Sep 2015 09:56:43 +0200 added comments to functions
|
||||
900e51b Cyril Soler 13 Sep 2015 18:08:06 -0400 Merge pull request #107 from PhenomRetroShare/AddFriendListItemMouseEvents
|
||||
48e6618 Phenom 13 Sep 2015 19:00:31 +0200 Send Mouse event to FriendList's item, since ElidedLabel was fixed.
|
||||
7195d4c Cyril Soler 10 Sep 2015 09:41:28 -0400 Merge pull request #105 from ericthefish/master
|
||||
4880fc4 Ivan Lucas 10 Sep 2015 11:21:01 +0100 Fixed grammar on add friend wizard by rewording slightly
|
||||
840e930 Ivan Lucas 10 Sep 2015 10:29:15 +0100 Fix Spelling and Grammar
|
||||
770e934 Ivan Lucas 10 Sep 2015 10:18:14 +0100 Merge remote-tracking branch 'upstream/master'
|
||||
4a0539c Cyril Soler 9 Sep 2015 19:57:07 -0400 Merge pull request #103 from AsamK/html_parsing
|
||||
1acd4a3 Cyril Soler 9 Sep 2015 16:44:59 -0400 Merge pull request #104 from PhenomRetroShare/Fix_ElidedLabel_mousePresEvent
|
||||
ce9fc7b Phenom 9 Sep 2015 22:37:38 +0200 Fix ElidedLabel::mousePressEvent.
|
||||
75a7a89 Ivan Lucas 9 Sep 2015 15:19:17 +0100 Fix typo
|
||||
7aad9c1 AsamK 9 Sep 2015 13:36:00 +0200 Improve HTML parsing in libresapi
|
||||
b8c3c89 AsamK 9 Sep 2015 11:53:01 +0200 Extract getPlainText method
|
||||
ebd5da5 thunder2 8 Sep 2015 16:34:22 +0200 Optimizations in RsGenExchange, p3GxsForums and p3GxsChannels. - Removed not used variables
|
||||
avoid copy constructors - Use swap instead of operator= to move elements of std containers
|
||||
490b88c Cyril Soler 8 Sep 2015 14:17:29 -0400 Merge pull request #100 from ericthefish/master
|
||||
a2e7e4d Ivan Lucas 8 Sep 2015 16:12:50 +0100 Fixed spelling/grammar
|
||||
4f8b098 Ivan Lucas 8 Sep 2015 16:00:00 +0100 Fixing spelling
|
||||
c4061fc thunder2 7 Sep 2015 22:27:04 +0200 Removed not used time consuming calculation of row count from RetroCursor.
|
||||
29a1fa2 thunder2 7 Sep 2015 21:48:18 +0200 Removed unnecessary copy of results in RsGxsDataAccess.
|
||||
0bc77d7 sehraf 8 Sep 2015 13:48:30 +0200 added some error handling
|
||||
da417ee Cyril Soler 7 Sep 2015 20:38:47 -0400 Merge pull request #96 from AsamK/qmake_3
|
||||
63e38af Cyril Soler 7 Sep 2015 20:36:03 -0400 Merge pull request #94 from AsamK/correct_libav_version
|
||||
03d99ae sehraf 7 Sep 2015 23:55:57 +0200 made GenCertDislog more generic
|
||||
4fc6c73 sehraf 7 Sep 2015 23:40:52 +0200 replaced some ifs with switch
|
||||
e2768e0 defnax 7 Sep 2015 23:34:39 +0200 Added last used field to Person Details Window
|
||||
fed4345 sehraf 7 Sep 2015 22:57:54 +0200 made server settings more generic and added i2p support
|
||||
95d6b06 sehraf 7 Sep 2015 18:46:19 +0200 first working version
|
||||
0107f4e sehraf 7 Sep 2015 12:59:21 +0200 first run on gui integration
|
||||
ba74c04 sehraf 7 Sep 2015 11:51:24 +0200 removed duplicated code, fixed compile, few additions
|
||||
c17d0e1 sehraf 7 Sep 2015 11:22:15 +0200 add i2p support to libretroshare
|
||||
2c1743f defnax 7 Sep 2015 15:13:32 +0200 Added send message function for Participants list.
|
||||
cc4be39 defnax 7 Sep 2015 15:08:56 +0200 Merge branch 'master' of https://github.com/RetroShare/RetroShare
|
||||
0793a6a AsamK 6 Sep 2015 14:19:21 +0200 Use PLUGIN_DIR to define plugin directory only once
|
||||
fe1ec9d AsamK 5 Sep 2015 22:49:57 +0200 Fixed mac compile. Moved sqlcipher.a to libretroshare.pro
|
||||
571336e AsamK 5 Sep 2015 23:49:15 +0200 Move duplicate common stuff out of platform parts
|
||||
66b9557 AsamK 5 Sep 2015 23:48:24 +0200 Use PKGCONFIG instead of manually specifying LIBS for Linux
|
||||
b8e3a43 thunder2 6 Sep 2015 21:28:34 +0200 Auto download of recommended files adds the sender as source of the download.
|
||||
5f36500 thunder2 6 Sep 2015 14:21:05 +0200 Fixed click in column "Friend nodes" in FriendList.
|
||||
869077b thunder2 5 Sep 2015 12:46:18 +0200 Combined selects in RsDataService::retrieveNxsGrps/RsDataService::retrieveNxsMsgs.
|
||||
d6f50c7 AsamK 5 Sep 2015 15:44:10 +0200 Fix libav version check
|
||||
e9a5523 defnax 5 Sep 2015 00:16:07 +0200 Merge branch 'master' of https://github.com/RetroShare/RetroShare
|
||||
7f8dae9 defnax 4 Sep 2015 16:33:43 +0200 Merge branch 'master' of https://github.com/RetroShare/RetroShare
|
||||
07c5030 defnax 3 Sep 2015 17:41:30 +0200 Merge branch 'master' of https://github.com/RetroShare/RetroShare
|
||||
3d6e978 defnax 2 Sep 2015 13:06:15 +0200 Fixed Status Label on Distant Chat
|
||||
|
||||
-- Cyril Soler <csoler@users.sourceforge.net> Mon, 21 Sep 2015 20:00:00 +0100
|
||||
|
||||
retroshare06 (0.6.0-1.20150905.8bb76c95~trusty) trusty; urgency=low
|
||||
|
||||
a276986 ( ) Merge pull request #60 from PhenomRetroShare/Fix_AllowChatTextFormatOption
|
||||
88a6931 (GUI ) Allow Chat Text Format Option working.
|
||||
0b5b20d ( ) Merge pull request #59 from AsamK/qmake_improvements
|
||||
@ -98,9 +162,9 @@ retroshare06 (0.6.0-1.XXXXXX~YYYYYY) YYYYYY; urgency=low
|
||||
4d7f733 (Packaging ) fixed bug in git parameter in packaging script
|
||||
9734f32 (Packaging ) updated ubuntu changelog. improved ubuntu packaging script
|
||||
|
||||
-- Cyril Soler <csoler@users.sourceforge.net> Sun, 16 Aug 2015 20:00:00 +0100
|
||||
-- Cyril Soler <csoler@users.sourceforge.net> Sun, 05 Sep 2015 20:00:00 +0100
|
||||
|
||||
retroshare06 (0.6.0-1.20150816~9734f32a) trusty; urgency=low
|
||||
retroshare06 (0.6.0-1.20150816.9734f32a~trusty) trusty; urgency=low
|
||||
|
||||
f6b830d (branch merging) Merge pull request #35 from hunbernd/chat-fix
|
||||
16859a1 (GUI ) Fix: chatlobby toaster not working
|
||||
|
@ -1,44 +0,0 @@
|
||||
CPPFLAGS += -g -Wall -D BE_DEBUG -lpthread
|
||||
LDFLAGS += -g -Wall -D BE_DEBUG -lpthread
|
||||
CFLAGS += -g -Wall -D BE_DEBUG
|
||||
CC = g++
|
||||
LIB = -lpthread
|
||||
CPPLIB = -lpthread
|
||||
|
||||
EXEC = bdmsgs_test bdmetric_test bdquery_test bdspace_test bdspace_test2 bdnode_test bdnode_test2 bdstore_test
|
||||
EXEC += bdnode_multitest1 bdmidids_test
|
||||
EXEC += udpbitdht_nettest bencode_test
|
||||
EXEC += bdmgr_multitest
|
||||
#EXEC += bdudp_test
|
||||
|
||||
all: $(EXEC)
|
||||
|
||||
OBJ = bencode.o bdmsgs.o bdobj.o
|
||||
OBJ += bdpeer.o bdquery.o bdnode.o bdstore.o bdhash.o
|
||||
OBJ += bdmanager.o bdstddht.o
|
||||
|
||||
# udp base objs
|
||||
OBJ += bdthreads.o udplayer.o udpstack.o
|
||||
OBJ += udpbitdht.o
|
||||
|
||||
bdmsgs_test: $(OBJ) bdmsgs_test.o
|
||||
bdmetric_test: $(OBJ) bdmetric_test.o
|
||||
bdquery_test: $(OBJ) bdquery_test.o
|
||||
bdspace_test: $(OBJ) bdspace_test.o
|
||||
bdspace_test2: $(OBJ) bdspace_test2.o
|
||||
bdnode_test: $(OBJ) bdnode_test.o
|
||||
bdnode_test2: $(OBJ) bdnode_test2.o
|
||||
bdmidids_test: $(OBJ) bdmidids_test.o
|
||||
|
||||
bdnode_multitest1: $(OBJ) bdnode_multitest1.o
|
||||
bdmgr_multitest: $(OBJ) bdmgr_multitest.o
|
||||
|
||||
bdstore_test: $(OBJ) bdstore_test.o
|
||||
bdudp_test: $(OBJ) bdudp_test.o
|
||||
udpbitdht_nettest: $(OBJ) udpbitdht_nettest.o
|
||||
bencode_test: $(OBJ) bencode_test.o
|
||||
|
||||
clean:
|
||||
rm -f *.o core $(EXEC)
|
||||
|
||||
.PHONY: all clean
|
@ -1,16 +0,0 @@
|
||||
|
||||
CXXFLAGS = -Wall -g -I..
|
||||
#CXXFLAGS += -arch i386 # OSX
|
||||
|
||||
LIBS = -L../lib -lbitdht -lpthread
|
||||
|
||||
|
||||
|
||||
EXEC : bssdht
|
||||
|
||||
EGOBJ = bdhandler.o bssdht.o bootstrap_fn.o
|
||||
|
||||
bssdht: $(EGOBJ)
|
||||
$(CXX) $(CXXFLAGS) -o bssdht $(EGOBJ) $(LIBS)
|
||||
|
||||
|
@ -4,6 +4,8 @@ TEMPLATE = lib
|
||||
CONFIG += staticlib
|
||||
CONFIG -= qt
|
||||
TARGET = bitdht
|
||||
DESTDIR = lib
|
||||
|
||||
QMAKE_CXXFLAGS *= -Wall -DBE_DEBUG
|
||||
|
||||
profiling {
|
||||
@ -27,7 +29,6 @@ debug {
|
||||
|
||||
################################# Linux ##########################################
|
||||
linux-* {
|
||||
DESTDIR = lib
|
||||
QMAKE_CC = g++
|
||||
}
|
||||
|
||||
@ -50,7 +51,6 @@ unix {
|
||||
|
||||
win32-x-g++ {
|
||||
OBJECTS_DIR = temp/win32xgcc/obj
|
||||
DESTDIR = lib.win32xgcc
|
||||
# These have been replaced by _WIN32 && __MINGW32__
|
||||
# DEFINES *= WINDOWS_SYS WIN32 WIN_CROSS_UBUNTU
|
||||
QMAKE_CXXFLAGS *= -Wmissing-include-dirs
|
||||
@ -70,7 +70,6 @@ win32 {
|
||||
DEFINES *= STATICLIB WIN32_LEAN_AND_MEAN _USE_32BIT_TIME_T
|
||||
# These have been replaced by _WIN32 && __MINGW32__
|
||||
#DEFINES *= WINDOWS_SYS WIN32 STATICLIB MINGW
|
||||
DESTDIR = lib
|
||||
|
||||
# Switch on extra warnings
|
||||
QMAKE_CFLAGS += -Wextra
|
||||
@ -93,19 +92,16 @@ mac {
|
||||
QMAKE_CC = g++
|
||||
OBJECTS_DIR = temp/obj
|
||||
MOC_DIR = temp/moc
|
||||
DESTDIR = lib
|
||||
}
|
||||
|
||||
################################# FreeBSD ##########################################
|
||||
|
||||
freebsd-* {
|
||||
DESTDIR = lib
|
||||
}
|
||||
|
||||
################################# OpenBSD ##########################################
|
||||
|
||||
openbsd-* {
|
||||
DESTDIR = lib
|
||||
}
|
||||
|
||||
################################### COMMON stuff ##################################
|
||||
@ -168,5 +164,3 @@ SOURCES += \
|
||||
bitdht/bdquerymgr.cc \
|
||||
util/bdbloom.cc \
|
||||
bitdht/bdfriendlist.cc \
|
||||
|
||||
|
||||
|
@ -1,91 +0,0 @@
|
||||
|
||||
LIB_TOP_DIR = ..
|
||||
TEST_TOP_DIR = $(LIB_TOP_DIR)/tests
|
||||
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(TEST_TOP_DIR)/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
# Generic Test Harnesses.
|
||||
TESTOBJ = bdmetric_test.o bdmsgs_test.o bdnode_test.o bdspace_test.o
|
||||
TESTOBJ += bdmgr_multitest.o bdquery_test.o bdstore_test.o
|
||||
TESTOBJ += bdmidids_test.o bdspace_test2.o udpbitdht_nettest.o
|
||||
TESTOBJ += bdbloom_test.o bdbloom_makefilter.o
|
||||
#TESTOBJ += bencode_test.o bdudp_test.o
|
||||
#TESTOBJ = bdnode_test.o bdnode_multitest1.o bdnode_test2.o
|
||||
|
||||
TESTS = bdmetric_test bdmsgs_test bdspace_test
|
||||
TESTS += bdmgr_multitest bdquery_test bdstore_test
|
||||
TESTS += bdmidids_test bdspace_test2 udpbitdht_nettest
|
||||
TESTS += bdbloom_test
|
||||
#TESTS += bencode_test bdudp_test
|
||||
#Tests to Fix.
|
||||
#TESTS = bdnode_test bdnode_multitest1 bdnode_test2
|
||||
|
||||
MANUAL_TESTS =
|
||||
|
||||
all: tests $(MANUAL_TESTS)
|
||||
|
||||
bdmsgs_test: bdmsgs_test.o
|
||||
$(CC) $(CFLAGS) -o bdmsgs_test bdmsgs_test.o $(LIBS)
|
||||
|
||||
bdmetric_test: bdmetric_test.o
|
||||
$(CC) $(CFLAGS) -o bdmetric_test bdmetric_test.o $(LIBS)
|
||||
|
||||
bdquery_test: bdquery_test.o
|
||||
$(CC) $(CFLAGS) -o bdquery_test bdquery_test.o $(LIBS)
|
||||
|
||||
bdspace_test: bdspace_test.o
|
||||
$(CC) $(CFLAGS) -o bdspace_test bdspace_test.o $(LIBS)
|
||||
|
||||
bdspace_test2: bdspace_test2.o
|
||||
$(CC) $(CFLAGS) -o bdspace_test2 bdspace_test2.o $(LIBS)
|
||||
|
||||
bdnode_test: bdnode_test.o
|
||||
$(CC) $(CFLAGS) -o bdnode_test bdnode_test.o $(LIBS)
|
||||
|
||||
bdnode_test2: bdnode_test2.o
|
||||
$(CC) $(CFLAGS) -o bdnode_test2 bdnode_test2.o $(LIBS)
|
||||
|
||||
bdmidids_test: bdmidids_test.o
|
||||
$(CC) $(CFLAGS) -o bdmidids_test bdmidids_test.o $(LIBS)
|
||||
|
||||
|
||||
bdnode_multitest1: bdnode_multitest1.o
|
||||
$(CC) $(CFLAGS) -o bdnode_multitest1 bdnode_multitest1.o $(LIBS)
|
||||
|
||||
bdmgr_multitest: bdmgr_multitest.o
|
||||
$(CC) $(CFLAGS) -o bdmgr_multitest bdmgr_multitest.o $(LIBS)
|
||||
|
||||
|
||||
bdstore_test: bdstore_test.o
|
||||
$(CC) $(CFLAGS) -o bdstore_test bdstore_test.o $(LIBS)
|
||||
|
||||
bdudp_test: bdudp_test.o
|
||||
$(CC) $(CFLAGS) -o bdudp_test bdudp_test.o $(LIBS)
|
||||
|
||||
udpbitdht_nettest: udpbitdht_nettest.o
|
||||
$(CC) $(CFLAGS) -o udpbitdht_nettest udpbitdht_nettest.o $(LIBS)
|
||||
|
||||
bencode_test: bencode_test.o
|
||||
$(CC) $(CFLAGS) -o bencode_test bencode_test.o $(LIBS)
|
||||
|
||||
bdbloom_test: bdbloom_test.o
|
||||
$(CC) $(CFLAGS) -o bdbloom_test bdbloom_test.o $(LIBS)
|
||||
|
||||
bdbloom_makefilter: bdbloom_makefilter.o
|
||||
$(CC) $(CFLAGS) -o bdbloom_makefilter bdbloom_makefilter.o $(LIBS)
|
||||
|
||||
|
||||
clobber: remove_extra_files
|
||||
|
||||
remove_extra_files:
|
||||
-$(RM) $(MANUAL_TESTS)
|
||||
|
||||
###############################################################
|
||||
include $(TEST_TOP_DIR)/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -42,6 +42,12 @@ StreamBase& operator << (StreamBase& left, ChatHandler::Msg& m)
|
||||
|
||||
bool compare_lobby_id(const ChatHandler::Lobby& l1, const ChatHandler::Lobby& l2)
|
||||
{
|
||||
if(l1.auto_subscribe && !l2.auto_subscribe) return true;
|
||||
if(!l1.auto_subscribe && l2.auto_subscribe) return false;
|
||||
if(l1.is_private && !l2.is_private) return true;
|
||||
if(!l1.is_private && l2.is_private) return false;
|
||||
if(l1.subscribed && !l2.subscribed) return true;
|
||||
if(!l1.subscribed && l2.subscribed) return false;
|
||||
return l1.id < l2.id;
|
||||
}
|
||||
|
||||
@ -65,13 +71,17 @@ StreamBase& operator <<(StreamBase& left, KeyValueReference<ChatLobbyId> kv)
|
||||
|
||||
StreamBase& operator << (StreamBase& left, ChatHandler::Lobby& l)
|
||||
{
|
||||
ChatId chatId(l.id);
|
||||
if (l.is_broadcast)
|
||||
chatId = ChatId::makeBroadcastId();
|
||||
left << makeKeyValueReference("id", l.id)
|
||||
<< makeKeyValue("chat_id", ChatId(l.id).toStdString())
|
||||
<< makeKeyValue("chat_id", chatId.toStdString())
|
||||
<< makeKeyValueReference("name",l.name)
|
||||
<< makeKeyValueReference("topic", l.topic)
|
||||
<< makeKeyValueReference("subscribed", l.subscribed)
|
||||
<< makeKeyValueReference("auto_subscribe", l.auto_subscribe)
|
||||
<< makeKeyValueReference("is_private", l.is_private)
|
||||
<< makeKeyValueReference("is_broadcast", l.is_broadcast)
|
||||
<< makeKeyValueReference("gxs_id", l.gxs_id);
|
||||
return left;
|
||||
}
|
||||
@ -157,11 +167,26 @@ void ChatHandler::tick()
|
||||
l.subscribed = true;
|
||||
l.auto_subscribe = info.lobby_flags & RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE;
|
||||
l.is_private = !(info.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC);
|
||||
l.is_broadcast = false;
|
||||
l.gxs_id = info.gxs_id;
|
||||
lobbies.push_back(l);
|
||||
}
|
||||
}
|
||||
|
||||
ChatId id = ChatId::makeBroadcastId();
|
||||
{
|
||||
Lobby l;
|
||||
l.id = id.toLobbyId();
|
||||
l.name = "BroadCast";
|
||||
l.topic = "Retroshare broadcast chat: messages are sent to all connected friends.";
|
||||
l.subscribed = true;
|
||||
l.auto_subscribe = false;
|
||||
l.is_private = false;
|
||||
l.is_broadcast = true;
|
||||
l.gxs_id = id.toGxsId();
|
||||
lobbies.push_back(l);
|
||||
}
|
||||
|
||||
std::vector<VisibleChatLobbyRecord> unsubscribed_lobbies;
|
||||
mRsMsgs->getListOfNearbyChatLobbies(unsubscribed_lobbies);
|
||||
for(std::vector<VisibleChatLobbyRecord>::iterator vit = unsubscribed_lobbies.begin(); vit != unsubscribed_lobbies.end(); ++vit)
|
||||
@ -176,6 +201,7 @@ void ChatHandler::tick()
|
||||
l.subscribed = false;
|
||||
l.auto_subscribe = info.lobby_flags & RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE;
|
||||
l.is_private = !(info.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC);
|
||||
l.is_broadcast = false;
|
||||
l.gxs_id = RsGxsId();
|
||||
lobbies.push_back(l);
|
||||
}
|
||||
@ -294,62 +320,7 @@ void ChatHandler::tick()
|
||||
|
||||
// remove html tags from chat message
|
||||
// extract links form href
|
||||
const std::string& in = msg.msg;
|
||||
std::string out;
|
||||
bool ignore = false;
|
||||
bool keep_link = false;
|
||||
std::string last_six_chars;
|
||||
Triple current_link;
|
||||
std::vector<Triple> links;
|
||||
for(unsigned int i = 0; i < in.size(); ++i)
|
||||
{
|
||||
if(keep_link && in[i] == '"')
|
||||
{
|
||||
keep_link = false;
|
||||
current_link.second = out.size();
|
||||
}
|
||||
if(last_six_chars == "href=\"")
|
||||
{
|
||||
keep_link = true;
|
||||
current_link.first = out.size();
|
||||
}
|
||||
|
||||
// "rising edge" sets mode to ignore
|
||||
if(in[i] == '<')
|
||||
{
|
||||
ignore = true;
|
||||
}
|
||||
if(!ignore || keep_link)
|
||||
out += in[i];
|
||||
// "falling edge" resets mode to keep
|
||||
if(in[i] == '>')
|
||||
ignore = false;
|
||||
|
||||
last_six_chars += in[i];
|
||||
if(last_six_chars.size() > 6)
|
||||
last_six_chars = last_six_chars.substr(1);
|
||||
std::string a = "</a>";
|
||||
if( current_link.first != -1
|
||||
&& last_six_chars.size() >= a.size()
|
||||
&& last_six_chars.substr(last_six_chars.size()-a.size()) == a)
|
||||
{
|
||||
// only allow these protocols
|
||||
// we don't want for example javascript:alert(0)
|
||||
std::string http = "http://";
|
||||
std::string https = "https://";
|
||||
std::string retroshare = "retroshare://";
|
||||
if( out.substr(current_link.first, http.size()) == http
|
||||
|| out.substr(current_link.first, https.size()) == https
|
||||
|| out.substr(current_link.first, retroshare.size()) == retroshare)
|
||||
{
|
||||
current_link.third = out.size();
|
||||
links.push_back(current_link);
|
||||
}
|
||||
current_link = Triple();
|
||||
}
|
||||
}
|
||||
m.msg = out;
|
||||
m.links = links;
|
||||
getPlainText(msg.msg, m.msg, m.links);
|
||||
m.recv_time = msg.recvTime;
|
||||
m.send_time = msg.sendTime;
|
||||
|
||||
@ -390,7 +361,77 @@ void ChatHandler::tick()
|
||||
}
|
||||
}
|
||||
|
||||
void ChatHandler::handleWildcard(Request &req, Response &resp)
|
||||
void ChatHandler::getPlainText(const std::string& in, std::string &out, std::vector<Triple> &links)
|
||||
{
|
||||
if (in.size() == 0)
|
||||
return;
|
||||
|
||||
if (in[0] != '<' || in[in.size() - 1] != '>')
|
||||
{
|
||||
// It's a plain text message without HTML
|
||||
out = in;
|
||||
return;
|
||||
}
|
||||
bool ignore = false;
|
||||
|
||||
bool keep_link = false;
|
||||
std::string last_six_chars;
|
||||
unsigned int tag_start_index = 0;
|
||||
Triple current_link;
|
||||
for(unsigned int i = 0; i < in.size(); ++i)
|
||||
{
|
||||
if(keep_link && in[i] == '"')
|
||||
{
|
||||
keep_link = false;
|
||||
current_link.second = out.size();
|
||||
}
|
||||
if(last_six_chars == "href=\"")
|
||||
{
|
||||
keep_link = true;
|
||||
current_link.first = out.size();
|
||||
}
|
||||
|
||||
// "rising edge" sets mode to ignore
|
||||
if(in[i] == '<')
|
||||
{
|
||||
tag_start_index = i;
|
||||
ignore = true;
|
||||
}
|
||||
if(!ignore || keep_link)
|
||||
out += in[i];
|
||||
// "falling edge" resets mode to keep
|
||||
if(in[i] == '>') {
|
||||
// leave ignore mode on, if it's a style tag
|
||||
if (tag_start_index == 0 || tag_start_index + 6 > i || in.substr(tag_start_index, 6) != "<style")
|
||||
ignore = false;
|
||||
}
|
||||
|
||||
last_six_chars += in[i];
|
||||
if(last_six_chars.size() > 6)
|
||||
last_six_chars = last_six_chars.substr(1);
|
||||
std::string a = "</a>";
|
||||
if( current_link.first != -1
|
||||
&& last_six_chars.size() >= a.size()
|
||||
&& last_six_chars.substr(last_six_chars.size()-a.size()) == a)
|
||||
{
|
||||
// only allow these protocols
|
||||
// we don't want for example javascript:alert(0)
|
||||
std::string http = "http://";
|
||||
std::string https = "https://";
|
||||
std::string retroshare = "retroshare://";
|
||||
if( out.substr(current_link.first, http.size()) == http
|
||||
|| out.substr(current_link.first, https.size()) == https
|
||||
|| out.substr(current_link.first, retroshare.size()) == retroshare)
|
||||
{
|
||||
current_link.third = out.size();
|
||||
links.push_back(current_link);
|
||||
}
|
||||
current_link = Triple();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChatHandler::handleWildcard(Request &/*req*/, Response &resp)
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
|
||||
resp.mDataStream.getStreamToMember();
|
||||
@ -447,7 +488,7 @@ void ChatHandler::handleSubscribeLobby(Request &req, Response &resp)
|
||||
resp.setFail("lobby join failed. (See console for more info)");
|
||||
}
|
||||
|
||||
void ChatHandler::handleUnsubscribeLobby(Request &req, Response &resp)
|
||||
void ChatHandler::handleUnsubscribeLobby(Request &req, Response &/*resp*/)
|
||||
{
|
||||
ChatLobbyId id = 0;
|
||||
req.mStream << makeKeyValueReference("id", id);
|
||||
@ -626,17 +667,17 @@ void ChatHandler::handleInfo(Request &req, Response &resp)
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void ChatHandler::handleTypingLabel(Request &req, Response &resp)
|
||||
void ChatHandler::handleTypingLabel(Request &/*req*/, Response &/*resp*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ChatHandler::handleSendStatus(Request &req, Response &resp)
|
||||
void ChatHandler::handleSendStatus(Request &/*req*/, Response &/*resp*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ChatHandler::handleUnreadMsgs(Request &req, Response &resp)
|
||||
void ChatHandler::handleUnreadMsgs(Request &/*req*/, Response &resp)
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
|
||||
|
||||
|
@ -57,13 +57,14 @@ public:
|
||||
|
||||
class Lobby{
|
||||
public:
|
||||
Lobby(): id(0), subscribed(false), auto_subscribe(false), is_private(false){}
|
||||
Lobby(): id(0), subscribed(false), auto_subscribe(false), is_private(false), is_broadcast(false){}
|
||||
ChatLobbyId id;
|
||||
std::string name;
|
||||
std::string topic;
|
||||
bool subscribed;
|
||||
bool auto_subscribe;
|
||||
bool is_private;
|
||||
bool is_broadcast;
|
||||
|
||||
RsGxsId gxs_id;// for subscribed lobbies: the id we use to write messages
|
||||
|
||||
@ -75,6 +76,7 @@ public:
|
||||
&& subscribed == l.subscribed
|
||||
&& auto_subscribe == l.auto_subscribe
|
||||
&& is_private == l.is_private
|
||||
&& is_broadcast == l.is_broadcast
|
||||
&& gxs_id == l.gxs_id;
|
||||
}
|
||||
};
|
||||
@ -102,6 +104,8 @@ private:
|
||||
void handleSendStatus(Request& req, Response& resp);
|
||||
void handleUnreadMsgs(Request& req, Response& resp);
|
||||
|
||||
void getPlainText(const std::string& in, std::string &out, std::vector<Triple> &links);
|
||||
|
||||
StateTokenServer* mStateTokenServer;
|
||||
RsNotify* mNotify;
|
||||
RsMsgs* mRsMsgs;
|
||||
|
@ -2,8 +2,10 @@
|
||||
|
||||
TEMPLATE = lib
|
||||
CONFIG += staticlib
|
||||
CONFIG += create_prl
|
||||
CONFIG -= qt
|
||||
TARGET = resapi
|
||||
TARGET_PRL = libresapi
|
||||
DESTDIR = lib
|
||||
|
||||
CONFIG += libmicrohttpd
|
||||
@ -26,6 +28,12 @@ win32{
|
||||
}
|
||||
|
||||
libmicrohttpd{
|
||||
linux {
|
||||
CONFIG += link_pkgconfig
|
||||
PKGCONFIG *= libmicrohttpd
|
||||
} else {
|
||||
LIBS *= -lmicrohttpd
|
||||
}
|
||||
SOURCES += \
|
||||
api/ApiServerMHD.cpp
|
||||
|
||||
|
@ -1,36 +0,0 @@
|
||||
REACT_VERSION = 0.13.1
|
||||
|
||||
DISTDIR = ../webfiles
|
||||
JSEXTLIBS = $(DISTDIR)/react.js $(DISTDIR)/JSXTransformer.js
|
||||
JSLIBS = RsXHRConnection.js RsApi.js
|
||||
HTML = index.html
|
||||
JSGUI = gui.jsx
|
||||
CSS = green-black.css
|
||||
|
||||
all: $(DISTDIR) $(JSEXTLIBS) $(addprefix $(DISTDIR)/, $(JSLIBS)) $(addprefix $(DISTDIR)/, $(HTML)) $(addprefix $(DISTDIR)/, $(JSGUI)) $(addprefix $(DISTDIR)/, $(CSS))
|
||||
.PHONY: all
|
||||
|
||||
$(DISTDIR)/livereload: $(DISTDIR) $(JSEXTLIBS) $(addprefix $(DISTDIR)/, $(JSLIBS)) $(addprefix $(DISTDIR)/, $(HTML)) $(addprefix $(DISTDIR)/, $(JSGUI)) $(addprefix $(DISTDIR)/, $(CSS))
|
||||
wget -qO- http://localhost:9090/api/v2/livereload/trigger
|
||||
touch $(DISTDIR)/livereload
|
||||
|
||||
$(DISTDIR)/react.js:
|
||||
cd $(DISTDIR) && wget --no-check-certificate --output-document react.js http://fb.me/react-$(REACT_VERSION).js
|
||||
|
||||
$(DISTDIR)/JSXTransformer.js:
|
||||
cd $(DISTDIR) && wget --no-check-certificate --output-document JSXTransformer.js http://fb.me/JSXTransformer-$(REACT_VERSION).js
|
||||
|
||||
$(addprefix $(DISTDIR)/, $(JSLIBS)): $(DISTDIR)/%: %
|
||||
cp $< $@
|
||||
|
||||
$(addprefix $(DISTDIR)/, $(HTML)): $(DISTDIR)/%: %
|
||||
cp $< $@
|
||||
|
||||
$(addprefix $(DISTDIR)/, $(JSGUI)): $(DISTDIR)/%: %
|
||||
cp $< $@
|
||||
|
||||
$(addprefix $(DISTDIR)/, $(CSS)): $(DISTDIR)/%: %
|
||||
cp $< $@
|
||||
|
||||
$(DISTDIR):
|
||||
mkdir $(DISTDIR)
|
@ -31,6 +31,7 @@
|
||||
#include "openssl/err.h"
|
||||
|
||||
#include "util/rsaes.h"
|
||||
#include "util/rsmemory.h"
|
||||
|
||||
#include <serialiser/rsmsgitems.h>
|
||||
|
||||
@ -435,10 +436,6 @@ bool DistantChatService::handleEncryptedData(const uint8_t *data_bytes,uint32_t
|
||||
{
|
||||
RS_STACK_MUTEX(mDistantChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
uint32_t decrypted_size = RsAES::get_buffer_size(data_size-8);
|
||||
uint8_t *decrypted_data = new uint8_t[decrypted_size];
|
||||
uint8_t aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
||||
|
||||
std::map<RsPeerId,DistantChatDHInfo>::iterator it = _distant_chat_virtual_peer_ids.find(virtual_peer_id) ;
|
||||
|
||||
if(it == _distant_chat_virtual_peer_ids.end())
|
||||
@ -455,8 +452,11 @@ bool DistantChatService::handleEncryptedData(const uint8_t *data_bytes,uint32_t
|
||||
std::cerr << "(EE) no GXS id data for ID=" << gxs_id << ". This is a bug." << std::endl;
|
||||
return true ;
|
||||
}
|
||||
uint8_t aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
||||
memcpy(aes_key,it2->second.aes_key,DISTANT_CHAT_AES_KEY_SIZE) ;
|
||||
|
||||
uint32_t decrypted_size = RsAES::get_buffer_size(data_size-8);
|
||||
uint8_t *decrypted_data = new uint8_t[decrypted_size];
|
||||
#ifdef DEBUG_DISTANT_CHAT
|
||||
std::cerr << " Using IV: " << std::hex << *(uint64_t*)data_bytes << std::dec << std::endl;
|
||||
std::cerr << " Decrypted buffer size: " << decrypted_size << std::endl;
|
||||
@ -540,7 +540,7 @@ void DistantChatService::handleRecvDHPublicKey(RsChatDHPublicKeyItem *item)
|
||||
#endif
|
||||
|
||||
uint32_t pubkey_size = BN_num_bytes(item->public_key) ;
|
||||
unsigned char *data = (unsigned char *)malloc(pubkey_size) ;
|
||||
RsTemporaryMemory data(pubkey_size) ;
|
||||
BN_bn2bin(item->public_key, data) ;
|
||||
|
||||
RsTlvSecurityKey signature_key ;
|
||||
@ -585,7 +585,7 @@ void DistantChatService::handleRecvDHPublicKey(RsChatDHPublicKeyItem *item)
|
||||
signature_key = item->gxs_key ;
|
||||
}
|
||||
|
||||
if(!GxsSecurity::validateSignature((char*)data,pubkey_size,signature_key,item->signature))
|
||||
if(!GxsSecurity::validateSignature((char*)(uint8_t*)data,pubkey_size,signature_key,item->signature))
|
||||
{
|
||||
std::cerr << "(SS) Signature was verified and it doesn't check! This is a security issue!" << std::endl;
|
||||
return ;
|
||||
@ -690,10 +690,10 @@ bool DistantChatService::locked_sendDHPublicKey(const DH *dh,const RsGxsId& own_
|
||||
uint32_t error_status ;
|
||||
|
||||
uint32_t size = BN_num_bytes(dhitem->public_key) ;
|
||||
unsigned char *data = (unsigned char *)malloc(size) ;
|
||||
RsTemporaryMemory data(size) ;
|
||||
BN_bn2bin(dhitem->public_key, data) ;
|
||||
|
||||
if(!mGixs->signData((unsigned char*)data,size,own_gxs_id,signature,error_status))
|
||||
if(!mGixs->signData(data,size,own_gxs_id,signature,error_status))
|
||||
{
|
||||
switch(error_status)
|
||||
{
|
||||
@ -702,11 +702,9 @@ bool DistantChatService::locked_sendDHPublicKey(const DH *dh,const RsGxsId& own_
|
||||
default: std::cerr << "(EE) Unknown error when signing" << std::endl;
|
||||
break ;
|
||||
}
|
||||
free(data) ;
|
||||
delete(dhitem);
|
||||
return false;
|
||||
}
|
||||
free(data) ;
|
||||
|
||||
if(!mGixs->getKey(own_gxs_id,signature_key_public))
|
||||
{
|
||||
@ -810,19 +808,16 @@ void DistantChatService::sendTurtleData(RsChatItem *item)
|
||||
else
|
||||
{
|
||||
uint32_t rssize = item->serial_size();
|
||||
uint8_t *buff = (uint8_t*)malloc(rssize) ;
|
||||
RsTemporaryMemory buff(rssize) ;
|
||||
|
||||
if(!item->serialise(buff,rssize))
|
||||
{
|
||||
std::cerr << "(EE) DistantChatService::sendTurtleData(): Could not serialise item!" << std::endl;
|
||||
free(buff) ;
|
||||
delete item ;
|
||||
return ;
|
||||
}
|
||||
|
||||
sendEncryptedTurtleData(buff,rssize,RsGxsId(item->PeerId())) ;
|
||||
|
||||
free(buff) ;
|
||||
}
|
||||
delete item ;
|
||||
}
|
||||
|
@ -780,7 +780,7 @@ int FileIndex::loadIndex(const std::string& filename, const RsFileHash& expected
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
int bytesread = 0 ;
|
||||
uint64_t bytesread = 0 ;
|
||||
if(size != (bytesread = fread(compressed_data,1,size,file)))
|
||||
{
|
||||
std::cerr << "FileIndex::loadIndex(): can't read " << size << " bytes from file " << filename << ". Only " << bytesread << " actually read." << std::endl;
|
||||
@ -1089,7 +1089,7 @@ int FileIndex::saveIndex(const std::string& filename, RsFileHash &fileHash, uint
|
||||
std::cerr << "FileIndex::saveIndex error opening file for writting: " << filename << ". Giving up." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
int outwritten ;
|
||||
uint32_t outwritten ;
|
||||
|
||||
if(compressed_data_size != (outwritten=fwrite(compressed_data,1,compressed_data_size,file)))
|
||||
{
|
||||
@ -1370,7 +1370,7 @@ void *FileIndex::findRef(const std::string& fpath) const
|
||||
std::cerr << "FileIndex::updateFileEntry() NULL parent";
|
||||
std::cerr << std::endl;
|
||||
//#endif
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
std::cerr << "Found parent directory: " << std::endl;
|
||||
std::cerr << " parent.name = " << parent->name << std::endl;
|
||||
|
@ -96,7 +96,7 @@ void ChunkMap::setAvailabilityMap(const CompressedChunkMap& map)
|
||||
// do some sanity check
|
||||
//
|
||||
|
||||
if( (((int)_map.size()-1)>>5) >= map._map.size() )
|
||||
if( (((int)_map.size()-1)>>5) >= (int)map._map.size() )
|
||||
{
|
||||
std::cerr << "ChunkMap::setPeerAvailabilityMap: Compressed chunkmap received is too small or corrupted." << std::endl;
|
||||
return ;
|
||||
|
@ -551,7 +551,7 @@ bool GxsSecurity::decrypt(uint8_t *& out, uint32_t & outlen, const uint8_t *in,
|
||||
in_offset += size_net_ekl;
|
||||
|
||||
// Conservative limits to detect weird errors due to corrupted encoding.
|
||||
if(eklen < 0 || eklen > 512 || eklen+in_offset > inlen)
|
||||
if(eklen < 0 || eklen > 512 || eklen+in_offset > (int)inlen)
|
||||
{
|
||||
std::cerr << "Error while deserialising encryption key length: eklen = " << std::dec << eklen << ". Giving up decryption." << std::endl;
|
||||
free(ek);
|
||||
|
@ -152,6 +152,11 @@ RsDataService::RsDataService(const std::string &serviceDir, const std::string &d
|
||||
mColMsg_MetaData = addColumn(mMsgColumns, KEY_NXS_META);
|
||||
mColMsg_MsgId = addColumn(mMsgColumns, KEY_MSG_ID);
|
||||
|
||||
// for retrieving msg data with meta
|
||||
mMsgColumnsWithMeta = mMsgColumns;
|
||||
mColMsg_WithMetaOffset = mMsgColumnsWithMeta.size();
|
||||
mMsgColumnsWithMeta.insert(mMsgColumnsWithMeta.end(), mMsgMetaColumns.begin(), mMsgMetaColumns.end());
|
||||
|
||||
// for retrieving grp meta data
|
||||
mColGrpMeta_GrpId = addColumn(mGrpMetaColumns, KEY_GRP_ID);
|
||||
mColGrpMeta_TimeStamp = addColumn(mGrpMetaColumns, KEY_TIME_STAMP);
|
||||
@ -184,6 +189,11 @@ RsDataService::RsDataService(const std::string &serviceDir, const std::string &d
|
||||
mColGrp_NxsData = addColumn(mGrpColumns, KEY_NXS_DATA);
|
||||
mColGrp_MetaData = addColumn(mGrpColumns, KEY_NXS_META);
|
||||
|
||||
// for retrieving grp data with meta
|
||||
mGrpColumnsWithMeta = mGrpColumns;
|
||||
mColGrp_WithMetaOffset = mGrpColumnsWithMeta.size();
|
||||
mGrpColumnsWithMeta.insert(mGrpColumnsWithMeta.end(), mGrpMetaColumns.begin(), mGrpMetaColumns.end());
|
||||
|
||||
// Group id columns
|
||||
mColGrpId_GrpId = addColumn(mGrpIdColumn, KEY_GRP_ID);
|
||||
|
||||
@ -474,7 +484,7 @@ bool RsDataService::finishReleaseUpdate(int release, bool result)
|
||||
return result;
|
||||
}
|
||||
|
||||
RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c)
|
||||
RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c, int colOffset)
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG
|
||||
std::cerr << "RsDataService::locked_getGrpMeta()";
|
||||
@ -492,27 +502,27 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c)
|
||||
|
||||
// grpId
|
||||
std::string tempId;
|
||||
c.getString(mColGrpMeta_GrpId, tempId);
|
||||
c.getString(mColGrpMeta_GrpId + colOffset, tempId);
|
||||
grpMeta->mGroupId = RsGxsGroupId(tempId);
|
||||
c.getString(mColGrpMeta_NxsIdentity, tempId);
|
||||
c.getString(mColGrpMeta_NxsIdentity + colOffset, tempId);
|
||||
grpMeta->mAuthorId = RsGxsId(tempId);
|
||||
|
||||
c.getString(mColGrpMeta_Name, grpMeta->mGroupName);
|
||||
c.getString(mColGrpMeta_OrigGrpId, tempId);
|
||||
c.getString(mColGrpMeta_Name + colOffset, grpMeta->mGroupName);
|
||||
c.getString(mColGrpMeta_OrigGrpId + colOffset, tempId);
|
||||
grpMeta->mOrigGrpId = RsGxsGroupId(tempId);
|
||||
c.getString(mColGrpMeta_ServString, grpMeta->mServiceString);
|
||||
c.getString(mColGrpMeta_ServString + colOffset, grpMeta->mServiceString);
|
||||
std::string temp;
|
||||
c.getString(mColGrpMeta_NxsHash, temp);
|
||||
c.getString(mColGrpMeta_NxsHash + colOffset, temp);
|
||||
grpMeta->mHash = RsFileHash(temp);
|
||||
grpMeta->mReputationCutOff = c.getInt32(mColGrpMeta_RepCutoff);
|
||||
grpMeta->mSignFlags = c.getInt32(mColGrpMeta_SignFlags);
|
||||
grpMeta->mReputationCutOff = c.getInt32(mColGrpMeta_RepCutoff + colOffset);
|
||||
grpMeta->mSignFlags = c.getInt32(mColGrpMeta_SignFlags + colOffset);
|
||||
|
||||
grpMeta->mPublishTs = c.getInt32(mColGrpMeta_TimeStamp);
|
||||
grpMeta->mGroupFlags = c.getInt32(mColGrpMeta_NxsFlags);
|
||||
grpMeta->mGrpSize = c.getInt32(mColGrpMeta_NxsDataLen);
|
||||
grpMeta->mPublishTs = c.getInt32(mColGrpMeta_TimeStamp + colOffset);
|
||||
grpMeta->mGroupFlags = c.getInt32(mColGrpMeta_NxsFlags + colOffset);
|
||||
grpMeta->mGrpSize = c.getInt32(mColGrpMeta_NxsDataLen + colOffset);
|
||||
|
||||
offset = 0; data = NULL; data_len = 0;
|
||||
data = (char*)c.getData(mColGrpMeta_KeySet, data_len);
|
||||
data = (char*)c.getData(mColGrpMeta_KeySet + colOffset, data_len);
|
||||
|
||||
if(data)
|
||||
ok &= grpMeta->keys.GetTlv(data, data_len, &offset);
|
||||
@ -520,22 +530,22 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c)
|
||||
grpMeta->keys.TlvClear() ;
|
||||
|
||||
// local meta
|
||||
grpMeta->mSubscribeFlags = c.getInt32(mColGrpMeta_SubscrFlag);
|
||||
grpMeta->mPop = c.getInt32(mColGrpMeta_Pop);
|
||||
grpMeta->mVisibleMsgCount = c.getInt32(mColGrpMeta_MsgCount);
|
||||
grpMeta->mLastPost = c.getInt32(mColGrpMeta_LastPost);
|
||||
grpMeta->mGroupStatus = c.getInt32(mColGrpMeta_Status);
|
||||
grpMeta->mSubscribeFlags = c.getInt32(mColGrpMeta_SubscrFlag + colOffset);
|
||||
grpMeta->mPop = c.getInt32(mColGrpMeta_Pop + colOffset);
|
||||
grpMeta->mVisibleMsgCount = c.getInt32(mColGrpMeta_MsgCount + colOffset);
|
||||
grpMeta->mLastPost = c.getInt32(mColGrpMeta_LastPost + colOffset);
|
||||
grpMeta->mGroupStatus = c.getInt32(mColGrpMeta_Status + colOffset);
|
||||
|
||||
c.getString(mColGrpMeta_CircleId, tempId);
|
||||
c.getString(mColGrpMeta_CircleId + colOffset, tempId);
|
||||
grpMeta->mCircleId = RsGxsCircleId(tempId);
|
||||
grpMeta->mCircleType = c.getInt32(mColGrpMeta_CircleType);
|
||||
c.getString(mColGrpMeta_InternCircle, tempId);
|
||||
grpMeta->mCircleType = c.getInt32(mColGrpMeta_CircleType + colOffset);
|
||||
c.getString(mColGrpMeta_InternCircle + colOffset, tempId);
|
||||
grpMeta->mInternalCircle = RsGxsCircleId(tempId);
|
||||
|
||||
std::string s ; c.getString(mColGrpMeta_Originator, s) ;
|
||||
std::string s ; c.getString(mColGrpMeta_Originator + colOffset, s) ;
|
||||
grpMeta->mOriginator = RsPeerId(s);
|
||||
grpMeta->mAuthenFlags = c.getInt32(mColGrpMeta_AuthenFlags);
|
||||
grpMeta->mRecvTS = c.getInt32(mColGrpMeta_RecvTs);
|
||||
grpMeta->mAuthenFlags = c.getInt32(mColGrpMeta_AuthenFlags + colOffset);
|
||||
grpMeta->mRecvTS = c.getInt32(mColGrpMeta_RecvTs + colOffset);
|
||||
|
||||
|
||||
c.getString(mColGrpMeta_ParentGrpId, tempId);
|
||||
@ -591,7 +601,7 @@ RsNxsGrp* RsDataService::locked_getGroup(RetroCursor &c)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RsGxsMsgMetaData* RsDataService::locked_getMsgMeta(RetroCursor &c)
|
||||
RsGxsMsgMetaData* RsDataService::locked_getMsgMeta(RetroCursor &c, int colOffset)
|
||||
{
|
||||
|
||||
RsGxsMsgMetaData* msgMeta = new RsGxsMsgMetaData();
|
||||
@ -602,44 +612,44 @@ RsGxsMsgMetaData* RsDataService::locked_getMsgMeta(RetroCursor &c)
|
||||
char* data = NULL;
|
||||
|
||||
std::string gId;
|
||||
c.getString(mColMsgMeta_GrpId, gId);
|
||||
c.getString(mColMsgMeta_GrpId + colOffset, gId);
|
||||
msgMeta->mGroupId = RsGxsGroupId(gId);
|
||||
std::string temp;
|
||||
c.getString(mColMsgMeta_MsgId, temp);
|
||||
c.getString(mColMsgMeta_MsgId + colOffset, temp);
|
||||
msgMeta->mMsgId = RsGxsMessageId(temp);
|
||||
// without these, a msg is meaningless
|
||||
ok &= (!msgMeta->mGroupId.isNull()) && (!msgMeta->mMsgId.isNull());
|
||||
|
||||
c.getString(mColMsgMeta_OrigMsgId, temp);
|
||||
c.getString(mColMsgMeta_OrigMsgId + colOffset, temp);
|
||||
msgMeta->mOrigMsgId = RsGxsMessageId(temp);
|
||||
c.getString(mColMsgMeta_NxsIdentity, temp);
|
||||
c.getString(mColMsgMeta_NxsIdentity + colOffset, temp);
|
||||
msgMeta->mAuthorId = RsGxsId(temp);
|
||||
c.getString(mColMsgMeta_Name, msgMeta->mMsgName);
|
||||
c.getString(mColMsgMeta_NxsServString, msgMeta->mServiceString);
|
||||
c.getString(mColMsgMeta_Name + colOffset, msgMeta->mMsgName);
|
||||
c.getString(mColMsgMeta_NxsServString + colOffset, msgMeta->mServiceString);
|
||||
|
||||
c.getString(mColMsgMeta_NxsHash, temp);
|
||||
c.getString(mColMsgMeta_NxsHash + colOffset, temp);
|
||||
msgMeta->mHash = RsFileHash(temp);
|
||||
msgMeta->recvTS = c.getInt32(mColMsgMeta_RecvTs);
|
||||
msgMeta->recvTS = c.getInt32(mColMsgMeta_RecvTs + colOffset);
|
||||
|
||||
offset = 0;
|
||||
data = (char*)c.getData(mColMsgMeta_SignSet, data_len);
|
||||
data = (char*)c.getData(mColMsgMeta_SignSet + colOffset, data_len);
|
||||
msgMeta->signSet.GetTlv(data, data_len, &offset);
|
||||
msgMeta->mMsgSize = c.getInt32(mColMsgMeta_NxsDataLen);
|
||||
msgMeta->mMsgSize = c.getInt32(mColMsgMeta_NxsDataLen + colOffset);
|
||||
|
||||
msgMeta->mMsgFlags = c.getInt32(mColMsgMeta_NxsFlags);
|
||||
msgMeta->mPublishTs = c.getInt32(mColMsgMeta_TimeStamp);
|
||||
msgMeta->mMsgFlags = c.getInt32(mColMsgMeta_NxsFlags + colOffset);
|
||||
msgMeta->mPublishTs = c.getInt32(mColMsgMeta_TimeStamp + colOffset);
|
||||
|
||||
offset = 0; data_len = 0;
|
||||
|
||||
// thread and parent id
|
||||
c.getString(mColMsgMeta_MsgThreadId, temp);
|
||||
c.getString(mColMsgMeta_MsgThreadId + colOffset, temp);
|
||||
msgMeta->mThreadId = RsGxsMessageId(temp);
|
||||
c.getString(mColMsgMeta_MsgParentId, temp);
|
||||
c.getString(mColMsgMeta_MsgParentId + colOffset, temp);
|
||||
msgMeta->mParentId = RsGxsMessageId(temp);
|
||||
|
||||
// local meta
|
||||
msgMeta->mMsgStatus = c.getInt32(mColMsgMeta_MsgStatus);
|
||||
msgMeta->mChildTs = c.getInt32(mColMsgMeta_ChildTs);
|
||||
msgMeta->mMsgStatus = c.getInt32(mColMsgMeta_MsgStatus + colOffset);
|
||||
msgMeta->mChildTs = c.getInt32(mColMsgMeta_ChildTs + colOffset);
|
||||
|
||||
if(ok)
|
||||
return msgMeta;
|
||||
@ -1020,13 +1030,13 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
||||
if(grp.empty()){
|
||||
|
||||
RsStackMutex stack(mDbMutex);
|
||||
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpColumns, "", "");
|
||||
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, withMeta ? mGrpColumnsWithMeta : mGrpColumns, "", "");
|
||||
|
||||
if(c)
|
||||
{
|
||||
std::vector<RsNxsGrp*> grps;
|
||||
|
||||
locked_retrieveGroups(c, grps);
|
||||
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0);
|
||||
std::vector<RsNxsGrp*>::iterator vit = grps.begin();
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
@ -1051,12 +1061,12 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
||||
for(; mit != grp.end(); ++mit)
|
||||
{
|
||||
const RsGxsGroupId& grpId = mit->first;
|
||||
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpColumns, "grpId='" + grpId.toStdString() + "'", "");
|
||||
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, withMeta ? mGrpColumnsWithMeta : mGrpColumns, "grpId='" + grpId.toStdString() + "'", "");
|
||||
|
||||
if(c)
|
||||
{
|
||||
std::vector<RsNxsGrp*> grps;
|
||||
locked_retrieveGroups(c, grps);
|
||||
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0);
|
||||
|
||||
if(!grps.empty())
|
||||
{
|
||||
@ -1085,38 +1095,10 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
||||
std::cerr << "RsDataService::retrieveNxsGrps() " << mDbName << ", Requests: " << requestedGroups << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl;
|
||||
#endif
|
||||
|
||||
if(withMeta && !grp.empty())
|
||||
{
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> metaMap;
|
||||
std::map<RsGxsGroupId, RsNxsGrp *>::iterator mit = grp.begin();
|
||||
for(; mit != grp.end(); ++mit)
|
||||
metaMap.insert(std::make_pair(mit->first, (RsGxsGrpMetaData*)(NULL)));
|
||||
|
||||
retrieveGxsGrpMetaData(metaMap);
|
||||
|
||||
mit = grp.begin();
|
||||
for(; mit != grp.end(); ++mit)
|
||||
{
|
||||
RsNxsGrp* grpPtr = grp[mit->first];
|
||||
grpPtr->metaData = metaMap[mit->first];
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG
|
||||
std::cerr << "RsDataService::retrieveNxsGrps() GrpId: " << mit->first.toStdString();
|
||||
std::cerr << " CircleType: " << (uint32_t) grpPtr->metaData->mCircleType;
|
||||
std::cerr << " CircleId: " << grpPtr->metaData->mCircleId.toStdString();
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
std::cerr << "RsDataService::retrieveNxsGrps() " << mDbName << ", Time with meta: " << timer.duration() << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps){
|
||||
void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset){
|
||||
|
||||
if(c){
|
||||
bool valid = c->moveToFirst();
|
||||
@ -1127,6 +1109,9 @@ void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>
|
||||
// only add the latest grp info
|
||||
if(g)
|
||||
{
|
||||
if (metaOffset) {
|
||||
g->metaData = locked_getGrpMeta(*c, metaOffset);
|
||||
}
|
||||
grps.push_back(g);
|
||||
}
|
||||
valid = c->moveToNext();
|
||||
@ -1143,8 +1128,6 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
||||
|
||||
GxsMsgReq::const_iterator mit = reqIds.begin();
|
||||
|
||||
GxsMsgReq metaReqIds;// collects metaReqIds if needed
|
||||
|
||||
for(; mit != reqIds.end(); ++mit)
|
||||
{
|
||||
|
||||
@ -1158,15 +1141,11 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
||||
|
||||
RsStackMutex stack(mDbMutex);
|
||||
|
||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, mMsgColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, withMeta ? mMsgColumnsWithMeta : mMsgColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
||||
|
||||
if(c)
|
||||
{
|
||||
locked_retrieveMessages(c, msgSet);
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
resultCount += msgSet.size();
|
||||
#endif
|
||||
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0);
|
||||
}
|
||||
|
||||
delete c;
|
||||
@ -1180,36 +1159,24 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
||||
|
||||
RsStackMutex stack(mDbMutex);
|
||||
|
||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, mMsgColumns, KEY_GRP_ID+ "='" + grpId.toStdString()
|
||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, withMeta ? mMsgColumnsWithMeta : mMsgColumns, KEY_GRP_ID+ "='" + grpId.toStdString()
|
||||
+ "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", "");
|
||||
|
||||
if(c)
|
||||
{
|
||||
locked_retrieveMessages(c, msgSet);
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
resultCount += c->getResultCount();
|
||||
#endif
|
||||
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0);
|
||||
}
|
||||
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
resultCount += msgSet.size();
|
||||
#endif
|
||||
|
||||
msg[grpId] = msgSet;
|
||||
|
||||
if(withMeta)
|
||||
{
|
||||
std::vector<RsGxsMessageId> msgIds;
|
||||
|
||||
std::vector<RsNxsMsg*>::iterator lit = msgSet.begin(),
|
||||
lit_end = msgSet.end();
|
||||
|
||||
for(; lit != lit_end; ++lit)
|
||||
msgIds.push_back( (*lit)->msgId );
|
||||
|
||||
metaReqIds[grpId] = msgIds;
|
||||
}
|
||||
msgSet.clear();
|
||||
}
|
||||
|
||||
@ -1217,73 +1184,19 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
||||
std::cerr << "RsDataService::retrieveNxsMsgs() " << mDbName << ", Requests: " << reqIds.size() << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl;
|
||||
#endif
|
||||
|
||||
// tres expensive !?
|
||||
if(withMeta)
|
||||
{
|
||||
|
||||
GxsMsgMetaResult metaResult;
|
||||
|
||||
// request with meta ids so there is no chance of
|
||||
// a mem leak being left over
|
||||
retrieveGxsMsgMetaData(metaReqIds, metaResult);
|
||||
|
||||
GxsMsgResult::iterator mit2 = msg.begin(), mit2_end = msg.end();
|
||||
|
||||
for(; mit2 != mit2_end; ++mit2)
|
||||
{
|
||||
const RsGxsGroupId& grpId = mit2->first;
|
||||
std::vector<RsNxsMsg*>& msgV = msg[grpId];
|
||||
std::vector<RsNxsMsg*>::iterator lit = msgV.begin(),
|
||||
lit_end = msgV.end();
|
||||
|
||||
// as retrieval only attempts to retrieve what was found this elimiates chance
|
||||
// of a memory fault as all are assigned
|
||||
for(; lit != lit_end; ++lit)
|
||||
{
|
||||
std::vector<RsGxsMsgMetaData*>& msgMetaV = metaResult[grpId];
|
||||
std::vector<RsGxsMsgMetaData*>::iterator meta_lit = msgMetaV.begin();
|
||||
RsNxsMsg* msgPtr = *lit;
|
||||
for(; meta_lit != msgMetaV.end(); )
|
||||
{
|
||||
RsGxsMsgMetaData* meta = *meta_lit;
|
||||
if(meta->mMsgId == msgPtr->msgId)
|
||||
{
|
||||
msgPtr->metaData = meta;
|
||||
meta_lit = msgMetaV.erase(meta_lit);
|
||||
}else{
|
||||
++meta_lit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<RsGxsMsgMetaData*>& msgMetaV = metaResult[grpId];
|
||||
std::vector<RsGxsMsgMetaData*>::iterator meta_lit;
|
||||
|
||||
// clean up just in case, should not go in here
|
||||
for(meta_lit = msgMetaV.begin(); meta_lit !=
|
||||
msgMetaV.end(); )
|
||||
{
|
||||
RsGxsMsgMetaData* meta = *meta_lit;
|
||||
delete meta;
|
||||
meta_lit = msgMetaV.erase(meta_lit);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
std::cerr << "RsDataService::retrieveNxsMsgs() " << mDbName << ", Time with meta: " << timer.duration() << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg *> &msgs)
|
||||
void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg *> &msgs, int metaOffset)
|
||||
{
|
||||
bool valid = c->moveToFirst();
|
||||
while(valid){
|
||||
RsNxsMsg* m = locked_getMessage(*c);
|
||||
|
||||
if(m){
|
||||
if (metaOffset) {
|
||||
m->metaData = locked_getMsgMeta(*c, metaOffset);
|
||||
}
|
||||
msgs.push_back(m);
|
||||
}
|
||||
|
||||
@ -1318,10 +1231,6 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
|
||||
if (c)
|
||||
{
|
||||
locked_retrieveMsgMeta(c, metaSet);
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
resultCount += metaSet.size();
|
||||
#endif
|
||||
}
|
||||
}else{
|
||||
|
||||
@ -1336,14 +1245,14 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
|
||||
if (c)
|
||||
{
|
||||
locked_retrieveMsgMeta(c, metaSet);
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
resultCount += c->getResultCount();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
resultCount += metaSet.size();
|
||||
#endif
|
||||
|
||||
msgMeta[grpId] = metaSet;
|
||||
}
|
||||
|
||||
@ -1361,7 +1270,7 @@ void RsDataService::locked_retrieveMsgMeta(RetroCursor *c, std::vector<RsGxsMsgM
|
||||
{
|
||||
bool valid = c->moveToFirst();
|
||||
while(valid){
|
||||
RsGxsMsgMetaData* m = locked_getMsgMeta(*c);
|
||||
RsGxsMsgMetaData* m = locked_getMsgMeta(*c, 0);
|
||||
|
||||
if(m != NULL)
|
||||
msgMeta.push_back(m);
|
||||
@ -1402,7 +1311,7 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaDat
|
||||
|
||||
while(valid)
|
||||
{
|
||||
RsGxsGrpMetaData* g = locked_getGrpMeta(*c);
|
||||
RsGxsGrpMetaData* g = locked_getGrpMeta(*c, 0);
|
||||
if(g)
|
||||
{
|
||||
grp[g->mGroupId] = g;
|
||||
@ -1431,7 +1340,7 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaDat
|
||||
|
||||
while(valid)
|
||||
{
|
||||
RsGxsGrpMetaData* g = locked_getGrpMeta(*c);
|
||||
RsGxsGrpMetaData* g = locked_getGrpMeta(*c, 0);
|
||||
|
||||
if(g)
|
||||
{
|
||||
|
@ -181,14 +181,15 @@ private:
|
||||
* @param c cursor to result set
|
||||
* @param msgs messages retrieved from cursor are stored here
|
||||
*/
|
||||
void locked_retrieveMessages(RetroCursor* c, std::vector<RsNxsMsg*>& msgs);
|
||||
void locked_retrieveMessages(RetroCursor* c, std::vector<RsNxsMsg*>& msgs, int metaOffset);
|
||||
|
||||
/*!
|
||||
* Retrieves all the grp results from a cursor
|
||||
* @param c cursor to result set
|
||||
* @param grps groups retrieved from cursor are stored here
|
||||
* @param withMeta this initialise the metaData member of the nxsgroups retrieved
|
||||
*/
|
||||
void locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps);
|
||||
void locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset);
|
||||
|
||||
/*!
|
||||
* Retrieves all the msg meta results from a cursor
|
||||
@ -201,13 +202,13 @@ private:
|
||||
* extracts a msg meta item from a cursor at its
|
||||
* current position
|
||||
*/
|
||||
RsGxsMsgMetaData* locked_getMsgMeta(RetroCursor& c);
|
||||
RsGxsMsgMetaData* locked_getMsgMeta(RetroCursor& c, int colOffset);
|
||||
|
||||
/*!
|
||||
* extracts a grp meta item from a cursor at its
|
||||
* current position
|
||||
*/
|
||||
RsGxsGrpMetaData* locked_getGrpMeta(RetroCursor& c);
|
||||
RsGxsGrpMetaData* locked_getGrpMeta(RetroCursor& c, int colOffset);
|
||||
|
||||
/*!
|
||||
* extracts a msg item from a cursor at its
|
||||
@ -257,10 +258,12 @@ private:
|
||||
|
||||
std::list<std::string> mMsgColumns;
|
||||
std::list<std::string> mMsgMetaColumns;
|
||||
std::list<std::string> mMsgColumnsWithMeta;
|
||||
std::list<std::string> mMsgIdColumn;
|
||||
|
||||
std::list<std::string> mGrpColumns;
|
||||
std::list<std::string> mGrpMetaColumns;
|
||||
std::list<std::string> mGrpColumnsWithMeta;
|
||||
std::list<std::string> mGrpIdColumn;
|
||||
|
||||
// Message meta column
|
||||
@ -287,6 +290,9 @@ private:
|
||||
int mColMsg_MetaData;
|
||||
int mColMsg_MsgId;
|
||||
|
||||
// Message columns with meta
|
||||
int mColMsg_WithMetaOffset;
|
||||
|
||||
// Group meta columns
|
||||
int mColGrpMeta_GrpId;
|
||||
int mColGrpMeta_TimeStamp;
|
||||
@ -319,6 +325,9 @@ private:
|
||||
int mColGrp_NxsData;
|
||||
int mColGrp_MetaData;
|
||||
|
||||
// Group columns with meta
|
||||
int mColGrp_WithMetaOffset;
|
||||
|
||||
// Group id columns
|
||||
int mColGrpId_GrpId;
|
||||
|
||||
|
@ -1135,7 +1135,6 @@ bool RsGenExchange::getGroupMeta(const uint32_t &token, std::list<RsGroupMetaDat
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool RsGenExchange::getMsgMeta(const uint32_t &token,
|
||||
GxsMsgMetaMap &msgInfo)
|
||||
{
|
||||
@ -1152,7 +1151,6 @@ bool RsGenExchange::getMsgMeta(const uint32_t &token,
|
||||
{
|
||||
std::vector<RsGxsMsgMetaData*>& metaV = mit->second;
|
||||
|
||||
msgInfo[mit->first] = std::vector<RsMsgMetaData>();
|
||||
std::vector<RsMsgMetaData>& msgInfoV = msgInfo[mit->first];
|
||||
|
||||
std::vector<RsGxsMsgMetaData*>::iterator vit = metaV.begin();
|
||||
@ -1181,7 +1179,6 @@ bool RsGenExchange::getMsgRelatedMeta(const uint32_t &token, GxsMsgRelatedMetaMa
|
||||
{
|
||||
std::vector<RsGxsMsgMetaData*>& metaV = mit->second;
|
||||
|
||||
msgMeta[mit->first] = std::vector<RsMsgMetaData>();
|
||||
std::vector<RsMsgMetaData>& msgInfoV = msgMeta[mit->first];
|
||||
|
||||
std::vector<RsGxsMsgMetaData*>::iterator vit = metaV.begin();
|
||||
@ -1265,14 +1262,14 @@ bool RsGenExchange::getMsgData(const uint32_t &token, GxsMsgDataMap &msgItems)
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
NxsMsgDataResult msgResult;
|
||||
bool ok = mDataAccess->getMsgData(token, msgResult);
|
||||
NxsMsgDataResult::iterator mit = msgResult.begin();
|
||||
|
||||
if(ok)
|
||||
{
|
||||
NxsMsgDataResult::iterator mit = msgResult.begin();
|
||||
for(; mit != msgResult.end(); ++mit)
|
||||
{
|
||||
std::vector<RsGxsMsgItem*> gxsMsgItems;
|
||||
const RsGxsGroupId& grpId = mit->first;
|
||||
std::vector<RsGxsMsgItem*>& gxsMsgItems = msgItems[grpId];
|
||||
std::vector<RsNxsMsg*>& nxsMsgsV = mit->second;
|
||||
std::vector<RsNxsMsg*>::iterator vit = nxsMsgsV.begin();
|
||||
for(; vit != nxsMsgsV.end(); ++vit)
|
||||
@ -1305,7 +1302,6 @@ bool RsGenExchange::getMsgData(const uint32_t &token, GxsMsgDataMap &msgItems)
|
||||
}
|
||||
delete msg;
|
||||
}
|
||||
msgItems[grpId] = gxsMsgItems;
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
@ -1317,17 +1313,15 @@ bool RsGenExchange::getMsgRelatedData(const uint32_t &token, GxsMsgRelatedDataMa
|
||||
NxsMsgRelatedDataResult msgResult;
|
||||
bool ok = mDataAccess->getMsgRelatedData(token, msgResult);
|
||||
|
||||
|
||||
if(ok)
|
||||
{
|
||||
NxsMsgRelatedDataResult::iterator mit = msgResult.begin();
|
||||
for(; mit != msgResult.end(); ++mit)
|
||||
{
|
||||
std::vector<RsGxsMsgItem*> gxsMsgItems;
|
||||
const RsGxsGrpMsgIdPair& msgId = mit->first;
|
||||
std::vector<RsGxsMsgItem*> &gxsMsgItems = msgItems[msgId];
|
||||
std::vector<RsNxsMsg*>& nxsMsgsV = mit->second;
|
||||
std::vector<RsNxsMsg*>::iterator vit
|
||||
= nxsMsgsV.begin();
|
||||
std::vector<RsNxsMsg*>::iterator vit = nxsMsgsV.begin();
|
||||
for(; vit != nxsMsgsV.end(); ++vit)
|
||||
{
|
||||
RsNxsMsg*& msg = *vit;
|
||||
@ -1360,15 +1354,11 @@ bool RsGenExchange::getMsgRelatedData(const uint32_t &token, GxsMsgRelatedDataMa
|
||||
|
||||
delete msg;
|
||||
}
|
||||
msgItems[msgId] = gxsMsgItems;
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
RsTokenService* RsGenExchange::getTokenService()
|
||||
{
|
||||
return mDataAccess;
|
||||
|
@ -448,7 +448,7 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list<RsNxsGrp*>&
|
||||
|
||||
if(gmreq)
|
||||
{
|
||||
grpData = gmreq->mGroupData;
|
||||
grpData.swap(gmreq->mGroupData);
|
||||
gmreq->mGroupData.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}else{
|
||||
@ -480,7 +480,7 @@ bool RsGxsDataAccess::getMsgData(const uint32_t& token, NxsMsgDataResult& msgDat
|
||||
|
||||
if(mdreq)
|
||||
{
|
||||
msgData = mdreq->mMsgData;
|
||||
msgData.swap(mdreq->mMsgData);
|
||||
mdreq->mMsgData.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
@ -517,7 +517,7 @@ bool RsGxsDataAccess::getMsgRelatedData(const uint32_t &token, NxsMsgRelatedData
|
||||
|
||||
if(mrireq)
|
||||
{
|
||||
msgData = mrireq->mMsgDataResult;
|
||||
msgData.swap(mrireq->mMsgDataResult);
|
||||
mrireq->mMsgDataResult.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
@ -551,7 +551,7 @@ bool RsGxsDataAccess::getMsgSummary(const uint32_t& token, GxsMsgMetaResult& msg
|
||||
|
||||
if(mmreq)
|
||||
{
|
||||
msgInfo = mmreq->mMsgMetaData;
|
||||
msgInfo.swap(mmreq->mMsgMetaData);
|
||||
mmreq->mMsgMetaData.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
|
||||
@ -591,7 +591,7 @@ bool RsGxsDataAccess::getMsgRelatedSummary(const uint32_t &token, MsgRelatedMeta
|
||||
|
||||
if(mrireq)
|
||||
{
|
||||
msgMeta = mrireq->mMsgMetaResult;
|
||||
msgMeta.swap(mrireq->mMsgMetaResult);
|
||||
mrireq->mMsgMetaResult.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
@ -630,7 +630,7 @@ bool RsGxsDataAccess::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResul
|
||||
|
||||
if(mrireq)
|
||||
{
|
||||
msgIds = mrireq->mMsgIdResult;
|
||||
msgIds.swap(mrireq->mMsgIdResult);
|
||||
mrireq->mMsgIdResult.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
@ -664,7 +664,7 @@ bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds)
|
||||
|
||||
if(mireq)
|
||||
{
|
||||
msgIds = mireq->mMsgIdResult;
|
||||
msgIds.swap(mireq->mMsgIdResult);
|
||||
mireq->mMsgIdResult.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
@ -697,7 +697,7 @@ bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::list<RsGxsGroupId
|
||||
|
||||
if(gireq)
|
||||
{
|
||||
groupIds = gireq->mGroupIdResult;
|
||||
groupIds.swap(gireq->mGroupIdResult);
|
||||
gireq->mGroupIdResult.clear();
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
|
||||
@ -1032,31 +1032,25 @@ bool RsGxsDataAccess::getGroupList(const std::list<RsGxsGroupId>& grpIdsIn, cons
|
||||
|
||||
bool RsGxsDataAccess::getMsgData(MsgDataReq* req)
|
||||
{
|
||||
GxsMsgResult result;
|
||||
|
||||
GxsMsgReq msgIdOut;
|
||||
|
||||
// filter based on options
|
||||
getMsgList(req->mMsgIds, req->Options, msgIdOut);
|
||||
|
||||
mDataStore->retrieveNxsMsgs(msgIdOut, result, true, true);
|
||||
mDataStore->retrieveNxsMsgs(msgIdOut, req->mMsgData, true, true);
|
||||
|
||||
req->mMsgData = result;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool RsGxsDataAccess::getMsgSummary(MsgMetaReq* req)
|
||||
{
|
||||
GxsMsgMetaResult result;
|
||||
|
||||
GxsMsgReq msgIdOut;
|
||||
|
||||
// filter based on options
|
||||
getMsgList(req->mMsgIds, req->Options, msgIdOut);
|
||||
|
||||
mDataStore->retrieveGxsMsgMetaData(msgIdOut, result);
|
||||
req->mMsgMetaData = result;
|
||||
mDataStore->retrieveGxsMsgMetaData(msgIdOut, req->mMsgMetaData);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -6,11 +6,7 @@ CONFIG += create_prl
|
||||
CONFIG -= qt
|
||||
TARGET = retroshare
|
||||
TARGET_PRL = libretroshare
|
||||
|
||||
|
||||
#GXS Stuff.
|
||||
# This should be disabled for releases until further notice.
|
||||
CONFIG += gxs
|
||||
DESTDIR = lib
|
||||
|
||||
#CONFIG += dsdv
|
||||
|
||||
@ -77,15 +73,13 @@ SOURCES += tcponudp/udppeer.cc \
|
||||
tcponudp/udpstunner.cc \
|
||||
tcponudp/udprelay.cc \
|
||||
|
||||
DEFINES *= RS_USE_BITDHT
|
||||
|
||||
BITDHT_DIR = ../../libbitdht/src
|
||||
BITDHT_DIR = ../../libbitdht/src
|
||||
DEPENDPATH += . $${BITDHT_DIR}
|
||||
INCLUDEPATH += . $${BITDHT_DIR}
|
||||
# The next line is for compliance with debian packages. Keep it!
|
||||
INCLUDEPATH += ../libbitdht
|
||||
DEFINES *= RS_USE_BITDHT
|
||||
PRE_TARGETDEPS *= ../../libbitdht/src/lib/libbitdht.a
|
||||
LIBS += ../../libbitdht/src/lib/libbitdht.a
|
||||
PRE_TARGETDEPS *= $${BITDHT_DIR}/lib/libbitdht.a
|
||||
LIBS *= $${BITDHT_DIR}/lib/libbitdht.a
|
||||
}
|
||||
|
||||
|
||||
@ -125,28 +119,17 @@ HEADERS += $$PUBLIC_HEADERS
|
||||
|
||||
################################# Linux ##########################################
|
||||
linux-* {
|
||||
# These two lines fixe compilation on ubuntu natty. Probably a ubuntu packaging error.
|
||||
INCLUDEPATH += $$system(pkg-config --cflags glib-2.0 | sed -e "s/-I//g")
|
||||
CONFIG += link_pkgconfig
|
||||
|
||||
OPENPGPSDK_DIR = ../../openpgpsdk/src
|
||||
DEPENDPATH *= $${OPENPGPSDK_DIR} ../openpgpsdk
|
||||
INCLUDEPATH *= $${OPENPGPSDK_DIR} ../openpgpsdk
|
||||
|
||||
DESTDIR = lib
|
||||
QMAKE_CXXFLAGS *= -Wall -D_FILE_OFFSET_BITS=64
|
||||
QMAKE_CC = g++
|
||||
|
||||
SSL_DIR = /usr/include/openssl
|
||||
UPNP_DIR = /usr/include/upnp
|
||||
DEPENDPATH += . $${SSL_DIR} $${UPNP_DIR}
|
||||
INCLUDEPATH += . $${SSL_DIR} $${UPNP_DIR}
|
||||
|
||||
contains(CONFIG, NO_SQLCIPHER) {
|
||||
DEFINES *= NO_SQLCIPHER
|
||||
LIBS *= -lsqlite3
|
||||
PKGCONFIG *= sqlite3
|
||||
} else {
|
||||
SQLCIPHER_OK = $$system(pkg-config --exists sqlcipher && echo yes)
|
||||
isEmpty(SQLCIPHER_OK) {
|
||||
SQLCIPHER_OK = $$system(pkg-config --exists sqlcipher && echo yes)
|
||||
isEmpty(SQLCIPHER_OK) {
|
||||
# We need a explicit path here, to force using the home version of sqlite3 that really encrypts the database.
|
||||
exists(../../../lib/sqlcipher/.libs/libsqlcipher.a) {
|
||||
LIBS += ../../../lib/sqlcipher/.libs/libsqlcipher.a
|
||||
@ -156,19 +139,21 @@ linux-* {
|
||||
error("libsqlcipher is not installed and libsqlcipher.a not found. SQLCIPHER is necessary for encrypted database, to build with unencrypted database, run: qmake CONFIG+=NO_SQLCIPHER")
|
||||
}
|
||||
} else {
|
||||
# Workaround for broken sqlcipher packages, e.g. Ubuntu 14.04
|
||||
# https://bugs.launchpad.net/ubuntu/+source/sqlcipher/+bug/1493928
|
||||
# PKGCONFIG *= sqlcipher
|
||||
LIBS *= -lsqlcipher
|
||||
}
|
||||
}
|
||||
|
||||
#CONFIG += version_detail_bash_script
|
||||
|
||||
|
||||
# linux/bsd can use either - libupnp is more complete and packaged.
|
||||
#CONFIG += upnp_miniupnpc
|
||||
CONFIG += upnp_libupnp
|
||||
|
||||
# Check if the systems libupnp has been Debian-patched
|
||||
system(grep -E 'char[[:space:]]+PublisherUrl' $${UPNP_DIR}/upnp.h >/dev/null 2>&1) {
|
||||
system(grep -E 'char[[:space:]]+PublisherUrl' /usr/include/upnp/upnp.h >/dev/null 2>&1) {
|
||||
# Normal libupnp
|
||||
} else {
|
||||
# Patched libupnp or new unreleased version
|
||||
@ -176,14 +161,14 @@ linux-* {
|
||||
}
|
||||
|
||||
DEFINES *= UBUNTU
|
||||
INCLUDEPATH += /usr/include/glib-2.0/ /usr/lib/glib-2.0/include
|
||||
LIBS *= -lgnome-keyring
|
||||
LIBS *= -lssl -lupnp -lixml
|
||||
LIBS *= -lcrypto -lz -lpthread
|
||||
PKGCONFIG *= gnome-keyring-1
|
||||
PKGCONFIG *= libssl libupnp
|
||||
PKGCONFIG *= libcrypto zlib
|
||||
LIBS *= -lpthread -ldl
|
||||
}
|
||||
|
||||
unix {
|
||||
DEFINES *= LIB_DIR=\"\\\"$${LIB_DIR}\\\"\"
|
||||
DEFINES *= PLUGIN_DIR=\"\\\"$${PLUGIN_DIR}\\\"\"
|
||||
DEFINES *= DATA_DIR=\"\\\"$${DATA_DIR}\\\"\"
|
||||
|
||||
## where to put the librarys interface
|
||||
@ -221,7 +206,6 @@ version_detail_bash_script {
|
||||
|
||||
win32-x-g++ {
|
||||
OBJECTS_DIR = temp/win32xgcc/obj
|
||||
DESTDIR = lib.win32xgcc
|
||||
DEFINES *= WINDOWS_SYS WIN32 WIN_CROSS_UBUNTU
|
||||
QMAKE_CXXFLAGS *= -Wmissing-include-dirs
|
||||
QMAKE_CC = i586-mingw32msvc-g++
|
||||
@ -248,7 +232,6 @@ win32 {
|
||||
DEFINES *= MINIUPNPC_VERSION=13
|
||||
# This defines the platform to be WinXP or later and is needed for getaddrinfo (_WIN32_WINNT_WINXP)
|
||||
DEFINES *= WINVER=0x0501
|
||||
DESTDIR = lib
|
||||
|
||||
# Switch on extra warnings
|
||||
QMAKE_CFLAGS += -Wextra
|
||||
@ -268,11 +251,12 @@ win32 {
|
||||
|
||||
CONFIG += upnp_miniupnpc
|
||||
|
||||
LIBS_DIR = $$PWD/../../../libs
|
||||
OPENPGPSDK_DIR = $$PWD/../../openpgpsdk/src
|
||||
LIBS += -lsqlcipher
|
||||
|
||||
DEPENDPATH += . $$LIBS_DIR/include $$LIBS_DIR/include/miniupnpc $$OPENPGPSDK_DIR
|
||||
INCLUDEPATH += . $$LIBS_DIR/include $$LIBS_DIR/include/miniupnpc $$OPENPGPSDK_DIR
|
||||
LIBS_DIR = $$PWD/../../../libs
|
||||
|
||||
DEPENDPATH += . $$LIBS_DIR/include $$LIBS_DIR/include/miniupnpc
|
||||
INCLUDEPATH += . $$LIBS_DIR/include $$LIBS_DIR/include/miniupnpc
|
||||
}
|
||||
|
||||
################################# MacOSX ##########################################
|
||||
@ -282,29 +266,28 @@ mac {
|
||||
OBJECTS_DIR = temp/obj
|
||||
MOC_DIR = temp/moc
|
||||
#DEFINES = WINDOWS_SYS WIN32 STATICLIB MINGW
|
||||
#DEFINES *= MINIUPNPC_VERSION=13
|
||||
DESTDIR = lib
|
||||
DEFINES *= MINIUPNPC_VERSION=13
|
||||
|
||||
CONFIG += upnp_miniupnpc
|
||||
|
||||
# zeroconf disabled at the end of libretroshare.pro (but need the code)
|
||||
CONFIG += zeroconf
|
||||
CONFIG += zcnatassist
|
||||
#CONFIG += zeroconf
|
||||
#CONFIG += zcnatassist
|
||||
|
||||
# Beautiful Hack to fix 64bit file access.
|
||||
QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dfopen64=fopen -Dvstatfs64=vstatfs
|
||||
|
||||
UPNPC_DIR = ../../../miniupnpc-1.0
|
||||
UPNPC_DIR = ../../../miniupnpc-1.3
|
||||
#GPG_ERROR_DIR = ../../../../libgpg-error-1.7
|
||||
#GPGME_DIR = ../../../../gpgme-1.1.8
|
||||
|
||||
OPENPGPSDK_DIR = ../../openpgpsdk/src
|
||||
|
||||
INCLUDEPATH += . $${UPNPC_DIR}
|
||||
INCLUDEPATH += $${OPENPGPSDK_DIR}
|
||||
|
||||
#../openpgpsdk
|
||||
#INCLUDEPATH += . $${UPNPC_DIR} $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src
|
||||
|
||||
# We need a explicit path here, to force using the home version of sqlite3 that really encrypts the database.
|
||||
LIBS += ../../../lib/libsqlcipher.a
|
||||
#LIBS += -lsqlite3
|
||||
}
|
||||
|
||||
################################# FreeBSD ##########################################
|
||||
@ -318,8 +301,6 @@ freebsd-* {
|
||||
# linux/bsd can use either - libupnp is more complete and packaged.
|
||||
#CONFIG += upnp_miniupnpc
|
||||
CONFIG += upnp_libupnp
|
||||
|
||||
DESTDIR = lib
|
||||
}
|
||||
|
||||
################################# OpenBSD ##########################################
|
||||
@ -328,21 +309,19 @@ openbsd-* {
|
||||
INCLUDEPATH *= /usr/local/include
|
||||
INCLUDEPATH += $$system(pkg-config --cflags glib-2.0 | sed -e "s/-I//g")
|
||||
|
||||
OPENPGPSDK_DIR = ../../openpgpsdk/src
|
||||
INCLUDEPATH *= $${OPENPGPSDK_DIR} ../openpgpsdk
|
||||
|
||||
QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dstat64=stat -Dstatvfs64=statvfs -Dfopen64=fopen
|
||||
|
||||
CONFIG += upnp_libupnp
|
||||
|
||||
DESTDIR = lib
|
||||
}
|
||||
|
||||
################################### COMMON stuff ##################################
|
||||
|
||||
# openpgpsdk
|
||||
PRE_TARGETDEPS *= ../../openpgpsdk/src/lib/libops.a
|
||||
LIBS *= ../../openpgpsdk/src/lib/libops.a -lbz2
|
||||
OPENPGPSDK_DIR = ../../openpgpsdk/src
|
||||
DEPENDPATH *= $${OPENPGPSDK_DIR}
|
||||
INCLUDEPATH *= $${OPENPGPSDK_DIR}
|
||||
PRE_TARGETDEPS *= $${OPENPGPSDK_DIR}/lib/libops.a
|
||||
LIBS *= $${OPENPGPSDK_DIR}/lib/libops.a -lbz2
|
||||
|
||||
HEADERS += dbase/cachestrapper.h \
|
||||
dbase/fimonitor.h \
|
||||
@ -464,8 +443,8 @@ HEADERS += serialiser/itempriorities.h \
|
||||
serialiser/rsheartbeatitems.h \
|
||||
serialiser/rsrttitems.h \
|
||||
serialiser/rsgxsrecognitems.h \
|
||||
serialiser/rsgxsupdateitems.h \
|
||||
serialiser/rsserviceinfoitems.h \
|
||||
serialiser/rsgxsupdateitems.h \
|
||||
serialiser/rsserviceinfoitems.h \
|
||||
|
||||
HEADERS += services/p3msgservice.h \
|
||||
services/p3service.h \
|
||||
@ -614,8 +593,8 @@ SOURCES += serialiser/rsbaseserial.cc \
|
||||
serialiser/rsheartbeatitems.cc \
|
||||
serialiser/rsrttitems.cc \
|
||||
serialiser/rsgxsrecognitems.cc \
|
||||
serialiser/rsgxsupdateitems.cc \
|
||||
serialiser/rsserviceinfoitems.cc \
|
||||
serialiser/rsgxsupdateitems.cc \
|
||||
serialiser/rsserviceinfoitems.cc \
|
||||
|
||||
SOURCES += services/p3msgservice.cc \
|
||||
services/p3service.cc \
|
||||
@ -696,96 +675,95 @@ SOURCES += zeroconf/p3zcnatassist.cc \
|
||||
|
||||
# new gxs cache system
|
||||
# this should be disabled for releases until further notice.
|
||||
gxs {
|
||||
DEFINES *= RS_ENABLE_GXS
|
||||
DEFINES *= SQLITE_HAS_CODEC
|
||||
DEFINES *= GXS_ENABLE_SYNC_MSGS
|
||||
|
||||
HEADERS += serialiser/rsnxsitems.h \
|
||||
gxs/rsgds.h \
|
||||
gxs/rsgxs.h \
|
||||
gxs/rsdataservice.h \
|
||||
gxs/rsgxsnetservice.h \
|
||||
retroshare/rsgxsflags.h \
|
||||
retroshare/rsgxsifacetypes.h \
|
||||
retroshare/rsreputations.h \
|
||||
gxs/rsgenexchange.h \
|
||||
gxs/rsnxsobserver.h \
|
||||
gxs/rsgxsdata.h \
|
||||
retroshare/rstokenservice.h \
|
||||
gxs/rsgxsdataaccess.h \
|
||||
retroshare/rsgxsservice.h \
|
||||
serialiser/rsgxsitems.h \
|
||||
util/retrodb.h \
|
||||
util/rsdbbind.h \
|
||||
gxs/rsgxsutil.h \
|
||||
util/contentvalue.h \
|
||||
gxs/gxssecurity.h \
|
||||
gxs/rsgxsifacehelper.h \
|
||||
gxs/gxstokenqueue.h \
|
||||
gxs/rsgxsnetutils.h \
|
||||
gxs/rsgxsiface.h \
|
||||
gxs/rsgxsrequesttypes.h
|
||||
DEFINES *= SQLITE_HAS_CODEC
|
||||
DEFINES *= GXS_ENABLE_SYNC_MSGS
|
||||
|
||||
HEADERS += serialiser/rsnxsitems.h \
|
||||
gxs/rsgds.h \
|
||||
gxs/rsgxs.h \
|
||||
gxs/rsdataservice.h \
|
||||
gxs/rsgxsnetservice.h \
|
||||
retroshare/rsgxsflags.h \
|
||||
retroshare/rsgxsifacetypes.h \
|
||||
gxs/rsgenexchange.h \
|
||||
gxs/rsnxsobserver.h \
|
||||
gxs/rsgxsdata.h \
|
||||
retroshare/rstokenservice.h \
|
||||
gxs/rsgxsdataaccess.h \
|
||||
retroshare/rsgxsservice.h \
|
||||
serialiser/rsgxsitems.h \
|
||||
util/retrodb.h \
|
||||
util/rsdbbind.h \
|
||||
gxs/rsgxsutil.h \
|
||||
util/contentvalue.h \
|
||||
gxs/gxssecurity.h \
|
||||
gxs/rsgxsifacehelper.h \
|
||||
gxs/gxstokenqueue.h \
|
||||
gxs/rsgxsnetutils.h \
|
||||
gxs/rsgxsiface.h \
|
||||
gxs/rsgxsrequesttypes.h
|
||||
|
||||
|
||||
SOURCES += serialiser/rsnxsitems.cc \
|
||||
gxs/rsdataservice.cc \
|
||||
gxs/rsgenexchange.cc \
|
||||
gxs/rsgxsnetservice.cc \
|
||||
gxs/rsgxsdata.cc \
|
||||
serialiser/rsgxsitems.cc \
|
||||
gxs/rsgxsdataaccess.cc \
|
||||
util/retrodb.cc \
|
||||
util/contentvalue.cc \
|
||||
util/rsdbbind.cc \
|
||||
gxs/gxssecurity.cc \
|
||||
gxs/gxstokenqueue.cc \
|
||||
gxs/rsgxsnetutils.cc \
|
||||
gxs/rsgxsutil.cc \
|
||||
gxs/rsgxsrequesttypes.cc
|
||||
SOURCES += serialiser/rsnxsitems.cc \
|
||||
gxs/rsdataservice.cc \
|
||||
gxs/rsgenexchange.cc \
|
||||
gxs/rsgxsnetservice.cc \
|
||||
gxs/rsgxsdata.cc \
|
||||
serialiser/rsgxsitems.cc \
|
||||
gxs/rsgxsdataaccess.cc \
|
||||
util/retrodb.cc \
|
||||
util/contentvalue.cc \
|
||||
util/rsdbbind.cc \
|
||||
gxs/gxssecurity.cc \
|
||||
gxs/gxstokenqueue.cc \
|
||||
gxs/rsgxsnetutils.cc \
|
||||
gxs/rsgxsutil.cc \
|
||||
gxs/rsgxsrequesttypes.cc
|
||||
|
||||
|
||||
# Identity Service
|
||||
HEADERS += retroshare/rsidentity.h \
|
||||
gxs/rsgixs.h \
|
||||
services/p3idservice.h \
|
||||
serialiser/rsgxsiditems.h \
|
||||
services/p3gxsreputation.h \
|
||||
serialiser/rsgxsreputationitems.h \
|
||||
# Identity Service
|
||||
HEADERS += retroshare/rsidentity.h \
|
||||
gxs/rsgixs.h \
|
||||
services/p3idservice.h \
|
||||
serialiser/rsgxsiditems.h \
|
||||
services/p3gxsreputation.h \
|
||||
serialiser/rsgxsreputationitems.h \
|
||||
|
||||
SOURCES += services/p3idservice.cc \
|
||||
serialiser/rsgxsiditems.cc \
|
||||
services/p3gxsreputation.cc \
|
||||
serialiser/rsgxsreputationitems.cc \
|
||||
SOURCES += services/p3idservice.cc \
|
||||
serialiser/rsgxsiditems.cc \
|
||||
services/p3gxsreputation.cc \
|
||||
serialiser/rsgxsreputationitems.cc \
|
||||
|
||||
# GxsCircles Service
|
||||
HEADERS += services/p3gxscircles.h \
|
||||
serialiser/rsgxscircleitems.h \
|
||||
retroshare/rsgxscircles.h \
|
||||
# GxsCircles Service
|
||||
HEADERS += services/p3gxscircles.h \
|
||||
serialiser/rsgxscircleitems.h \
|
||||
retroshare/rsgxscircles.h \
|
||||
|
||||
SOURCES += services/p3gxscircles.cc \
|
||||
serialiser/rsgxscircleitems.cc \
|
||||
SOURCES += services/p3gxscircles.cc \
|
||||
serialiser/rsgxscircleitems.cc \
|
||||
|
||||
# GxsForums Service
|
||||
HEADERS += retroshare/rsgxsforums.h \
|
||||
services/p3gxsforums.h \
|
||||
serialiser/rsgxsforumitems.h
|
||||
# GxsForums Service
|
||||
HEADERS += retroshare/rsgxsforums.h \
|
||||
services/p3gxsforums.h \
|
||||
serialiser/rsgxsforumitems.h
|
||||
|
||||
SOURCES += services/p3gxsforums.cc \
|
||||
serialiser/rsgxsforumitems.cc \
|
||||
SOURCES += services/p3gxsforums.cc \
|
||||
serialiser/rsgxsforumitems.cc \
|
||||
|
||||
# GxsChannels Service
|
||||
HEADERS += retroshare/rsgxschannels.h \
|
||||
services/p3gxschannels.h \
|
||||
services/p3gxscommon.h \
|
||||
serialiser/rsgxscommentitems.h \
|
||||
serialiser/rsgxschannelitems.h \
|
||||
# GxsChannels Service
|
||||
HEADERS += retroshare/rsgxschannels.h \
|
||||
services/p3gxschannels.h \
|
||||
services/p3gxscommon.h \
|
||||
serialiser/rsgxscommentitems.h \
|
||||
serialiser/rsgxschannelitems.h \
|
||||
|
||||
SOURCES += services/p3gxschannels.cc \
|
||||
services/p3gxscommon.cc \
|
||||
serialiser/rsgxscommentitems.cc \
|
||||
serialiser/rsgxschannelitems.cc \
|
||||
SOURCES += services/p3gxschannels.cc \
|
||||
services/p3gxscommon.cc \
|
||||
serialiser/rsgxscommentitems.cc \
|
||||
serialiser/rsgxschannelitems.cc \
|
||||
|
||||
wikipoos {
|
||||
# Wiki Service
|
||||
HEADERS += retroshare/rswiki.h \
|
||||
services/p3wiki.h \
|
||||
@ -793,7 +771,9 @@ gxs {
|
||||
|
||||
SOURCES += services/p3wiki.cc \
|
||||
serialiser/rswikiitems.cc \
|
||||
}
|
||||
|
||||
gxsthewire {
|
||||
# Wire Service
|
||||
HEADERS += retroshare/rswire.h \
|
||||
services/p3wire.h \
|
||||
@ -801,17 +781,19 @@ gxs {
|
||||
|
||||
SOURCES += services/p3wire.cc \
|
||||
serialiser/rswireitems.cc \
|
||||
}
|
||||
|
||||
# Posted Service
|
||||
HEADERS += services/p3postbase.h \
|
||||
services/p3posted.h \
|
||||
retroshare/rsposted.h \
|
||||
serialiser/rsposteditems.h
|
||||
# Posted Service
|
||||
HEADERS += services/p3postbase.h \
|
||||
services/p3posted.h \
|
||||
retroshare/rsposted.h \
|
||||
serialiser/rsposteditems.h
|
||||
|
||||
SOURCES += services/p3postbase.cc \
|
||||
services/p3posted.cc \
|
||||
serialiser/rsposteditems.cc
|
||||
SOURCES += services/p3postbase.cc \
|
||||
services/p3posted.cc \
|
||||
serialiser/rsposteditems.cc
|
||||
|
||||
gxsphotoshare {
|
||||
#Photo Service
|
||||
HEADERS += services/p3photoservice.h \
|
||||
retroshare/rsphoto.h \
|
||||
@ -859,6 +841,3 @@ test_bitdht {
|
||||
|
||||
# ENABLED UDP NOW.
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -125,7 +125,7 @@ std::string PGPKeyManagement::makeArmouredKey(const unsigned char *keydata,size_
|
||||
|
||||
uint32_t crc = compute24bitsCRC((unsigned char *)keydata,key_size) ;
|
||||
|
||||
unsigned char tmp[3] = { (crc >> 16) & 0xff, (crc >> 8) & 0xff, crc & 0xff } ;
|
||||
unsigned char tmp[3] = { uint8_t((crc >> 16) & 0xff), uint8_t((crc >> 8) & 0xff), uint8_t(crc & 0xff) } ;
|
||||
std::string crc_string ;
|
||||
Radix64::encode((const char *)tmp,3,crc_string) ;
|
||||
|
||||
|
@ -1,77 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ..
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
BASE_OBJ = pqisecurity.o pqinetwork.o
|
||||
#pqi_base.o
|
||||
|
||||
LOOP_OBJ = pqiloopback.o
|
||||
STREAM_OBJ = pqistreamer.o pqiarchive.o pqistore.o pqibin.o
|
||||
MGR_OBJ = pqimonitor.o p3dhtmgr.o p3connmgr.o p3cfgmgr.o p3authmgr.o
|
||||
GRP_OBJ = pqiperson.o pqihandler.o pqiservice.o pqipersongrp.o
|
||||
SSL_OBJ = pqissl.o pqissllistener.o pqisslpersongrp.o cleanupxpgp.o
|
||||
UDP_OBJ = pqissludp.o
|
||||
|
||||
OTHER_OBJ = p3notify.o
|
||||
|
||||
|
||||
TESTOBJ = net_test.o dht_test.o net_test1.o netiface_test.o
|
||||
#conn_test.o
|
||||
|
||||
TESTS = net_test dht_test net_test1 netiface_test
|
||||
#conn_test
|
||||
|
||||
ifdef PQI_USE_XPGP
|
||||
SSL_OBJ += authxpgp.o
|
||||
TESTOBJ += xpgp_id.o
|
||||
TESTS += xpgp_id
|
||||
else
|
||||
ifdef PQI_USE_SSLONLY
|
||||
SSL_OBJ += authssl.o
|
||||
else
|
||||
SSL_OBJ += authssl.o authgpg.o
|
||||
TESTOBJ += gpgme_tst.o
|
||||
TESTS += gpgme_tst
|
||||
endif
|
||||
endif
|
||||
|
||||
RSOBJ = $(BASE_OBJ) $(LOOP_OBJ) \
|
||||
$(STREAM_OBJ) \
|
||||
$(MGR_OBJ) \
|
||||
$(SSL_OBJ) \
|
||||
$(UDP_OBJ) \
|
||||
$(GRP_OBJ) \
|
||||
$(OTHER_OBJ)
|
||||
|
||||
all: librs tests
|
||||
|
||||
gpgme_tst: gpgme_tst.o
|
||||
$(CC) $(CFLAGS) -o gpgme_tst gpgme_tst.o $(LIBS)
|
||||
|
||||
xpgp_id: xpgp_id.o
|
||||
$(CC) $(CFLAGS) -o xpgp_id xpgp_id.o $(LIBS)
|
||||
|
||||
dht_test: dht_test.o
|
||||
$(CC) $(CFLAGS) -o dht_test dht_test.o $(LIBS)
|
||||
|
||||
conn_test: conn_test.o
|
||||
$(CC) $(CFLAGS) -o conn_test conn_test.o $(LIBS)
|
||||
|
||||
net_test: net_test.o
|
||||
$(CC) $(CFLAGS) -o net_test net_test.o $(LIBS)
|
||||
|
||||
net_test1: net_test1.o
|
||||
$(CC) $(CFLAGS) -o net_test1 net_test1.o $(LIBS)
|
||||
|
||||
netiface_test: netiface_test.o
|
||||
$(CC) $(CFLAGS) -o netiface_test netiface_test.o $(LIBS)
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -198,7 +198,7 @@ void tls_cleanup()
|
||||
CRYPTO_set_locking_callback(NULL);
|
||||
CRYPTO_set_id_callback(NULL);
|
||||
|
||||
if (mutex_buf == NULL) {
|
||||
if (mutex_buf != NULL) {
|
||||
for (int i = 0; i < CRYPTO_num_locks(); i++) {
|
||||
pthread_mutex_destroy(&mutex_buf[i]);
|
||||
}
|
||||
|
@ -964,24 +964,25 @@ bool p3LinkMgrIMPL::connectResult(const RsPeerId &id, bool success, bool isIncom
|
||||
if (flags == RS_NET_CONN_UDP_ALL)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
#endif
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() Sending Feedback for UDP connection";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
if (success)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
#endif
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() UDP Update CONNECTED to: " << id;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mNetMgr->netAssistStatusUpdate(id, NETMGR_DHT_FEEDBACK_CONNECTED);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
#endif
|
||||
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() UDP Update FAILED to: " << id;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* have no differentiation between failure and closed? */
|
||||
mNetMgr->netAssistStatusUpdate(id, NETMGR_DHT_FEEDBACK_CONN_FAILED);
|
||||
@ -1624,6 +1625,17 @@ bool p3LinkMgrIMPL::retryConnectTCP(const RsPeerId &id)
|
||||
/* first possibility - is it a hidden peer */
|
||||
if (mPeerMgr->isHiddenPeer(id))
|
||||
{
|
||||
/* check for valid hidden type */
|
||||
uint32_t type = mPeerMgr->getHiddenType(id);
|
||||
if (type & (~RS_HIDDEN_TYPE_MASK))
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectTCP() invalid hidden type (" << type << ") -> return false";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
struct sockaddr_storage proxy_addr;
|
||||
std::string domain_addr;
|
||||
uint16_t domain_port;
|
||||
@ -1636,7 +1648,7 @@ bool p3LinkMgrIMPL::retryConnectTCP(const RsPeerId &id)
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
if (mFriendList.end() != (it = mFriendList.find(id)))
|
||||
{
|
||||
locked_ConnectAttempt_ProxyAddress(&(it->second), proxy_addr, domain_addr, domain_port);
|
||||
locked_ConnectAttempt_ProxyAddress(&(it->second), type, proxy_addr, domain_addr, domain_port);
|
||||
return locked_ConnectAttempt_Complete(&(it->second));
|
||||
}
|
||||
}
|
||||
@ -2018,7 +2030,7 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_AddDynDNS(peerConnectState *peer, std
|
||||
}
|
||||
|
||||
|
||||
void p3LinkMgrIMPL::locked_ConnectAttempt_ProxyAddress(peerConnectState *peer, const struct sockaddr_storage &proxy_addr, const std::string &domain_addr, uint16_t domain_port)
|
||||
void p3LinkMgrIMPL::locked_ConnectAttempt_ProxyAddress(peerConnectState *peer, const uint32_t type, const struct sockaddr_storage &proxy_addr, const std::string &domain_addr, uint16_t domain_port)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_ProxyAddress() trying address: " << domain_addr << ":" << domain_port << std::endl;
|
||||
@ -2026,7 +2038,22 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_ProxyAddress(peerConnectState *peer,
|
||||
peerConnectAddress pca;
|
||||
pca.addr = proxy_addr;
|
||||
|
||||
pca.type = RS_NET_CONN_TCP_HIDDEN;
|
||||
switch (type) {
|
||||
case RS_HIDDEN_TYPE_TOR:
|
||||
pca.type = RS_NET_CONN_TCP_HIDDEN_TOR;
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_I2P:
|
||||
pca.type = RS_NET_CONN_TCP_HIDDEN_I2P;
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_UNKNOWN:
|
||||
default:
|
||||
/**** THIS CASE SHOULD NOT BE TRIGGERED - since this function is called with a valid hidden type only ****/
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_ProxyAddress() hidden type of addr: " << domain_addr << " is unkown -> THIS SHOULD NEVER HAPPEN!" << std::endl;
|
||||
std::cerr << " - peer : " << peer->id << "(" << peer->name << ")" << std::endl;
|
||||
std::cerr << " - proxy: " << sockaddr_storage_tostring(proxy_addr) << std::endl;
|
||||
std::cerr << " - addr : " << domain_addr << ":" << domain_port << std::endl;
|
||||
pca.type = RS_NET_CONN_TCP_UNKNOW_TOPOLOGY;
|
||||
}
|
||||
|
||||
//for the delay, we add a random time and some more time when the friend list is big
|
||||
pca.delay = P3CONNMGR_TCP_DEFAULT_DELAY;
|
||||
|
@ -40,16 +40,17 @@ class DNSResolver ;
|
||||
|
||||
|
||||
/* order of attempts ... */
|
||||
const uint32_t RS_NET_CONN_TCP_ALL = 0x000f;
|
||||
const uint32_t RS_NET_CONN_UDP_ALL = 0x00f0;
|
||||
const uint32_t RS_NET_CONN_TCP_ALL = 0x00ff;
|
||||
const uint32_t RS_NET_CONN_UDP_ALL = 0x0f00;
|
||||
|
||||
const uint32_t RS_NET_CONN_TCP_LOCAL = 0x0001;
|
||||
const uint32_t RS_NET_CONN_TCP_EXTERNAL = 0x0002;
|
||||
const uint32_t RS_NET_CONN_TCP_UNKNOW_TOPOLOGY = 0x0004;
|
||||
const uint32_t RS_NET_CONN_TCP_HIDDEN = 0x0008;
|
||||
const uint32_t RS_NET_CONN_TCP_HIDDEN_TOR = 0x0008;
|
||||
const uint32_t RS_NET_CONN_TCP_HIDDEN_I2P = 0x0010;
|
||||
|
||||
const uint32_t RS_NET_CONN_UDP_DHT_SYNC = 0x0010;
|
||||
const uint32_t RS_NET_CONN_UDP_PEER_SYNC = 0x0020; /* coming soon */
|
||||
const uint32_t RS_NET_CONN_UDP_DHT_SYNC = 0x0100;
|
||||
const uint32_t RS_NET_CONN_UDP_PEER_SYNC = 0x0200; /* coming soon */
|
||||
|
||||
// These are set in pqipersongroup.
|
||||
const uint32_t RS_TCP_STD_TIMEOUT_PERIOD = 5; /* 5 seconds! */
|
||||
@ -302,7 +303,7 @@ void locked_ConnectAttempt_CurrentAddresses(peerConnectState *peer, const struc
|
||||
void locked_ConnectAttempt_HistoricalAddresses(peerConnectState *peer, const pqiIpAddrSet &ipAddrs);
|
||||
void locked_ConnectAttempt_AddDynDNS(peerConnectState *peer, std::string dyndns, uint16_t dynPort);
|
||||
void locked_ConnectAttempt_AddTunnel(peerConnectState *peer);
|
||||
void locked_ConnectAttempt_ProxyAddress(peerConnectState *peer, const struct sockaddr_storage &proxy_addr, const std::string &domain_addr, uint16_t domain_port);
|
||||
void locked_ConnectAttempt_ProxyAddress(peerConnectState *peer, const uint32_t type, const struct sockaddr_storage &proxy_addr, const std::string &domain_addr, uint16_t domain_port);
|
||||
|
||||
bool locked_ConnectAttempt_Complete(peerConnectState *peer);
|
||||
|
||||
|
@ -696,9 +696,9 @@ void p3NetMgrIMPL::netExtCheck()
|
||||
bool isStable = false;
|
||||
struct sockaddr_storage tmpip ;
|
||||
|
||||
std::map<sockaddr_storage,ZeroInt> address_votes ;
|
||||
std::map<sockaddr_storage,ZeroInt> address_votes ;
|
||||
|
||||
/* check for External Address */
|
||||
/* check for External Address */
|
||||
/* in order of importance */
|
||||
/* (1) UPnP -> which handles itself */
|
||||
{
|
||||
@ -708,35 +708,41 @@ void p3NetMgrIMPL::netExtCheck()
|
||||
|
||||
/* net Assist */
|
||||
if (netAssistExtAddress(tmpip))
|
||||
{
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext supplied from netAssistExternalAddress()" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext supplied from netAssistExternalAddress()" << std::endl;
|
||||
#endif
|
||||
if(sockaddr_storage_isValidNet(tmpip))
|
||||
{
|
||||
if(rsBanList->isAddressAccepted(tmpip,RSBANLIST_CHECKING_FLAGS_BLACKLIST))
|
||||
{
|
||||
// must be stable???
|
||||
isStable = true;
|
||||
mNetFlags.mExtAddr = tmpip;
|
||||
mNetFlags.mExtAddrOk = true;
|
||||
mNetFlags.mExtAddrStableOk = isStable;
|
||||
if(sockaddr_storage_isValidNet(tmpip))
|
||||
{
|
||||
if(rsBanList->isAddressAccepted(tmpip,RSBANLIST_CHECKING_FLAGS_BLACKLIST))
|
||||
{
|
||||
// must be stable???
|
||||
isStable = true;
|
||||
//mNetFlags.mExtAddr = tmpip;
|
||||
mNetFlags.mExtAddrOk = true;
|
||||
mNetFlags.mExtAddrStableOk = isStable;
|
||||
|
||||
address_votes[tmpip].n++ ;
|
||||
}
|
||||
else
|
||||
std::cerr << "(SS) netAssisExternalAddress returned wrong own IP " << sockaddr_storage_iptostring(tmpip) << " (banned). Rejecting." << std::endl;
|
||||
}
|
||||
address_votes[tmpip].n++ ;
|
||||
|
||||
std::cerr << "NetAssistAddress reported external address " << sockaddr_storage_iptostring(tmpip) << std::endl;
|
||||
}
|
||||
else
|
||||
std::cerr << "(SS) netAssisExternalAddress returned banned own IP " << sockaddr_storage_iptostring(tmpip) << " (banned). Rejecting." << std::endl;
|
||||
}
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
else
|
||||
{
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Bad Address supplied from netAssistExternalAddress()" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Bad Address supplied from netAssistExternalAddress()" << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef ALLOW_DHT_STUNNER
|
||||
// (cyril) I disabled this because it's pretty dangerous. The DHT can report a wrong address quite easily
|
||||
// if the other DHT peers are not collaborating.
|
||||
|
||||
/* Next ask the DhtStunner */
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
@ -748,30 +754,31 @@ void p3NetMgrIMPL::netExtCheck()
|
||||
|
||||
if (mDhtStunner)
|
||||
{
|
||||
/* input network bits */
|
||||
if (mDhtStunner->getExternalAddr(tmpaddr, isstable))
|
||||
{
|
||||
if(rsBanList->isAddressAccepted(tmpaddr,RSBANLIST_CHECKING_FLAGS_BLACKLIST))
|
||||
{
|
||||
// must be stable???
|
||||
isStable = (isstable == 1);
|
||||
mNetFlags.mExtAddr = tmpaddr;
|
||||
mNetFlags.mExtAddrOk = true;
|
||||
mNetFlags.mExtAddrStableOk = isStable;
|
||||
/* input network bits */
|
||||
if (mDhtStunner->getExternalAddr(tmpaddr, isstable))
|
||||
{
|
||||
if(rsBanList->isAddressAccepted(tmpaddr,RSBANLIST_CHECKING_FLAGS_BLACKLIST))
|
||||
{
|
||||
// must be stable???
|
||||
isStable = (isstable == 1);
|
||||
//mNetFlags.mExtAddr = tmpaddr;
|
||||
mNetFlags.mExtAddrOk = true;
|
||||
mNetFlags.mExtAddrStableOk = isStable;
|
||||
|
||||
address_votes[tmpaddr].n++ ;
|
||||
address_votes[tmpaddr].n++ ;
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() From DhtStunner: ";
|
||||
std::cerr << sockaddr_storage_tostring(tmpaddr);
|
||||
std::cerr << " Stable: " << (uint32_t) isstable;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() From DhtStunner: ";
|
||||
std::cerr << sockaddr_storage_tostring(tmpaddr);
|
||||
std::cerr << " Stable: " << (uint32_t) isstable;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
std::cerr << "(SS) DHTStunner returned wrong own IP " << sockaddr_storage_iptostring(tmpaddr) << " (banned). Rejecting." << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
std::cerr << "(SS) DHTStunner returned wrong own IP " << sockaddr_storage_iptostring(tmpaddr) << " (banned). Rejecting." << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* otherwise ask ExtAddrFinder */
|
||||
{
|
||||
@ -782,7 +789,7 @@ void p3NetMgrIMPL::netExtCheck()
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() checking ExtAddrFinder" << std::endl;
|
||||
#endif
|
||||
bool extFinderOk = mExtAddrFinder->hasValidIP(tmpip);
|
||||
if (extFinderOk)
|
||||
if (extFinderOk)
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext supplied by ExtAddrFinder" << std::endl;
|
||||
@ -796,105 +803,145 @@ void p3NetMgrIMPL::netExtCheck()
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mNetFlags.mExtAddr = tmpip;
|
||||
//mNetFlags.mExtAddr = tmpip;
|
||||
mNetFlags.mExtAddrOk = true;
|
||||
|
||||
address_votes[tmpip].n++ ;
|
||||
address_votes[tmpip].n++ ;
|
||||
|
||||
/* XXX HACK TO FIX */
|
||||
#warning "ALLOWING ExtAddrFinder -> ExtAddrStableOk = true (which it is not normally)"
|
||||
mNetFlags.mExtAddrStableOk = true;
|
||||
|
||||
std::cerr << "ExtAddrFinder reported external address " << sockaddr_storage_iptostring(tmpip) << std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* also ask peer mgr. */
|
||||
|
||||
if (mPeerMgr)
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() checking mPeerMgr" << std::endl;
|
||||
#endif
|
||||
uint8_t isstable ; // unused
|
||||
sockaddr_storage tmpaddr ;
|
||||
|
||||
if (mPeerMgr->getExtAddressReportedByFriends(tmpaddr, isstable))
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext supplied by ExtAddrFinder" << std::endl;
|
||||
#endif
|
||||
/* best guess at port */
|
||||
sockaddr_storage_setport(tmpaddr, sockaddr_storage_port(mLocalAddr));
|
||||
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() ";
|
||||
std::cerr << "ExtAddr: " << sockaddr_storage_tostring(tmpip);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
//mNetFlags.mExtAddr = tmpaddr;
|
||||
mNetFlags.mExtAddrOk = true;
|
||||
mNetFlags.mExtAddrStableOk = isstable;
|
||||
|
||||
address_votes[tmpaddr].n++ ;
|
||||
|
||||
std::cerr << "PeerMgr reported external address " << sockaddr_storage_iptostring(tmpaddr) << std::endl;
|
||||
}
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
else
|
||||
std::cerr << " No reliable address returned." << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* any other sources ??? */
|
||||
|
||||
/* finalise address */
|
||||
if (mNetFlags.mExtAddrOk)
|
||||
{
|
||||
// look at votes.
|
||||
{
|
||||
// look at votes.
|
||||
|
||||
std::cerr << "Figuring out ext addr from voting:" << std::endl;
|
||||
uint32_t admax = 0 ;
|
||||
std::cerr << "Figuring out ext addr from voting:" << std::endl;
|
||||
uint32_t admax = 0 ;
|
||||
|
||||
for(std::map<sockaddr_storage,ZeroInt>::const_iterator it(address_votes.begin());it!=address_votes.end();++it)
|
||||
{
|
||||
std::cerr << " Vote: " << sockaddr_storage_iptostring(it->first) << " : " << it->second.n << " votes." ;
|
||||
for(std::map<sockaddr_storage,ZeroInt>::const_iterator it(address_votes.begin());it!=address_votes.end();++it)
|
||||
{
|
||||
std::cerr << " Vote: " << sockaddr_storage_iptostring(it->first) << " : " << it->second.n << " votes." ;
|
||||
|
||||
if(it->second.n > admax)
|
||||
{
|
||||
mNetFlags.mExtAddr = it->first ;
|
||||
admax = it->second.n ;
|
||||
if(it->second.n > admax)
|
||||
{
|
||||
mNetFlags.mExtAddr = it->first ;
|
||||
admax = it->second.n ;
|
||||
|
||||
std::cerr << " Kept!" << std::endl;
|
||||
}
|
||||
else
|
||||
std::cerr << " Discarded." << std::endl;
|
||||
}
|
||||
std::cerr << " Kept!" << std::endl;
|
||||
}
|
||||
else
|
||||
std::cerr << " Discarded." << std::endl;
|
||||
}
|
||||
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() ";
|
||||
std::cerr << "ExtAddr: " << sockaddr_storage_tostring(mNetFlags.mExtAddr);
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() ";
|
||||
std::cerr << "ExtAddr: " << sockaddr_storage_tostring(mNetFlags.mExtAddr);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
//update ip address list
|
||||
mExtAddr = mNetFlags.mExtAddr;
|
||||
//update ip address list
|
||||
mExtAddr = mNetFlags.mExtAddr;
|
||||
|
||||
mNetStatus = RS_NET_DONE;
|
||||
netSetupDone = true;
|
||||
mNetStatus = RS_NET_DONE;
|
||||
netSetupDone = true;
|
||||
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext Ok: RS_NET_DONE" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext Ok: RS_NET_DONE" << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if (!mNetFlags.mExtAddrStableOk)
|
||||
{
|
||||
if (!mNetFlags.mExtAddrStableOk)
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgrIMPL::netUdpCheck() UDP Unstable :( ";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netUdpCheck() We are unreachable";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "netMode => RS_NET_MODE_UNREACHABLE";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netUdpCheck() UDP Unstable :( ";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netUdpCheck() We are unreachable";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "netMode => RS_NET_MODE_UNREACHABLE";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
// Due to the new UDP connections - we can still connect some of the time!
|
||||
// So limit warning!
|
||||
// Due to the new UDP connections - we can still connect some of the time!
|
||||
// So limit warning!
|
||||
|
||||
//mNetMode &= ~(RS_NET_MODE_ACTUAL);
|
||||
//mNetMode |= RS_NET_MODE_UNREACHABLE;
|
||||
//mNetMode &= ~(RS_NET_MODE_ACTUAL);
|
||||
//mNetMode |= RS_NET_MODE_UNREACHABLE;
|
||||
|
||||
/* send a system warning message */
|
||||
//pqiNotify *notify = getPqiNotify();
|
||||
//if (notify)
|
||||
{
|
||||
std::string title =
|
||||
"Warning: Bad Firewall Configuration";
|
||||
/* send a system warning message */
|
||||
//pqiNotify *notify = getPqiNotify();
|
||||
//if (notify)
|
||||
{
|
||||
std::string title =
|
||||
"Warning: Bad Firewall Configuration";
|
||||
|
||||
std::string msg;
|
||||
msg += " **** WARNING **** \n";
|
||||
msg += "Retroshare has detected that you are behind";
|
||||
msg += " a restrictive Firewall\n";
|
||||
msg += "\n";
|
||||
msg += "You will have limited connectivity to other firewalled peers\n";
|
||||
msg += "\n";
|
||||
msg += "You can fix this by:\n";
|
||||
msg += " (1) opening an External Port\n";
|
||||
msg += " (2) enabling UPnP, or\n";
|
||||
msg += " (3) get a new (approved) Firewall/Router\n";
|
||||
std::string msg;
|
||||
msg += " **** WARNING **** \n";
|
||||
msg += "Retroshare has detected that you are behind";
|
||||
msg += " a restrictive Firewall\n";
|
||||
msg += "\n";
|
||||
msg += "You will have limited connectivity to other firewalled peers\n";
|
||||
msg += "\n";
|
||||
msg += "You can fix this by:\n";
|
||||
msg += " (1) opening an External Port\n";
|
||||
msg += " (2) enabling UPnP, or\n";
|
||||
msg += " (3) get a new (approved) Firewall/Router\n";
|
||||
|
||||
//notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
|
||||
//notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
|
||||
|
||||
std::cerr << msg << std::endl;
|
||||
}
|
||||
std::cerr << msg << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (mNetFlags.mExtAddrOk)
|
||||
{
|
||||
|
@ -74,17 +74,20 @@ const uint32_t PEER_IP_CONNECT_STATE_MAX_LIST_SIZE = 4;
|
||||
#define MIN_RETRY_PERIOD 140
|
||||
|
||||
static const std::string kConfigDefaultProxyServerIpAddr = "127.0.0.1";
|
||||
static const uint16_t kConfigDefaultProxyServerPort = 9050; // standard port.
|
||||
static const uint16_t kConfigDefaultProxyServerPortTor = 9050; // standard port.
|
||||
static const uint16_t kConfigDefaultProxyServerPortI2P = 10; // there is no standard port though
|
||||
|
||||
static const std::string kConfigKeyExtIpFinder = "USE_EXTR_IP_FINDER";
|
||||
static const std::string kConfigKeyProxyServerIpAddr = "PROXY_SERVER_IPADDR";
|
||||
static const std::string kConfigKeyProxyServerPort = "PROXY_SERVER_PORT";
|
||||
static const std::string kConfigKeyProxyServerIpAddrTor = "PROXY_SERVER_IPADDR";
|
||||
static const std::string kConfigKeyProxyServerPortTor = "PROXY_SERVER_PORT";
|
||||
static const std::string kConfigKeyProxyServerIpAddrI2P = "PROXY_SERVER_IPADDR_I2P";
|
||||
static const std::string kConfigKeyProxyServerPortI2P = "PROXY_SERVER_PORT_I2P";
|
||||
|
||||
void printConnectState(std::ostream &out, peerState &peer);
|
||||
|
||||
peerState::peerState()
|
||||
:netMode(RS_NET_MODE_UNKNOWN), vs_disc(RS_VS_DISC_FULL), vs_dht(RS_VS_DHT_FULL), lastcontact(0),
|
||||
hiddenNode(false), hiddenPort(0)
|
||||
hiddenNode(false), hiddenPort(0), hiddenType(RS_HIDDEN_TYPE_NONE)
|
||||
{
|
||||
sockaddr_storage_clear(localaddr);
|
||||
sockaddr_storage_clear(serveraddr);
|
||||
@ -130,13 +133,21 @@ p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const RsPgpId& gpg_own_
|
||||
lastGroupId = 1;
|
||||
|
||||
// setup default ProxyServerAddress.
|
||||
sockaddr_storage_clear(mProxyServerAddress);
|
||||
sockaddr_storage_ipv4_aton(mProxyServerAddress,
|
||||
// Tor
|
||||
sockaddr_storage_clear(mProxyServerAddressTor);
|
||||
sockaddr_storage_ipv4_aton(mProxyServerAddressTor,
|
||||
kConfigDefaultProxyServerIpAddr.c_str());
|
||||
sockaddr_storage_ipv4_setport(mProxyServerAddress,
|
||||
kConfigDefaultProxyServerPort);
|
||||
sockaddr_storage_ipv4_setport(mProxyServerAddressTor,
|
||||
kConfigDefaultProxyServerPortTor);
|
||||
// I2P
|
||||
sockaddr_storage_clear(mProxyServerAddressI2P);
|
||||
sockaddr_storage_ipv4_aton(mProxyServerAddressI2P,
|
||||
kConfigDefaultProxyServerIpAddr.c_str());
|
||||
sockaddr_storage_ipv4_setport(mProxyServerAddressI2P,
|
||||
kConfigDefaultProxyServerPortI2P);
|
||||
|
||||
mProxyServerStatus = RS_NET_PROXY_STATUS_UNKNOWN ;
|
||||
mProxyServerStatusTor = RS_NET_PROXY_STATUS_UNKNOWN ;
|
||||
mProxyServerStatusI2P = RS_NET_PROXY_STATUS_UNKNOWN;
|
||||
}
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
@ -169,6 +180,7 @@ bool p3PeerMgrIMPL::setupHiddenNode(const std::string &hiddenAddress, const uint
|
||||
mOwnState.hiddenNode = true;
|
||||
mOwnState.hiddenPort = hiddenPort;
|
||||
mOwnState.hiddenDomain = hiddenAddress;
|
||||
mOwnState.hiddenType = hiddenDomainToHiddenType(hiddenAddress);
|
||||
}
|
||||
|
||||
forceHiddenNode();
|
||||
@ -188,6 +200,7 @@ bool p3PeerMgrIMPL::forceHiddenNode()
|
||||
#endif
|
||||
}
|
||||
mOwnState.hiddenNode = true;
|
||||
mOwnState.hiddenType = hiddenDomainToHiddenType(mOwnState.hiddenDomain);
|
||||
|
||||
// force external address - otherwise its invalid.
|
||||
sockaddr_storage_clear(mOwnState.serveraddr);
|
||||
@ -372,8 +385,43 @@ bool p3PeerMgrIMPL::isHidden()
|
||||
return mOwnState.hiddenNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief checks the hidden type of the own peer.
|
||||
* @param type type to check
|
||||
* @return true when the peer has the same hidden type than type
|
||||
*/
|
||||
bool p3PeerMgrIMPL::isHidden(const uint32_t type)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
switch (type) {
|
||||
case RS_HIDDEN_TYPE_TOR:
|
||||
return mOwnState.hiddenType == RS_HIDDEN_TYPE_TOR;
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_I2P:
|
||||
return mOwnState.hiddenType == RS_HIDDEN_TYPE_I2P;
|
||||
break;
|
||||
default:
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::isHidden(" << type << ") unkown type -> false";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::isHiddenPeer(const RsPeerId &ssl_id)
|
||||
{
|
||||
return isHiddenPeer(ssl_id, RS_HIDDEN_TYPE_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief checks the hidden type of a given ssl id. When type RS_HIDDEN_TYPE_NONE is choosen it returns the 'hiddenNode' value instead
|
||||
* @param ssl_id to check
|
||||
* @param type type to check. Use RS_HIDDEN_TYPE_NONE to check 'hiddenNode' value
|
||||
* @return true when the peer has the same hidden type than type
|
||||
*/
|
||||
bool p3PeerMgrIMPL::isHiddenPeer(const RsPeerId &ssl_id, const uint32_t type)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -394,9 +442,91 @@ bool p3PeerMgrIMPL::isHiddenPeer(const RsPeerId &ssl_id)
|
||||
std::cerr << "p3PeerMgrIMPL::isHiddenPeer(" << ssl_id << ") = " << (it->second).hiddenNode;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return (it->second).hiddenNode;
|
||||
switch (type) {
|
||||
case RS_HIDDEN_TYPE_TOR:
|
||||
return (it->second).hiddenType == RS_HIDDEN_TYPE_TOR;
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_I2P:
|
||||
return (it->second).hiddenType == RS_HIDDEN_TYPE_I2P;
|
||||
break;
|
||||
default:
|
||||
return (it->second).hiddenNode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool hasEnding (std::string const &fullString, std::string const &ending) {
|
||||
if (fullString.length() < ending.length())
|
||||
return false;
|
||||
|
||||
return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief resolves the hidden type (tor or i2p) from a domain
|
||||
* @param domain to check
|
||||
* @return RS_HIDDEN_TYPE_TOR, RS_HIDDEN_TYPE_I2P or RS_HIDDEN_TYPE_NONE
|
||||
*
|
||||
* Tor: ^[a-z2-7]{16}\.onion$
|
||||
*
|
||||
* I2P: There is more than one address:
|
||||
* - pub. key in base64
|
||||
* - hash in base32 ( ^[a-z2-7]{52}\.b32\.i2p$ )
|
||||
* - "normal" .i2p domains
|
||||
*/
|
||||
uint32_t p3PeerMgrIMPL::hiddenDomainToHiddenType(const std::string &domain)
|
||||
{
|
||||
if(hasEnding(domain, ".onion"))
|
||||
return RS_HIDDEN_TYPE_TOR;
|
||||
if(hasEnding(domain, ".i2p"))
|
||||
return RS_HIDDEN_TYPE_I2P;
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::hiddenDomainToHiddenType() unknown hidden type: " << domain;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return RS_HIDDEN_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief returns the hidden type of a peer
|
||||
* @param ssl_id peer id
|
||||
* @return hidden type
|
||||
*/
|
||||
uint32_t p3PeerMgrIMPL::getHiddenType(const RsPeerId &ssl_id)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
if (ssl_id == AuthSSL::getAuthSSL()->OwnId())
|
||||
return mOwnState.hiddenType;
|
||||
|
||||
/* check for existing */
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::getHiddenType(" << ssl_id << ") Missing Peer => false";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::getHiddenType(" << ssl_id << ") = " << (it->second).hiddenType;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return (it->second).hiddenType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief sets hidden domain and port for a given ssl ID
|
||||
* @param ssl_id peer to set domain and port for
|
||||
* @param domain_addr
|
||||
* @param domain_port
|
||||
* @return true on success
|
||||
*/
|
||||
bool p3PeerMgrIMPL::setHiddenDomainPort(const RsPeerId &ssl_id, const std::string &domain_addr, const uint16_t domain_port)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
@ -426,6 +556,7 @@ bool p3PeerMgrIMPL::setHiddenDomainPort(const RsPeerId &ssl_id, const std::strin
|
||||
mOwnState.hiddenNode = true;
|
||||
mOwnState.hiddenDomain = domain;
|
||||
mOwnState.hiddenPort = domain_port;
|
||||
mOwnState.hiddenType = hiddenDomainToHiddenType(domain);
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::setHiddenDomainPort() Set own State";
|
||||
std::cerr << std::endl;
|
||||
@ -448,6 +579,7 @@ bool p3PeerMgrIMPL::setHiddenDomainPort(const RsPeerId &ssl_id, const std::strin
|
||||
it->second.hiddenDomain = domain;
|
||||
it->second.hiddenPort = domain_port;
|
||||
it->second.hiddenNode = true;
|
||||
it->second.hiddenType = hiddenDomainToHiddenType(domain);
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::setHiddenDomainPort() Set Peers State";
|
||||
std::cerr << std::endl;
|
||||
@ -456,15 +588,40 @@ bool p3PeerMgrIMPL::setHiddenDomainPort(const RsPeerId &ssl_id, const std::strin
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setProxyServerAddress(const struct sockaddr_storage &proxy_addr)
|
||||
/**
|
||||
* @brief sets the proxy server address for a hidden service
|
||||
* @param type hidden service type
|
||||
* @param proxy_addr proxy address
|
||||
* @return true on success
|
||||
*/
|
||||
bool p3PeerMgrIMPL::setProxyServerAddress(const uint32_t type, const struct sockaddr_storage &proxy_addr)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
if (!sockaddr_storage_same(mProxyServerAddress,proxy_addr))
|
||||
{
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
mProxyServerAddress = proxy_addr;
|
||||
switch (type) {
|
||||
case RS_HIDDEN_TYPE_I2P:
|
||||
if (!sockaddr_storage_same(mProxyServerAddressI2P, proxy_addr))
|
||||
{
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
mProxyServerAddressI2P = proxy_addr;
|
||||
}
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_TOR:
|
||||
if (!sockaddr_storage_same(mProxyServerAddressTor, proxy_addr))
|
||||
{
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
mProxyServerAddressTor = proxy_addr;
|
||||
}
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_UNKNOWN:
|
||||
default:
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::setProxyServerAddress() unknown hidden type " << type << " -> false";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -480,21 +637,71 @@ bool p3PeerMgrIMPL::resetOwnExternalAddressList()
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::getProxyServerStatus(uint32_t& proxy_status)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
proxy_status = mProxyServerStatus;
|
||||
return true;
|
||||
}
|
||||
bool p3PeerMgrIMPL::getProxyServerAddress(struct sockaddr_storage &proxy_addr)
|
||||
/**
|
||||
* @brief returs proxy server status for a hidden service proxy
|
||||
* @param type hidden service type
|
||||
* @param proxy_status
|
||||
* @return true on success
|
||||
*/
|
||||
bool p3PeerMgrIMPL::getProxyServerStatus(const uint32_t type, uint32_t& proxy_status)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
proxy_addr = mProxyServerAddress;
|
||||
switch (type) {
|
||||
case RS_HIDDEN_TYPE_I2P:
|
||||
proxy_status = mProxyServerStatusI2P;
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_TOR:
|
||||
proxy_status = mProxyServerStatusTor;
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_UNKNOWN:
|
||||
default:
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::getProxyServerStatus() unknown hidden type " << type << " -> false";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief returs proxy server address for a hidden service proxy
|
||||
* @param type hidden service type
|
||||
* @param proxy_addr
|
||||
* @return true on success
|
||||
*/
|
||||
bool p3PeerMgrIMPL::getProxyServerAddress(const uint32_t type, struct sockaddr_storage &proxy_addr)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
switch (type) {
|
||||
case RS_HIDDEN_TYPE_I2P:
|
||||
proxy_addr = mProxyServerAddressI2P;
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_TOR:
|
||||
proxy_addr = mProxyServerAddressTor;
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_UNKNOWN:
|
||||
default:
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::getProxyServerAddress() unknown hidden type " << type << " -> false";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief looks up the proxy address and domain/port that have to be used when connecting to a peer
|
||||
* @param ssl_id peer to connect to
|
||||
* @param proxy_addr proxy address to be used
|
||||
* @param domain_addr domain to connect to
|
||||
* @param domain_port port to connect to
|
||||
* @return true on success
|
||||
*/
|
||||
bool p3PeerMgrIMPL::getProxyAddress(const RsPeerId &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
@ -515,7 +722,21 @@ bool p3PeerMgrIMPL::getProxyAddress(const RsPeerId &ssl_id, struct sockaddr_stor
|
||||
domain_addr = it->second.hiddenDomain;
|
||||
domain_port = it->second.hiddenPort;
|
||||
|
||||
proxy_addr = mProxyServerAddress;
|
||||
switch (it->second.hiddenType) {
|
||||
case RS_HIDDEN_TYPE_I2P:
|
||||
proxy_addr = mProxyServerAddressI2P;
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_TOR:
|
||||
proxy_addr = mProxyServerAddressTor;
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_UNKNOWN:
|
||||
default:
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::getProxyAddress() no valid hidden type (" << it->second.hiddenType << ") for peer id " << ssl_id << " -> false";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -805,7 +1026,7 @@ bool p3PeerMgrIMPL::removeFriend(const RsPgpId &id)
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* move to othersList */
|
||||
bool success = false;
|
||||
//bool success = false;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
//remove ssl and gpg_ids
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); ++it)
|
||||
@ -822,7 +1043,7 @@ bool p3PeerMgrIMPL::removeFriend(const RsPgpId &id)
|
||||
mOthersList[it->second.id] = peer;
|
||||
mStatusChanged = true;
|
||||
|
||||
success = true;
|
||||
//success = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -878,7 +1099,7 @@ bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId)
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* move to othersList */
|
||||
bool success = false;
|
||||
//bool success = false;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
//remove ssl and gpg_ids
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); ++it)
|
||||
@ -897,7 +1118,7 @@ bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId)
|
||||
mOthersList[id] = peer;
|
||||
mStatusChanged = true;
|
||||
|
||||
success = true;
|
||||
//success = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1246,21 +1467,52 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons
|
||||
// * emit a warnign when the address is unknown
|
||||
// * if multiple peers report the same address => notify the LinkMgr that the external address had changed.
|
||||
|
||||
sockaddr_storage addr_filtered ;
|
||||
sockaddr_storage_copyip(addr_filtered,addr) ;
|
||||
sockaddr_storage addr_filtered ;
|
||||
sockaddr_storage_clear(addr_filtered) ;
|
||||
sockaddr_storage_copyip(addr_filtered,addr) ;
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Own external address is " << sockaddr_storage_iptostring(addr_filtered) << ", as reported by friend " << from << std::endl;
|
||||
std::cerr << "Own external address is " << sockaddr_storage_iptostring(addr_filtered) << ", as reported by friend " << from << std::endl;
|
||||
#endif
|
||||
|
||||
if(!sockaddr_storage_isExternalNet(addr_filtered))
|
||||
if(!sockaddr_storage_isExternalNet(addr_filtered))
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << " address is not an external address. Returning false" << std::endl ;
|
||||
#endif
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Update a list of own IPs:
|
||||
// - remove old values for that same peer
|
||||
// - remove values for non connected peers
|
||||
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << " address is not an external address. Returning false" << std::endl ;
|
||||
#endif
|
||||
return false ;
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
mReportedOwnAddresses[from] = addr_filtered ;
|
||||
|
||||
for(std::map<RsPeerId,sockaddr_storage>::iterator it(mReportedOwnAddresses.begin());it!=mReportedOwnAddresses.end();)
|
||||
if(!mLinkMgr->isOnline(it->first))
|
||||
{
|
||||
std::map<RsPeerId,sockaddr_storage>::iterator tmp(it) ;
|
||||
++tmp ;
|
||||
mReportedOwnAddresses.erase(it) ;
|
||||
it=tmp ;
|
||||
}
|
||||
else
|
||||
++it ;
|
||||
|
||||
sockaddr_storage current_best_ext_address_guess ;
|
||||
uint32_t count ;
|
||||
|
||||
locked_computeCurrentBestOwnExtAddressCandidate(current_best_ext_address_guess,count) ;
|
||||
|
||||
std::cerr << "p3PeerMgr:: Current external address is calculated to be: " << sockaddr_storage_iptostring(current_best_ext_address_guess) << " (simultaneously reported by " << count << " peers)." << std::endl;
|
||||
}
|
||||
|
||||
// now current
|
||||
|
||||
sockaddr_storage own_addr ;
|
||||
|
||||
if(!mNetMgr->getExtAddress(own_addr))
|
||||
@ -1283,9 +1535,55 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons
|
||||
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, from.toStdString(), sockaddr_storage_iptostring(own_addr), sockaddr_storage_iptostring(addr));
|
||||
}
|
||||
|
||||
// we could also sweep over all connected friends and see if some report a different address.
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::locked_computeCurrentBestOwnExtAddressCandidate(sockaddr_storage& addr, uint32_t& count)
|
||||
{
|
||||
std::map<sockaddr_storage,ZeroedInt> addr_counts ;
|
||||
|
||||
for(std::map<RsPeerId,sockaddr_storage>::iterator it(mReportedOwnAddresses.begin());it!=mReportedOwnAddresses.end();++it)
|
||||
++addr_counts[it->second].n ;
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Current ext addr statistics:" << std::endl;
|
||||
#endif
|
||||
|
||||
count = 0 ;
|
||||
|
||||
for(std::map<sockaddr_storage,ZeroedInt>::const_iterator it(addr_counts.begin());it!=addr_counts.end();++it)
|
||||
{
|
||||
if(uint32_t(it->second.n) > count)
|
||||
{
|
||||
addr = it->first ;
|
||||
count = it->second.n ;
|
||||
}
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << sockaddr_storage_iptostring(it->first) << " : " << it->second.n << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::getExtAddressReportedByFriends(sockaddr_storage &addr, uint8_t& isstable)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
uint32_t count ;
|
||||
|
||||
locked_computeCurrentBestOwnExtAddressCandidate(addr,count) ;
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Estimation count = " << count << ". Trusted? = " << (count>=2) << std::endl;
|
||||
#endif
|
||||
|
||||
return count >= 2 ;// 2 is not conservative enough. 3 should be probably better.
|
||||
}
|
||||
|
||||
static bool cleanIpList(std::list<pqiIpAddress>& lst,const RsPeerId& pid,p3LinkMgr *link_mgr)
|
||||
{
|
||||
bool changed = false ;
|
||||
@ -1620,9 +1918,10 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
cleanup = false;
|
||||
bool useExtAddrFinder = mNetMgr->getIPServersEnabled();
|
||||
|
||||
// Store Proxy Server.
|
||||
struct sockaddr_storage proxy_addr;
|
||||
getProxyServerAddress(proxy_addr);
|
||||
/* gather these information before mPeerMtx is locked! */
|
||||
struct sockaddr_storage proxy_addr_tor, proxy_addr_i2p;
|
||||
getProxyServerAddress(RS_HIDDEN_TYPE_TOR, proxy_addr_tor);
|
||||
getProxyServerAddress(RS_HIDDEN_TYPE_I2P, proxy_addr_i2p);
|
||||
|
||||
mPeerMtx.lock(); /****** MUTEX LOCKED *******/
|
||||
|
||||
@ -1733,17 +2032,33 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
vitem->tlvkvs.pairs.push_back(kv) ;
|
||||
|
||||
|
||||
// Store Proxy Server.
|
||||
// Tor
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Saving proxyServerAddress: " << sockaddr_storage_tostring(proxy_addr);
|
||||
std::cerr << "Saving proxyServerAddress for Tor: " << sockaddr_storage_tostring(proxy_addr_tor);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
kv.key = kConfigKeyProxyServerIpAddr;
|
||||
kv.value = sockaddr_storage_iptostring(proxy_addr);
|
||||
kv.key = kConfigKeyProxyServerIpAddrTor;
|
||||
kv.value = sockaddr_storage_iptostring(proxy_addr_tor);
|
||||
vitem->tlvkvs.pairs.push_back(kv) ;
|
||||
|
||||
kv.key = kConfigKeyProxyServerPort;
|
||||
kv.value = sockaddr_storage_porttostring(proxy_addr);
|
||||
kv.key = kConfigKeyProxyServerPortTor;
|
||||
kv.value = sockaddr_storage_porttostring(proxy_addr_tor);
|
||||
vitem->tlvkvs.pairs.push_back(kv) ;
|
||||
|
||||
// I2P
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Saving proxyServerAddress for I2P: " << sockaddr_storage_tostring(proxy_addr_i2p);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
kv.key = kConfigKeyProxyServerIpAddrI2P;
|
||||
kv.value = sockaddr_storage_iptostring(proxy_addr_i2p);
|
||||
vitem->tlvkvs.pairs.push_back(kv) ;
|
||||
|
||||
kv.key = kConfigKeyProxyServerPortI2P;
|
||||
kv.value = sockaddr_storage_porttostring(proxy_addr_i2p);
|
||||
vitem->tlvkvs.pairs.push_back(kv) ;
|
||||
|
||||
saveData.push_back(vitem);
|
||||
@ -1779,8 +2094,10 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
|
||||
// DEFAULTS.
|
||||
bool useExtAddrFinder = true;
|
||||
std::string proxyIpAddress = kConfigDefaultProxyServerIpAddr;
|
||||
uint16_t proxyPort = kConfigDefaultProxyServerPort;
|
||||
std::string proxyIpAddressTor = kConfigDefaultProxyServerIpAddr;
|
||||
uint16_t proxyPortTor = kConfigDefaultProxyServerPortTor;
|
||||
std::string proxyIpAddressI2P = kConfigDefaultProxyServerIpAddr;
|
||||
uint16_t proxyPortI2P = kConfigDefaultProxyServerPortI2P;
|
||||
|
||||
if (load.empty()) {
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() list is empty, it may be a configuration problem." << std::endl;
|
||||
@ -1876,20 +2193,38 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
std::cerr << "setting use_extr_addr_finder to " << useExtAddrFinder << std::endl ;
|
||||
#endif
|
||||
}
|
||||
else if (kit->key == kConfigKeyProxyServerIpAddr)
|
||||
// Tor
|
||||
else if (kit->key == kConfigKeyProxyServerIpAddrTor)
|
||||
{
|
||||
proxyIpAddress = kit->value;
|
||||
proxyIpAddressTor = kit->value;
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded proxyIpAddress: " << proxyIpAddress;
|
||||
std::cerr << "Loaded proxyIpAddress for Tor: " << proxyIpAddressTor;
|
||||
std::cerr << std::endl ;
|
||||
#endif
|
||||
|
||||
}
|
||||
else if (kit->key == kConfigKeyProxyServerPort)
|
||||
else if (kit->key == kConfigKeyProxyServerPortTor)
|
||||
{
|
||||
proxyPort = atoi(kit->value.c_str());
|
||||
proxyPortTor = atoi(kit->value.c_str());
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded proxyPort: " << proxyPort;
|
||||
std::cerr << "Loaded proxyPort for Tor: " << proxyPortTor;
|
||||
std::cerr << std::endl ;
|
||||
#endif
|
||||
}
|
||||
// I2p
|
||||
else if (kit->key == kConfigKeyProxyServerIpAddrI2P)
|
||||
{
|
||||
proxyIpAddressI2P = kit->value;
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded proxyIpAddress for I2P: " << proxyIpAddressI2P;
|
||||
std::cerr << std::endl ;
|
||||
#endif
|
||||
}
|
||||
else if (kit->key == kConfigKeyProxyServerPortI2P)
|
||||
{
|
||||
proxyPortI2P = atoi(kit->value.c_str());
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded proxyPort for I2P: " << proxyPortI2P;
|
||||
std::cerr << std::endl ;
|
||||
#endif
|
||||
}
|
||||
@ -2005,13 +2340,24 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
|
||||
// Configure Proxy Server.
|
||||
struct sockaddr_storage proxy_addr;
|
||||
// Tor
|
||||
sockaddr_storage_clear(proxy_addr);
|
||||
sockaddr_storage_ipv4_aton(proxy_addr, proxyIpAddress.c_str());
|
||||
sockaddr_storage_ipv4_setport(proxy_addr, proxyPort);
|
||||
sockaddr_storage_ipv4_aton(proxy_addr, proxyIpAddressTor.c_str());
|
||||
sockaddr_storage_ipv4_setport(proxy_addr, proxyPortTor);
|
||||
|
||||
if (sockaddr_storage_isValidNet(proxy_addr))
|
||||
{
|
||||
setProxyServerAddress(proxy_addr);
|
||||
setProxyServerAddress(RS_HIDDEN_TYPE_TOR, proxy_addr);
|
||||
}
|
||||
|
||||
// I2P
|
||||
sockaddr_storage_clear(proxy_addr);
|
||||
sockaddr_storage_ipv4_aton(proxy_addr, proxyIpAddressI2P.c_str());
|
||||
sockaddr_storage_ipv4_setport(proxy_addr, proxyPortI2P);
|
||||
|
||||
if (sockaddr_storage_isValidNet(proxy_addr))
|
||||
{
|
||||
setProxyServerAddress(RS_HIDDEN_TYPE_I2P, proxy_addr);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -90,6 +90,7 @@ class peerState
|
||||
bool hiddenNode; /* all IP addresses / dyndns must be blank */
|
||||
std::string hiddenDomain;
|
||||
uint16_t hiddenPort;
|
||||
uint32_t hiddenType;
|
||||
|
||||
std::string location;
|
||||
std::string name;
|
||||
@ -153,6 +154,7 @@ virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage
|
||||
virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr) = 0;
|
||||
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns) = 0;
|
||||
virtual bool addCandidateForOwnExternalAddress(const RsPeerId& from, const struct sockaddr_storage &addr) = 0;
|
||||
virtual bool getExtAddressReportedByFriends(struct sockaddr_storage& addr,uint8_t& isstable) = 0;
|
||||
|
||||
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode) = 0;
|
||||
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht) = 0;
|
||||
@ -185,12 +187,16 @@ virtual bool getPeerName(const RsPeerId &ssl_id, std::string &name) = 0;
|
||||
virtual bool getGpgId(const RsPeerId &sslId, RsPgpId &gpgId) = 0;
|
||||
virtual uint32_t getConnectionType(const RsPeerId &sslId) = 0;
|
||||
|
||||
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr) = 0;
|
||||
virtual bool getProxyServerAddress(struct sockaddr_storage &proxy_addr) = 0;
|
||||
virtual bool getProxyServerStatus(uint32_t& status) = 0;
|
||||
virtual bool setProxyServerAddress(const uint32_t type, const struct sockaddr_storage &proxy_addr) = 0;
|
||||
virtual bool getProxyServerAddress(const uint32_t type, struct sockaddr_storage &proxy_addr) = 0;
|
||||
virtual bool getProxyServerStatus(const uint32_t type, uint32_t& status) = 0;
|
||||
virtual bool isHidden() = 0;
|
||||
virtual bool isHidden(const uint32_t type) = 0;
|
||||
virtual bool isHiddenPeer(const RsPeerId &ssl_id) = 0;
|
||||
virtual bool isHiddenPeer(const RsPeerId &ssl_id, const uint32_t type) = 0;
|
||||
virtual bool getProxyAddress(const RsPeerId &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port) = 0;
|
||||
virtual uint32_t hiddenDomainToHiddenType(const std::string &domain) = 0;
|
||||
virtual uint32_t getHiddenType(const RsPeerId &ssl_id) = 0;
|
||||
|
||||
|
||||
virtual int getFriendCount(bool ssl, bool online) = 0;
|
||||
@ -200,6 +206,7 @@ virtual int getFriendCount(bool ssl, bool online) = 0;
|
||||
// Single Use Function... shouldn't be here. used by p3serverconfig.cc
|
||||
virtual bool haveOnceConnected() = 0;
|
||||
|
||||
virtual bool locked_computeCurrentBestOwnExtAddressCandidate(sockaddr_storage &addr, uint32_t &count)=0;
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*************************************************************************************************/
|
||||
@ -256,6 +263,7 @@ virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage
|
||||
virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
|
||||
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
|
||||
virtual bool addCandidateForOwnExternalAddress(const RsPeerId& from, const struct sockaddr_storage &addr) ;
|
||||
virtual bool getExtAddressReportedByFriends(struct sockaddr_storage& addr, uint8_t &isstable) ;
|
||||
|
||||
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
|
||||
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
|
||||
@ -288,12 +296,16 @@ virtual bool getPeerName(const RsPeerId& ssl_id, std::string& name);
|
||||
virtual bool getGpgId(const RsPeerId& sslId, RsPgpId& gpgId);
|
||||
virtual uint32_t getConnectionType(const RsPeerId& sslId);
|
||||
|
||||
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr);
|
||||
virtual bool getProxyServerAddress(struct sockaddr_storage &proxy_addr);
|
||||
virtual bool getProxyServerStatus(uint32_t &proxy_status);
|
||||
virtual bool setProxyServerAddress(const uint32_t type, const struct sockaddr_storage &proxy_addr);
|
||||
virtual bool getProxyServerAddress(const uint32_t type, struct sockaddr_storage &proxy_addr);
|
||||
virtual bool getProxyServerStatus(const uint32_t type, uint32_t &proxy_status);
|
||||
virtual bool isHidden();
|
||||
virtual bool isHiddenPeer(const RsPeerId& ssl_id);
|
||||
virtual bool isHidden(const uint32_t type);
|
||||
virtual bool isHiddenPeer(const RsPeerId &ssl_id);
|
||||
virtual bool isHiddenPeer(const RsPeerId &ssl_id, const uint32_t type);
|
||||
virtual bool getProxyAddress(const RsPeerId& ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port);
|
||||
virtual uint32_t hiddenDomainToHiddenType(const std::string &domain);
|
||||
virtual uint32_t getHiddenType(const RsPeerId &ssl_id);
|
||||
|
||||
virtual int getFriendCount(bool ssl, bool online);
|
||||
|
||||
@ -327,6 +339,7 @@ int getConnectAddresses(const RsPeerId &id,
|
||||
struct sockaddr_storage &lAddr, struct sockaddr_storage &eAddr,
|
||||
pqiIpAddrSet &histAddrs, std::string &dyndns);
|
||||
|
||||
|
||||
protected:
|
||||
/* Internal Functions */
|
||||
|
||||
@ -335,6 +348,8 @@ bool removeBannedIps();
|
||||
|
||||
void printPeerLists(std::ostream &out);
|
||||
|
||||
virtual bool locked_computeCurrentBestOwnExtAddressCandidate(sockaddr_storage &addr, uint32_t &count);
|
||||
|
||||
protected:
|
||||
/*****************************************************************/
|
||||
/*********************** p3config ******************************/
|
||||
@ -362,6 +377,8 @@ private:
|
||||
std::map<RsPeerId, peerState> mFriendList; // <SSLid , peerState>
|
||||
std::map<RsPeerId, peerState> mOthersList;
|
||||
|
||||
std::map<RsPeerId,sockaddr_storage> mReportedOwnAddresses ;
|
||||
|
||||
std::list<RsPeerGroupItem *> groupList;
|
||||
uint32_t lastGroupId;
|
||||
|
||||
@ -369,8 +386,10 @@ private:
|
||||
|
||||
std::map<RsPgpId, ServicePermissionFlags> mFriendsPermissionFlags ; // permission flags for each gpg key
|
||||
|
||||
struct sockaddr_storage mProxyServerAddress;
|
||||
uint32_t mProxyServerStatus ;
|
||||
struct sockaddr_storage mProxyServerAddressTor;
|
||||
struct sockaddr_storage mProxyServerAddressI2P;
|
||||
uint32_t mProxyServerStatusTor ;
|
||||
uint32_t mProxyServerStatusI2P ;
|
||||
|
||||
};
|
||||
|
||||
|
@ -148,7 +148,7 @@ public:
|
||||
uint32_t tmp ;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &tmp);
|
||||
|
||||
for(int i=0;i<tmp && offset < rssize;++i)
|
||||
for(uint32_t i=0;i<tmp && offset < rssize;++i)
|
||||
{
|
||||
RsPeerId peer_id ;
|
||||
ok &= peer_id.deserialise(data,rssize,offset) ;
|
||||
@ -157,7 +157,7 @@ public:
|
||||
|
||||
ok &= getRawUInt32(data, rssize, &offset, &tmp);
|
||||
|
||||
for(int i=0;i<tmp && offset < rssize;++i)
|
||||
for(uint32_t i=0;i<tmp && offset < rssize;++i)
|
||||
{
|
||||
RsPeerId peer_id ;
|
||||
ok &= peer_id.deserialise(data,rssize,offset) ;
|
||||
|
@ -249,7 +249,8 @@ class PQInterface: public RateInterface
|
||||
|
||||
const uint32_t PQI_CONNECT_TCP = 0x0001;
|
||||
const uint32_t PQI_CONNECT_UDP = 0x0002;
|
||||
const uint32_t PQI_CONNECT_HIDDEN_TCP = 0x0004;
|
||||
const uint32_t PQI_CONNECT_HIDDEN_TOR_TCP = 0x0004;
|
||||
const uint32_t PQI_CONNECT_HIDDEN_I2P_TCP = 0x0008;
|
||||
|
||||
|
||||
#define BIN_FLAGS_NO_CLOSE 0x0001
|
||||
|
@ -500,7 +500,7 @@ void printNetBinID(std::ostream &out, const RsPeerId& id, uint32_t t)
|
||||
{
|
||||
out << "TCP)";
|
||||
}
|
||||
else if (t == PQI_CONNECT_HIDDEN_TCP)
|
||||
else if (t & (PQI_CONNECT_HIDDEN_TOR_TCP | PQI_CONNECT_HIDDEN_I2P_TCP))
|
||||
{
|
||||
out << "HTCP";
|
||||
}
|
||||
@ -544,7 +544,7 @@ int NetBinDummy::connect(const struct sockaddr_storage &raddr)
|
||||
std::cerr << std::endl;
|
||||
if (parent())
|
||||
{
|
||||
struct sockaddr_storage addr = raddr;
|
||||
//struct sockaddr_storage addr = raddr;
|
||||
parent()->notifyEvent(this, CONNECT_FAILED, raddr);
|
||||
}
|
||||
}
|
||||
|
@ -48,57 +48,36 @@ static const int HEARTBEAT_REPEAT_TIME = 5;
|
||||
#include "pqi/pqiqosstreamer.h"
|
||||
#include "pqi/pqithreadstreamer.h"
|
||||
|
||||
class pqiconnect: public pqiQoSstreamer, public NetInterface
|
||||
class pqiconnect : public pqiQoSstreamer, public NetInterface
|
||||
{
|
||||
public:
|
||||
pqiconnect(PQInterface *parent, RsSerialiser *rss, NetBinInterface *ni_in)
|
||||
:pqiQoSstreamer(parent, rss, ni_in->PeerId(), ni_in, 0), // pqistreamer will cleanup NetInterface.
|
||||
NetInterface(NULL, ni_in->PeerId()), // No need for callback
|
||||
ni(ni_in)
|
||||
{
|
||||
if (!ni_in)
|
||||
{
|
||||
std::cerr << "pqiconnect::pqiconnect() NetInterface == NULL, FATAL!";
|
||||
std::cerr << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
pqiconnect(PQInterface *parent, RsSerialiser *rss, NetBinInterface *ni_in) :
|
||||
pqiQoSstreamer(parent, rss, ni_in->PeerId(), ni_in, 0), // pqistreamer will cleanup NetInterface.
|
||||
NetInterface(NULL, ni_in->PeerId()), // No need for callback
|
||||
ni(ni_in) {}
|
||||
|
||||
virtual ~pqiconnect() { return; }
|
||||
virtual bool getCryptoParams(RsPeerCryptoParams& params) ;
|
||||
virtual ~pqiconnect() {}
|
||||
virtual bool getCryptoParams(RsPeerCryptoParams& params);
|
||||
|
||||
// presents a virtual NetInterface -> passes to ni.
|
||||
virtual int connect(const struct sockaddr_storage &raddr) { return ni->connect(raddr); }
|
||||
virtual int listen() { return ni -> listen(); }
|
||||
virtual int stoplistening() { return ni -> stoplistening(); }
|
||||
virtual int reset() { return ni -> reset(); }
|
||||
virtual int disconnect() { return ni -> reset(); }
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value) { return ni -> connect_parameter(type, value);}
|
||||
virtual bool connect_parameter(uint32_t type, std::string value) { return ni -> connect_parameter(type, value);}
|
||||
virtual bool connect_additional_address(uint32_t type, const struct sockaddr_storage &addr) { return ni -> connect_additional_address(type, addr);}
|
||||
|
||||
|
||||
virtual int getConnectAddress(struct sockaddr_storage &raddr){ return ni->getConnectAddress(raddr); }
|
||||
virtual int connect(const struct sockaddr_storage &raddr) { return ni->connect(raddr); }
|
||||
virtual int listen() { return ni->listen(); }
|
||||
virtual int stoplistening() { return ni->stoplistening(); }
|
||||
virtual int reset() { return ni->reset(); }
|
||||
virtual int disconnect() { return ni->reset(); }
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value) { return ni->connect_parameter(type, value);}
|
||||
virtual bool connect_parameter(uint32_t type, std::string value) { return ni->connect_parameter(type, value);}
|
||||
virtual bool connect_additional_address(uint32_t type, const struct sockaddr_storage &addr) { return ni->connect_additional_address(type, addr); }
|
||||
virtual int getConnectAddress(struct sockaddr_storage &raddr){ return ni->getConnectAddress(raddr); }
|
||||
|
||||
// get the contact from the net side!
|
||||
virtual const RsPeerId& PeerId()
|
||||
{
|
||||
if (ni)
|
||||
{
|
||||
return ni->PeerId();
|
||||
}
|
||||
else
|
||||
{
|
||||
return PQInterface::PeerId();
|
||||
}
|
||||
}
|
||||
virtual const RsPeerId& PeerId() { return ni->PeerId(); }
|
||||
|
||||
// to check if our interface.
|
||||
virtual bool thisNetInterface(NetInterface *ni_in) { return (ni_in == ni); }
|
||||
virtual bool thisNetInterface(NetInterface *ni_in) { return (ni_in == ni); }
|
||||
|
||||
protected:
|
||||
NetBinInterface *ni;
|
||||
protected:
|
||||
};
|
||||
|
||||
|
||||
|
@ -617,15 +617,19 @@ int pqipersongrp::connectPeer(const RsPeerId& id
|
||||
uint32_t ptype;
|
||||
if (type & RS_NET_CONN_TCP_ALL)
|
||||
{
|
||||
if (type == RS_NET_CONN_TCP_HIDDEN)
|
||||
{
|
||||
ptype = PQI_CONNECT_HIDDEN_TCP;
|
||||
switch (type) {
|
||||
case RS_NET_CONN_TCP_HIDDEN_TOR:
|
||||
ptype = PQI_CONNECT_HIDDEN_TOR_TCP;
|
||||
timeout = RS_TCP_HIDDEN_TIMEOUT_PERIOD;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
case RS_NET_CONN_TCP_HIDDEN_I2P:
|
||||
ptype = PQI_CONNECT_HIDDEN_I2P_TCP;
|
||||
timeout = RS_TCP_HIDDEN_TIMEOUT_PERIOD;
|
||||
break;
|
||||
default:
|
||||
ptype = PQI_CONNECT_TCP;
|
||||
timeout = RS_TCP_STD_TIMEOUT_PERIOD;
|
||||
break;
|
||||
}
|
||||
#ifdef PGRP_DEBUG
|
||||
std::cerr << " pqipersongrp::connectPeer() connecting with TCP: Timeout :" << timeout;
|
||||
|
@ -27,7 +27,7 @@ void pqiQoS::clear()
|
||||
{
|
||||
void *item ;
|
||||
|
||||
for(int i=0;i<_item_queues.size();++i)
|
||||
for(uint32_t i=0;i<_item_queues.size();++i)
|
||||
while( (item = _item_queues[i].pop()) != NULL)
|
||||
free(item) ;
|
||||
|
||||
@ -46,7 +46,7 @@ void pqiQoS::print() const
|
||||
|
||||
void pqiQoS::in_rsItem(void *ptr,int priority)
|
||||
{
|
||||
if(priority >= _item_queues.size())
|
||||
if(uint32_t(priority) >= _item_queues.size())
|
||||
{
|
||||
std::cerr << "pqiQoS::in_rsRawItem() ****Warning****: priority " << priority << " out of scope [0," << _item_queues.size()-1 << "]. Priority will be clamped to maximum value." << std::endl;
|
||||
priority = _item_queues.size()-1 ;
|
||||
|
@ -286,54 +286,40 @@ int pqissl::reset_locked()
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool pqissl::connect_parameter(uint32_t type, const std::string &value)
|
||||
bool pqissl::connect_parameter(uint32_t type, uint32_t value)
|
||||
{
|
||||
RsStackMutex stack(mSslMtx); /**** LOCKED MUTEX ****/
|
||||
|
||||
/* remove unused parameter warnings */
|
||||
(void) type;
|
||||
(void) value;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool pqissl::connect_parameter(uint32_t type, uint32_t value)
|
||||
{
|
||||
RsStackMutex stack(mSslMtx); /**** LOCKED MUTEX ****/
|
||||
|
||||
#ifdef PQISSL_LOG_DEBUG
|
||||
{
|
||||
std::string out = "pqissl::connect_parameter() Peer: " + PeerId();
|
||||
rs_sprintf_append(out, " type: %u value: %u", type, value);
|
||||
rslog(RSL_DEBUG_ALL, pqisslzone, out);
|
||||
}
|
||||
std::cerr << "pqissl::connect_parameter() Peer: " << PeerId();
|
||||
#endif
|
||||
|
||||
if (type == NET_PARAM_CONNECT_DELAY)
|
||||
switch(type)
|
||||
{
|
||||
case NET_PARAM_CONNECT_DELAY:
|
||||
{
|
||||
#ifdef PQISSL_LOG_DEBUG
|
||||
std::string out = "pqissl::connect_parameter() Peer: " + PeerId();
|
||||
rs_sprintf_append(out, " DELAY: %u", value);
|
||||
rslog(RSL_DEBUG_BASIC, pqisslzone, out);
|
||||
std::cerr << " DELAY: " << value << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
RS_STACK_MUTEX(mSslMtx);
|
||||
mConnectDelay = value;
|
||||
return true;
|
||||
}
|
||||
else if (type == NET_PARAM_CONNECT_TIMEOUT)
|
||||
case NET_PARAM_CONNECT_TIMEOUT:
|
||||
{
|
||||
#ifdef PQISSL_LOG_DEBUG
|
||||
std::string out = "pqissl::connect_parameter() Peer: " + PeerId();
|
||||
rs_sprintf_append(out, " TIMEOUT: %u", value);
|
||||
rslog(RSL_DEBUG_BASIC, pqisslzone, out);
|
||||
std::cerr << " TIMEOUT: " << value << std::endl;
|
||||
#endif
|
||||
|
||||
RS_STACK_MUTEX(mSslMtx);
|
||||
mConnectTimeout = value;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
//return NetInterface::connect_parameter(type, value);
|
||||
default:
|
||||
{
|
||||
#ifdef PQISSL_LOG_DEBUG
|
||||
std::cerr << " type: " << type << " value: " << value << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,7 +98,7 @@ virtual int reset();
|
||||
virtual int disconnect();
|
||||
virtual int getConnectAddress(struct sockaddr_storage &raddr);
|
||||
|
||||
virtual bool connect_parameter(uint32_t type, const std::string &value);
|
||||
virtual bool connect_parameter(uint32_t /*type*/, const std::string & /*value*/) { return false; }
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value);
|
||||
|
||||
// BinInterface
|
||||
|
@ -123,6 +123,10 @@ int pqissllistenbase::setuplisten()
|
||||
err = fcntl(lsock, F_SETFL, O_NONBLOCK);
|
||||
if (err < 0)
|
||||
{
|
||||
shutdown(lsock,SHUT_RDWR) ;
|
||||
close(lsock) ;
|
||||
lsock = -1 ;
|
||||
|
||||
std::string out;
|
||||
rs_sprintf(out, "Error: Cannot make socket NON-Blocking: %d", err);
|
||||
pqioutput(PQL_ERROR, pqissllistenzone, out);
|
||||
@ -145,6 +149,9 @@ int pqissllistenbase::setuplisten()
|
||||
unsigned long int on = 1;
|
||||
if (0 != (err = ioctlsocket(lsock, FIONBIO, &on)))
|
||||
{
|
||||
closesocket(lsock) ;
|
||||
lsock = -1 ;
|
||||
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqissllistenbase::setuplisten() Error: Cannot make socket NON-Blocking: %d\n", err);
|
||||
out += "Socket Error: " + socket_errorType(WSAGetLastError());
|
||||
|
@ -91,7 +91,36 @@ pqiperson * pqisslpersongrp::locked_createPerson(const RsPeerId& id, pqilistener
|
||||
|
||||
pqiconnect *pqisc = new pqiconnect(pqip, rss, pqis);
|
||||
|
||||
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_TCP, pqisc);
|
||||
/* first select type based on peer */
|
||||
uint32_t typePeer = mPeerMgr->getHiddenType(id);
|
||||
switch (typePeer) {
|
||||
case RS_HIDDEN_TYPE_TOR:
|
||||
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_TOR_TCP, pqisc);
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_I2P:
|
||||
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_I2P_TCP, pqisc);
|
||||
break;
|
||||
default:
|
||||
/* peer is not a hidden one but we are */
|
||||
/* select type based on ourselves */
|
||||
uint32_t typeOwn = mPeerMgr->getHiddenType(AuthSSL::getAuthSSL()->OwnId());
|
||||
switch (typeOwn) {
|
||||
case RS_HIDDEN_TYPE_I2P:
|
||||
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_I2P_TCP, pqisc);
|
||||
break;
|
||||
default:
|
||||
/* this case shouldn't happen! */
|
||||
std::cerr << "pqisslpersongrp::locked_createPerson WARNING INVALID HIDDEN TYPES - THIS SHOULD NOT HAPPEN!" << std::endl;
|
||||
std::cerr << " - ID: " << id << std::endl;
|
||||
std::cerr << " - mPeerMgr->isHidden(): " << mPeerMgr->isHidden() << std::endl;
|
||||
std::cerr << " - mPeerMgr->isHiddenPeer(id): " << mPeerMgr->isHiddenPeer(id) << std::endl;
|
||||
std::cerr << " - hidden types: peer=" << typePeer << " own=" << typeOwn << std::endl;
|
||||
std::cerr << " --> falling back to Tor" << std::endl;
|
||||
case RS_HIDDEN_TYPE_TOR:
|
||||
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_TOR_TCP, pqisc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,25 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ..
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
OBJ = notifytxt.o retroshare.o
|
||||
|
||||
#TESTOBJ =
|
||||
|
||||
TESTS = retroshare-nogui
|
||||
|
||||
all: tests
|
||||
|
||||
retroshare-nogui: $(OBJ)
|
||||
$(CC) $(CFLAGS) -o retroshare-nogui $(OBJ) $(LIBS)
|
||||
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -63,6 +63,14 @@ const uint32_t RS_NETMODE_EXT = 0x0003;
|
||||
const uint32_t RS_NETMODE_HIDDEN = 0x0004;
|
||||
const uint32_t RS_NETMODE_UNREACHABLE = 0x0005;
|
||||
|
||||
/* Hidden Type */
|
||||
const uint32_t RS_HIDDEN_TYPE_NONE = 0x0000;
|
||||
const uint32_t RS_HIDDEN_TYPE_UNKNOWN = 0x0001;
|
||||
const uint32_t RS_HIDDEN_TYPE_TOR = 0x0002;
|
||||
const uint32_t RS_HIDDEN_TYPE_I2P = 0x0004;
|
||||
/* mask to match all valid hidden types */
|
||||
const uint32_t RS_HIDDEN_TYPE_MASK = RS_HIDDEN_TYPE_I2P | RS_HIDDEN_TYPE_TOR;
|
||||
|
||||
/* Visibility */
|
||||
const uint32_t RS_VS_DISC_OFF = 0x0000;
|
||||
const uint32_t RS_VS_DISC_MINIMAL = 0x0001;
|
||||
@ -96,7 +104,8 @@ const uint32_t RS_PEER_CONNECTSTATE_TRYING_UDP = 3;
|
||||
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_TCP = 4;
|
||||
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UDP = 5;
|
||||
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_TOR = 6;
|
||||
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN = 7;
|
||||
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_I2P = 7;
|
||||
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN = 8;
|
||||
|
||||
/* Error codes for certificate cleaning and cert parsing. Numbers should not overlap. */
|
||||
|
||||
@ -232,6 +241,7 @@ class RsPeerDetails
|
||||
bool isHiddenNode;
|
||||
std::string hiddenNodeAddress;
|
||||
uint16_t hiddenNodePort;
|
||||
uint32_t hiddenType;
|
||||
|
||||
// Filled in for Standard Node.
|
||||
std::string localAddr;
|
||||
@ -350,8 +360,8 @@ class RsPeers
|
||||
virtual bool setNetworkMode(const RsPeerId &ssl_id, uint32_t netMode) = 0;
|
||||
virtual bool setVisState(const RsPeerId &ssl_id, uint16_t vs_disc, uint16_t vs_dht) = 0;
|
||||
|
||||
virtual bool getProxyServer(std::string &addr, uint16_t &port,uint32_t& status_flags) = 0;
|
||||
virtual bool setProxyServer(const std::string &addr, const uint16_t port) = 0;
|
||||
virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status_flags) = 0;
|
||||
virtual bool setProxyServer(const uint32_t type, const std::string &addr, const uint16_t port) = 0;
|
||||
|
||||
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
|
||||
virtual void allowServerIPDetermination(bool) = 0;
|
||||
|
@ -1,35 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ..
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
RSOBJ = rsinit.o \
|
||||
p3peers.o \
|
||||
p3rank.o \
|
||||
p3photo.o \
|
||||
p3msgs.o \
|
||||
p3blog.o \
|
||||
p3discovery.o \
|
||||
p3face-server.o \
|
||||
p3face-config.o \
|
||||
p3face-msgs.o \
|
||||
rsiface.o \
|
||||
rstypes.o
|
||||
|
||||
#TESTOBJ =
|
||||
|
||||
#TESTS =
|
||||
|
||||
all: librs tests
|
||||
|
||||
#tlvbase_test : tlvbase_test.o
|
||||
# $(CC) $(CFLAGS) -o tlvbase_test tlvbase_test.o $(OBJ) $(LIBS)
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -313,6 +313,7 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
d.isHiddenNode = true;
|
||||
d.hiddenNodeAddress = ps.hiddenDomain;
|
||||
d.hiddenNodePort = ps.hiddenPort;
|
||||
d.hiddenType = ps.hiddenType;
|
||||
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
|
||||
d.localPort = sockaddr_storage_port(ps.localaddr);
|
||||
d.extAddr = "hidden";
|
||||
@ -324,6 +325,7 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
d.isHiddenNode = false;
|
||||
d.hiddenNodeAddress = "";
|
||||
d.hiddenNodePort = 0;
|
||||
d.hiddenType = RS_HIDDEN_TYPE_NONE;
|
||||
|
||||
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
|
||||
d.localPort = sockaddr_storage_port(ps.localaddr);
|
||||
@ -435,20 +437,79 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
}
|
||||
else if (pcs.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
if(isProxyAddress(pcs.connectaddr) || mPeerMgr->isHidden())
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TOR;
|
||||
else if (pcs.connecttype == RS_NET_CONN_TCP_ALL)
|
||||
{
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TCP;
|
||||
}
|
||||
else if (pcs.connecttype == RS_NET_CONN_UDP_ALL)
|
||||
{
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UDP;
|
||||
}
|
||||
else
|
||||
{
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN;
|
||||
}
|
||||
/* peer is connected - determine how and set proper connectState */
|
||||
if(mPeerMgr->isHidden())
|
||||
{
|
||||
uint32_t type;
|
||||
/* hidden location */
|
||||
/* use connection direction to determine connection type */
|
||||
if(pcs.actAsServer)
|
||||
{
|
||||
/* incoming connection */
|
||||
/* use own type to set connectState */
|
||||
type = mPeerMgr->getHiddenType(AuthSSL::getAuthSSL()->OwnId());
|
||||
switch (type) {
|
||||
case RS_HIDDEN_TYPE_TOR:
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TOR;
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_I2P:
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_I2P;
|
||||
break;
|
||||
default:
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* outgoing connection */
|
||||
/* use peer hidden type to set connectState */
|
||||
switch (ps.hiddenType) {
|
||||
case RS_HIDDEN_TYPE_TOR:
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TOR;
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_I2P:
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_I2P;
|
||||
break;
|
||||
default:
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ps.hiddenType & RS_HIDDEN_TYPE_MASK)
|
||||
{
|
||||
/* hidden peer */
|
||||
/* use hidden type to set connectState */
|
||||
switch (ps.hiddenType) {
|
||||
case RS_HIDDEN_TYPE_TOR:
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TOR;
|
||||
break;
|
||||
case RS_HIDDEN_TYPE_I2P:
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_I2P;
|
||||
break;
|
||||
default:
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* peer and we are normal nodes */
|
||||
/* use normal detection to set connectState */
|
||||
if (pcs.connecttype == RS_NET_CONN_TCP_ALL)
|
||||
{
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TCP;
|
||||
}
|
||||
else if (pcs.connecttype == RS_NET_CONN_UDP_ALL)
|
||||
{
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UDP;
|
||||
}
|
||||
else
|
||||
{
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
d.wasDeniedConnection = pcs.wasDeniedConnection;
|
||||
@ -457,13 +518,13 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3Peers::isProxyAddress(const sockaddr_storage& addr)
|
||||
bool p3Peers::isProxyAddress(const uint32_t type, const sockaddr_storage& addr)
|
||||
{
|
||||
uint16_t port ;
|
||||
std::string string_addr;
|
||||
uint32_t status ;
|
||||
uint32_t status ;
|
||||
|
||||
if(!getProxyServer(string_addr, port, status))
|
||||
if(!getProxyServer(type, string_addr, port, status))
|
||||
return false ;
|
||||
|
||||
return sockaddr_storage_iptostring(addr)==string_addr && sockaddr_storage_port(addr)==port ;
|
||||
@ -923,21 +984,21 @@ bool p3Peers::setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht)
|
||||
return mPeerMgr->setVisState(id, vs_disc, vs_dht);
|
||||
}
|
||||
|
||||
bool p3Peers::getProxyServer(std::string &addr, uint16_t &port, uint32_t &status)
|
||||
bool p3Peers::getProxyServer(const uint32_t type, std::string &addr, uint16_t &port, uint32_t &status)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getProxyServer()" << std::endl;
|
||||
#endif
|
||||
|
||||
struct sockaddr_storage proxy_addr;
|
||||
mPeerMgr->getProxyServerAddress(proxy_addr);
|
||||
mPeerMgr->getProxyServerAddress(type, proxy_addr);
|
||||
addr = sockaddr_storage_iptostring(proxy_addr);
|
||||
port = sockaddr_storage_port(proxy_addr);
|
||||
mPeerMgr->getProxyServerStatus(status);
|
||||
mPeerMgr->getProxyServerStatus(type, status);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3Peers::setProxyServer(const std::string &addr_str, const uint16_t port)
|
||||
bool p3Peers::setProxyServer(const uint32_t type, const std::string &addr_str, const uint16_t port)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::setProxyServer() " << std::endl;
|
||||
@ -958,7 +1019,7 @@ bool p3Peers::setProxyServer(const std::string &addr_str, const uint16_t port)
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART *******************/
|
||||
{
|
||||
return mPeerMgr->setProxyServerAddress(addr);
|
||||
return mPeerMgr->setProxyServerAddress(type, addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1017,7 +1078,7 @@ bool p3Peers::GetPGPBase64StringAndCheckSum( const RsPgpId& gpg_id,
|
||||
|
||||
uint32_t crc = PGPKeyManagement::compute24bitsCRC((unsigned char *)mem_block,mem_block_size) ;
|
||||
|
||||
unsigned char tmp[3] = { (crc >> 16) & 0xff, (crc >> 8) & 0xff, crc & 0xff } ;
|
||||
unsigned char tmp[3] = { uint8_t((crc >> 16) & 0xff), uint8_t((crc >> 8) & 0xff), uint8_t(crc & 0xff) } ;
|
||||
Radix64::encode((const char *)tmp,3,gpg_base64_checksum) ;
|
||||
|
||||
delete[] mem_block ;
|
||||
@ -1107,6 +1168,7 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
|
||||
{
|
||||
pd.hiddenNodeAddress = domain;
|
||||
pd.hiddenNodePort = port;
|
||||
pd.hiddenType = mPeerMgr->hiddenDomainToHiddenType(domain);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1311,7 +1373,7 @@ RsPeerDetails::RsPeerDetails()
|
||||
hasSignedMe(false),accept_connection(false),
|
||||
state(0),localAddr(""),localPort(0),extAddr(""),extPort(0),netMode(0),vs_disc(0), vs_dht(0),
|
||||
lastConnect(0),connectState(0),connectStateString(""),connectPeriod(0),foundDHT(false),
|
||||
wasDeniedConnection(false), deniedTS(0)
|
||||
wasDeniedConnection(false), deniedTS(0), hiddenType(RS_HIDDEN_TYPE_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -94,9 +94,9 @@ virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
|
||||
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
|
||||
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
|
||||
|
||||
virtual bool getProxyServer(std::string &addr, uint16_t &port,uint32_t& status);
|
||||
virtual bool setProxyServer(const std::string &addr, const uint16_t port);
|
||||
virtual bool isProxyAddress(const sockaddr_storage&);
|
||||
virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status);
|
||||
virtual bool setProxyServer(const uint32_t type,const std::string &addr, const uint16_t port);
|
||||
virtual bool isProxyAddress(const uint32_t type,const sockaddr_storage&);
|
||||
|
||||
virtual void getIPServersList(std::list<std::string>& ip_servers) ;
|
||||
virtual void allowServerIPDetermination(bool) ;
|
||||
|
@ -1253,7 +1253,7 @@ int RsServer::StartupRetroShare()
|
||||
std::vector<std::string> plugins_directories ;
|
||||
|
||||
#ifndef WINDOWS_SYS
|
||||
plugins_directories.push_back(std::string(LIB_DIR) + "/retroshare/extensions6/") ;
|
||||
plugins_directories.push_back(std::string(PLUGIN_DIR)) ;
|
||||
#endif
|
||||
std::string extensions_dir = rsAccounts->PathBaseDirectory() + "/extensions6/" ;
|
||||
plugins_directories.push_back(extensions_dir) ;
|
||||
@ -1371,9 +1371,9 @@ int RsServer::StartupRetroShare()
|
||||
RS_SERVICE_GXS_TYPE_WIKI,
|
||||
NULL, rsInitConfig->gxs_passwd);
|
||||
|
||||
#ifdef RS_USE_WIKI
|
||||
p3Wiki *mWiki = new p3Wiki(wiki_ds, NULL, mGxsIdService);
|
||||
|
||||
// create GXS photo service
|
||||
// create GXS wiki service
|
||||
RsGxsNetService* wiki_ns = new RsGxsNetService(
|
||||
RS_SERVICE_GXS_TYPE_WIKI, wiki_ds, nxsMgr,
|
||||
mWiki, mWiki->getServiceInfo(),
|
||||
@ -1381,6 +1381,7 @@ int RsServer::StartupRetroShare()
|
||||
pgpAuxUtils);
|
||||
|
||||
mWiki->setNetworkExchangeService(wiki_ns) ;
|
||||
#endif
|
||||
|
||||
/**** Forum GXS service ****/
|
||||
|
||||
@ -1450,7 +1451,9 @@ int RsServer::StartupRetroShare()
|
||||
pqih->addService(gxsid_ns, true);
|
||||
pqih->addService(gxscircles_ns, true);
|
||||
pqih->addService(posted_ns, true);
|
||||
#ifdef RS_USE_WIKI
|
||||
pqih->addService(wiki_ns, true);
|
||||
#endif
|
||||
pqih->addService(gxsforums_ns, true);
|
||||
pqih->addService(gxschannels_ns, true);
|
||||
//pqih->addService(photo_ns, true);
|
||||
@ -1629,7 +1632,9 @@ int RsServer::StartupRetroShare()
|
||||
mConfigMgr->addConfiguration("gxschannels.cfg", gxschannels_ns);
|
||||
mConfigMgr->addConfiguration("gxscircles.cfg", gxscircles_ns);
|
||||
mConfigMgr->addConfiguration("posted.cfg", posted_ns);
|
||||
#ifdef RS_USE_WIKI
|
||||
mConfigMgr->addConfiguration("wiki.cfg", wiki_ns);
|
||||
#endif
|
||||
//mConfigMgr->addConfiguration("photo.cfg", photo_ns);
|
||||
//mConfigMgr->addConfiguration("wire.cfg", wire_ns);
|
||||
#endif
|
||||
@ -1738,7 +1743,9 @@ int RsServer::StartupRetroShare()
|
||||
// Must Set the GXS pointers before starting threads.
|
||||
rsIdentity = mGxsIdService;
|
||||
rsGxsCircles = mGxsCircles;
|
||||
#if RS_USE_WIKI
|
||||
rsWiki = mWiki;
|
||||
#endif
|
||||
rsPosted = mPosted;
|
||||
rsGxsForums = mGxsForums;
|
||||
rsGxsChannels = mGxsChannels;
|
||||
@ -1749,7 +1756,9 @@ int RsServer::StartupRetroShare()
|
||||
startServiceThread(mGxsIdService);
|
||||
startServiceThread(mGxsCircles);
|
||||
startServiceThread(mPosted);
|
||||
#if RS_USE_WIKI
|
||||
startServiceThread(mWiki);
|
||||
#endif
|
||||
startServiceThread(mGxsForums);
|
||||
startServiceThread(mGxsChannels);
|
||||
|
||||
@ -1760,7 +1769,9 @@ int RsServer::StartupRetroShare()
|
||||
startServiceThread(gxsid_ns);
|
||||
startServiceThread(gxscircles_ns);
|
||||
startServiceThread(posted_ns);
|
||||
#if RS_USE_WIKI
|
||||
startServiceThread(wiki_ns);
|
||||
#endif
|
||||
startServiceThread(gxsforums_ns);
|
||||
startServiceThread(gxschannels_ns);
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "rsloginhandler.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "rsaccounts.h"
|
||||
|
||||
#if defined(UBUNTU) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#include <gnome-keyring-1/gnome-keyring.h>
|
||||
|
||||
@ -145,8 +144,9 @@ bool RsLoginHandler::tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd
|
||||
|
||||
void *passwordData = NULL;
|
||||
UInt32 passwordLength = 0;
|
||||
const char *userId = ssl_id.c_str();
|
||||
UInt32 uidLength = strlen(ssl_id.c_str());
|
||||
std::string idtemp = ssl_id.toStdString();
|
||||
const char *userId = idtemp.c_str();
|
||||
UInt32 uidLength = strlen(userId);
|
||||
SecKeychainItemRef itemRef = NULL;
|
||||
|
||||
OSStatus status = SecKeychainFindGenericPassword (
|
||||
@ -381,8 +381,9 @@ bool RsLoginHandler::enableAutoLogin(const RsPeerId& ssl_id,const std::string& s
|
||||
|
||||
const void *password = ssl_passwd.c_str();
|
||||
UInt32 passwordLength = strlen(ssl_passwd.c_str());
|
||||
const char *userid = ssl_id.c_str();
|
||||
UInt32 uidLength = strlen(ssl_id.c_str());
|
||||
std::string idtemp = ssl_id.toStdString();
|
||||
const char *userid = idtemp.c_str();
|
||||
UInt32 uidLength = strlen(userid);
|
||||
|
||||
OSStatus status = SecKeychainAddGenericPassword (
|
||||
NULL, // default keychain
|
||||
@ -540,8 +541,9 @@ bool RsLoginHandler::clearAutoLogin(const RsPeerId& ssl_id)
|
||||
|
||||
void *passwordData = NULL;
|
||||
UInt32 passwordLength = 0;
|
||||
const char *userId = ssl_id.c_str();
|
||||
UInt32 uidLength = strlen(ssl_id.c_str());
|
||||
std::string idtemp = ssl_id.toStdString();
|
||||
const char *userId = idtemp.c_str();
|
||||
UInt32 uidLength = strlen(userId);
|
||||
SecKeychainItemRef itemRef = NULL;
|
||||
|
||||
OSStatus status = SecKeychainFindGenericPassword (
|
||||
|
@ -427,7 +427,7 @@ RsItem * RsSerialiser::deserialise(void *data, uint32_t *size)
|
||||
std::cerr << "RsSerialiser::deserialise() pkt_size: " << pkt_size << " vs *size: " << *size;
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsItem *item2 = (it->second)->deserialise(data, &pkt_size);
|
||||
//RsItem *item2 = (it->second)->deserialise(data, &pkt_size);
|
||||
|
||||
uint32_t failedtype = getRsItemId(data);
|
||||
std::cerr << "RsSerialiser::deserialise() FAILED PACKET Size: ";
|
||||
|
@ -523,9 +523,9 @@ static bool readHex(char s1,char s2,uint8_t& v)
|
||||
|
||||
static bool find_decoded_string(const std::string& in,const std::string& suspicious_string)
|
||||
{
|
||||
int ss_pointer = 0 ;
|
||||
uint32_t ss_pointer = 0 ;
|
||||
|
||||
for(int i=0;i<in.length();++i)
|
||||
for(uint32_t i=0;i<in.length();++i)
|
||||
{
|
||||
uint8_t hexv ;
|
||||
char next_char ;
|
||||
|
@ -1,36 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ..
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
RSOBJ = p3service.o p3chatservice.o p3msgservice.o \
|
||||
p3gamelauncher.o p3ranking.o p3disc.o \
|
||||
p3photoservice.o \
|
||||
p3distrib.o \
|
||||
p3status.o \
|
||||
p3Qblog.o \
|
||||
p3forums.o \
|
||||
p3channels.o \
|
||||
p3portservice.o
|
||||
|
||||
# dummy forums interface.
|
||||
# p3forums-dummy.o \
|
||||
|
||||
TESTOBJ = forum_test.o
|
||||
|
||||
TESTS = forum_test
|
||||
|
||||
all: librs tests
|
||||
|
||||
forum_test : forum_test.o
|
||||
$(CC) $(CFLAGS) -o forum_test forum_test.o $(OBJ) $(LIBS)
|
||||
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -439,8 +439,6 @@ void p3BanList::getBannedIps(std::list<BanListPeer> &lst)
|
||||
lst.clear() ;
|
||||
for(std::map<sockaddr_storage,BanListPeer>::const_iterator it(mBanSet.begin());it!=mBanSet.end();++it)
|
||||
{
|
||||
bool already_banned = false ;
|
||||
|
||||
if(!acceptedBanSet_locked(it->second))
|
||||
continue ;
|
||||
|
||||
@ -498,7 +496,7 @@ bool p3BanList::addIpRange(const sockaddr_storage &addr, int masked_bytes,uint32
|
||||
{
|
||||
RS_STACK_MUTEX(mBanMtx) ;
|
||||
|
||||
if(getBitRange(addr) > masked_bytes)
|
||||
if(getBitRange(addr) > uint32_t(masked_bytes))
|
||||
{
|
||||
std::cerr << "(EE) Input to p3BanList::addIpRange is inconsistent: ip=" << sockaddr_storage_iptostring(addr) << "/" << 32-8*masked_bytes << std::endl;
|
||||
return false ;
|
||||
@ -955,7 +953,7 @@ bool p3BanList::addBanEntry(const RsPeerId &peerId, const struct sockaddr_storag
|
||||
{
|
||||
/* see if it needs an update */
|
||||
if ((mit->second.reason != reason) ||
|
||||
(mit->second.level != level) ||
|
||||
(mit->second.level != uint32_t(level)) ||
|
||||
(mit->second.mTs < time_stamp))
|
||||
{
|
||||
/* update */
|
||||
@ -1044,7 +1042,7 @@ int p3BanList::condenseBanSources_locked()
|
||||
continue;
|
||||
}
|
||||
|
||||
int lvl = lit->second.level;
|
||||
uint32_t lvl = lit->second.level;
|
||||
if (it->first != ownId)
|
||||
{
|
||||
/* as from someone else, increment level */
|
||||
|
@ -337,7 +337,6 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelP
|
||||
|
||||
for(; mit != msgData.end(); ++mit)
|
||||
{
|
||||
RsGxsGroupId grpId = mit->first;
|
||||
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
||||
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
||||
|
||||
|
@ -199,8 +199,7 @@ bool p3GxsForums::getGroupData(const uint32_t &token, std::vector<RsGxsForumGrou
|
||||
if (item)
|
||||
{
|
||||
RsGxsForumGroup grp = item->mGroup;
|
||||
item->mGroup.mMeta = item->meta;
|
||||
grp.mMeta = item->mGroup.mMeta;
|
||||
grp.mMeta = item->meta;
|
||||
delete item;
|
||||
groups.push_back(grp);
|
||||
}
|
||||
@ -230,7 +229,6 @@ bool p3GxsForums::getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &
|
||||
|
||||
for(; mit != msgData.end(); ++mit)
|
||||
{
|
||||
RsGxsGroupId grpId = mit->first;
|
||||
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
||||
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
||||
|
||||
|
@ -187,19 +187,26 @@ void p3MsgService::processMsg(RsMsgItem *mi, bool incoming)
|
||||
msi->srcId = mi->PeerId();
|
||||
mSrcIds.insert(std::pair<uint32_t, RsMsgSrcId*>(msi->msgId, msi));
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
||||
/**** STACK UNLOCKED ***/
|
||||
}
|
||||
// If the peer is allowed to push files, then auto-download the recommended files.
|
||||
|
||||
if(rsPeers->servicePermissionFlags(mi->PeerId()) & RS_NODE_PERM_ALLOW_PUSH)
|
||||
for(std::list<RsTlvFileItem>::const_iterator it(mi->attachment.items.begin());it!=mi->attachment.items.end();++it)
|
||||
rsFiles->FileRequest((*it).name,(*it).hash,(*it).filesize,std::string(),RS_FILE_REQ_ANONYMOUS_ROUTING,std::list<RsPeerId>()) ;
|
||||
|
||||
if (incoming)
|
||||
{
|
||||
// If the peer is allowed to push files, then auto-download the recommended files.
|
||||
if(rsPeers->servicePermissionFlags(mi->PeerId()) & RS_NODE_PERM_ALLOW_PUSH)
|
||||
{
|
||||
std::list<RsPeerId> srcIds;
|
||||
srcIds.push_back(mi->PeerId());
|
||||
|
||||
for(std::list<RsTlvFileItem>::const_iterator it(mi->attachment.items.begin());it!=mi->attachment.items.end();++it)
|
||||
rsFiles->FileRequest((*it).name,(*it).hash,(*it).filesize,std::string(),RS_FILE_REQ_ANONYMOUS_ROUTING,srcIds) ;
|
||||
}
|
||||
}
|
||||
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);
|
||||
|
||||
/**** STACK UNLOCKED ***/
|
||||
}
|
||||
|
||||
bool p3MsgService::checkAndRebuildPartialMessage(RsMsgItem *ci)
|
||||
{
|
||||
// Check is the item is ending an incomplete item.
|
||||
|
@ -1,55 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ../..
|
||||
DHT_TOP_DIR = ../../../../libbitdht/src
|
||||
OPS_TOP_DIR = ../../../../openpgpsdk/src
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
TESTOBJ = fitest2.o fisavetest.o searchtest.o #ficachetest.o
|
||||
#ficachetest.o
|
||||
|
||||
TESTS = fitest2 fisavetest searchtest #ficachetest
|
||||
#ficachetest
|
||||
|
||||
ifeq ($(OS),Linux)
|
||||
TESTOBJ += fimontest.o
|
||||
TESTS += fimontest
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(OS),MacOSX)
|
||||
TESTOBJ += fimontest.o
|
||||
TESTS += fimontest
|
||||
endif
|
||||
|
||||
|
||||
all: tests
|
||||
|
||||
fitest2 : fitest2.o $(OBJ)
|
||||
$(CC) $(CFLAGS) -o fitest2 fitest2.o $(OBJ) $(LIBS)
|
||||
|
||||
fisavetest : fisavetest.o $(OBJ)
|
||||
$(CC) $(CFLAGS) -o fisavetest fisavetest.o $(OBJ) $(LIBS)
|
||||
|
||||
fimontest : fimontest.o $(OBJ)
|
||||
$(CC) $(CFLAGS) -o fimontest fimontest.o $(OBJ) $(LIBS)
|
||||
|
||||
ficachetest : ficachetest.o $(OBJ)
|
||||
$(CC) $(CFLAGS) -o ficachetest ficachetest.o $(OBJ) $(LIBS)
|
||||
|
||||
searchtest : searchtest.o $(OBJ)
|
||||
$(CC) $(CFLAGS) -o searchtest searchtest.o $(OBJ) $(LIBS)
|
||||
|
||||
clobber: rmtestfiles
|
||||
|
||||
rmtestfiles:
|
||||
$(RM) test.index
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -1,60 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ../..
|
||||
DHT_TOP_DIR = ../../../../libbitdht/src
|
||||
OPS_TOP_DIR = ../../../../openpgpsdk/src
|
||||
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
TESTOBJ = pqitestor.o ftfilemappertest.o ftfileprovidertest.o ftfilecreatortest.o ftextralisttest.o ftdataplextest.o fttransfermoduletest.o ftcrc32test.o ftcrossprovidercreatortest.o ftcontrollertest.o ftserver1test.o ftserver2test.o ftserver3test.o ftdata_dummy.o ftsearch_dummy.o
|
||||
|
||||
TESTS = ftfileprovidertest ftfilecreatortest ftextralisttest ftdataplextest fttransfermoduletest ftcrc32test ftcrossprovidercreatortest ftcontrollertest ftserver1test ftserver2test fttransfermoduletest ftserver3test
|
||||
#ftfilemappertest
|
||||
|
||||
all: tests
|
||||
|
||||
ftfilemappertest : ftfilemappertest.o
|
||||
$(CC) $(CFLAGS) -o ftfilemappertest ftfilemappertest.o $(LIBS)
|
||||
|
||||
ftcontrollertest : ftcontrollertest.o pqitestor.o
|
||||
$(CC) $(CFLAGS) -o ftcontrollertest ftcontrollertest.o pqitestor.o $(LIBS)
|
||||
|
||||
ftfilecreatortest : ftfilecreatortest.o
|
||||
$(CC) $(CFLAGS) -o ftfilecreatortest ftfilecreatortest.o $(LIBS)
|
||||
|
||||
ftcrossprovidercreatortest : ftcrossprovidercreatortest.o
|
||||
$(CC) $(CFLAGS) -o ftcrossprovidercreatortest ftcrossprovidercreatortest.o $(LIBS)
|
||||
|
||||
ftfileprovidertest : ftfileprovidertest.o
|
||||
$(CC) $(CFLAGS) -o ftfileprovidertest ftfileprovidertest.o $(LIBS)
|
||||
|
||||
fttransfermoduletest : fttransfermoduletest.o
|
||||
$(CC) $(CFLAGS) -o fttransfermoduletest ftdata_dummy.o ftsearch_dummy.o fttransfermoduletest.o $(LIBS)
|
||||
|
||||
ftextralisttest : ftextralisttest.o
|
||||
$(CC) $(CFLAGS) -o ftextralisttest ftextralisttest.o $(LIBS)
|
||||
|
||||
ftdataplextest : ftdataplextest.o ftsearch_dummy.o ftdata_dummy.o
|
||||
$(CC) $(CFLAGS) -o ftdataplextest ftdata_dummy.o ftdataplextest.o ftsearch_dummy.o $(LIBS)
|
||||
|
||||
ftserver1test : ftserver1test.o pqitestor.o
|
||||
$(CC) $(CFLAGS) -o ftserver1test ftserver1test.o pqitestor.o $(LIBS)
|
||||
|
||||
ftserver2test : ftserver2test.o pqitestor.o
|
||||
$(CC) $(CFLAGS) -o ftserver2test ftserver2test.o pqitestor.o $(LIBS)
|
||||
|
||||
ftserver3test : ftserver3test.o pqitestor.o
|
||||
$(CC) $(CFLAGS) -o ftserver3test ftserver3test.o pqitestor.o $(LIBS)
|
||||
|
||||
ftcrc32test : ftcrc32test.o
|
||||
$(CC) $(CFLAGS) -O0 -g -o ftcrc32test ftcrc32test.o $(LIBS)
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/rules.mk
|
||||
###############################################################
|
||||
|
||||
|
@ -1,32 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ../..
|
||||
DHT_TOP_DIR = ../../../../libbitdht/src
|
||||
OPS_TOP_DIR = ../../../../openpgpsdk/src
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
TESTOBJ = netsetup_test.o random_test.o memory_management_test.o pgpkey_test.o
|
||||
TESTS = netsetup_test random_test memory_management_test pgpkey_test
|
||||
|
||||
all: tests
|
||||
|
||||
pgpkey_test: pgpkey_test.o
|
||||
$(CC) $(CFLAGS) -o pgpkey_test pgpkey_test.o $(LIBS)
|
||||
|
||||
netsetup_test: netsetup_test.o
|
||||
$(CC) $(CFLAGS) -o netsetup_test netsetup_test.o $(LIBS)
|
||||
|
||||
random_test: random_test.o
|
||||
$(CC) $(CFLAGS) -o random_test random_test.o $(LIBS)
|
||||
|
||||
memory_management_test: memory_management_test.o
|
||||
$(CC) $(CFLAGS) -o memory_management_test memory_management_test.o $(LIBS)
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -1,39 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ../..
|
||||
DHT_TOP_DIR = ../../../../libbitdht/src
|
||||
OPS_TOP_DIR = ../../../../openpgpsdk/src
|
||||
OPENPGP_INCLUDE_DIR = ../../../../openpgpsdk/src
|
||||
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
TESTOBJ = test_pgp_handler.o test_pgp_signature_parsing.o test_key_parsing.o test_certificate.o test_identity_import.o
|
||||
TESTS = test_pgp_handler test_pgp_signature_parsing test_key_parsing test_certificate test_identity_import
|
||||
|
||||
#rsbaseitem_test
|
||||
|
||||
all: tests
|
||||
|
||||
test_certificate : test_certificate.o
|
||||
$(CC) $(CFLAGS) -o test_certificate test_certificate.o $(OBJ) $(LIBS) -L../../../../openpgpsdk/src/lib/ -lops -lbz2
|
||||
|
||||
test_identity_import : test_identity_import.o
|
||||
$(CC) $(CFLAGS) -o test_identity_import test_identity_import.o $(OBJ) $(LIBS) -L../../../../openpgpsdk/src/lib/ -lops -lbz2
|
||||
|
||||
test_pgp_handler : test_pgp_handler.o
|
||||
$(CC) $(CFLAGS) -o test_pgp_handler test_pgp_handler.o $(OBJ) $(LIBS) -L../../../../openpgpsdk/src/lib/ -lops -lbz2
|
||||
|
||||
test_pgp_signature_parsing : test_pgp_signature_parsing.o
|
||||
$(CC) $(CFLAGS) -o test_pgp_signature_parsing test_pgp_signature_parsing.o $(OBJ) $(LIBS) -L../../../../openpgpsdk/src/lib/ -lops -lbz2
|
||||
|
||||
test_key_parsing : test_key_parsing.o
|
||||
$(CC) $(CFLAGS) -o test_key_parsing test_key_parsing.o ../../../../openpgpsdk/src/lib/libops.a -lssl -lcrypto -lbz2
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -1,93 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ../..
|
||||
DHT_TOP_DIR = ../../../../libbitdht/src/
|
||||
OPS_TOP_DIR = ../../../../openpgpsdk/src/
|
||||
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
# Generic Test Harnesses.
|
||||
TESTOBJ = conn_harness.o ppg_harness.o
|
||||
|
||||
TESTOBJ += pqiqos_test.o
|
||||
TESTOBJ += net_test.o dht_test.o net_test1.o netiface_test.o dht_test.o
|
||||
TESTOBJ += pkt_test.o pqiarchive_test.o pqiperson_test.o
|
||||
TESTOBJ += extaddrfinder_test.o dnsresolver_test.o pqiipset_test.o
|
||||
TESTOBJ += p3connmgr_reset_test.o p3connmgr_connect_test.o
|
||||
#conn_test.o
|
||||
|
||||
TESTS = net_test net_test1 netiface_test pqiarchive_test pqiperson_test dnsresolver_test extaddrfinder_test
|
||||
TESTS += pqiipset_test
|
||||
TESTS += pqiqos_test
|
||||
TESTS += p3connmgr_reset_test p3connmgr_connect_test
|
||||
#TESTS = p3connmgr_test1
|
||||
|
||||
MANUAL_TESTS = dht_test
|
||||
#conn_test
|
||||
|
||||
all: tests $(MANUAL_TESTS)
|
||||
|
||||
gpgme_tst: gpgme_tst.o
|
||||
$(CC) $(CFLAGS) -o gpgme_tst gpgme_tst.o $(LIBS)
|
||||
|
||||
xpgp_id: xpgp_id.o
|
||||
$(CC) $(CFLAGS) -o xpgp_id xpgp_id.o $(LIBS)
|
||||
|
||||
dht_test: dht_test.o
|
||||
$(CC) $(CFLAGS) -o dht_test dht_test.o $(LIBS)
|
||||
|
||||
conn_test: conn_test.o
|
||||
$(CC) $(CFLAGS) -o conn_test conn_test.o $(LIBS)
|
||||
|
||||
net_test: net_test.o
|
||||
$(CC) $(CFLAGS) -o net_test net_test.o $(LIBS)
|
||||
|
||||
net_test1: net_test1.o
|
||||
$(CC) $(CFLAGS) -o net_test1 net_test1.o $(LIBS)
|
||||
|
||||
netiface_test: netiface_test.o
|
||||
$(CC) $(CFLAGS) -o netiface_test netiface_test.o $(LIBS)
|
||||
|
||||
pqiarchive_test: pqiarchive_test.o pkt_test.o
|
||||
$(CC) $(CFLAGS) -o pqiarchive_test pkt_test.o pqiarchive_test.o $(LIBS)
|
||||
|
||||
pqiperson_test: pqiperson_test.o testconnect.o
|
||||
$(CC) $(CFLAGS) -o pqiperson_test pqiperson_test.o testconnect.o $(LIBS) -lstdc++
|
||||
|
||||
extaddrfinder_test: extaddrfinder_test.o
|
||||
$(CC) $(CFLAGS) -DEXTADDRSEARCH_DEBUG=1 -o extaddrfinder_test extaddrfinder_test.o $(LIBS)
|
||||
|
||||
pqiqos_test: pqiqos_test.o
|
||||
$(CC) $(CFLAGS) -o pqiqos_test pqiqos_test.o $(LIBS)
|
||||
|
||||
dnsresolver_test: dnsresolver_test.o
|
||||
$(CC) $(CFLAGS) -o dnsresolver_test dnsresolver_test.o $(LIBS)
|
||||
|
||||
pqiipset_test: pqiipset_test.o
|
||||
$(CC) $(CFLAGS) -o pqiipset_test pqiipset_test.o $(LIBS)
|
||||
|
||||
p3connmgr_reset_test: p3connmgr_reset_test.o
|
||||
$(CC) $(CFLAGS) -o p3connmgr_reset_test p3connmgr_reset_test.o $(LIBS)
|
||||
|
||||
p3connmgr_connect_test: p3connmgr_connect_test.o conn_harness.o ppg_harness.o
|
||||
$(CC) $(CFLAGS) -o p3connmgr_connect_test p3connmgr_connect_test.o conn_harness.o ppg_harness.o $(LIBS)
|
||||
|
||||
|
||||
p3connmgr_test1: p3connmgr_test1.o
|
||||
$(CC) $(CFLAGS) -o p3connmgr_test1 p3connmgr_test1.o $(LIBS)
|
||||
|
||||
|
||||
|
||||
clobber: remove_extra_files
|
||||
|
||||
remove_extra_files:
|
||||
-$(RM) $(MANUAL_TESTS)
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -1,92 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ../..
|
||||
DHT_TOP_DIR = ../../../../libbitdht/src
|
||||
OPS_TOP_DIR = ../../../../openpgpsdk/src
|
||||
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
OBJ = rstlvutil.o
|
||||
|
||||
TESTOBJ = tlvbase_test.o tlvbase_test2.o rstunnelitem_test.o
|
||||
TESTOBJ += tlvitems_test.o tlvstack_test.o rsserial_test.o
|
||||
TESTOBJ += rstlvwidetest.o tlvrandom_test.o rsturtleitem_test.o
|
||||
TESTOBJ += tlvtypes_test.o support.o distribitem_test.o rsmsgitem_test.o
|
||||
TESTOBJ += rsstatusitem_test.o rsconfigitem_test.o
|
||||
TESTOBJ += rsgrouteritem_test.o $(OBJ)
|
||||
|
||||
TESTS = tlvbase_test tlvbase_test2
|
||||
#rstlvwidetest
|
||||
TESTS += tlvitems_test tlvstack_test
|
||||
#rstunnelitem_test
|
||||
TESTS += tlvrandom_test rsturtleitem_test
|
||||
#rsserial_test
|
||||
TESTS += tlvtypes_test
|
||||
#rsmsgitem_test
|
||||
#distribitem_test
|
||||
TESTS += rsstatusitem_test
|
||||
#rsconfigitem_test
|
||||
#TESTS += rsgrouteritem_test
|
||||
|
||||
#rsbaseitem_test
|
||||
|
||||
all: tests
|
||||
|
||||
tests: $(OBJ)
|
||||
|
||||
tlvbase_test : tlvbase_test.o
|
||||
$(CC) $(CFLAGS) -o tlvbase_test tlvbase_test.o $(OBJ) $(LIBS)
|
||||
|
||||
tlvbase_test2 : tlvbase_test2.o
|
||||
$(CC) $(CFLAGS) -o tlvbase_test2 tlvbase_test2.o $(OBJ) $(LIBS)
|
||||
|
||||
tlvitems_test : tlvitems_test.o
|
||||
$(CC) $(CFLAGS) -o tlvitems_test tlvitems_test.o $(OBJ) $(LIBS)
|
||||
|
||||
tlvstack_test : tlvstack_test.o
|
||||
$(CC) $(CFLAGS) -o tlvstack_test tlvstack_test.o $(OBJ) $(LIBS)
|
||||
|
||||
rsserial_test : rsserial_test.o
|
||||
$(CC) $(CFLAGS) -o rsserial_test rsserial_test.o $(OBJ) $(LIBS)
|
||||
|
||||
rsgrouteritem_test : rsgrouteritem_test.o
|
||||
$(CC) $(CFLAGS) -o rsgrouteritem_test rsgrouteritem_test.o $(OBJ) $(LIBS)
|
||||
|
||||
rsbaseitem_test : rsbaseitem_test.o
|
||||
$(CC) $(CFLAGS) -o rsbaseitem_test rsbaseitem_test.o $(OBJ) $(LIBS)
|
||||
|
||||
#rstlvwidetest : rstlvwidetest.o
|
||||
# $(CC) $(CFLAGS) -o rstlvwidetest rstlvwidetest.o $(OBJ) $(LIBS)
|
||||
|
||||
tlvrandom_test : tlvrandom_test.o
|
||||
$(CC) $(CFLAGS) -o tlvrandom_test tlvrandom_test.o $(OBJ) $(LIBS)
|
||||
|
||||
rsturtleitem_test : rsturtleitem_test.o support.o
|
||||
$(CC) $(CFLAGS) -o rsturtleitem_test rsturtleitem_test.o support.o $(OBJ) $(LIBS)
|
||||
|
||||
rstunnelitem_test : rstunnelitem_test.o support.o
|
||||
$(CC) $(CFLAGS) -o rstunnelitem_test rstunnelitem_test.o support.o $(OBJ) $(LIBS)
|
||||
|
||||
tlvtypes_test : tlvtypes_test.o
|
||||
$(CC) $(CFLAGS) -o tlvtypes_test tlvtypes_test.o $(OBJ) $(LIBS)
|
||||
|
||||
distribitem_test : distribitem_test.o support.o
|
||||
$(CC) $(CFLAGS) -o distribitem_test distribitem_test.o support.o $(OBJ) $(LIBS)
|
||||
|
||||
rsmsgitem_test : rsmsgitem_test.o support.o
|
||||
$(CC) $(CFLAGS) -o rsmsgitem_test rsmsgitem_test.o support.o $(OBJ) $(LIBS)
|
||||
|
||||
rsstatusitem_test : rsstatusitem_test.o support.o
|
||||
$(CC) $(CFLAGS) -o rsstatusitem_test rsstatusitem_test.o support.o $(OBJ) $(LIBS)
|
||||
|
||||
rsconfigitem_test : rsconfigitem_test.o
|
||||
$(CC) $(CFLAGS) -o rsconfigitem_test rsconfigitem_test.o support.o $(OBJ) $(LIBS)
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -1,33 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ../..
|
||||
DHT_TOP_DIR = ../../../../libbitdht/src
|
||||
OPS_TOP_DIR = ../../../../openpgpsdk/src
|
||||
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
|
||||
TESTOBJ = servicetest.o forumservicetest.o chatservicetest.o
|
||||
TESTOBJ += chattest.o distribtest.o
|
||||
|
||||
TESTS = chattest distribtest
|
||||
|
||||
all: tests
|
||||
|
||||
distribtest: distribtest.o servicetest.o forumservicetest.o
|
||||
$(CC) $(CFLAGS) -o distribtest distribtest.o servicetest.o \
|
||||
forumservicetest.o $(OBJ) $(LIBS)
|
||||
|
||||
chattest: chattest.o servicetest.o chatservicetest.o
|
||||
$(CC) $(CFLAGS) -o chattest chattest.o servicetest.o \
|
||||
chatservicetest.o $(OBJ) $(LIBS)
|
||||
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -1,83 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ../..
|
||||
DHT_TOP_DIR = ../../../../libbitdht/src
|
||||
OPS_TOP_DIR = ../../../../openpgpsdk/src
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
#BIOOBJ = bss_tou.o
|
||||
|
||||
#RSOBJ = tou_net.o udplayer.o udpsorter.o udptestfn.o extaddrfinder.o
|
||||
#RSOBJ += tcppacket.o tcpstream.o tou.o $(BIOOBJ)
|
||||
|
||||
OBJ = udptestfn.o
|
||||
|
||||
EXECS = udpsock_test udpsort_test udp_server test_tou
|
||||
EXECS += pair_tou stacks_tou bidir_tou timed_tou
|
||||
#pair_tou reset_tou internal_tou largefile_tou
|
||||
|
||||
TESTOBJ = udpsock_test.o udpsort_test.o udp_server.o test_tou.o
|
||||
TESTOBJ += pair_tou.o udptestfn.o
|
||||
TESTOBJ += stacks_tou.o bidir_tou.o timed_tou.o
|
||||
|
||||
#TESTOBJ += pair_tou.o reset_tou.o largefile_tou.o
|
||||
#internal_tou.o
|
||||
|
||||
TESTS = udpsock_test udpsort_test udp_server test_tou
|
||||
TESTS += stacks_tou bidir_tou timed_tou
|
||||
#TESTS += pair_tou
|
||||
# Unfortunately the design of tou has changed over time.
|
||||
# and these tests cannot be performed at the moment.
|
||||
#TESTS += reset_tou largefile_tou
|
||||
#internal_tou
|
||||
|
||||
all: tests $(EXECS)
|
||||
|
||||
udpsock_test : $(OBJ) udpsock_test.o
|
||||
$(CC) $(CFLAGS) -o udpsock_test udpsock_test.o $(OBJ) $(LIBS)
|
||||
|
||||
udpsort_test : $(OBJ) udpsort_test.o
|
||||
$(CC) $(CFLAGS) -o udpsort_test udpsort_test.o $(OBJ) $(LIBS)
|
||||
|
||||
udp_server: $(OBJ) udp_server.o
|
||||
$(CC) $(CFLAGS) -o udp_server udp_server.o $(OBJ) $(LIBS)
|
||||
|
||||
test_tou : $(OBJ) test_tou.o
|
||||
$(CC) $(CFLAGS) -o test_tou test_tou.o $(OBJ) $(LIBS)
|
||||
|
||||
pair_tou : $(OBJ) pair_tou.o
|
||||
$(CC) $(CFLAGS) -o pair_tou pair_tou.o $(OBJ) $(LIBS)
|
||||
|
||||
stacks_tou : $(OBJ) stacks_tou.o
|
||||
$(CC) $(CFLAGS) -o stacks_tou stacks_tou.o $(OBJ) $(LIBS)
|
||||
|
||||
bidir_tou : $(OBJ) bidir_tou.o
|
||||
$(CC) $(CFLAGS) -o bidir_tou bidir_tou.o $(OBJ) $(LIBS)
|
||||
|
||||
timed_tou : $(OBJ) timed_tou.o
|
||||
$(CC) $(CFLAGS) -o timed_tou timed_tou.o $(OBJ) $(LIBS)
|
||||
|
||||
reset_tou : $(OBJ) reset_tou.o
|
||||
$(CC) $(CFLAGS) -o reset_tou reset_tou.o $(OBJ) $(LIBS)
|
||||
|
||||
internal_tou : $(OBJ) internal_tou.o
|
||||
$(CC) $(CFLAGS) -o internal_tou internal_tou.o $(OBJ) $(LIBS)
|
||||
|
||||
largefile_tou : $(OBJ) largefile_tou.o
|
||||
$(CC) $(CFLAGS) -o largefile_tou largefile_tou.o $(OBJ) $(LIBS)
|
||||
|
||||
|
||||
# Extra Rule for BIOFLAGS
|
||||
.c.o:
|
||||
$(BIOCC) $(BIOCFLAGS) -c $<
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/rules.mk
|
||||
###############################################################
|
||||
|
||||
CFLAGS += -DRS_USE_BITDHT -I$(DHT_TOP_DIR)
|
||||
|
@ -1,23 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ../..
|
||||
DHT_TOP_DIR = ../../../../libbitdht/src
|
||||
OPS_TOP_DIR = ../../../../openpgpsdk/src
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
TESTOBJ =
|
||||
TESTS =
|
||||
|
||||
all: upnpforward
|
||||
|
||||
upnpforward: upnpforward.o
|
||||
$(CC) $(CFLAGS) -o upnpforward upnpforward.o $(LIBS)
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -1,31 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ../..
|
||||
DHT_TOP_DIR = ../../../../libbitdht/src
|
||||
OPS_TOP_DIR = ../../../../openpgpsdk/src
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
TESTOBJ = dirtest.o compress_test.o sha1_test.o aes_test.o dchat_decrypt.o
|
||||
TESTS = dirtest sha1_test aes_test compress_test dchat_decrypt
|
||||
|
||||
all: tests
|
||||
|
||||
sha1_test: sha1_test.o
|
||||
$(CC) $(CFLAGS) -o sha1_test sha1_test.o $(LIBS)
|
||||
compress_test: compress_test.o
|
||||
$(CC) $(CFLAGS) -o compress_test compress_test.o $(LIBS)
|
||||
dirtest: dirtest.o
|
||||
$(CC) $(CFLAGS) -o dirtest dirtest.o $(LIBS)
|
||||
dirtest: aes_test.o
|
||||
$(CC) $(CFLAGS) -o aes_test aes_test.o $(LIBS)
|
||||
dchat_decrypt: dchat_decrypt.o
|
||||
$(CC) $(CFLAGS) -o dchat_decrypt dchat_decrypt.o $(LIBS)
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/tests/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -1,23 +0,0 @@
|
||||
RS_TOP_DIR = ..
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
RSOBJ = p3turtle.o rsturtleitem.o
|
||||
|
||||
#TESTOBJ =
|
||||
|
||||
#TESTS =
|
||||
|
||||
all: librs tests
|
||||
|
||||
#tlvbase_test : tlvbase_test.o
|
||||
# $(CC) $(CFLAGS) -o tlvbase_test tlvbase_test.o $(OBJ) $(LIBS)
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -289,7 +289,11 @@ void p3turtle::locked_addDistantPeer(const TurtleFileHash&,TurtleTunnelId tid)
|
||||
unsigned char tmp[RsPeerId::SIZE_IN_BYTES] ;
|
||||
memset(tmp,0,RsPeerId::SIZE_IN_BYTES) ;
|
||||
|
||||
((uint32_t*)tmp)[0] = tid ;
|
||||
assert(sizeof(tid) == 4) ;
|
||||
|
||||
for(int i=0;i<4;++i)
|
||||
tmp[i] = uint8_t( (tid >> ((3-i)*8)) & 0xff ) ;
|
||||
|
||||
RsPeerId virtual_peer_id(tmp) ;
|
||||
|
||||
_virtual_peers[virtual_peer_id] = tid ;
|
||||
|
@ -1,28 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ..
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
EXTRA_CFLAGS += -I$(UPNPC_DIR) -DMINIUPNP_EXPORTS
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
CFLAGS += $(EXTRA_CFLAGS)
|
||||
|
||||
RSOBJ = upnphandler.o upnputil.o
|
||||
|
||||
TESTOBJ = upnptest.o
|
||||
|
||||
TESTS = upnptest
|
||||
|
||||
all: librs tests
|
||||
|
||||
upnptest: $(OBJ) upnptest.o
|
||||
$(CC) $(CFLAGS) -o upnptest $(OBJ) upnptest.o $(LIBS)
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -1,27 +0,0 @@
|
||||
|
||||
RS_TOP_DIR = ..
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
RSOBJ = rsthreads.o rsprint.o rsnet.o rsdebug.o rsdir.o rsversion.o
|
||||
|
||||
TESTOBJ = dirtest.o dir2test.o
|
||||
|
||||
TESTS = dirtest dir2test
|
||||
|
||||
all: librs tests
|
||||
|
||||
dirtest: $(OBJ) dirtest.o
|
||||
$(CC) $(CFLAGS) -o dirtest dirtest.o $(OBJ) $(LIBS)
|
||||
|
||||
dir2test: $(OBJ) dir2test.o
|
||||
$(CC) $(CFLAGS) -o dir2test dir2test.o $(OBJ) $(LIBS)
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/rules.mk
|
||||
###############################################################
|
||||
|
@ -62,25 +62,33 @@ void *solveDNSEntries(void *p)
|
||||
|
||||
if(!next_call.empty())
|
||||
{
|
||||
hostent *pHost = gethostbyname(next_call.c_str());
|
||||
in_addr in ;
|
||||
|
||||
{
|
||||
RsStackMutex mut(dnsr->_rdnsMtx) ;
|
||||
bool succeed = rsGetHostByName(next_call.c_str(),in);
|
||||
|
||||
DNSResolver::AddrInfo &info = (*dnsr->_addr_map)[next_call];
|
||||
{
|
||||
RsStackMutex mut(dnsr->_rdnsMtx) ;
|
||||
|
||||
if(pHost)
|
||||
DNSResolver::AddrInfo &info = (*dnsr->_addr_map)[next_call];
|
||||
|
||||
if(succeed)
|
||||
{
|
||||
info.state = DNSResolver::DNS_HAVE ;
|
||||
// IPv4 for the moment.
|
||||
struct sockaddr_in *addrv4p = (struct sockaddr_in *) &(info.addr);
|
||||
addrv4p->sin_family = AF_INET;
|
||||
addrv4p->sin_addr= in ;
|
||||
addrv4p->sin_port = htons(0);
|
||||
|
||||
std::cerr << "LOOKUP succeeded: " << next_call.c_str() << " => " << rs_inet_ntoa(addrv4p->sin_addr) << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.state = DNSResolver::DNS_HAVE ;
|
||||
// IPv4 for the moment.
|
||||
struct sockaddr_in *addrv4p = (struct sockaddr_in *) &(info.addr);
|
||||
addrv4p->sin_family = AF_INET;
|
||||
addrv4p->sin_addr.s_addr = *(unsigned long*) (pHost->h_addr);
|
||||
addrv4p->sin_port = htons(0);
|
||||
}
|
||||
else
|
||||
info.state = DNSResolver::DNS_LOOKUP_ERROR ;
|
||||
}
|
||||
|
||||
std::cerr << "DNSResolver: lookup error for address \"" << next_call.c_str() << "\"" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "pqi/pqinetwork.h"
|
||||
#include "util/rsstring.h"
|
||||
#include "util/rsmemory.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#include <netdb.h>
|
||||
@ -58,7 +59,6 @@ static void getPage(const std::string& server_name,std::string& page)
|
||||
int sockfd,n=0; // socket descriptor
|
||||
struct sockaddr_in serveur; // server's parameters
|
||||
memset(&serveur.sin_zero, 0, sizeof(serveur.sin_zero));
|
||||
struct hostent *hostinfo=NULL; // structure for storing the server's ip
|
||||
|
||||
char buf[1024];
|
||||
char request[1024];
|
||||
@ -78,20 +78,21 @@ static void getPage(const std::string& server_name,std::string& page)
|
||||
|
||||
// get server's ipv4 adress
|
||||
|
||||
hostinfo = gethostbyname(server_name.c_str());
|
||||
in_addr in ;
|
||||
|
||||
if (hostinfo == NULL) /* l'hôte n'existe pas */
|
||||
if(!rsGetHostByName(server_name.c_str(),in)) /* l'hôte n'existe pas */
|
||||
{
|
||||
std::cerr << "ExtAddrFinder: Unknown host " << server_name << std::endl;
|
||||
unix_close(sockfd);
|
||||
return ;
|
||||
}
|
||||
serveur.sin_addr = *(struct in_addr*) hostinfo->h_addr;
|
||||
serveur.sin_addr = in ;
|
||||
serveur.sin_port = htons(80);
|
||||
|
||||
#ifdef EXTADDRSEARCH_DEBUG
|
||||
printf("Connection attempt\n");
|
||||
#endif
|
||||
std::cerr << "ExtAddrFinder: resolved hostname " << server_name << " to " << rs_inet_ntoa(in) << std::endl;
|
||||
|
||||
if(unix_connect(sockfd,(struct sockaddr *)&serveur, sizeof(serveur)) == -1)
|
||||
{
|
||||
@ -104,12 +105,18 @@ static void getPage(const std::string& server_name,std::string& page)
|
||||
#endif
|
||||
|
||||
// envoi
|
||||
sprintf( request,
|
||||
if(snprintf( request,
|
||||
1024,
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"Host: %s:%d\r\n"
|
||||
"Connection: Close\r\n"
|
||||
"\r\n",
|
||||
server_name.c_str(), 80);
|
||||
server_name.c_str(), 80) > 1020)
|
||||
{
|
||||
std::cerr << "ExtAddrFinder: buffer overrun. The server name \"" << server_name << "\" is too long. This is quite unexpected." << std::endl;
|
||||
unix_close(sockfd);
|
||||
return ;
|
||||
}
|
||||
|
||||
if(send(sockfd,request,strlen(request),0)== -1)
|
||||
{
|
||||
|
@ -598,7 +598,7 @@ bool RetroDb::tableExists(const std::string &tableName)
|
||||
/********************** RetroCursor ************************/
|
||||
|
||||
RetroCursor::RetroCursor(sqlite3_stmt *stmt)
|
||||
: mStmt(NULL), mCount(0), mPosCounter(0) {
|
||||
: mStmt(NULL) {
|
||||
|
||||
open(stmt);
|
||||
}
|
||||
@ -635,7 +635,6 @@ bool RetroCursor::moveToFirst(){
|
||||
rc = sqlite3_step(mStmt);
|
||||
|
||||
if(rc == SQLITE_ROW){
|
||||
mPosCounter = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -673,17 +672,10 @@ bool RetroCursor::moveToLast(){
|
||||
return false;
|
||||
|
||||
}else{
|
||||
mPosCounter = mCount;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
int RetroCursor::getResultCount() const {
|
||||
|
||||
if(isOpen())
|
||||
return mCount;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
int RetroCursor::columnCount() const {
|
||||
|
||||
if(isOpen())
|
||||
@ -704,8 +696,6 @@ bool RetroCursor::close(){
|
||||
|
||||
int rc = sqlite3_finalize(mStmt);
|
||||
mStmt = NULL;
|
||||
mPosCounter = 0;
|
||||
mCount = 0;
|
||||
|
||||
return (rc == SQLITE_OK);
|
||||
}
|
||||
@ -725,12 +715,6 @@ bool RetroCursor::open(sqlite3_stmt *stm){
|
||||
int rc = sqlite3_reset(mStmt);
|
||||
|
||||
if(rc == SQLITE_OK){
|
||||
|
||||
while((rc = sqlite3_step(mStmt)) == SQLITE_ROW)
|
||||
mCount++;
|
||||
|
||||
sqlite3_reset(mStmt);
|
||||
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
@ -753,7 +737,6 @@ bool RetroCursor::moveToNext(){
|
||||
int rc = sqlite3_step(mStmt);
|
||||
|
||||
if(rc == SQLITE_ROW){
|
||||
mPosCounter++;
|
||||
return true;
|
||||
|
||||
}else if(rc == SQLITE_DONE){ // no more results
|
||||
@ -772,16 +755,6 @@ bool RetroCursor::moveToNext(){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t RetroCursor::getPosition() const {
|
||||
|
||||
if(isOpen())
|
||||
return mPosCounter;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int32_t RetroCursor::getInt32(int columnIndex){
|
||||
return sqlite3_column_int(mStmt, columnIndex);
|
||||
}
|
||||
|
@ -239,12 +239,6 @@ public:
|
||||
*/
|
||||
bool moveToLast();
|
||||
|
||||
/*!
|
||||
* gets current position of cursor
|
||||
* @return current position of cursor
|
||||
*/
|
||||
int32_t getPosition() const;
|
||||
|
||||
/* data retrieval */
|
||||
|
||||
/*!
|
||||
@ -260,11 +254,10 @@ public:
|
||||
|
||||
/*!
|
||||
*
|
||||
* @return -1 if cursor is in error, otherwise number of rows in result
|
||||
* @return -1 if cursor is in error, otherwise number of columns in result
|
||||
*/
|
||||
int32_t getResultCount() const;
|
||||
|
||||
int32_t columnCount() const ;
|
||||
|
||||
/*!
|
||||
* Current statement is closed and discarded (finalised)
|
||||
* before actual opening occurs
|
||||
@ -274,8 +267,6 @@ public:
|
||||
bool open(sqlite3_stmt* stm);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
/*!
|
||||
* Returns the value of the requested column as a String.
|
||||
* @param columnIndex the zero-based index of the target column.
|
||||
@ -326,17 +317,8 @@ public:
|
||||
getString(columnIndex, temp);
|
||||
str = T(temp);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
sqlite3_stmt* mStmt;
|
||||
int mCount; /// number of results
|
||||
int mPosCounter;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // RSSQLITE_H
|
||||
|
@ -21,29 +21,37 @@
|
||||
//
|
||||
class RsTemporaryMemory
|
||||
{
|
||||
public:
|
||||
RsTemporaryMemory(size_t s)
|
||||
{
|
||||
_mem = (unsigned char *)malloc(s) ;
|
||||
}
|
||||
public:
|
||||
RsTemporaryMemory(size_t s)
|
||||
{
|
||||
_mem = (unsigned char *)malloc(s) ;
|
||||
|
||||
operator unsigned char *() { return _mem ; }
|
||||
if(_mem)
|
||||
_size = s ;
|
||||
else
|
||||
_size = 0 ;
|
||||
}
|
||||
|
||||
~RsTemporaryMemory()
|
||||
{
|
||||
if(_mem != NULL)
|
||||
{
|
||||
free(_mem) ;
|
||||
_mem = NULL ;
|
||||
}
|
||||
}
|
||||
operator unsigned char *() { return _mem ; }
|
||||
|
||||
private:
|
||||
unsigned char *_mem ;
|
||||
size_t size() const { return _size ; }
|
||||
|
||||
// make it noncopyable
|
||||
RsTemporaryMemory& operator=(const RsTemporaryMemory&) { return *this ;}
|
||||
RsTemporaryMemory(const RsTemporaryMemory&) {}
|
||||
~RsTemporaryMemory()
|
||||
{
|
||||
if(_mem != NULL)
|
||||
{
|
||||
free(_mem) ;
|
||||
_mem = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned char *_mem ;
|
||||
size_t _size ;
|
||||
|
||||
// make it noncopyable
|
||||
RsTemporaryMemory& operator=(const RsTemporaryMemory&) { return *this ;}
|
||||
RsTemporaryMemory(const RsTemporaryMemory&) {}
|
||||
};
|
||||
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "util/rsnet.h"
|
||||
#include "util/rsthreads.h"
|
||||
#include "util/rsstring.h"
|
||||
#include "util/rsmemory.h"
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
#else
|
||||
@ -72,6 +73,40 @@ void sockaddr_clear(struct sockaddr_in *addr)
|
||||
addr->sin_family = AF_INET;
|
||||
}
|
||||
|
||||
bool rsGetHostByName(const std::string& hostname, in_addr& returned_addr)
|
||||
{
|
||||
#if defined(WINDOWS_SYS) || defined(__APPLE__)
|
||||
hostent *result = gethostbyname(hostname.c_str()) ;
|
||||
#else
|
||||
RsTemporaryMemory mem(8192) ;
|
||||
|
||||
if(!mem)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": Cannot allocate memory!" << std::endl;
|
||||
return false; // Do something.
|
||||
}
|
||||
|
||||
int error = 0;
|
||||
struct hostent pHost;
|
||||
struct hostent *result;
|
||||
|
||||
if(gethostbyname_r(hostname.c_str(), &pHost, (char*)(unsigned char*)mem, mem.size(), &result, &error) != 0)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": cannot call gethostname_r. Internal error reported. Check buffer size." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
#endif
|
||||
if(!result)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": gethostname returned null result." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
// Use contents of result.
|
||||
|
||||
returned_addr.s_addr = *(unsigned long*) (result->h_addr);
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool isValidNet(const struct in_addr *addr)
|
||||
{
|
||||
|
@ -70,6 +70,9 @@ bool isLoopbackNet(const struct in_addr *addr);
|
||||
bool isPrivateNet(const struct in_addr *addr);
|
||||
bool isExternalNet(const struct in_addr *addr);
|
||||
|
||||
// uses a re-entrant version of gethostbyname
|
||||
bool rsGetHostByName(const std::string& hostname, in_addr& returned_addr) ;
|
||||
|
||||
std::ostream& operator<<(std::ostream& o,const struct sockaddr_in&) ;
|
||||
|
||||
/* thread-safe version of inet_ntoa */
|
||||
|
@ -7,7 +7,7 @@ DEPENDPATH += ../../libretroshare/src/ ../../retroshare-gui/src/
|
||||
INCLUDEPATH += ../../libretroshare/src/ ../../retroshare-gui/src/
|
||||
|
||||
unix {
|
||||
target.path = "$${LIB_DIR}/retroshare/extensions6"
|
||||
target.path = "$${PLUGIN_DIR}"
|
||||
INSTALLS += target
|
||||
}
|
||||
|
||||
|
@ -81,12 +81,9 @@ TRANSLATIONS += \
|
||||
lang/FeedReader_zh_CN.ts
|
||||
|
||||
linux-* {
|
||||
LIBXML2_DIR = /usr/include/libxml2
|
||||
CONFIG += link_pkgconfig
|
||||
|
||||
DEPENDPATH += $${LIBXML2_DIR}
|
||||
INCLUDEPATH += $${LIBXML2_DIR}
|
||||
|
||||
LIBS += -lcurl -lxml2 -lxslt
|
||||
PKGCONFIG *= libcurl libxml-2.0 libxslt
|
||||
}
|
||||
|
||||
win32 {
|
||||
@ -102,4 +99,3 @@ openbsd-* {
|
||||
|
||||
LIBS += -lcurl -lxml2 -lxslt
|
||||
}
|
||||
|
||||
|
@ -19,21 +19,68 @@ INCLUDEPATH += ../../retroshare-gui/src/temp/ui ../../libretroshare/src
|
||||
#################################### Windows #####################################
|
||||
|
||||
linux-* {
|
||||
INCLUDEPATH += /usr/include
|
||||
LIBS += $$system(pkg-config --libs opencv)
|
||||
CONFIG += link_pkgconfig
|
||||
|
||||
PKGCONFIG += libavcodec libavutil
|
||||
PKGCONFIG += speex speexdsp
|
||||
PKGCONFIG += opencv
|
||||
} else {
|
||||
LIBS += -lspeex -lspeexdsp -lavcodec -lavutil
|
||||
}
|
||||
|
||||
win32 {
|
||||
# ffmpeg
|
||||
QMAKE_CXXFLAGS += -D__STDC_CONSTANT_MACROS
|
||||
|
||||
LIBS_DIR = $$PWD/../../../libs
|
||||
LIBS += -L"$$LIBS_DIR/lib/opencv"
|
||||
DEPENDPATH += . $$INC_DIR
|
||||
INCLUDEPATH += . $$INC_DIR
|
||||
|
||||
OPENCV_VERSION = 249
|
||||
LIBS += -lopencv_core$$OPENCV_VERSION -lopencv_highgui$$OPENCV_VERSION -lopencv_imgproc$$OPENCV_VERSION -llibjpeg -llibtiff -llibpng -llibjasper -lIlmImf -lole32 -loleaut32 -luuid -lavicap32 -lavifil32 -lvfw32 -lz
|
||||
OPENCV_VERSION = "249"
|
||||
USE_PRECOMPILED_LIBS =
|
||||
for(lib, LIB_DIR) {
|
||||
#message(Scanning $$lib)
|
||||
exists( $$lib/opencv/libopencv_core249.a) {
|
||||
isEmpty(USE_PRECOMPILED_LIBS) {
|
||||
message(Get pre-compiled opencv 249 libraries here:)
|
||||
message($$lib)
|
||||
LIBS += -L"$$lib/opencv"
|
||||
LIBS += -lopencv_core$$OPENCV_VERSION -lopencv_highgui$$OPENCV_VERSION -lopencv_imgproc$$OPENCV_VERSION
|
||||
USE_PRECOMPILED_LIBS = 1
|
||||
}
|
||||
}
|
||||
exists( $$lib/opencv/libopencv_core.a) {
|
||||
isEmpty(USE_PRECOMPILED_LIBS) {
|
||||
message(Get pre-compiled opencv libraries here:)
|
||||
message($$lib)
|
||||
LIBS += -L"$$lib/opencv"
|
||||
LIBS += -lopencv_core -lopencv_highgui -lopencv_imgproc
|
||||
USE_PRECOMPILED_LIBS = 1
|
||||
}
|
||||
}
|
||||
exists( $$lib/libopencv_core.dll.a) {
|
||||
isEmpty(USE_PRECOMPILED_LIBS) {
|
||||
message(Get pre-compiled opencv libraries here:)
|
||||
message($$lib)
|
||||
LIBS += -L"$$lib/opencv"
|
||||
LIBS += -lopencv_core -lopencv_highgui -lopencv_imgproc
|
||||
USE_PRECOMPILED_LIBS = 1
|
||||
}
|
||||
}
|
||||
exists( $$lib/libopencv_videoio.dll.a) {
|
||||
message(videoio found in opencv libraries.)
|
||||
message($$lib)
|
||||
LIBS += -lopencv_videoio
|
||||
}
|
||||
}
|
||||
isEmpty(USE_PRECOMPILED_LIBS) {
|
||||
message(Use system opencv libraries.)
|
||||
LIBS += -lopencv_core -lopencv_highgui -lopencv_imgproc
|
||||
}
|
||||
LIBS += -lz -lole32 -loleaut32 -luuid -lvfw32 -llibjpeg -llibtiff -llibpng -llibjasper -lIlmImf
|
||||
LIBS += -lavifil32 -lavicap32 -lavcodec -lavutil -lswresample
|
||||
}
|
||||
|
||||
# ffmpeg (and libavutil: https://github.com/ffms/ffms2/issues/11)
|
||||
QMAKE_CXXFLAGS += -D__STDC_CONSTANT_MACROS
|
||||
|
||||
QMAKE_CXXFLAGS *= -Wall
|
||||
|
||||
SOURCES = VOIPPlugin.cpp \
|
||||
@ -98,5 +145,3 @@ TRANSLATIONS += \
|
||||
lang/VOIP_sv.ts \
|
||||
lang/VOIP_tr.ts \
|
||||
lang/VOIP_zh_CN.ts
|
||||
|
||||
LIBS += -lspeex -lspeexdsp -lavformat -lavcodec -lavutil
|
||||
|
@ -20,6 +20,7 @@
|
||||
****************************************************************/
|
||||
#include <retroshare/rsplugin.h>
|
||||
#include <retroshare/rsversion.h>
|
||||
#include <retroshare/rsinit.h>
|
||||
#include <retroshare-gui/RsAutoUpdatePage.h>
|
||||
#include <QTranslator>
|
||||
#include <QApplication>
|
||||
@ -90,14 +91,16 @@ VOIPPlugin::VOIPPlugin()
|
||||
mVOIPGUIHandler = new VOIPGUIHandler ;
|
||||
mVOIPNotify = new VOIPNotify ;
|
||||
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipInvitationReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedInvitation(const RsPeerId&)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipInvitationReceived(const RsPeerId&,int)),mVOIPGUIHandler,SLOT(ReceivedInvitation(const RsPeerId&,int)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipDataReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedVoipData(const RsPeerId&)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipAcceptReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedVoipAccept(const RsPeerId&)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipHangUpReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedVoipHangUp(const RsPeerId&)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipAcceptReceived(const RsPeerId&,int)),mVOIPGUIHandler,SLOT(ReceivedVoipAccept(const RsPeerId&,int)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipHangUpReceived(const RsPeerId&,int)),mVOIPGUIHandler,SLOT(ReceivedVoipHangUp(const RsPeerId&,int)),Qt::QueuedConnection) ;
|
||||
QObject::connect(mVOIPNotify,SIGNAL(voipBandwidthInfoReceived(const RsPeerId&,int)),mVOIPGUIHandler,SLOT(ReceivedVoipBandwidthInfo(const RsPeerId&,int)),Qt::QueuedConnection) ;
|
||||
|
||||
Q_INIT_RESOURCE(VOIP_images);
|
||||
Q_INIT_RESOURCE(VOIP_qss);
|
||||
|
||||
avcodec_register_all();
|
||||
}
|
||||
|
||||
void VOIPPlugin::setInterfaces(RsPlugInInterfaces &interfaces)
|
||||
@ -211,9 +214,26 @@ QTranslator* VOIPPlugin::qt_translator(QApplication */*app*/, const QString& lan
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void VOIPPlugin::qt_sound_events(SoundEvents &/*events*/) const
|
||||
void VOIPPlugin::qt_sound_events(SoundEvents &events) const
|
||||
{
|
||||
// events.addEvent(QApplication::translate("VOIP", "VOIP"), QApplication::translate("VOIP", "Incoming call"), VOIP_SOUND_INCOMING_CALL);
|
||||
QDir baseDir = QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str()) + "/sounds");
|
||||
|
||||
events.addEvent(QApplication::translate("VOIP", "VOIP")
|
||||
, QApplication::translate("VOIP", "Incoming audio call")
|
||||
, VOIP_SOUND_INCOMING_AUDIO_CALL
|
||||
, QFileInfo(baseDir, "incomingcall.wav").absoluteFilePath());
|
||||
events.addEvent(QApplication::translate("VOIP", "VOIP")
|
||||
, QApplication::translate("VOIP", "Incoming video call")
|
||||
, VOIP_SOUND_INCOMING_VIDEO_CALL
|
||||
, QFileInfo(baseDir, "incomingcall.wav").absoluteFilePath());
|
||||
events.addEvent(QApplication::translate("VOIP", "VOIP")
|
||||
, QApplication::translate("VOIP", "Outgoing audio call")
|
||||
, VOIP_SOUND_OUTGOING_AUDIO_CALL
|
||||
, QFileInfo(baseDir, "outgoingcall.wav").absoluteFilePath());
|
||||
events.addEvent(QApplication::translate("VOIP", "VOIP")
|
||||
, QApplication::translate("VOIP", "Outgoing video call")
|
||||
, VOIP_SOUND_OUTGOING_VIDEO_CALL
|
||||
, QFileInfo(baseDir, "outgoingcall.wav").absoluteFilePath());
|
||||
}
|
||||
|
||||
ToasterNotify *VOIPPlugin::qt_toasterNotify(){
|
||||
|
@ -37,6 +37,7 @@ class VOIPPlugin: public RsPlugin
|
||||
virtual ~VOIPPlugin() {}
|
||||
|
||||
virtual p3Service *p3_service() const ;
|
||||
virtual p3Config *p3_config() const { return mVOIP; }
|
||||
virtual uint16_t rs_service_id() const { return RS_SERVICE_TYPE_VOIP_PLUGIN ; }
|
||||
virtual ConfigPage *qt_config_page() const ;
|
||||
virtual QDialog *qt_about_page() const ;
|
||||
|
@ -146,12 +146,12 @@ void AudioInputConfig::togglePreview(bool b)
|
||||
if(b)
|
||||
{
|
||||
videoInput->setEchoVideoTarget(NULL) ;
|
||||
videoProcessor->setDisplayTarget(ui.videoDisplay) ;
|
||||
videoProcessor->setDisplayTarget(ui.videoDisplay) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
videoProcessor->setDisplayTarget(NULL) ;
|
||||
videoInput->setEchoVideoTarget(ui.videoDisplay) ;
|
||||
videoProcessor->setDisplayTarget(NULL) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,9 @@ void QVideoInputDevice::stop()
|
||||
}
|
||||
if(_capture_device != NULL)
|
||||
{
|
||||
cvReleaseCapture(&_capture_device) ;
|
||||
// the camera will be deinitialized automatically in VideoCapture destructor
|
||||
_capture_device->release();
|
||||
delete _capture_device ;
|
||||
_capture_device = NULL ;
|
||||
}
|
||||
}
|
||||
@ -43,9 +45,9 @@ void QVideoInputDevice::start()
|
||||
|
||||
// Initialise la capture
|
||||
static const int cam_id = 0 ;
|
||||
_capture_device = cvCaptureFromCAM(cam_id);
|
||||
_capture_device = new cv::VideoCapture(cam_id);
|
||||
|
||||
if(_capture_device == NULL)
|
||||
if(!_capture_device->isOpened())
|
||||
{
|
||||
std::cerr << "Cannot initialise camera. Something's wrong." << std::endl;
|
||||
return ;
|
||||
@ -62,35 +64,34 @@ void QVideoInputDevice::grabFrame()
|
||||
if(!_timer)
|
||||
return ;
|
||||
|
||||
IplImage *img=cvQueryFrame(_capture_device);
|
||||
|
||||
if(img == NULL)
|
||||
cv::Mat frame;
|
||||
if(!_capture_device->read(frame))
|
||||
{
|
||||
std::cerr << "(EE) Cannot capture image from camera. Something's wrong." << std::endl;
|
||||
return ;
|
||||
std::cerr << "(EE) Cannot capture image from camera. Something's wrong." << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
// get the image data
|
||||
|
||||
if(img->nChannels != 3)
|
||||
if(frame.channels() != 3)
|
||||
{
|
||||
std::cerr << "(EE) expected 3 channels. Got " << img->nChannels << std::endl;
|
||||
return ;
|
||||
std::cerr << "(EE) expected 3 channels. Got " << frame.channels() << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
// convert to RGB and copy to new buffer, because cvQueryFrame tells us to not modify the buffer
|
||||
cv::Mat img_rgb;
|
||||
cv::cvtColor(cv::Mat(img), img_rgb, CV_BGR2RGB);
|
||||
|
||||
cv::cvtColor(frame, img_rgb, CV_BGR2RGB);
|
||||
QImage image = QImage(img_rgb.data,img_rgb.cols,img_rgb.rows,QImage::Format_RGB888);
|
||||
|
||||
if(_video_processor != NULL)
|
||||
{
|
||||
_video_processor->processImage(image) ;
|
||||
_video_processor->processImage(image) ;
|
||||
|
||||
emit networkPacketReady() ;
|
||||
emit networkPacketReady() ;
|
||||
}
|
||||
if(_echo_output_device != NULL)
|
||||
_echo_output_device->showFrame(image) ;
|
||||
_echo_output_device->showFrame(image) ;
|
||||
}
|
||||
|
||||
bool QVideoInputDevice::getNextEncodedPacket(RsVOIPDataChunk& chunk)
|
||||
@ -99,14 +100,14 @@ bool QVideoInputDevice::getNextEncodedPacket(RsVOIPDataChunk& chunk)
|
||||
return false ;
|
||||
|
||||
if(_video_processor)
|
||||
return _video_processor->nextEncodedPacket(chunk) ;
|
||||
return _video_processor->nextEncodedPacket(chunk) ;
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
uint32_t QVideoInputDevice::currentBandwidth() const
|
||||
{
|
||||
return _video_processor->currentBandwidthOut() ;
|
||||
return _video_processor->currentBandwidthOut() ;
|
||||
}
|
||||
|
||||
QVideoInputDevice::~QVideoInputDevice()
|
||||
@ -117,19 +118,20 @@ QVideoInputDevice::~QVideoInputDevice()
|
||||
|
||||
|
||||
QVideoOutputDevice::QVideoOutputDevice(QWidget *parent)
|
||||
: QLabel(parent)
|
||||
: QLabel(parent)
|
||||
{
|
||||
showFrameOff() ;
|
||||
}
|
||||
|
||||
void QVideoOutputDevice::showFrameOff()
|
||||
{
|
||||
setPixmap(QPixmap(":/images/video-icon-big.png").scaled(320,256,Qt::KeepAspectRatio,Qt::SmoothTransformation)) ;
|
||||
setPixmap(QPixmap(":/images/video-icon-big.png").scaled(QSize(height()*4/3,height()),Qt::KeepAspectRatio,Qt::SmoothTransformation)) ;
|
||||
setAlignment(Qt::AlignCenter);
|
||||
}
|
||||
|
||||
void QVideoOutputDevice::showFrame(const QImage& img)
|
||||
{
|
||||
std::cerr << "img.size = " << img.width() << " x " << img.height() << std::endl;
|
||||
setPixmap(QPixmap::fromImage(img).scaled( QSize(height()*640/480,height()),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)) ;
|
||||
setPixmap(QPixmap::fromImage(img).scaled( QSize(height()*4/3,height()),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)) ;
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,12 @@
|
||||
|
||||
#include <QLabel>
|
||||
#include "interface/rsVOIP.h"
|
||||
|
||||
#include "opencv2/opencv.hpp"
|
||||
|
||||
#include "gui/VideoProcessor.h"
|
||||
|
||||
class VideoEncoder ;
|
||||
class CvCapture ;
|
||||
|
||||
// Responsible from displaying the video. The source of the video is
|
||||
// a VideoDecoder object, which uses a codec.
|
||||
@ -61,7 +63,7 @@ protected slots:
|
||||
private:
|
||||
VideoProcessor *_video_processor ;
|
||||
QTimer *_timer ;
|
||||
CvCapture *_capture_device ;
|
||||
cv::VideoCapture *_capture_device ;
|
||||
|
||||
QVideoOutputDevice *_echo_output_device ;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -20,12 +20,16 @@
|
||||
****************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gui/VOIPNotify.h"
|
||||
|
||||
//Qt
|
||||
#include <QObject>
|
||||
#include <QGraphicsEffect>
|
||||
#include <QProgressBar>
|
||||
#include <QTimer>
|
||||
//VOIP
|
||||
#include "gui/VOIPNotify.h"
|
||||
#include <gui/SpeexProcessor.h>
|
||||
#include "services/rsVOIPItems.h"
|
||||
//retroshare-gui
|
||||
#include <gui/chat/ChatWidget.h>
|
||||
#include <gui/common/RsButtonOnText.h>
|
||||
|
||||
@ -36,7 +40,10 @@ class QVideoInputDevice ;
|
||||
class QVideoOutputDevice ;
|
||||
class VideoProcessor ;
|
||||
|
||||
#define VOIP_SOUND_INCOMING_CALL "VOIP_incoming_call"
|
||||
#define VOIP_SOUND_INCOMING_AUDIO_CALL "VOIP_incoming_audio_call"
|
||||
#define VOIP_SOUND_INCOMING_VIDEO_CALL "VOIP_incoming_video_call"
|
||||
#define VOIP_SOUND_OUTGOING_AUDIO_CALL "VOIP_outgoing_audio_call"
|
||||
#define VOIP_SOUND_OUTGOING_VIDEO_CALL "VOIP_outgoing_video_call"
|
||||
|
||||
class VOIPChatWidgetHolder : public QObject, public ChatWidgetHolder
|
||||
{
|
||||
@ -52,6 +59,10 @@ public:
|
||||
void addVideoData(const RsPeerId &peer_id, QByteArray* array) ;
|
||||
void setAcceptedBandwidth(uint32_t bytes_per_sec) ;
|
||||
|
||||
void ReceivedInvitation(const RsPeerId &peer_id, int flags) ;
|
||||
void ReceivedVoipHangUp(const RsPeerId &peer_id, int flags) ;
|
||||
void ReceivedVoipAccept(const RsPeerId &peer_id, int flags) ;
|
||||
|
||||
public slots:
|
||||
void sendAudioData();
|
||||
void sendVideoData();
|
||||
@ -60,13 +71,34 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void toggleAudioListen();
|
||||
void toggleAudioListenFS();
|
||||
void toggleAudioCapture();
|
||||
void toggleAudioCaptureFS();
|
||||
void toggleVideoCapture();
|
||||
void toggleVideoCaptureFS();
|
||||
void toggleHideChatText();
|
||||
void toggleFullScreen();
|
||||
void toggleFullScreenFS();
|
||||
void hangupCall() ;
|
||||
void botMouseEnter();
|
||||
void botMouseLeave();
|
||||
void hangupCallAudio() ;
|
||||
void hangupCallVideo() ;
|
||||
void botMouseEnterTake();
|
||||
void botMouseLeaveTake();
|
||||
void botMouseEnterDecline();
|
||||
void botMouseLeaveDecline();
|
||||
void timerAudioRingTimeOut();
|
||||
void timerVideoRingTimeOut();
|
||||
|
||||
private:
|
||||
void deleteButtonMap(int flags = RS_VOIP_FLAGS_AUDIO_DATA | RS_VOIP_FLAGS_VIDEO_DATA);
|
||||
void addNewVideoButtonMap(const RsPeerId &peer_id);
|
||||
void addNewAudioButtonMap(const RsPeerId &peer_id);
|
||||
void replaceFullscreenWidget();
|
||||
void showNormalView();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
// Audio input/output
|
||||
QAudioInput* inputAudioDevice;
|
||||
QAudioOutput* outputAudioDevice;
|
||||
@ -79,18 +111,45 @@ protected:
|
||||
QVideoOutputDevice *echoVideoDevice;
|
||||
QVideoInputDevice *inputVideoDevice;
|
||||
|
||||
//For FullScreen Mode
|
||||
QFrame *fullScreenFrame;
|
||||
QVideoOutputDevice *outputVideoDeviceFS;
|
||||
QVideoOutputDevice *echoVideoDeviceFS;
|
||||
Qt::WindowFlags outputVideoDeviceFlags;
|
||||
|
||||
QWidget *videoWidget ; // pointer to call show/hide
|
||||
|
||||
VideoProcessor *videoProcessor;
|
||||
|
||||
// Additional buttons to the chat bar
|
||||
QToolButton *audioListenToggleButton ;
|
||||
QToolButton *audioListenToggleButtonFS ;
|
||||
QToolButton *audioCaptureToggleButton ;
|
||||
QToolButton *audioCaptureToggleButtonFS ;
|
||||
QToolButton *videoCaptureToggleButton ;
|
||||
QToolButton *videoCaptureToggleButtonFS ;
|
||||
QToolButton *hideChatTextToggleButton ;
|
||||
QToolButton *fullscreenToggleButton ;
|
||||
QToolButton *fullscreenToggleButtonFS ;
|
||||
QToolButton *hangupButton ;
|
||||
QToolButton *hangupButtonFS ;
|
||||
QFrame *toolBarFS;
|
||||
|
||||
typedef QMap<QString, RSButtonOnText*> button_map;
|
||||
button_map buttonMapTakeVideo;
|
||||
typedef QMap<QString, QPair<RSButtonOnText*, RSButtonOnText*> > button_map;
|
||||
button_map buttonMapTakeCall;
|
||||
|
||||
//Waiting for peer accept
|
||||
QProgressBar *pbAudioRing;
|
||||
QProgressBar *pbVideoRing;
|
||||
QTimer *timerAudioRing;
|
||||
QTimer *timerVideoRing;
|
||||
int sendAudioRingTime; //(-2 connected, -1 reseted, >=0 in progress)
|
||||
int sendVideoRingTime; //(-2 connected, -1 reseted, >=0 in progress)
|
||||
int recAudioRingTime; //(-2 connected, -1 reseted, >=0 in progress)
|
||||
int recVideoRingTime; //(-2 connected, -1 reseted, >=0 in progress)
|
||||
|
||||
//TODO, remove this when soundManager can manage multi events.
|
||||
int lastTimePlayOccurs;
|
||||
|
||||
VOIPNotify *mVOIPNotify;
|
||||
};
|
||||
|
@ -22,28 +22,89 @@
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include "VOIPGUIHandler.h"
|
||||
#include <gui/chat/ChatDialog.h>
|
||||
#include <gui/VOIPChatWidgetHolder.h>
|
||||
|
||||
#include <gui/chat/ChatDialog.h>
|
||||
#include "gui/chat/ChatWidget.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
||||
void VOIPGUIHandler::ReceivedInvitation(const RsPeerId &/*peer_id*/)
|
||||
void VOIPGUIHandler::ReceivedInvitation(const RsPeerId &peer_id, int flags)
|
||||
{
|
||||
std::cerr << "****** VOIPGUIHandler: received Invitation!" << std::endl;
|
||||
#ifdef VOIPGUIHANDLER_DEBUG
|
||||
std::cerr << "****** VOIPGUIHandler: received Invitation from peer " << peer_id.toStdString() << " with flags==" << flags << std::endl;
|
||||
#endif
|
||||
ChatDialog *di = ChatDialog::getChat(ChatId(peer_id), Settings->getChatFlags());
|
||||
if (di) {
|
||||
ChatWidget *cw = di->getChatWidget();
|
||||
if(cw) {
|
||||
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
|
||||
|
||||
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList)
|
||||
{
|
||||
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
|
||||
|
||||
if (acwh)
|
||||
acwh->ReceivedInvitation(peer_id, flags);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cerr << "VOIPGUIHandler::ReceivedInvitation() Error: received invitaion call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void VOIPGUIHandler::ReceivedVoipHangUp(const RsPeerId &/*peer_id*/)
|
||||
void VOIPGUIHandler::ReceivedVoipHangUp(const RsPeerId &peer_id, int flags)
|
||||
{
|
||||
std::cerr << "****** VOIPGUIHandler: received HangUp!" << std::endl;
|
||||
#ifdef VOIPGUIHANDLER_DEBUG
|
||||
std::cerr << "****** VOIPGUIHandler: received HangUp from peer " << peer_id.toStdString() << " with flags==" << flags << std::endl;
|
||||
#endif
|
||||
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ;
|
||||
if (di) {
|
||||
ChatWidget *cw = di->getChatWidget();
|
||||
if(cw) {
|
||||
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
|
||||
|
||||
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList)
|
||||
{
|
||||
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
|
||||
|
||||
if (acwh)
|
||||
acwh->ReceivedVoipHangUp(peer_id, flags);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cerr << "VOIPGUIHandler::ReceivedVoipHangUp() Error: Received hangup call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void VOIPGUIHandler::ReceivedVoipAccept(const RsPeerId &/*peer_id*/)
|
||||
void VOIPGUIHandler::ReceivedVoipAccept(const RsPeerId &peer_id, int flags)
|
||||
{
|
||||
std::cerr << "****** VOIPGUIHandler: received VoipAccept!" << std::endl;
|
||||
#ifdef VOIPGUIHANDLER_DEBUG
|
||||
std::cerr << "****** VOIPGUIHandler: received VoipAccept from peer " << peer_id.toStdString() << " with flags==" << flags << std::endl;
|
||||
#endif
|
||||
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ;
|
||||
if (di) {
|
||||
ChatWidget *cw = di->getChatWidget();
|
||||
if(cw) {
|
||||
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
|
||||
|
||||
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList)
|
||||
{
|
||||
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
|
||||
|
||||
if (acwh)
|
||||
acwh->ReceivedVoipAccept(peer_id, flags);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cerr << "VOIPGUIHandler::ReceivedVoipAccept() Error: Received accept call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void VOIPGUIHandler::ReceivedVoipData(const RsPeerId &peer_id)
|
||||
{
|
||||
#ifdef VOIPGUIHANDLER_DEBUG
|
||||
std::cerr << "****** VOIPGUIHandler: received VoipData from peer " << peer_id.toStdString() << std::endl;
|
||||
#endif
|
||||
std::vector<RsVOIPDataChunk> chunks ;
|
||||
|
||||
if(!rsVOIP->getIncomingData(peer_id,chunks))
|
||||
@ -72,14 +133,14 @@ void VOIPGUIHandler::ReceivedVoipData(const RsPeerId &peer_id)
|
||||
else if(chunks[chunkIndex].type == RsVOIPDataChunk::RS_VOIP_DATA_TYPE_VIDEO)
|
||||
acwh->addVideoData(peer_id, &qb);
|
||||
else
|
||||
std::cerr << "VOIPGUIHandler: Unknown data type received. type=" << chunks[chunkIndex].type << std::endl;
|
||||
std::cerr << "VOIPGUIHandler::ReceivedVoipData(): Unknown data type received. type=" << chunks[chunkIndex].type << std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cerr << "VOIPGUIHandler Error: received audio data for a chat dialog that does not stand Audio (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
std::cerr << "VOIPGUIHandler::ReceivedVoipData() Error: received data for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
}
|
||||
|
||||
for(unsigned int chunkIndex=0; chunkIndex<chunks.size(); chunkIndex++){
|
||||
@ -89,34 +150,40 @@ void VOIPGUIHandler::ReceivedVoipData(const RsPeerId &peer_id)
|
||||
|
||||
void VOIPGUIHandler::ReceivedVoipBandwidthInfo(const RsPeerId &peer_id, int bytes_per_sec)
|
||||
{
|
||||
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ;
|
||||
|
||||
#ifdef VOIPGUIHANDLER_DEBUG
|
||||
std::cerr << "VOIPGUIHandler::received bw info for peer " << peer_id.toStdString() << ": " << bytes_per_sec << " Bps" << std::endl;
|
||||
#endif
|
||||
|
||||
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ;
|
||||
if(!di)
|
||||
{
|
||||
std::cerr << "VOIPGUIHandler Error: received bandwidth info for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
ChatWidget *cw = di->getChatWidget();
|
||||
if(!cw)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
ChatWidget *cw = di->getChatWidget();
|
||||
if(!cw)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
|
||||
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
|
||||
|
||||
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList)
|
||||
{
|
||||
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
|
||||
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList)
|
||||
{
|
||||
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
|
||||
|
||||
if (acwh)
|
||||
acwh->setAcceptedBandwidth(bytes_per_sec);
|
||||
if (acwh)
|
||||
acwh->setAcceptedBandwidth(bytes_per_sec);
|
||||
}
|
||||
} else {
|
||||
std::cerr << "VOIPGUIHandler::ReceivedVoipBandwidthInfo() Error: received bandwidth info for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void VOIPGUIHandler::AnswerAudioCall(const RsPeerId &peer_id)
|
||||
{
|
||||
#ifdef VOIPGUIHANDLER_DEBUG
|
||||
std::cerr << "VOIPGUIHandler::Answer to Audio Call for peer " << peer_id.toStdString() << std::endl;
|
||||
#endif
|
||||
|
||||
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ;
|
||||
if (di) {
|
||||
ChatWidget *cw = di->getChatWidget();
|
||||
@ -132,9 +199,8 @@ void VOIPGUIHandler::AnswerAudioCall(const RsPeerId &peer_id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cerr << "VOIPGUIHandler Error: answer audio call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
std::cerr << "VOIPGUIHandler::AnswerAudioCall() Error: answer audio call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void VOIPGUIHandler::AnswerVideoCall(const RsPeerId &peer_id)
|
||||
@ -154,7 +220,6 @@ void VOIPGUIHandler::AnswerVideoCall(const RsPeerId &peer_id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cerr << "VOIPGUIHandler Error: answer video call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
std::cerr << "VOIPGUIHandler::AnswerVideoCall() Error: answer video call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <QObject>
|
||||
/***
|
||||
#define VOIPGUIHANDLER_DEBUG 1
|
||||
***/
|
||||
|
||||
class VOIPGUIHandler: public QObject
|
||||
{
|
||||
@ -41,9 +44,9 @@ public:
|
||||
static void AnswerVideoCall(const RsPeerId &peer_id) ;
|
||||
|
||||
public slots:
|
||||
void ReceivedInvitation(const RsPeerId &peer_id) ;
|
||||
void ReceivedInvitation(const RsPeerId &peer_id, int flags) ;
|
||||
void ReceivedVoipData(const RsPeerId &peer_id) ;
|
||||
void ReceivedVoipHangUp(const RsPeerId &peer_id) ;
|
||||
void ReceivedVoipAccept(const RsPeerId &peer_id) ;
|
||||
void ReceivedVoipHangUp(const RsPeerId &peer_id, int flags) ;
|
||||
void ReceivedVoipAccept(const RsPeerId &peer_id, int flags) ;
|
||||
void ReceivedVoipBandwidthInfo(const RsPeerId &peer_id, int) ;
|
||||
};
|
||||
|
@ -23,9 +23,9 @@
|
||||
|
||||
//Call qRegisterMetaType<RsPeerId>("RsPeerId"); to enable these SIGNALs
|
||||
|
||||
void VOIPNotify::notifyReceivedVoipAccept(const RsPeerId& peer_id)
|
||||
void VOIPNotify::notifyReceivedVoipAccept(const RsPeerId& peer_id, const uint32_t flags)
|
||||
{
|
||||
emit voipAcceptReceived(peer_id) ;
|
||||
emit voipAcceptReceived(peer_id, flags) ;
|
||||
}
|
||||
void VOIPNotify::notifyReceivedVoipBandwidth(const RsPeerId &peer_id,uint32_t bytes_per_sec)
|
||||
{
|
||||
@ -35,13 +35,13 @@ void VOIPNotify::notifyReceivedVoipData(const RsPeerId &peer_id)
|
||||
{
|
||||
emit voipDataReceived(peer_id) ;
|
||||
}
|
||||
void VOIPNotify::notifyReceivedVoipHangUp(const RsPeerId &peer_id)
|
||||
void VOIPNotify::notifyReceivedVoipHangUp(const RsPeerId &peer_id, const uint32_t flags)
|
||||
{
|
||||
emit voipHangUpReceived(peer_id) ;
|
||||
emit voipHangUpReceived(peer_id, flags) ;
|
||||
}
|
||||
void VOIPNotify::notifyReceivedVoipInvite(const RsPeerId& peer_id)
|
||||
void VOIPNotify::notifyReceivedVoipInvite(const RsPeerId& peer_id, const uint32_t flags)
|
||||
{
|
||||
emit voipInvitationReceived(peer_id) ;
|
||||
emit voipInvitationReceived(peer_id, flags) ;
|
||||
}
|
||||
void VOIPNotify::notifyReceivedVoipAudioCall(const RsPeerId &peer_id)
|
||||
{
|
||||
|
@ -38,21 +38,20 @@ class VOIPNotify: public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
void notifyReceivedVoipAccept(const RsPeerId &peer_id) ;
|
||||
void notifyReceivedVoipAccept(const RsPeerId &peer_id, const uint32_t flags) ;
|
||||
void notifyReceivedVoipBandwidth(const RsPeerId &peer_id, uint32_t bytes_per_sec) ;
|
||||
void notifyReceivedVoipData(const RsPeerId &peer_id) ;
|
||||
void notifyReceivedVoipHangUp(const RsPeerId &peer_id) ;
|
||||
void notifyReceivedVoipInvite(const RsPeerId &peer_id) ;
|
||||
void notifyReceivedVoipHangUp(const RsPeerId &peer_id, const uint32_t flags) ;
|
||||
void notifyReceivedVoipInvite(const RsPeerId &peer_id, const uint32_t flags) ;
|
||||
void notifyReceivedVoipAudioCall(const RsPeerId &peer_id) ;
|
||||
void notifyReceivedVoipVideoCall(const RsPeerId &peer_id) ;
|
||||
|
||||
signals:
|
||||
void voipAcceptReceived(const RsPeerId &peer_id) ; // emitted when the peer accepts the call
|
||||
void voipAcceptReceived(const RsPeerId &peer_id, int flags) ; // emitted when the peer accepts the call
|
||||
void voipBandwidthInfoReceived(const RsPeerId &peer_id, int bytes_per_sec) ; // emitted when measured bandwidth info is received by the peer.
|
||||
void voipDataReceived(const RsPeerId &peer_id) ; // signal emitted when some voip data has been received
|
||||
void voipHangUpReceived(const RsPeerId &peer_id) ; // emitted when the peer closes the call (i.e. hangs up)
|
||||
void voipInvitationReceived(const RsPeerId &peer_id) ; // signal emitted when an invitation has been received
|
||||
|
||||
void voipHangUpReceived(const RsPeerId &peer_id, int flags) ; // emitted when the peer closes the call (i.e. hangs up)
|
||||
void voipInvitationReceived(const RsPeerId &peer_id, int flags) ; // signal emitted when an invitation has been received
|
||||
void voipAudioCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send audio
|
||||
void voipVideoCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send video
|
||||
};
|
||||
|
@ -79,7 +79,8 @@ void VOIPToasterItem::chatButtonSlot()
|
||||
hide();
|
||||
}
|
||||
|
||||
void VOIPToasterItem::voipAcceptReceived(const RsPeerId &)
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
void VOIPToasterItem::voipAcceptReceived(const RsPeerId &, int )
|
||||
{
|
||||
}
|
||||
|
||||
@ -91,11 +92,11 @@ void VOIPToasterItem::voipDataReceived(const RsPeerId &)
|
||||
{
|
||||
}
|
||||
|
||||
void VOIPToasterItem::voipHangUpReceived(const RsPeerId &)
|
||||
void VOIPToasterItem::voipHangUpReceived(const RsPeerId &, int )
|
||||
{
|
||||
}
|
||||
|
||||
void VOIPToasterItem::voipInvitationReceived(const RsPeerId &)
|
||||
void VOIPToasterItem::voipInvitationReceived(const RsPeerId &, int )
|
||||
{
|
||||
}
|
||||
|
||||
@ -106,4 +107,4 @@ void VOIPToasterItem::voipAudioCallReceived(const RsPeerId &)
|
||||
void VOIPToasterItem::voipVideoCallReceived(const RsPeerId &)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -45,13 +45,15 @@ public:
|
||||
private slots:
|
||||
void chatButtonSlot();
|
||||
|
||||
void voipAcceptReceived(const RsPeerId &peer_id) ; // emitted when the peer accepts the call
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
void voipAcceptReceived(const RsPeerId &peer_id, int flags) ; // emitted when the peer accepts the call
|
||||
void voipBandwidthInfoReceived(const RsPeerId &peer_id, int bytes_per_sec) ; // emitted when measured bandwidth info is received by the peer.
|
||||
void voipDataReceived(const RsPeerId &peer_id) ; // signal emitted when some voip data has been received
|
||||
void voipHangUpReceived(const RsPeerId &peer_id) ; // emitted when the peer closes the call (i.e. hangs up)
|
||||
void voipInvitationReceived(const RsPeerId &peer_id) ; // signal emitted when an invitation has been received
|
||||
void voipHangUpReceived(const RsPeerId &peer_id, int flags) ; // emitted when the peer closes the call (i.e. hangs up)
|
||||
void voipInvitationReceived(const RsPeerId &peer_id, int flags) ; // signal emitted when an invitation has been received
|
||||
void voipAudioCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send audio
|
||||
void voipVideoCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send video
|
||||
#endif
|
||||
|
||||
private:
|
||||
RsPeerId mPeerId;
|
||||
|
@ -36,11 +36,11 @@ VOIPToasterNotify::VOIPToasterNotify(RsVOIP *VOIP, VOIPNotify *notify, QObject *
|
||||
mMutex = new QMutex();
|
||||
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
connect(mVOIPNotify, SIGNAL(voipAcceptReceived(const RsPeerId&)), this, SLOT(voipAcceptReceived(const RsPeerId&)), Qt::QueuedConnection);
|
||||
connect(mVOIPNotify, SIGNAL(voipAcceptReceived(const RsPeerId&, int)), this, SLOT(voipAcceptReceived(const RsPeerId&, int)), Qt::QueuedConnection);
|
||||
connect(mVOIPNotify, SIGNAL(voipBandwidthInfoReceived(const RsPeerId&, int)), this, SLOT(voipBandwidthInfoReceived(RsPeerId&, int)), Qt::QueuedConnection);
|
||||
connect(mVOIPNotify, SIGNAL(voipDataReceived(const RsPeerId&)), this, SLOT(voipDataReceived(const RsPeerId&)), Qt::QueuedConnection);
|
||||
connect(mVOIPNotify, SIGNAL(voipHangUpReceived(const RsPeerId&)), this, SLOT(voipHangUpReceived(const RsPeerId&)), Qt::QueuedConnection);
|
||||
connect(mVOIPNotify, SIGNAL(voipInvitationReceived(const RsPeerId&)), this, SLOT(voipInvitationReceived(const RsPeerId&)), Qt::QueuedConnection);
|
||||
connect(mVOIPNotify, SIGNAL(voipHangUpReceived(const RsPeerId&, int)), this, SLOT(voipHangUpReceived(const RsPeerId&, int)), Qt::QueuedConnection);
|
||||
connect(mVOIPNotify, SIGNAL(voipInvitationReceived(const RsPeerId&, int)), this, SLOT(voipInvitationReceived(const RsPeerId&, int)), Qt::QueuedConnection);
|
||||
#endif
|
||||
connect(mVOIPNotify, SIGNAL(voipAudioCallReceived(const RsPeerId&)), this, SLOT(voipAudioCallReceived(const RsPeerId&)), Qt::QueuedConnection);
|
||||
connect(mVOIPNotify, SIGNAL(voipVideoCallReceived(const RsPeerId&)), this, SLOT(voipVideoCallReceived(const RsPeerId&)), Qt::QueuedConnection);
|
||||
@ -186,7 +186,7 @@ ToasterItem* VOIPToasterNotify::testToasterItem(QString tag)
|
||||
}
|
||||
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
void VOIPToasterNotify::voipAcceptReceived(const RsPeerId &peer_id)
|
||||
void VOIPToasterNotify::voipAcceptReceived(const RsPeerId &peer_id, int flags)
|
||||
{
|
||||
if (peer_id.isNull()) {
|
||||
return;
|
||||
@ -258,7 +258,7 @@ void VOIPToasterNotify::voipDataReceived(const RsPeerId &peer_id)
|
||||
mMutex->unlock();
|
||||
}
|
||||
|
||||
void VOIPToasterNotify::voipHangUpReceived(const RsPeerId &peer_id)
|
||||
void VOIPToasterNotify::voipHangUpReceived(const RsPeerId &peer_id, int flags)
|
||||
{
|
||||
if (peer_id.isNull()) {
|
||||
return;
|
||||
@ -282,7 +282,7 @@ void VOIPToasterNotify::voipHangUpReceived(const RsPeerId &peer_id)
|
||||
mMutex->unlock();
|
||||
}
|
||||
|
||||
void VOIPToasterNotify::voipInvitationReceived(const RsPeerId &peer_id)
|
||||
void VOIPToasterNotify::voipInvitationReceived(const RsPeerId &peer_id, int flags)
|
||||
{
|
||||
if (peer_id.isNull()) {
|
||||
return;
|
||||
|
@ -60,11 +60,11 @@ public:
|
||||
|
||||
private slots:
|
||||
#ifdef VOIPTOASTERNOTIFY_ALL
|
||||
void voipAcceptReceived(const RsPeerId &peer_id) ; // emitted when the peer accepts the call
|
||||
void voipAcceptReceived(const RsPeerId &peer_id, int flags) ; // emitted when the peer accepts the call
|
||||
void voipBandwidthInfoReceived(const RsPeerId &peer_id, int bytes_per_sec) ; // emitted when measured bandwidth info is received by the peer.
|
||||
void voipDataReceived(const RsPeerId &peer_id) ; // signal emitted when some voip data has been received
|
||||
void voipHangUpReceived(const RsPeerId &peer_id) ; // emitted when the peer closes the call (i.e. hangs up)
|
||||
void voipInvitationReceived(const RsPeerId &peer_id) ; // signal emitted when an invitation has been received
|
||||
void voipHangUpReceived(const RsPeerId &peer_id, int flags) ; // emitted when the peer closes the call (i.e. hangs up)
|
||||
void voipInvitationReceived(const RsPeerId &peer_id, int flags) ; // signal emitted when an invitation has been received
|
||||
#endif
|
||||
void voipAudioCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send audio
|
||||
void voipVideoCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send video
|
||||
|
@ -12,22 +12,91 @@
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#define memalign _aligned_malloc
|
||||
#endif //MINGW
|
||||
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
||||
#include <libavutil/opt.h>
|
||||
#include <libavutil/channel_layout.h>
|
||||
#include <libavutil/common.h>
|
||||
//#include <libavutil/channel_layout.h>
|
||||
#include <libavutil/mem.h>
|
||||
#include <libavutil/imgutils.h>
|
||||
#include <libavutil/mathematics.h>
|
||||
#include <libavutil/samplefmt.h>
|
||||
//#include <libavutil/mathematics.h>
|
||||
//#include <libavutil/samplefmt.h>
|
||||
}
|
||||
//#define DEBUG_MPEG_VIDEO 1
|
||||
|
||||
#ifndef AV_INPUT_BUFFER_PADDING_SIZE
|
||||
#ifndef FF_INPUT_BUFFER_PADDING_SIZE
|
||||
#define AV_INPUT_BUFFER_PADDING_SIZE 32
|
||||
#else
|
||||
#define AV_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (LIBAVUTIL_VERSION_MAJOR < 52) || ((LIBAVUTIL_VERSION_MAJOR == 52) && (LIBAVUTIL_VERSION_MINOR < 63))
|
||||
//since https://github.com/FFmpeg/FFmpeg/commit/3532dd52c51f3d4b95f31d1b195e64a04a8aea5d
|
||||
static inline AVRational av_make_q(int num, int den)
|
||||
{
|
||||
AVRational r = { num, den };
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (LIBAVUTIL_VERSION_MAJOR < 55) || ((LIBAVUTIL_VERSION_MAJOR == 55) && (LIBAVUTIL_VERSION_MINOR < 52))
|
||||
//since https://github.com/FFmpeg/FFmpeg/commit/fd056029f45a9f6d213d9fce8165632042511d4f
|
||||
void avcodec_free_context(AVCodecContext **pavctx)
|
||||
{
|
||||
AVCodecContext *avctx = *pavctx;
|
||||
|
||||
if (!avctx)
|
||||
return;
|
||||
|
||||
avcodec_close(avctx);
|
||||
|
||||
av_freep(&avctx->extradata);
|
||||
av_freep(&avctx->subtitle_header);
|
||||
|
||||
av_freep(pavctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if (LIBAVUTIL_VERSION_MAJOR < 57) || ((LIBAVUTIL_VERSION_MAJOR == 57) && (LIBAVUTIL_VERSION_MINOR < 52))
|
||||
//Since https://github.com/FFmpeg/FFmpeg/commit/7ecc2d403ce5c7b6ea3b1f368dccefd105209c7e
|
||||
static void get_frame_defaults(AVFrame *frame)
|
||||
{
|
||||
if (frame->extended_data != frame->data)
|
||||
av_freep(&frame->extended_data);
|
||||
return;
|
||||
|
||||
frame->extended_data = NULL;
|
||||
get_frame_defaults(frame);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
AVFrame *av_frame_alloc(void)
|
||||
{
|
||||
AVFrame *frame = (AVFrame *)av_mallocz(sizeof(*frame));
|
||||
|
||||
if (!frame)
|
||||
return NULL;
|
||||
|
||||
get_frame_defaults(frame);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
void av_frame_free(AVFrame **frame)
|
||||
{
|
||||
if (!frame || !*frame)
|
||||
return;
|
||||
|
||||
av_freep(frame);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
VideoProcessor::VideoProcessor()
|
||||
:_encoded_frame_size(640,480) , vpMtx("VideoProcessor")
|
||||
{
|
||||
@ -114,7 +183,7 @@ bool VideoProcessor::processImage(const QImage& img)
|
||||
|
||||
bool VideoProcessor::nextEncodedPacket(RsVOIPDataChunk& chunk)
|
||||
{
|
||||
RS_STACK_MUTEX(vpMtx) ;
|
||||
RS_STACK_MUTEX(vpMtx) ;
|
||||
if(_encoded_out_queue.empty())
|
||||
return false ;
|
||||
|
||||
@ -164,7 +233,6 @@ void VideoProcessor::receiveEncodedData(const RsVOIPDataChunk& chunk)
|
||||
default:
|
||||
codec = NULL ;
|
||||
}
|
||||
QImage img ;
|
||||
|
||||
if(codec == NULL)
|
||||
{
|
||||
@ -190,6 +258,8 @@ void VideoProcessor::receiveEncodedData(const RsVOIPDataChunk& chunk)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
QImage img ;
|
||||
if(!codec->decodeData(chunk,img))
|
||||
{
|
||||
std::cerr << "No image decoded. Probably in the middle of something..." << std::endl;
|
||||
@ -197,7 +267,7 @@ void VideoProcessor::receiveEncodedData(const RsVOIPDataChunk& chunk)
|
||||
}
|
||||
|
||||
if(_decoded_output_device)
|
||||
_decoded_output_device->showFrame(img) ;
|
||||
_decoded_output_device->showFrame(img) ;
|
||||
}
|
||||
|
||||
void VideoProcessor::setMaximumBandwidth(uint32_t bytes_per_sec)
|
||||
@ -211,7 +281,7 @@ void VideoProcessor::setMaximumBandwidth(uint32_t bytes_per_sec)
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
JPEGVideo::JPEGVideo()
|
||||
: _encoded_ref_frame_max_distance(10),_encoded_ref_frame_count(10)
|
||||
: _encoded_ref_frame_max_distance(10),_encoded_ref_frame_count(10)
|
||||
{
|
||||
}
|
||||
|
||||
@ -266,8 +336,10 @@ bool JPEGVideo::encodeData(const QImage& image,uint32_t /* size_hint */,RsVOIPDa
|
||||
QImage encoded_frame ;
|
||||
bool differential_frame ;
|
||||
|
||||
if(_encoded_ref_frame_count++ < _encoded_ref_frame_max_distance && image.size() == _encoded_reference_frame.size())
|
||||
{
|
||||
if (_encoded_ref_frame_count++ < _encoded_ref_frame_max_distance
|
||||
&& image.size() == _encoded_reference_frame.size()
|
||||
&& image.byteCount() == _encoded_reference_frame.byteCount())
|
||||
{
|
||||
// compute difference with reference frame.
|
||||
encoded_frame = image ;
|
||||
|
||||
@ -285,7 +357,7 @@ bool JPEGVideo::encodeData(const QImage& image,uint32_t /* size_hint */,RsVOIPDa
|
||||
else
|
||||
{
|
||||
_encoded_ref_frame_count = 0 ;
|
||||
_encoded_reference_frame = image ;
|
||||
_encoded_reference_frame = image.copy() ;
|
||||
encoded_frame = image ;
|
||||
|
||||
differential_frame = false ;
|
||||
@ -317,6 +389,7 @@ bool JPEGVideo::encodeData(const QImage& image,uint32_t /* size_hint */,RsVOIPDa
|
||||
|
||||
FFmpegVideo::FFmpegVideo()
|
||||
{
|
||||
avcodec_register_all();
|
||||
// Encoding
|
||||
|
||||
encoding_codec = NULL ;
|
||||
@ -325,18 +398,22 @@ FFmpegVideo::FFmpegVideo()
|
||||
|
||||
//AVCodecID codec_id = AV_CODEC_ID_H264 ;
|
||||
//AVCodecID codec_id = AV_CODEC_ID_MPEG2VIDEO;
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 54
|
||||
CodecID codec_id = CODEC_ID_MPEG4;
|
||||
#else
|
||||
AVCodecID codec_id = AV_CODEC_ID_MPEG4;
|
||||
#endif
|
||||
|
||||
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
|
||||
|
||||
/* find the mpeg1 video encoder */
|
||||
/* find the video encoder */
|
||||
encoding_codec = avcodec_find_encoder(codec_id);
|
||||
|
||||
if (!encoding_codec) throw("AV codec not found for codec id ") ;
|
||||
if (!encoding_codec) std::cerr << "AV codec not found for codec id " << std::endl;
|
||||
if (!encoding_codec) throw std::runtime_error("AV codec not found for codec id ") ;
|
||||
|
||||
encoding_context = avcodec_alloc_context3(encoding_codec);
|
||||
|
||||
if (!encoding_context) throw std::runtime_error("AV: Could not allocate video codec encoding context");
|
||||
if (!encoding_context) std::cerr << "AV: Could not allocate video codec encoding context" << std::endl;
|
||||
if (!encoding_context) throw std::runtime_error("AV: Could not allocate video codec encoding context");
|
||||
|
||||
/* put sample parameters */
|
||||
encoding_context->bit_rate = 10*1024 ; // default bitrate is 30KB/s
|
||||
@ -354,8 +431,9 @@ FFmpegVideo::FFmpegVideo()
|
||||
encoding_context->rc_max_rate = 0;
|
||||
encoding_context->rc_buffer_size = 0;
|
||||
#endif
|
||||
encoding_context->flags |= CODEC_FLAG_PSNR;
|
||||
encoding_context->flags |= CODEC_FLAG_TRUNCATED;
|
||||
if (encoding_codec->capabilities & CODEC_CAP_TRUNCATED)
|
||||
encoding_context->flags |= CODEC_FLAG_TRUNCATED;
|
||||
encoding_context->flags |= CODEC_FLAG_PSNR;//Peak signal-to-noise ratio
|
||||
encoding_context->flags |= CODEC_CAP_PARAM_CHANGE;
|
||||
encoding_context->i_quant_factor = 0.769f;
|
||||
encoding_context->b_quant_factor = 1.4f;
|
||||
@ -376,7 +454,7 @@ FFmpegVideo::FFmpegVideo()
|
||||
encoding_context->width = 640;//176;
|
||||
encoding_context->height = 480;//144;
|
||||
/* frames per second */
|
||||
encoding_context->time_base = (AVRational){1,25};
|
||||
encoding_context->time_base = av_make_q(1, 25);
|
||||
/* emit one intra frame every ten frames
|
||||
* check frame pict_type before passing frame
|
||||
* to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
|
||||
@ -385,17 +463,30 @@ FFmpegVideo::FFmpegVideo()
|
||||
*/
|
||||
encoding_context->gop_size = 100;
|
||||
//encoding_context->max_b_frames = 1;
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 54
|
||||
encoding_context->pix_fmt = PIX_FMT_YUV420P; //context->pix_fmt = PIX_FMT_RGB24;
|
||||
if (codec_id == CODEC_ID_H264) {
|
||||
#else
|
||||
encoding_context->pix_fmt = AV_PIX_FMT_YUV420P; //context->pix_fmt = AV_PIX_FMT_RGB24;
|
||||
|
||||
if (codec_id == AV_CODEC_ID_H264)
|
||||
if (codec_id == AV_CODEC_ID_H264) {
|
||||
#endif
|
||||
av_opt_set(encoding_context->priv_data, "preset", "slow", 0);
|
||||
}
|
||||
|
||||
/* open it */
|
||||
if (avcodec_open2(encoding_context, encoding_codec, NULL) < 0)
|
||||
{
|
||||
std::cerr << "AV: Could not open codec context. Something's wrong." << std::endl;
|
||||
throw std::runtime_error( "AV: Could not open codec context. Something's wrong.");
|
||||
}
|
||||
|
||||
#if (LIBAVCODEC_VERSION_MAJOR < 57) | (LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR <3 )
|
||||
encoding_frame_buffer = avcodec_alloc_frame() ;//(AVFrame*)malloc(sizeof(AVFrame)) ;
|
||||
#else
|
||||
encoding_frame_buffer = av_frame_alloc() ;
|
||||
#endif
|
||||
|
||||
if(!encoding_frame_buffer) std::cerr << "AV: could not allocate frame buffer." << std::endl;
|
||||
if(!encoding_frame_buffer)
|
||||
throw std::runtime_error("AV: could not allocate frame buffer.") ;
|
||||
|
||||
@ -409,34 +500,47 @@ FFmpegVideo::FFmpegVideo()
|
||||
int ret = av_image_alloc(encoding_frame_buffer->data, encoding_frame_buffer->linesize,
|
||||
encoding_context->width, encoding_context->height, encoding_context->pix_fmt, 32);
|
||||
|
||||
if (ret < 0) std::cerr << "AV: Could not allocate raw picture buffer" << std::endl;
|
||||
if (ret < 0)
|
||||
throw std::runtime_error("AV: Could not allocate raw picture buffer");
|
||||
throw std::runtime_error("AV: Could not allocate raw picture buffer");
|
||||
|
||||
encoding_frame_count = 0 ;
|
||||
|
||||
// Decoding
|
||||
|
||||
decoding_codec = avcodec_find_decoder(codec_id);
|
||||
|
||||
if (!decoding_codec) std::cerr << "AV codec not found for codec id " << std::endl;
|
||||
if (!decoding_codec)
|
||||
throw("AV codec not found for codec id ") ;
|
||||
|
||||
decoding_context = avcodec_alloc_context3(decoding_codec);
|
||||
|
||||
if(!decoding_context) std::cerr << "AV: Could not allocate video codec decoding context" << std::endl;
|
||||
if(!decoding_context)
|
||||
throw std::runtime_error("AV: Could not allocate video codec decoding context");
|
||||
|
||||
decoding_context->width = encoding_context->width;
|
||||
decoding_context->height = encoding_context->height;
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 54
|
||||
decoding_context->pix_fmt = PIX_FMT_YUV420P;
|
||||
#else
|
||||
decoding_context->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||
#endif
|
||||
|
||||
if(decoding_codec->capabilities & CODEC_CAP_TRUNCATED)
|
||||
decoding_context->flags |= CODEC_FLAG_TRUNCATED; // we do not send complete frames
|
||||
decoding_context->flags |= CODEC_FLAG_TRUNCATED; // we do not send complete frames
|
||||
//we can receive truncated frames
|
||||
decoding_context->flags2 |= CODEC_FLAG2_CHUNKS;
|
||||
|
||||
if(avcodec_open2(decoding_context,decoding_codec,NULL) < 0)
|
||||
AVDictionary* dictionary = NULL;
|
||||
if(avcodec_open2(decoding_context, decoding_codec, &dictionary) < 0)
|
||||
{
|
||||
std::cerr << "AV codec open action failed! " << std::endl;
|
||||
throw("AV codec open action failed! ") ;
|
||||
}
|
||||
|
||||
decoding_frame_buffer = avcodec_alloc_frame() ;//(AVFrame*)malloc(sizeof(AVFrame)) ;
|
||||
//decoding_frame_buffer = avcodec_alloc_frame() ;//(AVFrame*)malloc(sizeof(AVFrame)) ;
|
||||
decoding_frame_buffer = av_frame_alloc() ;
|
||||
|
||||
av_init_packet(&decoding_buffer);
|
||||
decoding_buffer.data = NULL ;
|
||||
@ -445,7 +549,7 @@ FFmpegVideo::FFmpegVideo()
|
||||
//ret = av_image_alloc(decoding_frame_buffer->data, decoding_frame_buffer->linesize, decoding_context->width, decoding_context->height, decoding_context->pix_fmt, 32);
|
||||
|
||||
//if (ret < 0)
|
||||
//throw std::runtime_error("AV: Could not allocate raw picture buffer");
|
||||
//throw std::runtime_error("AV: Could not allocate raw picture buffer");
|
||||
|
||||
// debug
|
||||
#ifdef DEBUG_MPEG_VIDEO
|
||||
@ -456,14 +560,10 @@ FFmpegVideo::FFmpegVideo()
|
||||
|
||||
FFmpegVideo::~FFmpegVideo()
|
||||
{
|
||||
avcodec_close(encoding_context);
|
||||
avcodec_close(decoding_context);
|
||||
av_free(encoding_context);
|
||||
av_free(decoding_context);
|
||||
av_freep(&encoding_frame_buffer->data[0]);
|
||||
av_freep(&decoding_frame_buffer->data[0]);
|
||||
free(encoding_frame_buffer);
|
||||
free(decoding_frame_buffer);
|
||||
avcodec_free_context(&encoding_context);
|
||||
avcodec_free_context(&decoding_context);
|
||||
av_frame_free(&encoding_frame_buffer);
|
||||
av_frame_free(&decoding_frame_buffer);
|
||||
}
|
||||
|
||||
#define MAX_FFMPEG_ENCODING_BITRATE 81920
|
||||
@ -475,11 +575,11 @@ bool FFmpegVideo::encodeData(const QImage& image, uint32_t target_encoding_bitra
|
||||
#endif
|
||||
QImage input ;
|
||||
|
||||
if(target_encoding_bitrate > MAX_FFMPEG_ENCODING_BITRATE)
|
||||
{
|
||||
std::cerr << "Max encodign bitrate eexceeded. Capping to " << MAX_FFMPEG_ENCODING_BITRATE << std::endl;
|
||||
target_encoding_bitrate = MAX_FFMPEG_ENCODING_BITRATE ;
|
||||
}
|
||||
if(target_encoding_bitrate > MAX_FFMPEG_ENCODING_BITRATE)
|
||||
{
|
||||
std::cerr << "Max encodign bitrate eexceeded. Capping to " << MAX_FFMPEG_ENCODING_BITRATE << std::endl;
|
||||
target_encoding_bitrate = MAX_FFMPEG_ENCODING_BITRATE ;
|
||||
}
|
||||
//encoding_context->bit_rate = target_encoding_bitrate;
|
||||
encoding_context->rc_max_rate = target_encoding_bitrate;
|
||||
//encoding_context->bit_rate_tolerance = target_encoding_bitrate;
|
||||
@ -509,9 +609,9 @@ bool FFmpegVideo::encodeData(const QImage& image, uint32_t target_encoding_bitra
|
||||
int Y10 = (0.257 * R10) + (0.504 * G10) + (0.098 * B10) + 16 ;
|
||||
int Y11 = (0.257 * R11) + (0.504 * G11) + (0.098 * B11) + 16 ;
|
||||
|
||||
float R = 0.25*(R00+R01+R10+R11) ;
|
||||
float G = 0.25*(G00+G01+G10+G11) ;
|
||||
float B = 0.25*(B00+B01+B10+B11) ;
|
||||
float R = 0.25*(R00+R01+R10+R11) ;
|
||||
float G = 0.25*(G00+G01+G10+G11) ;
|
||||
float B = 0.25*(B00+B01+B10+B11) ;
|
||||
|
||||
int U = (0.439 * R) - (0.368 * G) - (0.071 * B) + 128 ;
|
||||
int V = -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128 ;
|
||||
@ -532,16 +632,26 @@ bool FFmpegVideo::encodeData(const QImage& image, uint32_t target_encoding_bitra
|
||||
|
||||
int got_output = 0;
|
||||
|
||||
AVFrame *frame = encoding_frame_buffer ;
|
||||
|
||||
AVPacket pkt ;
|
||||
av_init_packet(&pkt);
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 54
|
||||
pkt.size = avpicture_get_size(encoding_context->pix_fmt, encoding_context->width, encoding_context->height);
|
||||
pkt.data = (uint8_t*)av_malloc(pkt.size);
|
||||
|
||||
// do
|
||||
// {
|
||||
int ret = avcodec_encode_video(encoding_context, pkt.data, pkt.size, encoding_frame_buffer) ;
|
||||
if (ret > 0) {
|
||||
got_output = ret;
|
||||
}
|
||||
#else
|
||||
pkt.data = NULL; // packet data will be allocated by the encoder
|
||||
pkt.size = 0;
|
||||
|
||||
// do
|
||||
// {
|
||||
int ret = avcodec_encode_video2(encoding_context, &pkt, frame, &got_output) ;
|
||||
int ret = avcodec_encode_video2(encoding_context, &pkt, encoding_frame_buffer, &got_output) ;
|
||||
#endif
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -574,7 +684,7 @@ bool FFmpegVideo::encodeData(const QImage& image, uint32_t target_encoding_bitra
|
||||
#endif
|
||||
av_free_packet(&pkt);
|
||||
|
||||
return true ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -583,7 +693,7 @@ bool FFmpegVideo::encodeData(const QImage& image, uint32_t target_encoding_bitra
|
||||
voip_chunk.type = RsVOIPDataChunk::RS_VOIP_DATA_TYPE_VIDEO ;
|
||||
|
||||
std::cerr << "No output produced." << std::endl;
|
||||
return false ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
}
|
||||
@ -592,94 +702,68 @@ bool FFmpegVideo::decodeData(const RsVOIPDataChunk& chunk,QImage& image)
|
||||
{
|
||||
#ifdef DEBUG_MPEG_VIDEO
|
||||
std::cerr << "Decoding data of size " << chunk.size << std::endl;
|
||||
#endif
|
||||
unsigned char *buff ;
|
||||
|
||||
if(decoding_buffer.data != NULL)
|
||||
{
|
||||
#ifdef DEBUG_MPEG_VIDEO
|
||||
std::cerr << "Completing buffer with size " << chunk.size - HEADER_SIZE + decoding_buffer.size << ": copying existing "
|
||||
<< decoding_buffer.size << " bytes. Adding new " << chunk.size - HEADER_SIZE<< " bytes " << std::endl;
|
||||
std::cerr << "Allocating new buffer of size " << chunk.size - HEADER_SIZE << std::endl;
|
||||
#endif
|
||||
|
||||
uint32_t s = chunk.size - HEADER_SIZE + decoding_buffer.size ;
|
||||
unsigned char *tmp = (unsigned char*)memalign(16,s + FF_INPUT_BUFFER_PADDING_SIZE) ;
|
||||
memset(tmp,0,s+FF_INPUT_BUFFER_PADDING_SIZE) ;
|
||||
|
||||
memcpy(tmp,decoding_buffer.data,decoding_buffer.size) ;
|
||||
|
||||
free(decoding_buffer.data) ;
|
||||
|
||||
buff = &tmp[decoding_buffer.size] ;
|
||||
decoding_buffer.size = s ;
|
||||
decoding_buffer.data = tmp ;
|
||||
uint32_t s = chunk.size - HEADER_SIZE ;
|
||||
#if defined(__MINGW32__)
|
||||
unsigned char *tmp = (unsigned char*)_aligned_malloc(s + AV_INPUT_BUFFER_PADDING_SIZE, 16) ;
|
||||
#else
|
||||
unsigned char *tmp = (unsigned char*)memalign(16, s + AV_INPUT_BUFFER_PADDING_SIZE) ;
|
||||
#endif //MINGW
|
||||
if (tmp == NULL) {
|
||||
std::cerr << "FFmpegVideo::decodeData() Unable to allocate new buffer of size " << s << std::endl;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_MPEG_VIDEO
|
||||
std::cerr << "Allocating new buffer of size " << chunk.size - HEADER_SIZE << std::endl;
|
||||
#endif
|
||||
/* copy chunk data without header to new buffer */
|
||||
memcpy(tmp, &((unsigned char*)chunk.data)[HEADER_SIZE], s);
|
||||
|
||||
decoding_buffer.data = (unsigned char *)memalign(16,chunk.size - HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE) ;
|
||||
decoding_buffer.size = chunk.size - HEADER_SIZE ;
|
||||
memset(decoding_buffer.data,0,decoding_buffer.size + FF_INPUT_BUFFER_PADDING_SIZE) ;
|
||||
/* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
|
||||
memset(&tmp[s], 0, AV_INPUT_BUFFER_PADDING_SIZE) ;
|
||||
|
||||
buff = decoding_buffer.data ;
|
||||
}
|
||||
decoding_buffer.size = s ;
|
||||
decoding_buffer.data = tmp;
|
||||
int got_frame = 1 ;
|
||||
|
||||
memcpy(buff,&((unsigned char*)chunk.data)[HEADER_SIZE],chunk.size - HEADER_SIZE) ;
|
||||
while (decoding_buffer.size > 0 || (!decoding_buffer.data && got_frame)) {
|
||||
int len = avcodec_decode_video2(decoding_context,decoding_frame_buffer,&got_frame,&decoding_buffer) ;
|
||||
|
||||
int got_frame = 0 ;
|
||||
int len = avcodec_decode_video2(decoding_context,decoding_frame_buffer,&got_frame,&decoding_buffer) ;
|
||||
if (len < 0)
|
||||
{
|
||||
std::cerr << "Error decoding frame! Return=" << len << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
if(len < 0)
|
||||
{
|
||||
std::cerr << "Error decodign frame!" << std::endl;
|
||||
return false ;
|
||||
}
|
||||
#ifdef DEBUG_MPEG_VIDEO
|
||||
std::cerr << "Used " << len << " bytes out of " << decoding_buffer.size << ". got_frame = " << got_frame << std::endl;
|
||||
#endif
|
||||
decoding_buffer.data += len;
|
||||
decoding_buffer.size -= len;
|
||||
|
||||
if(got_frame)
|
||||
{
|
||||
image = QImage(QSize(decoding_frame_buffer->width,decoding_frame_buffer->height),QImage::Format_ARGB32) ;
|
||||
if(got_frame)
|
||||
{
|
||||
image = QImage(QSize(decoding_frame_buffer->width,decoding_frame_buffer->height),QImage::Format_ARGB32) ;
|
||||
|
||||
#ifdef DEBUG_MPEG_VIDEO
|
||||
std::cerr << "Decoded frame. Size=" << image.width() << "x" << image.height() << std::endl;
|
||||
std::cerr << "Decoded frame. Size=" << image.width() << "x" << image.height() << std::endl;
|
||||
#endif
|
||||
|
||||
for (int y = 0; y < decoding_frame_buffer->height; y++)
|
||||
for (int x = 0; x < decoding_frame_buffer->width; x++)
|
||||
{
|
||||
int Y = decoding_frame_buffer->data[0][y * decoding_frame_buffer->linesize[0] + x] ;
|
||||
int U = decoding_frame_buffer->data[1][(y/2) * decoding_frame_buffer->linesize[1] + x/2] ;
|
||||
int V = decoding_frame_buffer->data[2][(y/2) * decoding_frame_buffer->linesize[2] + x/2] ;
|
||||
for (int y = 0; y < decoding_frame_buffer->height; y++)
|
||||
for (int x = 0; x < decoding_frame_buffer->width; x++)
|
||||
{
|
||||
int Y = decoding_frame_buffer->data[0][y * decoding_frame_buffer->linesize[0] + x] ;
|
||||
int U = decoding_frame_buffer->data[1][(y/2) * decoding_frame_buffer->linesize[1] + x/2] ;
|
||||
int V = decoding_frame_buffer->data[2][(y/2) * decoding_frame_buffer->linesize[2] + x/2] ;
|
||||
|
||||
int B = std::min(255,std::max(0,(int)(1.164*(Y - 16) + 1.596*(V - 128)))) ;
|
||||
int G = std::min(255,std::max(0,(int)(1.164*(Y - 16) - 0.813*(V - 128) - 0.391*(U - 128)))) ;
|
||||
int R = std::min(255,std::max(0,(int)(1.164*(Y - 16) + 2.018*(U - 128)))) ;
|
||||
int B = std::min(255,std::max(0,(int)(1.164*(Y - 16) + 1.596*(V - 128)))) ;
|
||||
int G = std::min(255,std::max(0,(int)(1.164*(Y - 16) - 0.813*(V - 128) - 0.391*(U - 128)))) ;
|
||||
int R = std::min(255,std::max(0,(int)(1.164*(Y - 16) + 2.018*(U - 128)))) ;
|
||||
|
||||
image.setPixel(QPoint(x,y),QRgb( 0xff000000 + (R << 16) + (G << 8) + B)) ;
|
||||
}
|
||||
}
|
||||
|
||||
if(len == decoding_buffer.size)
|
||||
{
|
||||
free(decoding_buffer.data) ;
|
||||
decoding_buffer.data = NULL;
|
||||
decoding_buffer.size = 0;
|
||||
}
|
||||
else if(len != 0)
|
||||
{
|
||||
#ifdef DEBUG_MPEG_VIDEO
|
||||
std::cerr << "Moving remaining data (" << decoding_buffer.size - len << " bytes) back to 0" << std::endl;
|
||||
#endif
|
||||
|
||||
memmove(decoding_buffer.data,decoding_buffer.data+len,decoding_buffer.size - len) ;
|
||||
decoding_buffer.size -= len ;
|
||||
image.setPixel(QPoint(x,y),QRgb( 0xff000000 + (R << 16) + (G << 8) + B)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* flush the decoder */
|
||||
decoding_buffer.data = NULL;
|
||||
decoding_buffer.size = 0;
|
||||
//avcodec_decode_video2(decoding_context,decoding_frame_buffer,&got_frame,&decoding_buffer) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 9.4 KiB |
@ -51,23 +51,23 @@ class RsVOIPPongResult
|
||||
|
||||
struct RsVOIPDataChunk
|
||||
{
|
||||
typedef enum { RS_VOIP_DATA_TYPE_UNKNOWN = 0x00,
|
||||
RS_VOIP_DATA_TYPE_AUDIO = 0x01,
|
||||
RS_VOIP_DATA_TYPE_VIDEO = 0x02 } RsVOIPDataType ;
|
||||
typedef enum { RS_VOIP_DATA_TYPE_UNKNOWN = 0x00,
|
||||
RS_VOIP_DATA_TYPE_AUDIO = 0x01,
|
||||
RS_VOIP_DATA_TYPE_VIDEO = 0x02 } RsVOIPDataType ;
|
||||
|
||||
void *data ; // create/delete using malloc/free.
|
||||
uint32_t size ;
|
||||
RsVOIPDataType type ; // video or audio
|
||||
|
||||
void clear() ;
|
||||
void clear() ;
|
||||
};
|
||||
|
||||
class RsVOIP
|
||||
{
|
||||
public:
|
||||
virtual int sendVoipHangUpCall(const RsPeerId& peer_id) = 0;
|
||||
virtual int sendVoipRinging(const RsPeerId& peer_id) = 0;
|
||||
virtual int sendVoipAcceptCall(const RsPeerId& peer_id) = 0;
|
||||
virtual int sendVoipHangUpCall(const RsPeerId& peer_id, uint32_t flags) = 0;
|
||||
virtual int sendVoipRinging(const RsPeerId& peer_id, uint32_t flags) = 0;
|
||||
virtual int sendVoipAcceptCall(const RsPeerId& peer_id, uint32_t flags) = 0;
|
||||
|
||||
// Sending data. The client keeps the memory ownership and must delete it after calling this.
|
||||
virtual int sendVoipData(const RsPeerId& peer_id,const RsVOIPDataChunk& chunk) = 0;
|
||||
|
@ -219,36 +219,36 @@ void p3VOIP::sendBandwidthInfo()
|
||||
}
|
||||
}
|
||||
|
||||
int p3VOIP::sendVoipHangUpCall(const RsPeerId &peer_id)
|
||||
int p3VOIP::sendVoipHangUpCall(const RsPeerId &peer_id, uint32_t flags)
|
||||
{
|
||||
RsVOIPProtocolItem *item = new RsVOIPProtocolItem ;
|
||||
|
||||
item->protocol = RsVOIPProtocolItem::VoipProtocol_Close;
|
||||
item->flags = 0 ;
|
||||
item->flags = flags ;
|
||||
item->PeerId(peer_id) ;
|
||||
|
||||
sendItem(item) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
int p3VOIP::sendVoipAcceptCall(const RsPeerId& peer_id)
|
||||
int p3VOIP::sendVoipAcceptCall(const RsPeerId& peer_id, uint32_t flags)
|
||||
{
|
||||
RsVOIPProtocolItem *item = new RsVOIPProtocolItem ;
|
||||
|
||||
item->protocol = RsVOIPProtocolItem::VoipProtocol_Ackn ;
|
||||
item->flags = 0 ;
|
||||
item->flags = flags ;
|
||||
item->PeerId(peer_id) ;
|
||||
|
||||
sendItem(item) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
int p3VOIP::sendVoipRinging(const RsPeerId &peer_id)
|
||||
int p3VOIP::sendVoipRinging(const RsPeerId &peer_id, uint32_t flags)
|
||||
{
|
||||
RsVOIPProtocolItem *item = new RsVOIPProtocolItem ;
|
||||
|
||||
item->protocol = RsVOIPProtocolItem::VoipProtocol_Ring ;
|
||||
item->flags = 0 ;
|
||||
item->flags = flags ;
|
||||
item->PeerId(peer_id) ;
|
||||
|
||||
sendItem(item) ;
|
||||
@ -362,33 +362,31 @@ void p3VOIP::handleProtocol(RsVOIPProtocolItem *item)
|
||||
|
||||
switch(item->protocol)
|
||||
{
|
||||
case RsVOIPProtocolItem::VoipProtocol_Ring: mNotify->notifyReceivedVoipInvite(item->PeerId());
|
||||
case RsVOIPProtocolItem::VoipProtocol_Ring: mNotify->notifyReceivedVoipInvite(item->PeerId(), (uint32_t)item->flags);
|
||||
#ifdef DEBUG_VOIP
|
||||
std::cerr << "p3VOIP::handleProtocol(): Received protocol ring item." << std::endl;
|
||||
std::cerr << "p3VOIP::handleProtocol(): Received protocol ring item." << std::endl;
|
||||
#endif
|
||||
break ;
|
||||
break ;
|
||||
|
||||
case RsVOIPProtocolItem::VoipProtocol_Ackn: mNotify->notifyReceivedVoipAccept(item->PeerId());
|
||||
case RsVOIPProtocolItem::VoipProtocol_Ackn: mNotify->notifyReceivedVoipAccept(item->PeerId(), (uint32_t)item->flags);
|
||||
#ifdef DEBUG_VOIP
|
||||
std::cerr << "p3VOIP::handleProtocol(): Received protocol accept call" << std::endl;
|
||||
std::cerr << "p3VOIP::handleProtocol(): Received protocol accept call" << std::endl;
|
||||
#endif
|
||||
break ;
|
||||
break ;
|
||||
|
||||
case RsVOIPProtocolItem::VoipProtocol_Close: mNotify->notifyReceivedVoipHangUp(item->PeerId());
|
||||
case RsVOIPProtocolItem::VoipProtocol_Close: mNotify->notifyReceivedVoipHangUp(item->PeerId(), (uint32_t)item->flags);
|
||||
#ifdef DEBUG_VOIP
|
||||
std::cerr << "p3VOIP::handleProtocol(): Received protocol Close call." << std::endl;
|
||||
std::cerr << "p3VOIP::handleProtocol(): Received protocol Close call." << std::endl;
|
||||
#endif
|
||||
break ;
|
||||
break ;
|
||||
case RsVOIPProtocolItem::VoipProtocol_Bandwidth: mNotify->notifyReceivedVoipBandwidth(item->PeerId(),(uint32_t)item->flags);
|
||||
#ifdef DEBUG_VOIP
|
||||
std::cerr << "p3VOIP::handleProtocol(): Received protocol bandwidth. Value=" << item->flags << std::endl;
|
||||
std::cerr << "p3VOIP::handleProtocol(): Received protocol bandwidth. Value=" << item->flags << std::endl;
|
||||
#endif
|
||||
break ;
|
||||
break ;
|
||||
default:
|
||||
#ifdef DEBUG_VOIP
|
||||
std::cerr << "p3VOIP::handleProtocol(): Received protocol item # " << item->protocol << ": not handled yet ! Sorry" << std::endl;
|
||||
#endif
|
||||
break ;
|
||||
std::cerr << "p3VOIP::handleProtocol(): Received protocol item # " << item->protocol << ": not handled yet ! Sorry" << std::endl;
|
||||
break ;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -83,9 +83,9 @@ class p3VOIP: public RsPQIService, public RsVOIP
|
||||
//
|
||||
virtual bool getIncomingData(const RsPeerId& peer_id,std::vector<RsVOIPDataChunk>& chunks) ;
|
||||
|
||||
virtual int sendVoipHangUpCall(const RsPeerId& peer_id) ;
|
||||
virtual int sendVoipRinging(const RsPeerId& peer_id) ;
|
||||
virtual int sendVoipAcceptCall(const RsPeerId &peer_id) ;
|
||||
virtual int sendVoipHangUpCall(const RsPeerId& peer_id, uint32_t flags) ;
|
||||
virtual int sendVoipRinging(const RsPeerId& peer_id, uint32_t flags) ;
|
||||
virtual int sendVoipAcceptCall(const RsPeerId &peer_id, uint32_t flags) ;
|
||||
|
||||
/***** overloaded from p3Service *****/
|
||||
/*!
|
||||
|
@ -71,7 +71,7 @@ std::ostream& RsVOIPProtocolItem::print(std::ostream &out, uint16_t indent)
|
||||
out << "flags: " << flags << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "protocol: " << std::hex << protocol << std::dec << std::endl;
|
||||
out << "protocol: " << std::hex << (uint32_t)protocol << std::dec << std::endl;
|
||||
|
||||
printRsItemEnd(out, "RsVOIPProtocolItem", indent);
|
||||
return out;
|
||||
@ -160,7 +160,7 @@ bool RsVOIPProtocolItem::serialise(void *data, uint32_t& pktsize)
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, protocol);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, (uint32_t)protocol);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, flags);
|
||||
|
||||
if (offset != tlvsize)
|
||||
@ -300,7 +300,9 @@ RsVOIPProtocolItem::RsVOIPProtocolItem(void *data, uint32_t pktsize)
|
||||
offset += 8;
|
||||
|
||||
/* get mandatory parts first */
|
||||
ok &= getRawUInt32(data, rssize, &offset, &protocol);
|
||||
uint32_t uint_Protocol;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &uint_Protocol);
|
||||
protocol = static_cast<en_Protocol>(uint_Protocol);
|
||||
ok &= getRawUInt32(data, rssize, &offset, &flags);
|
||||
|
||||
if (offset != rssize)
|
||||
|
@ -76,8 +76,8 @@ class RsVOIPItem: public RsItem
|
||||
setPriorityLevel(QOS_PRIORITY_RS_VOIP) ;
|
||||
}
|
||||
|
||||
virtual ~RsVOIPItem() {};
|
||||
virtual void clear() {};
|
||||
virtual ~RsVOIPItem() {}
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) = 0 ;
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) = 0 ; // Isn't it better that items can serialise themselves ?
|
||||
@ -138,14 +138,13 @@ class RsVOIPBandwidthItem: public RsVOIPItem
|
||||
uint32_t bytes_per_sec ; // bandwidth in bytes per sec.
|
||||
};
|
||||
|
||||
|
||||
class RsVOIPProtocolItem: public RsVOIPItem
|
||||
{
|
||||
public:
|
||||
RsVOIPProtocolItem() :RsVOIPItem(RS_PKT_SUBTYPE_VOIP_PROTOCOL) {}
|
||||
RsVOIPProtocolItem(void *data,uint32_t size) ;
|
||||
|
||||
enum { VoipProtocol_Ring = 1, VoipProtocol_Ackn = 2, VoipProtocol_Close = 3, VoipProtocol_Bandwidth = 4 } ;
|
||||
typedef enum { VoipProtocol_Ring = 1, VoipProtocol_Ackn = 2, VoipProtocol_Close = 3, VoipProtocol_Bandwidth = 4 } en_Protocol;
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ;
|
||||
virtual uint32_t serial_size() const ;
|
||||
@ -153,7 +152,7 @@ class RsVOIPProtocolItem: public RsVOIPItem
|
||||
virtual ~RsVOIPProtocolItem() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
uint32_t protocol ;
|
||||
en_Protocol protocol ;
|
||||
uint32_t flags ;
|
||||
};
|
||||
|
||||
|
@ -165,7 +165,7 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent)
|
||||
#if QT_VERSION >= 0x040700
|
||||
ui.email_input->setPlaceholderText(tr("[Optional] Visible to your friends, and friends of friends.")) ;
|
||||
ui.node_input->setPlaceholderText(tr("[Required] Examples: Home, Laptop,...")) ;
|
||||
ui.hiddenaddr_input->setPlaceholderText(tr("[Required] Examples: xa76giaf6ifda7ri63i263.onion (obtained by you from Tor)")) ;
|
||||
ui.hiddenaddr_input->setPlaceholderText(tr("[Required] Tor/I2P address - Examples: xa76giaf6ifda7ri63i263.onion (obtained by you from Tor)")) ;
|
||||
ui.name_input->setPlaceholderText(tr("[Required] Visible to your friends, and friends of friends."));
|
||||
ui.password_input->setPlaceholderText(tr("[Required] This password protects your private PGP key."));
|
||||
ui.password_input_2->setPlaceholderText(tr("[Required] Type the same password again here."));
|
||||
@ -458,7 +458,7 @@ void GenCertDialog::genPerson()
|
||||
/* Message Dialog */
|
||||
QMessageBox::warning(this,
|
||||
tr("Invalid hidden node"),
|
||||
tr("Please enter a valid address of the form: 31769173498.onion:7800"),
|
||||
tr("Please enter a valid address of the form: 31769173498.onion:7800 or [52 characters].b32.i2p"),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user