shithub: 9pro

Download patch

ref: a7b4dd4caec8a65cee0156e355c6cb18aea4b834
parent: 891af29bb4b94abf4dfe18451fdc8db169cb9bf7
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Nov 26 16:54:04 EST 2020

fall back to a know hostname

--- a/9gc.c
+++ b/9gc.c
@@ -42,6 +42,8 @@
 static const char *nick;
 static int printjoin;
 static uint64_t chatoff, skipuntil;
+static char *registry = "tcp!registry.9gridchan.org!6675";
+static char *defsrv = "tcp!chat.9gridchan.org!9997";
 
 static uint8_t *
 ctxread(C9ctx *ctx, uint32_t size, int *err)
@@ -242,6 +244,7 @@
 				*s++ = 0;
 			if (strstr(b, "tlssrv") == NULL && (s = strchr(b, ' ')) != NULL) {
 				*s = 0;
+fallback:
 				close(a->f);
 				if ((a->f = dial(b)) < 0)
 					exit(1);
@@ -254,9 +257,8 @@
 				return;
 			}
 		}
-		fprintf(stderr, "chat hasn't been found in the registry\n");
-		exit(1);
-		break;
+		b = defsrv;
+		goto fallback;
 
 	case Rerror:
 		fprintf(stderr, "registry error: %s\n", r->error);
@@ -307,12 +309,18 @@
 	int i;
 
 	for (i = 0; i < 10; i++) {
-		if ((a = srv("tcp!registry.9gridchan.org!6675")) != NULL)
+		if ((a = srv(registry)) != NULL)
 			break;
 		sleep(5);
 	}
-	if (a == NULL)
-		return NULL;
+	if (a == NULL) {
+		if ((a = srv(defsrv)) != NULL) {
+			ctx->r = ctxchatR;
+			c9version(ctx, &tag, Msize);
+			wrsend(a);
+		}
+		return a;
+	}
 
 	a->c.r = ctxregistryR;
 	c9version(&a->c, &tag, Msize);