hanatsumi / rakuyomi

A manga reader plugin for KOReader.
GNU Affero General Public License v3.0
6 stars 0 forks source link

Kobo Libra 2 support #22

Open yafyz opened 2 weeks ago

yafyz commented 2 weeks ago

There are currently 2 issues with Libra 2.

  1. Loopback does not get set up and must be set up manually (https://www.mobileread.com/forums/showthread.php?t=353887)
  2. There are DNS lookup issues? ping binary on the same domain works just fine will look into this, probably
    reqwest::Error {
        kind: Request,
        url: Url {
            scheme: "https",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: Some(
                Domain(
                    "api.mangadex.org",
                ),
            ),
            port: None,
            path: "/manga/",
            query: Some(
                "includes[]=cover_art&limit=20&offset=0&title=",
            ),
            fragment: None,
        },
        source: hyper::Error(
            Connect,
            ConnectError(
                "dns error",
                Custom {
                    kind: Uncategorized,
                    error: "failed to lookup address information: Try again",
                },
            ),
        ),
    }
hanatsumi commented 2 weeks ago

For the first issue, I've updated the startup code to bring the loopback interface up on Kobo devices, could you test it and see if it works? Here's an updated build

As for the second issue, I do suspect those DNS failures are due to some wonkiness with how musl's libc DNS resolver works... The quickest way to test this would be to cross-compile something like the below code using musl's compiler, running it via SSH on the device and see if it works or not (here's a compiled binary):

#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>

#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif

int main(void)
{
    struct addrinfo *result;
    struct addrinfo *res;
    int error;

    /* resolve the domain name into a list of addresses */
    error = getaddrinfo("api.mangadex.org", NULL, NULL, &result);
    if (error != 0)
    {
        if (error == EAI_SYSTEM)
        {
            perror("getaddrinfo");
        }
        else
        {
            fprintf(stderr, "error in getaddrinfo: %s\n", gai_strerror(error));
        }
        exit(EXIT_FAILURE);
    }

    /* IPv4 */
    char ipv4[INET_ADDRSTRLEN];
    struct sockaddr_in *addr4;

    /* IPv6 */
    char ipv6[INET6_ADDRSTRLEN];
    struct sockaddr_in6 *addr6;

    /* loop over all returned results and do inverse lookup */
    for (res = result; res != NULL; res = res->ai_next)
    {
        if (res->ai_addr->sa_family == AF_INET)
        {
            addr4 = (struct sockaddr_in *)res->ai_addr;
            inet_ntop(AF_INET, &addr4->sin_addr, ipv4, INET_ADDRSTRLEN);
            printf("IP: %s\n", ipv4);
        }
        else if (res->ai_addr->sa_family == AF_INET6)
        {
            addr6 = (struct sockaddr_in6 *)res->ai_addr;
            inet_ntop(AF_INET6, &addr6->sin6_addr, ipv6, INET6_ADDRSTRLEN);
            printf("IP: %s\n", ipv6);
        }
    }

    freeaddrinfo(result);
    return 0;
}