]> git.meshlink.io Git - meshlink/blobdiff - src/net_setup.c
Use strerror() instead of gai_strerror() when err == EAI_SYSTEM.
[meshlink] / src / net_setup.c
index cb14c5179fb3489c37e3a05abf16a166becf78ae..c61a90122810719d924be949f5f46ea459859a2e 100644 (file)
@@ -223,6 +223,30 @@ static bool read_ecdsa_private_key(void) {
        return myself->connection->ecdsa;
 }
 
+static bool read_invitation_key(void) {
+       FILE *fp;
+       char *fname;
+
+       if(invitation_key) {
+               ecdsa_free(invitation_key);
+               invitation_key = NULL;
+       }
+
+       xasprintf(&fname, "%s" SLASH "invitations" SLASH "ecdsa_key.priv", confbase);
+
+       fp = fopen(fname, "r");
+
+       if(fp) {
+               invitation_key = ecdsa_read_pem_private_key(fp);
+               fclose(fp);
+               if(!invitation_key)
+                       logger(DEBUG_ALWAYS, LOG_ERR, "Reading ECDSA private key file `%s' failed: %s", fname, strerror(errno));
+       }
+
+       free(fname);
+       return invitation_key;
+}
+
 static bool read_rsa_private_key(void) {
        FILE *fp;
        char *fname;
@@ -603,6 +627,8 @@ bool setup_myself_reloadable(void) {
 
        get_config_bool(lookup_config(config_tree, "DisableBuggyPeers"), &disablebuggypeers);
 
+       read_invitation_key();
+
        return true;
 }
 
@@ -912,8 +938,7 @@ static bool setup_myself(void) {
                        free(address);
 
                        if(err || !ai) {
-                               logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "getaddrinfo",
-                                          gai_strerror(err));
+                               logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "getaddrinfo", err == EAI_SYSTEM ? strerror(err) : gai_strerror(err));
                                return false;
                        }