Posts in category "Python"

Wasat v1.3.0

1 min read; 11 GFI

A quick bump of Wasat to v1.3.0. This follows on from the work started in v1.2.0, improving how hybrid mode works and also making host certificate verification information available in the response object.

The main improvement to hybrid mode is that it's now a little more discerning about when to fall back on TOFU mode. Only if the CA route fails due to an untrusted root or a self-signed certificate does it then fall back to TOFU; otherwise, an exception is raised.

I've also added verification information -- such as the method used and the fingerprint -- to the response object. This will be useful in Rogallo if I want to show in the display how the current server was verified.

As a handy diagnostic tool, I've also added the verification method and the fingerprint to the verbose output of the library's CLI command.

$ wasat --verify-mode=hybrid -v gemini://astrobotany.mozz.us/ | head -7
--- Gemini Response ---
URI: gemini://astrobotany.mozz.us/
Verification Method: ca
Certificate Fingerprint: sha256:dafe13d51b1aff133dd153c6d66a1a15761020017daa69378aef6e0eefb75474
Status: 20 (SUCCESS)
Meta: text/gemini
-----------------------

$ wasat --verify-mode=hybrid -v gemini://tilde.team/~davep/ | head -7
--- Gemini Response ---
URI: gemini://tilde.team/~davep/
Verification Method: tofu
Certificate Fingerprint: sha256:239f2642895698fbd16bd6fc59f2361caf6b7449a37d861d86936978c175bf78
Status: 20 (SUCCESS)
Meta: text/gemini; lang=en
-----------------------

With these changes in place, I think I'm set for making some improvements to Rogallo relating to host certificates.

Wasat v1.2.0

2 min read; 6 GFI

I've just released Wasat v1.2.0. This release aims to help out with a change I want to make in Rogallo in relation to certificate verification.

The issue is that, until now, Wasat offered either ca or tofu as verification modes. Meanwhile Rogallo was using tofu. Long story short: this meant that sometimes some sites looked like they were changing fingerprint way more often than you'd expect. The obvious solution here is to first check if a site can be validated via the ca route and, if not, fall back to the tofu route. This sort of change could have been made in Rogallo itself, but it would have been inelegant. Rogallo maintains a single Gemini client object, and the verification mode is baked in when the object is created. To move to this "try one way then the other" approach would have meant either maintaining two instances of the object, or tearing it down and making another each time we connected to a capsule.

Nah.

So the verify_mode of the Client has grown a new option: hybrid. When set to hybrid, the client will do the dance mentioned above: it will try and see if ca will work and, if it does, it will take that approach. If it fails, it will then fall back on pure tofu.

Out of the box, the defaults for the client are the same (it uses ca by default), and for the moment Rogallo is still hard-baked to tofu; given this, there should be no change in how things work when Wasat is updated. Now that this is up on PyPI, I'm going to pin Rogallo's use of wasat to >=1.2.0 and then, in an update, I'll swap over to hybrid. Hopefully this will result in a smoother journey when using sites like AstroBotany and Station.

â„šī¸ Note

While writing this, I've noticed that there's one change I still need to make to this hybrid flow. I realised that, at the moment, any kind of CA failure will result in a fallback to TOFU. That's not ideal and needs refining. All part of the learning process.


PS: If you're wondering what happened to v1.1.0 of Wasat... there wasn't one. While preparing this release, I was also fighting with the fact that my MX Mechanical Mini keyboard seemed to be dying (and its battery does seem to be dying) and, because of that, managed to bump the version from v1.0.1 to v1.2.0. Oh well...

GopherMap v0.2.0

1 min read; 10 GFI

A quick little update to GopherMap. v0.2.0 greatly relaxes the validation of incoming lines, being a lot less fussy about missing tab characters and also about fully empty lines.

In the first take on this I was being pretty strict but, unsurprisingly, there are sites out there with likely-malformed maps that should otherwise work if you're chill about their mistakes.

I've got no desire for Rogallo to be harsh in this respect, so here's a much more relaxed version of GopherMap.

As of right now, the exceptions that are defined in the library are never raised. I've left them in for the moment because there's a window of time between this version being pushed to PyPI and Rogallo being updated (it does use the exceptions), where failure to supply them would cause Rogallo to crash under normal circumstances (nobody wants an unnecessary ImportError). Once I've updated Rogallo to pin a new lower bound, and removed use of the exceptions, I'll remove them from GopherMap.

GopherMap - A simple library for parsing Gopher responses

1 min read; 9 GFI

Having spun up Port70 as a support library for my effort to add gopher support to Rogallo, the next thing I needed was some code to parse the "gopher map" responses that you get back from Gopher servers. While this could have been some code in Rogallo itself, much like with Gemtext, it seemed sensible to put it in its own library so it could be useful elsewhere.

So... GopherMap v0.1.0 is a thing. Its main provision is a class called GopherMap, which is used to parse some text you give it. Its items property is then a tuple of GopherItem objects. Each one of those objects has a type property which can be used to check the type of the resource.

Because Rogallo heavily relies on MIME types to make decisions about what to do with content, each ItemType has a best-efforts-guess mime_type associated with it. This will make it pretty straightforward for me to decide if a resource from a Gopher server is something Rogallo can display.

All of this has prompted me to have a go at creating my own little Gopher site to help with testing. As with my wee Gemini capsule, this is all thanks to tilde.team.

Port70 - A Gopher protocol library for Python

1 min read; 9 GFI

It was, of course, inevitable that this would happen. After spinning up Port79 so that I could add finger support to Rogallo, it made sense that I start to think about Gopher support too. So here we go: Port70, a similar library for async interaction with Gopher servers.

This is going to be a bit of an adventure for me. While I'm long familiar with the existence of Gopher, and I'm fairly certain I used a client once or twice back in the 90s, I've never really had dealings with the protocol so know very little about it. Which is a good thing: something new (old?) to learn.

My plan with this is to add the GopherURI class to the list of URI types that Rogallo understands and handles and then provide a method of displaying and navigating the result. I think the cleanest and easiest way of doing this will be to add some code that transforms a menu response into gemtext and then just let the viewer widget display it as normal; each of the links in the menu being turned into gopher:// URIs.

This should be fun to play with. I'm looking forward to pulling it all together.

Port79 v1.0.0

1 min read; 10 GFI

I've just bumped Port79 to v1.0.0. There's no significant change in this release, other than the addition of the usual dunder-based metadata that is common in Python libraries; somehow I'd managed to leave it out in the last couple of releases.

Now that I've successfully added finger support to Rogallo, and the library is working out well, there didn't seem much point in letting it hang around in zero-point-whatever-land.

Port79 v0.2.0

1 min read; 8 GFI

A quick update to Port79. When I kicked this off I'd set up the FingerURI class so that it was pretty permissive in what it would accept. So, for example, you could do any of:

>>> FingerURI("davep")
FingerURI('finger://davep/')
>>> FingerURI("davep@example.com")
FingerURI('finger://example.com/davep')
>>> FingerURI("finger://example.com/davep")
FingerURI('finger://example.com/davep')

Nice and handy, right? Accept pretty much any input and turn it into a finger URI. However, once I started to add finger support to Rogallo, I realised that this wasn't as helpful as I'd like as it meant I couldn't use it to actually check for a valid URI. It would be more useful to have the class be strict about only being passed finger: URIs.

So now, the first two examples give an error.

>>> FingerURI("davep")
port79.exceptions.URIError: Invalid URI scheme: ''. Expected 'finger'
>>> FingerURI("davep@example.com")
port79.exceptions.URIError: Invalid URI scheme: ''. Expected 'finger'

Instead, if you want the more relaxed approach, you should use the from_string method.

>>> FingerURI.from_string("davep")
FingerURI('finger://davep/')
>>> FingerURI.from_string("davep@example.com")
FingerURI('finger://example.com/davep')

With this change I can confidently use FingerURI to test if any given input is an actual finger URI, and this also makes it work in a similar way to GeminiURI in Wasat.

Port79 - A finger protocol library for Python

1 min read; 10 GFI

Now that Rogallo is starting to settle down somewhat, with all the main Gemini Protocol work falling into place, I've been thinking about adding one or two adjacent protocols. The two most common and obvious ones are Finger and Gopher. While I'm still undecided about adding the latter, the former seems like a fun one to include (if only because I've had an account on plan.cat for around four years now).

With that in mind, much like I did with Wasat, I wrote a spec for what I wanted and pointed Antigravity at it. The result is Port79. As well as providing a library, there's also a small finger clone CLI, which can be run with python -m port79 (if it's installed as a library) or with port79 (if installed along with any command scripts).

$ port79 davep@tilde.team

hello [removed],

Project:
  Rogallo: https://rogallo.davep.dev/

Plan:
  Currently building gemini://tilde.team/~davep/

Pronouns: he/him

$ port79 davep@plan.cat
Login: davep                            Name: Dave Pearson
Directory: /home/davep                 Shell: /bin/plan.cat
Last login Mon Jul 20 19:06:33 2026 UTC
No Mail.
Plan:
Rogallo v0.12.0, with some more QoL changes:
https://blog.davep.org/2026/07/20/rogallo-v0-12-0.html

To be clear: this isn't intended to be a serious finger command (like, why would anyone even need that?), it's just a tool within the library that can be used to do some testing within a development (v)environment.

At some point soon I'll be adding port79 as a dependency of Rogallo and adding finger as a "native protocol".

Wasat v0.8.0

1 min read; 7 GFI

Wasat v0.8.0 is now available. This provides a small update to the GeminiURI class, adding three utility properties for extra URI manipulation.

  • without_query - gives the URI minus any attached query
  • parent - gives the parent path of the current URI (also minus the query)
  • root - gives the root path for the current URI (also minus the query)

In each case, the result is a fresh GeminiURI instance.

These are added because I'm aiming to add "go to parent" and "go to root" commands to Rogallo.