commit - 6edcfca97fb01418cfdb8a2595060a63b7471d48
commit + 321341f6c09b8d51f6ed137833300af5417a3b61
blob - 1b4b649070c2f364030aad0c49b2015f0023dcaf
blob + 960228998852e8bdd9bf588c2ef07bd034704b57
--- ChangeLog
+++ ChangeLog
2021-07-06 Omar Polo <op@omarpolo.com>
+
+ * regress/gg.c (main): add -T timeout
* configure (guessing_cflags): try to preserve CFLAGS/LDFLAGS
blob - ad47822a9b871beab8e34e4ad26466b12203fa71
blob + acda5da3a1af327595cec18b5761df584bd8fc4d
--- regress/gg.1
+++ regress/gg.1
.Op Fl 23bchNVv
.Op Fl C Pa cert.pem Fl K Pa key.pem
.Op Fl H Ar hostname
+.Op Fl T Ar timeout
.Ar IRI
.Ek
.Sh DESCRIPTION
.It Fl N
Don't check whether the peer certificate name matches the requested
hostname.
+.It Fl T Ar timeout
+Kill
+.Nm
+after
+.Ar timeout
+seconds.
.It Fl V
Only validate the IRI, don't do the Gemini transaction.
.It Fl v
blob - 7eb698f5700f3ad09a243917ce979f3da2e3dc82
blob + 5537c68eec8de396ddc247ac2c6af97fd8e47a92
--- regress/gg.c
+++ regress/gg.c
int flag2, flag3, bflag, cflag, hflag, Nflag, Vflag, vflag;
const char *cert, *key;
+static void
+timeout(int signo)
+{
+ dprintf(2, "%s: timer expired\n", getprogname());
+ exit(1);
+}
+
int
main(int argc, char **argv)
{
struct tls_config *conf;
struct tls *ctx;
char iribuf[GEMINI_URL_LEN], buf[GEMINI_URL_LEN];
- const char *parse_err = "unknown error", *port = "1965";
+ const char *parse_err = "unknown error", *port = "1965", *errstr;
const char *hostname;
char *t;
- int ch;
- int handshake;
+ int ch, handshake, timer;
ssize_t len;
hostname = NULL;
- while ((ch = getopt(argc, argv, "23C:cbH:hK:NVv")) != -1) {
+ while ((ch = getopt(argc, argv, "23C:cbH:hK:NT:Vv")) != -1) {
switch (ch) {
case '2':
flag2 = 1;
case 'N':
Nflag = 1;
break;
+ case 'T':
+ timer = strtonum(optarg, 1, 1000, &errstr);
+ if (errstr != NULL)
+ errx(1, "timeout is %s: %s", errstr, optarg);
+ signal(SIGALRM, timeout);
+ alarm(timer);
+ break;
case 'V':
Vflag = 1;
break;
blob - 267331e63627545e78fda1e4107433c6b8d876c7
blob + 6b8fdbbeda97ecfcec95bc0e20986efbb6606c92
--- regress/runtime
+++ regress/runtime
# usage: get <path>
# return the body of the request on stdout
get() {
- ./gg -b $ggflags "gemini://localhost:10965/$1"
+ ./gg -T30 -b $ggflags "gemini://localhost:10965/$1"
}
# usage: head <path>
# return the meta response line on stdout
head() {
- ./gg -h $ggflags "gemini://localhost:10965/$1"
+ ./gg -T30 -h $ggflags "gemini://localhost:10965/$1"
}
# usage: raw <path>
# return both header and body
raw() {
- ./gg $ggflags "gemini://localhost:10965/$1"
+ ./gg -T30 $ggflags "gemini://localhost:10965/$1"
}
run() {