g0orx / linhpsdr

Linux HPSDR
GNU General Public License v3.0
74 stars 44 forks source link

dicovery routine incompatible with wireguard #103

Open zvpunry opened 3 years ago

zvpunry commented 3 years ago

It is easy to replicate, just create a wireguard interface and linhpsdr exits with the message:

discover: looking for HPSDR devices on wg0 discover: bound to wg0 discover: sendto socket failed for discovery_socket : Required key not available

The solution is to continue after ENOKEY errors, something like this:

diff --git a/protocol1_discovery.c b/protocol1_discovery.c
index 7d833c7..43bf53e 100644
--- a/protocol1_discovery.c
+++ b/protocol1_discovery.c
@@ -117,7 +117,7 @@ static void discover(struct ifaddrs* iface) {

     if(sendto(discovery_socket,buffer,63,0,(struct sockaddr*)&to_addr,sizeof(to_addr))<0) {
         perror("discover: sendto socket failed for discovery_socket\n");
-        if(errno!=EHOSTUNREACH && errno!=EADDRNOTAVAIL) {
+        if(errno!=EHOSTUNREACH && errno!=EADDRNOTAVAIL && errno!=ENOKEY) {
             exit(-1);
         }
     }

I think it is the easiest when you test it and edit your own source tree, so I don't need to push it somewhere.

zvpunry commented 3 years ago

I should have tested to run it with that change... there is copy&paste code in protocol2_discovery.c that also needs to be fixed.