cgmnlm

colorful gemini line mode browser
git clone https://git.clttr.info/cgmnlm.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit eb01fde6007ea86b61227f690f8ee7ff0047bfeb
parent fd914b3aa40d63eb7fb2aafb1f6a30c1f78ee92f
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 20 Sep 2020 14:21:03 -0400

Implement -4 and -6

To force IPv4 and IPv6 respectively.

Diffstat:
Msrc/client.c | 2+-
Msrc/gmnic.c | 13++++++++++---
2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/client.c b/src/client.c @@ -23,7 +23,7 @@ gemini_get_addrinfo(struct Curl_URL *uri, struct gemini_options *options, free(uport); } - if (options && options->addr->ai_family != AF_UNSPEC) { + if (options && options->addr && options->addr->ai_family != AF_UNSPEC) { *addr = options->addr; } else { struct addrinfo hints = {0}; diff --git a/src/gmnic.c b/src/gmnic.c @@ -1,12 +1,15 @@ #include <assert.h> #include <errno.h> #include <getopt.h> +#include <netdb.h> #include <openssl/bio.h> #include <openssl/err.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/socket.h> +#include <sys/types.h> #include <unistd.h> #include "client.h" @@ -35,15 +38,19 @@ main(int argc, char *argv[]) enum input_mode input_mode = INPUT_READ; FILE *input_source = stdin; bool follow_redirects = false, linefeed = true; + struct addrinfo hints = {0}; + struct gemini_options opts = { + .hints = &hints, + }; int c; while ((c = getopt(argc, argv, "46C:d:D:hlLiIN")) != -1) { switch (c) { case '4': - assert(0); // TODO + hints.ai_family = AF_INET; break; case '6': - assert(0); // TODO + hints.ai_family = AF_INET6; break; case 'C': assert(0); // TODO: Client certificates @@ -104,7 +111,7 @@ main(int argc, char *argv[]) int ret = 0; while (!exit) { struct gemini_response resp; - enum gemini_result r = gemini_request(url, NULL, &resp); + enum gemini_result r = gemini_request(url, &opts, &resp); if (r != GEMINI_OK) { fprintf(stderr, "Error: %s\n", gemini_strerr(r, &resp)); ret = (int)r;