Commit Diff
--- 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); --- 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; --- 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;