Commit graph

258 commits

Author SHA1 Message Date
Laurent Montel
6957b6aa39 GIT_SILENT: add missing override 2021-10-27 06:53:06 +02:00
Vladimir Panteleev
b706750af8
Use device ID from client SSL certificate, not UDP packet
Consider the following scenario:

1. We send a UDP broadcast
2. We receive a reply from 192.168.0.1 with device ID "foo"
3. We connect to 192.168.0.1, and find that the device's certificate
   is actually for a different ID "bar". This could be because the
   packet did not actually originate from 192.168.0.1, or this host is
   malicious / malfunctioning.
4. We remember that device ID "foo" has certificate with common name "bar".
5. When we finally attempt to connect to the real device ID "foo", we
   reject their certificate (common name "foo"). We can now never
   successfully connect to "foo".

On some network (mis-)configurations, this completely prevents
kdeconnectd from connecting to any peers, because a reply which is
seen as originating from the local interface address will cause
kdeconnectd to immediately connect to itself and remember its own
certificate.

Address this by using the certificate display name of the peer, which
will match the real device ID.
2021-09-25 12:51:59 +00:00
Weixuan XIAO
664da445ee Empty capabilities in identity packet for UDP
To avoid incomplete UDP transmission on macOS
2021-07-04 19:13:21 +00:00
Nicolas Fella
9082ed4699 Fix build with bluetooth enabled
We need to implement this pure virtual method.

This is just a placeholder and lacks a proper implementation.
2020-11-30 20:11:47 +01:00
Albert Vaca Cintora
e7518493df Add a verification key that's displayed when pairing
The key is a sha256 of both devices' certificates. Both should generate the
same key, so hey user can check they are pairing against the right device.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-11-26 11:28:49 +01:00
Albert Vaca Cintora
bd27aec9d2 Do not replace connections for a given deviceId if the certs have changed
Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Albert Vaca Cintora
ce0f00fc2d Limit the ports we try to connect to to the port range of KDE Connect
So we can't trigger connections to other services.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Albert Vaca Cintora
613899be24 Do not remember more than a few identity packets at a time
To prevent the kdeconnect process from using too much memory.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Albert Vaca Cintora
542d94a70c Limit number of connected sockets from unpaired devices
Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Aleix Pol
8112729eb0 Don't brute-force reading the socket
The package will arrive eventually, and dataReceived will be emitted.
Otherwise we just end up calling dataReceived to no end.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Aleix Pol
024e5f23db Do not let lanlink connections stay open for long without authenticating
If there's no information received, close the socket to try again.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Aleix Pol
4fbd01a3d4 Limit identity packets to 8KiB
Healthy identity packages shouldn't be that big and we don't want to
allow systems around us to send us ever humongous packages that will
just leave us without any memory.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Matthias Gerstner
7e47d04053 Fix use after free in LanLinkProvider::connectError()
If QSslSocket::connectToHost() hasn't finished running.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Albert Vaca Cintora
7b904f47b3 Do not ignore SSL errors, except for self-signed cert errors.
Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Aleix Pol
bf089f3461 Remove unused variable 2020-09-24 18:31:11 +02:00
Aleix Pol
d4cf48901c SocketLineReader: don't call packets bytes 2020-09-16 02:16:06 +02:00
Richard Liebscher
8d16d05c8a Custom devices 2020-08-18 21:55:24 +02:00
Nicolas Fella
87db95b22f Convert license headers to SPDX expressions 2020-08-17 09:48:10 +00:00
Piyush Aggarwal
771c9dcd22 fix code indentation in lanlinkprovider 2020-08-07 21:22:28 +00:00
Piyush Aggarwal
e3225a1430 fix QSslKey::ca-certificate deprecated warning 2020-08-07 21:22:28 +00:00
Nicolas Fella
93e68756bc Port away from deprecated error signal 2020-05-09 17:21:14 +00:00
Nicolas Fella
4254b23d5d trim some whitespace 2020-05-09 16:46:52 +02:00
Abdel-Rahman Abdel-Rahman
2728f8d864 Close all sockets before suspension 2020-04-16 22:32:57 +00:00
Nicolas Fella
6025f7cc48 Remove usused includes 2020-01-20 22:35:37 +01:00
Yuri Chornoivan
ba8ee54558 Fix minor typos 2019-12-22 10:15:58 +02:00
Yuri Chornoivan
01c4d0411b Fix minor EBN issues 2019-12-22 09:49:55 +02:00
Richard Liebscher
ba34672cbd Make build for SailfishConnect possible 2019-12-09 22:14:19 +00:00
Nicolas Fella
724a5a14a8 Don't use KIO in core when building for Sailfish 2019-10-27 19:35:18 +00:00
Nicolas Fella
39fe270cd1 Port Kdeconnectconfig to reference based singleton
It's more expressive in the sense that it makes clear that the user should not delete the object
2019-09-08 17:09:52 +02:00
Albert Astals Cid
af1255ed99 Use "new" connect syntax 2019-07-21 18:57:09 +00:00
Matthijs Tijink
0b6224fc0e Bluetooth multiplexer integration and assorted fixes 2019-07-20 12:29:33 +02:00
Matthijs Tijink
cda1280456 Add connection multiplexer 2019-07-20 12:29:33 +02:00
Nicolas Fella
e601755644 Force usage of QStringLiteral and port remaining offenders 2019-06-10 14:40:28 +00:00
Simon Redman
c7579eb170 Fix LanLinkProviderTest on Windows
## Summary
LanLinkProviderTest fails on Windows. This patch fixes that.

I believe the root cause is that we are using a shared UDP socket to listen for identity broadcasts both in the LanLinkProvider and in the test. Apparently this works on Linux, but on Windows the LanLinkProvider picks up its own identity packet and pairs with itself.

This patch gives a parameter to LanLinkProvider to allow it to listen and broadcast on different ports, then uses that ability in the test to make the test pass on Windows.

## Test Plan

### Before:
lanlinkprovider test fails, first because it can't bind its UDP listener socket, and then because Windows seems to handle shared sockets differently than Linux, so the UDP broadcasts were not reaching the test's listener.

### After:
lanlinkprovider test seems to pass reliably both in my Windows VM and in the CI
2019-06-05 15:14:50 +00:00
Simon Redman
4c75626919 Fix build
Commit 637285378d was not properly tested
2019-06-02 22:24:25 -06:00
Simon Redman
637285378d Add error logging to LanLinkProvider when binding the listener socket 2019-06-02 22:14:10 -06:00
Nicolas Fella
e1827ae33c Print socket error when connection fails 2019-05-26 20:36:35 +02:00
Nicolas Fella
3c353e7828 Improve debug message wording 2019-05-26 20:30:39 +02:00
Nicolas Fella
67efdc4fef s/Q_DECL_OVERRIDE/override 2019-05-09 01:03:20 +02:00
Nicolas Fella
89987eb025 Coding style 2019-05-04 19:27:04 +02:00
Nicolas Fella
eef04f124b [backends/lan] Don't fail silently when a UDP packet could not be unserialized 2019-05-04 18:34:59 +02:00
Nicolas Fella
aff3d20e7e [lanlinkprovider] Improve method names 2019-05-04 13:10:27 +00:00
Nicolas Fella
ecacb0eb80 Remove unneeded disconnects 2019-05-02 12:05:52 +00:00
Nicolas Fella
d3b6d1717d Port old connects 2019-05-01 23:42:24 +02:00
Nicolas Fella
ad0acbfae3 move initialization to initializer list 2019-05-01 23:26:07 +02:00
Nicolas Fella
d4026861ab Clean up includes 2019-04-30 19:03:24 +02:00
Nicolas Fella
147fb6f35f Tweak Upload job finished notification 2019-03-31 19:19:28 +00:00
Nicolas Fella
3b8fedea1a Replace http GNU urls with https 2019-03-23 17:29:26 +01:00
Matthijs Tijink
97705c3c76 Retry the network packet if it failed to unserialize
This happens if the network packet is big enough to not transfer in one
go.
2019-03-09 18:29:55 +01:00
Nicolas Fella
5c268466c3 Don't use empty QStringLiteral 2019-02-28 14:20:22 +01:00