Commit Diff


commit - 689c72b42950384e355dfb91d5355d3506684480
commit + 10346511f2c0711aef878eb76413b27b809bf29b
blob - 09318ad060eb6efd5e010a2b7cb65e248cdbd584
blob + 3f13eb4d75c4c1fa2d714003700e0c6dfbb576ae
--- telescope.c
+++ telescope.c
@@ -85,9 +85,13 @@ handle_imsg_err(struct imsg *imsg, size_t datalen)
 static void
 handle_imsg_check_cert(struct imsg *imsg, size_t datalen)
 {
-	int	tofu_res = 1;
+	int		 tofu_res = 1;
+	struct tab	*tab;
 
-	imsg_compose(netibuf, IMSG_CERT_STATUS, imsg->hdr.peerid, 0, -1, &tofu_res, sizeof(tofu_res));
+	tab = tab_by_id(imsg->hdr.peerid);
+	tab->trust = TS_TRUSTED;
+	imsg_compose(netibuf, IMSG_CERT_STATUS, imsg->hdr.peerid, 0, -1,
+	    &tofu_res, sizeof(tofu_res));
 	imsg_flush(netibuf);
 }
 
@@ -241,6 +245,7 @@ load_about_url(struct tab *tab, const char *url)
 	char	*m;
 	size_t	 len;
 
+	tab->trust = TS_VERIFIED;
 
 	memset(&tab->url, 0, sizeof(tab->url));
 
@@ -295,6 +300,8 @@ do_load_url(struct tab *tab, const char *url)
 {
 	struct proto *p;
 
+	tab->trust = TS_UNKNOWN;
+
 	for (p = protos; p->schema != NULL; ++p) {
 		if (has_prefix(url, p->schema)) {
 			p->loadfn(tab, url);
blob - 69e80765784c05ccf84708cf87817cc2bbd58512
blob + 811f20caa981b1c93958d7de3d10c9b24c111ee2
--- telescope.h
+++ telescope.h
@@ -122,6 +122,17 @@ struct ui_state {
 	TAILQ_HEAD(vhead, vline)	 head;
 };
 
+/*
+ * differnt types of trust for a certificate.  Following
+ * gemini://thfr.info/gemini/modified-trust-verify.gmi
+ */
+enum trust_state {
+	TS_UNKNOWN,
+	TS_UNTRUSTED,
+	TS_TRUSTED,
+	TS_VERIFIED,
+};
+
 extern TAILQ_HEAD(tabshead, tab) tabshead;
 struct tab {
 	struct parser		 page;
@@ -129,6 +140,7 @@ struct tab {
 	uint32_t		 id;
 	uint32_t		 flags;
 
+	enum trust_state	 trust;
 	struct url		 url;
 	struct histhead		 hist;
 	struct hist		*hist_cur;
blob - c7ed6daaa8218496e0d4f18bf711cca551d49805
blob + 3166ccdfff301cd9d88ff56e1a489d5814e5dd33
--- ui.c
+++ ui.c
@@ -1336,6 +1336,17 @@ redraw_tabline(void)
 		waddch(tabline, ' ');
 	if (truncated)
 		mvwprintw(tabline, 0, COLS-1, ">");
+}
+
+static inline char
+trust_status_char(enum trust_state ts)
+{
+	switch (ts) {
+	case TS_UNKNOWN:	return 'u';
+	case TS_UNTRUSTED:	return '!';
+	case TS_TRUSTED:	return 'v';
+	case TS_VERIFIED:	return 'V';
+	}
 }
 
 static void
@@ -1350,8 +1361,9 @@ redraw_modeline(struct tab *tab)
 	wattron(modeline, A_REVERSE);
 	wmove(modeline, 0, 0);
 
-	wprintw(modeline, "-%c %s ",
+	wprintw(modeline, "-%c%c %s ",
 	    spin[tab->s.loading_anim_step],
+	    trust_status_char(tab->trust),
 	    mode == NULL ? "(none)" : mode);
 
 	pct = (tab->s.line_off + tab->s.curs_y) * 100.0 / tab->s.line_max;