summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2019-10-18Return unique_ptr in PlatformIDNConverter::create()Tobias Markmann
There are cases where users of this method forget to free the pointer. This is now avoided by returning a unique_ptr. Test-Information: All existing unit and integration tests, i.e. `./scons test=all` pass. Change-Id: I10a88c3361823074d81db7af8cec1bd70c409995
2019-09-03Add enhanced OpenSSL configurationTim Costen
Adds TLSOptions to the OpenSSLContext, which invokes a new private 'configure' method which allows various OpenSSL options to be set. Also add standard verification callbacks and external (via a std::function field in TLSOptions) to allow the user to specify their own method which will perform client certificate checking when a new TLS connection is accepted. Only set up the internal verifyCertCallback if the user-supplied hook is set. All callback hooks are set up in the 'configure' method, and only then if TLSOptions.verifyMode is present (i.e. not defaulted to boost::none), to preserve compatibility for users of this class (e.g. Swift) which want to use OpenSSL's own internal validation functions rather than setting the callbacks. Test-information: Used new code under development in M-Link when setting up a TLSContext, setting verify-mode=require, and set up verifyCertCallback with a local method. Making a client TLS connection which includes a client certificate results in the local verify callback being invoked. Change-Id: Idbb7279e1711fca8123f430bfca0dcfb65bc8da6
2019-01-22Don't assume that tribool has an implicit bool conversionBruce Stephens
In boost 1.68.0 the conversion is implicit, but in 1.69.0 it's explicit and we must explicitly call it. Change-Id: I24eb78be7510c89b88342d28c539cad4977f99fd
2019-01-14Add optional message to TLSErrorEdwin Mons
TLSError now takes an optional error message. OpenSSLContext has been updated to send out one, and calls to SWIFT_LOG have been removed from it for anything but setCertificateChain. OpenSSLContext::handleDataFromApplication misinterpreted the return code of SSL_write, triggering an onError in cases where more network I/O was required. Test-Information: Unit tests pass on Debian 9 Server test code no longer emits undesirable warnings to stderr on macOS 10.14. Change-Id: If0f932693361ef9738ae50d5445bfb4d3ed9b28f
2018-11-15Allow HostAddress(Port) to be used in a mapKevin Smith
Test-Information: Added unit tests Change-Id: I405d9e9c2b64c4953ca0cec8f6481b695c15e30f
2018-11-13Update one forgotten port in BoostConnectionEdwin Mons
Test-Information: Unit tests pass on Debian 9 and macOS 10.14 Change-Id: I7881249c68a294679a6a9d0f6bef65cad5034687
2018-11-09Store NATPortMapping lifetime as uint32_tEdwin Mons
The NAT-PMP RFC specifies lifetime as an unsigned, 32 bit integer, so using this internally makes sense. This also removes the need for casts in interface code. A slight bug in the NATPMPInterface implementation to remove a mapping has been addressed. Test-Information: Unit tests pass on macOS 10.13 Change-Id: I06687fd2735a8706f339f85d6c957ad7aadaaf02
2018-11-08Consistently use unsigned short for network portsEdwin Mons
Network ports are now consistently stored as unsigned shorts, apart from the options and user interface, where -1 is still used to denote the use of default ports. Test-Information: Unit tests pass on macOS 10.13 and Debian 9 On macOS: tested the UI with various proxy and manual ports, behaviour as expected. Change-Id: I7a65f40083022887aa30ed7b21eadc56d0c52be1
2018-10-01Catch numeric cast errors in BoostConnectionServerEdwin Mons
When BoostConnectionServer tries to set up a listener, it casts an int to an unsigned short, which may throw an uncaught exception if the cast fails. Test-Information: Unit tests pass on Debian 9 Test server code no longer crashes when it tries to set up a listener on an invalid port. Change-Id: If6b920e54481ce6bf174df01d14ad12eff90e3f4
2018-07-30Use std::unique_ptr to have TLS classes own the TLSContextTobias Markmann
TLSLayer and TLSConnection now own the TLSContext they use. The TLSContextFactory interface is adjusted to use std::unique_ptr. Test-Information: Builds and all tests pass on macOS with clang-7-master. Change-Id: I14e33c98b48445094f404b73ea41af0a51d2dde6
2018-07-27Autofix boost-use-to-string clang-tidy warningsKevin Smith
Done by adding --fix --fix-errors to the clang-tidy args in the Makefile Test-Information: Unit tests pass (macOS) Change-Id: I3a4df955ac3553afeb9384f23f9d8b2ef01117e2
2018-06-19Don't double-connect to IP literalsKevin Smith
Before this change, an IP literal would be attempted directly, and if that failed it would then 'resolve' the literal and try the result. Test-Information: Added a unit test verifying the bug before fixing it. Change-Id: Ic887c74152f5a4b259392dad402952b3777268b1
2018-05-07Replace boost::lambda with C++11 lambdasTobias Markmann
Test-Information: Builds on macOS 10.13.4 with clang trunk. All unit and integration tests pass. Produces fewer warnings with clang trunk (previously reported marked-unused-but-used warnings). Change-Id: I849d764537cfbc380155e87b033dc5e517b3c342
2018-05-03Replace BOOST_AUTO with C++11 auto keywordTobias Markmann
Test-Information: Code builds on macOS 10.13.4 with clang trunk. Change-Id: Ia80ef02701f93e32447a471b2398ba8a3cc29c32
2018-03-20Merge branch 'swift-4.x'swift-5.0alpha2Tobias Markmann
* swift-4.x: (44 commits) Test-Information: Builds on macOS 10.13.3 with clang trunk. Change-Id: If50381f103b0ad18d038b920d3d43537642141cb
2018-01-09Avoid crash with Connector failure race conditionKevin Smith
We were seeing crashes on macOS on a slept laptop overnight, very rarely. The backtraces pointed to accessing a deleted currentConnection in Connector. Eyeballing the code for a path that could trigger this, if the timer fires onTick, queing on the eventloop, and before that event is processed the connection queues onConnectFinished in the event loop, currentConnection will be reset by the timeout tick handling, and will then boom when the handleConnectionConnectFinished is called for onConnectFinished. Test-Information: Eyeballs Change-Id: Iaf4af1450ca8ee13761a33c0dc75f0311d2291b2
2018-01-09Add an log assertion to ConnectorsThanos Doukoudakis
This will check that the connection object is valid when a connector timeouts, and if not log it. Test-Information: None Change-Id: I0af3e88fe1f527c25c4bb6c886668d19167b489b
2017-07-13Remove Swiften/Base/Override.hTobias Markmann
Replaced SWIFTEN_OVERRIDE with C++11 standard override keyword. Test-Information: Tested on macOS 10.12.5 with clang trunk. Change-Id: If89c6cc2a648662522a320834c314496c943a55a
2017-07-11Add missing SWIFTEN_OVERRIDE statements to dtorsTobias Markmann
Also removes -Winconsistent-missing-destructor-override from the list of ignored clang warnings. Test-Information: Tested on macOS 10.12.5 with clang trunk. Change-Id: Iad951879e01eb951a2a393399f55e4e37437c6a2
2017-06-26Fix compiler warnings raise by Clang on LinuxTobias Markmann
Clang raises warnings about unused members and macros on Linux. These are fixed with this change. Test-Information: Tested with clang-3.9 on Debian Stretch. Change-Id: I87bc0606cfd14365330aaad4ed433d3bca2d5330
2017-06-26Remove unneeded forward declarations from Swiften headersTobias Markmann
Found by cppclean. Test-Information: Still builds on macOS 10.12.5 with clang trunk. Change-Id: Ie8a154e12b196587c956c8b333abf529a36f6bb3
2017-04-04Verify certificates for HTTPS BOSH connectionsTobias Markmann
Test-Information: Tested against a BOSH server with a valid HTTPS certificate and against a BOSH server with an expired HTTPS certificate. Tested on macOS 10.12.3 with Qt 5.5.1. Change-Id: I9989389b271961fc4d66db56198b32715af52ae7
2017-03-31Use std::random instead of boost::randomJoanna Hulboj
Test-Infotmation: Unit tests pass OK. Change-Id: I1b6d3711d97daa86cccbb44aecb1b4025f2fcc8a
2017-03-15Do no emit onXMPPDataRead when the session is terminatedTobias Markmann
On a bosh error BOSHSessionStream, posts an event to the event loop that closes the XMPP stream. If onXMPPDataRead is emitted, that data is handled before the close of the stream though, which can cause another BOSH request to be sent. Test-Information: Added a unit test verifying the behaviour. Wrote a custom python script replicating the original error and verified that Swift does not stay connected on a BOSH error with additional text data. Tested on macOS 10.12.3 with recent clang trunk. Change-Id: Ie90099afa0934707a6758b00706a65227ceb48b8
2017-03-13Add LogSerializer for BOSHErrorTobias Markmann
Test-Information: Tested and used it during a recent debugging session on macOS 10.12.3 with recent clang. Change-Id: Ia4883a69a94f962006a39b294d6b9b67e0990541
2017-02-27Handle boost::bad_lexical_cast exception in HostAddressPort::toString()Tobias Markmann
Test-Information: Builds and unit tests pass on macOS 10.12.3 with Qt 5.7.1. Change-Id: I258ea7a70a025bc0ebf61eea7acd636e90fc8b1e
2017-02-10Display error message in profile window if vCard request failedTobias Markmann
Also fixed an typo error in GConfProxyProvider.cpp that prevented compilation on Linux. Test-Information: Tested with an XMPP server with vCard support disabled and also with vCard support enabled. Tested profile window and profile editor window. The profile window will show cached vCard data if present and the error message. The profile editor window will only show the error message in case of an error. Tested profile window and profile editor window in a scenario where vCard support is first enabled in the server, then disabled, and finally enabled again, and opening the editors in between. Potential error messages were always correctly cleared before showing the dialog. Tested on macOS 10.12.3 with Qt 5.7.1. Change-Id: I3958c35286f6f0096d1605c29816f666530aae03
2017-02-09Update GConfProxyProvider to new string to HostAddress functionTobias Markmann
This change was missing in commit 43479ef. glib is automatically initialised nowadays and g_type_init() is a deprecated function. Surrounded the relevant code with a GLIB_CHECK_VERSION macro. Test-Information: Tested build on Ubuntu 16.04.1 LTS. Change-Id: Iea7242f6366d827b2cc6ce355cb923872f774a6c
2016-12-15Merge branch 'swift-3.x’Tobias Markmann
* swift-3.x: - Fix building Swift on 32-bit Linux distributions - Remove optional_fwd.hpp use; workaround for Boost Bug #12179 - Split COPYING.thirdparty in contributions/dependencies - Fixes for building packages on Debian Conflicts: BuildTools/SCons/SConstruct Sluift/Console.h Sluift/ITunesInterface.h Sluift/Terminal.h Swift/Packaging/Debian/debian/control.in Swift/QtUI/SConscript Swiften/Elements/Stanza.h Swiften/FileTransfer/FileTransferTransporter.h Swiften/FileTransfer/IBBReceiveSession.h Swiften/JID/JID.h Swiften/Network/BoostConnectionServer.h Swiften/Network/ConnectionServer.h Swiften/Parser/AttributeMap.h Test-Information: Builds on macOS 10.12.1 with clang trunk. Change-Id: I9f41ab199f227bc106721627ea994313c68e5cfe
2016-11-23Migrate remaining Swiften/Base/foreach.h use to range-based for loopTobias Markmann
Test-Information: Build on macOS 10.12.1 and all tests pass. Change-Id: Iedaa3fa7e7672c77909fd0568bf30e9393cb87e0
2016-11-18Improve string to HostAddress conversion APITobias Markmann
Previously HostAddress had a constructor which allowed initialisation via a std::string. This initialisation can fail and this is heavily used for checking whether a string is a valid IP address. This constructor is removed in this commit and replaced by a static method HostAddress::fromString, taking a string and returning an optional HostAddress. This clearly communicates that the conversion can fail. Test-Information: ./scons test=all passes on macOS 10.12.1. Change-Id: Idaafee6f84010ce541c55f267ac77ad6ac8f02b4
2016-11-07Log address when failing to initialise HostAddress from stringTobias Markmann
Test-Information: Builds on macOS 10.12.1. Change-Id: Id06e66171cbc5b6417701a8de57b901b0d80f17c
2016-11-04Change logging output to use SWIFT_LOGTobias Markmann
Test-Information: Builds on macOS 10.12 and unit tests pass. Change-Id: Icc1bce9a0e0e85377eef0c8b87bf82d37943d3a5
2016-10-21Fix version number for libminiupnpc version switchTobias Markmann
Test-Information: Without this building failed under Gentoo Linux distribution. Verified this on Sabayon, a desktop Linux distribution based on Gentoo, by adding it to our cross distribution test. With this fix it builds on all platforms, including Sabayon. Change-Id: I23aec19b9755244dd3dbe6f581cf170eaf334dfc
2016-10-04Remove optional_fwd.hpp use; workaround for Boost Ticket #12179Tobias Markmann
Test-Information: Builds on macOS 10.12 and unit tests pass. Change-Id: Ia979e7dbd6f6c84085b1b951d81b925dffbed262
2016-09-30Change custom memory copy loop to std::memcpyTobias Markmann
Test-Information: Swift builds with test=all on macOS 10.12 and all tests pass. Change-Id: I9d7e8c49e65ac272a7ee672a95da5e24609d0a22
2016-09-30Add missing error check in HostAddress::toStringTobias Markmann
In the process converted try/catch use to Boost's error code for more explicit error checking and added log output. Test-Information: Swift builds with test=all on macOS 10.12 and all tests pass. Change-Id: I6e465354dbb38c7178b0406b9a544ebd3be62ddd
2016-09-26Use const std::unique_ptr for pimpl idiom usageTobias Markmann
All our pimpl idiom usage used std::shared_ptr due to being written in C++03. Now we use C++11 and const std::unique_ptr is more sensible. Test-Information: Builds on macOS 10.12 and unit tests pass. Change-Id: I1b9b3fbb22e337d53ae71e5a5e03118998cc3376
2016-07-22Add support for libminiupnpc version 2Tobias Markmann
Test-Information: Build successfully on openSUSE Tumbleweed which only has libminiupnpc 2.0 as package. Unit tests passed. Change-Id: I650e1224014162b55cdf64df7e72466b52dc3ade
2016-05-25Remove unnecessary include of iostream headerTobias Markmann
Move std::cout/cerr logging to SWIFT_LOG. Test-Information: Builds and all tests pass on OS X 10.11.5. Change-Id: I0a0c24654a8b3abf3244a79fd6d970eee90559d0
2016-04-25Convert hard tabs to four spaces in all our SConscript/*.py filesTobias Markmann
Test-Information: Test that it still builds and unit test pass on OS X 10.11.4. Change-Id: I2eb4a0b707991aee553db36a8cd1ae28b813acab
2016-04-12Use C++11 threading library instead of Boost.ThreadTobias Markmann
This cuts down our dependency on Boost further. Another benefit is that mutex classes of C++11 standard library are recognized by TSAN. Test-Information: Unit and integration tests pass on OS X 10.11.4. Change-Id: Id4dcdb42e3d5155e107ce1d7618acbf26f913b6f
2016-04-11Drop executable permission on source filesMichael Vetter
Drop executable rights on Swiften/Network/UnboundDomainNameResolver.* License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details. Change-Id: Ie6e6eab48b96dff64e82e76615c51863baf37816
2016-04-08Fix code in response to compiler warnings by clangTobias Markmann
Test-Information: Builds on OS X 10.11.4 with Apple clang and clang master. Change-Id: I012577e29c6fcf2fb452b4f13912aaeb37250fb5
2016-04-05Migrate to Boost.Signals2 from Boost.SignalsTobias Markmann
Boost.Signals was deprecated and is not improved further. This patch removes Boost.Signals from 3rdParty and adds Boost.Signals2 and its dependencies. Also removed the Qt signals compatibility file Swiften/Base/boost_bsignals.h. Test-Information: Build and ran unit tests on OS X 10.11.4. Confirmed successful login using Swift client. Change-Id: Ie6e3b2d15aac2462cda95401582f5287a479fb54
2016-04-04Modernize code to use range based for loops using clang-tidyTobias Markmann
Run 'clang-tidy -fix -checks=modernize-loop-convert' on all source code files on OS X. This does not modernize platform specific code on Linux and Windows Test-Information: Code builds and unit tests pass on OS X 10.11.4. Change-Id: I65b99e0978cfab8ca6de2a3e5342e7a81416c12c
2016-04-04Apply automated clang-tidy fixes and add missing includesTobias Markmann
Test-Information: Builds on OS X 10.11.4 and unit tests pass. Change-Id: I8775e8d1e3addbc88b220c1cc618637f706daca2
2016-04-04Modernize code to use C++11 shared_ptr instead of Boost'sTobias Markmann
This change was done by applying the following 'gsed' replacement calls to all source files: 's/\#include <boost\/shared_ptr\.hpp>/\#include <memory>/g' 's/\#include <boost\/enable_shared_from_this\.hpp>/\#include <memory>/g' 's/\#include <boost\/smart_ptr\/make_shared\.hpp>/\#include <memory>/g' 's/\#include <boost\/make_shared\.hpp>/\#include <memory>/g' 's/\#include <boost\/weak_ptr\.hpp>/\#include <memory>/g' 's/boost::make_shared/std::make_shared/g' 's/boost::dynamic_pointer_cast/std::dynamic_pointer_cast/g' 's/boost::shared_ptr/std::shared_ptr/g' 's/boost::weak_ptr/std::weak_ptr/g' 's/boost::enable_shared_from_this/std::enable_shared_from_this/g' The remaining issues have been fixed manually. Test-Information: Code builds on OS X 10.11.4 and unit tests pass. Change-Id: Ia7ae34eab869fb9ad6387a1348426b71ae4acd5f
2016-04-01Modernize code to use C++11 nullptr using clang-tidyTobias Markmann
Run 'clang-tidy -fix -checks=modernize-use-nullptr' on all source code files on OS X. This does not modernize platform specific code on Linux and Windows Test-Information: Code builds and unit tests pass on OS X 10.11.4. Change-Id: Ic43ffeb1b76c1a933a55af03db3c54977f5f60dd
2016-03-31Convert tabs to 4 spaces for all source filesTobias Markmann
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480