Commits


imsg: allow fdpass on the net socket it's used to pass the client certificate to the net process so has to be enabled. Issue <https://github.com/telescope-browser/telescope/issues/21> spotted by linuxcult; thank you!


update imsg


code: add wrappers for common failure cases Certain calls to well-known functions sometimes result in similar error handling across the code base. Sometimes there's a need to centralise the failure case. Achieve this for common wrappers to often-used functions. The transformation is achieved via coccinelle, commited with this patch. Note that coccinelle can be told to ignore code blocks with comment delimiters. This transformation applies just to telescope's code, and not any of the bundled depdencies in telescope (libgrapheme).


removed unneeded #include <assert.h>


tls: guard against faulty gemini servers Some gemini servers have faulty TLS handling, such as: gg: tls_close: EOF without close notify In such cases, telescope will receive that error and naturally assume there was a problem and stop processing. However, in the case of there still being legitimate content read from the request, this should still be displayed, rather than ignored. This change therefore detects this condition and adds a status of 'W' to telescope's modeline to indicate that the information presented is from a faulty gemini server and could be truncated and hence display oddly.


slightly rework gemini reply handling - rename `r' to `code' - defer the buf_drain() call With libevent we had to free() the header string, whereas buf_getdelim() returns a string from the buffer itself, so we can safely defer the drain operation after the sanity checks.


grammar


make gemini_parse_reply() return -1 on error


don't pause the request in gemini_parse_reply() a parse routine shouldn't interfere with the handling of the events; pulling this into the caller makes the logic simpler to follow.


simplify gemini_parse_reply()


simplify gemini header handling with buf_getdelim()


decouple bufio from ev more a matter of cleanliness than a strong reason, but this allows to reuse bufio without ev (if wanted to.)


net: initialize fds earlier


net: use a single timer for asr and handshake timeout


move imsgev & co to their own file This avoids bringing the dependency on ev on telescope-identity(1) and the tests as well.


net: re-enable asr_run Make asr_run() work on top of ev. While here, rename the function names and add real error checking.


add a paranoic check


add missing return otherwise we try to reschedule the socket we've just closed.


convert telescope to use ev instead of libevent libevent is a very cool library, I like the APIs and enjoy using it. However, telescope is not as large and doesn't have as many file descriptor, so libevent is quite ``too big'' for our needs. ev started as a small event loop on top of poll(2) for amused, and can be used here too, it just needed to grow the ability to handle several timers, as we need quite some on telescope (in fact, we use more timers than fds!)


net: improve error messages for connection failures


net: improve handling of connect(2) failures If we succeed to make a socket(2) but fail to connect(2), still attempt to reconnect using the other results from getaddrinfo(3).


improve error message on connection interruption


first draft of client certificate support At the moment telescope loads a mapping host:port/path -> certificate from a file and always uses it, no ways to change it, use a temporary one, generate a new one, etc are provided yet. The format of ~/.telescope/certs/certs is host port path certificate file name where the certificate file name is the name of a file inside ~/.telescope/certs. ~/.telescope/certs/ is ~/.local/share/telescope/ when using XDG.


send the reply code and meta in a single imsg


net: switch to new imsg apis