Re: The future of PyGopherd
Christoph Lohmann <20h-hp7/[email protected]>
| Newsgroups | gmane.network.gopher.general |
|---|---|
| Message-ID | <[email protected]> |
Greetings. On Tue, 16 Jun 2020 12:10:54 +0200 James Mills <[email protected]> wrote: > I would port it to Go using https://github.com/prologic/go-gopher > > :D Happy to help with this! Thanks for your offer. You will not really need a full gopher protocol implementation. To get some more public interest, I will describe how the CGI/DCGI model in geomyidae works and how it can be easily leveraged to emulate whatever old gophermap format you like. # Index Files By default there is four interesting types for output in geomyidae and file types: char *indexf[] = {"/index.gph", "/index.cgi", "/index.dcgi", "/index.bin"}; When you put some file named like one in the index, it will be opened, when you for example request gopher://bitreich.org/lawn and the file is in the index. ## Index.gph When you request the index.gph, then geomyidae expects the gph format, specific to geomyidae, like: [1|Some nice new menu.|./some/path|server|port] Some text. ttext The first line will create a menu entry pointing to /lawn/some/path (Yes, geomyidae now supports relative paths.) and »server« and »port« will be replaced with the configuration of the geomyidae daemon running. This allows easily running the same file on for example some domain and tor. Then »server« will be replaced be either the domain or the .onion domain. The »ttext« shows, that every line beginning with »t« needs to be escaped with »t«. In the manpage is an easy filter for this: »sed 's/^t/&&/'«. ## Index.dcgi When you would put an index.dcgi into the lawn directory, then geomyidae will execute the script in the way mentioned under »DYNAMIC CONTENT« in the geomyidae manpage. There is also a brief description of how argc and argv are handled and all environment variables. Because of the ».dcgi«, geomyidae will take gph on stdout of the script and convert it to a raw menu, giving the »port«, »server« and relative path feature. ## Index.cgi This is like index.dcgi, but this time, the file outputs the raw gopher menu, without geomyidae doing any filtering. ## Index.bin Here the file given back by geomyidae is just this file, without any execution. So there should be the raw gopher menu in the file. Of course it could be something else, depending on how you like to it using the menu item type. Where is this useful? 1.) If you have any menu generator or gopher application, which generates raw menus for compatibility to some other server, then this is an easy output format. 2.) If you created a raw mirror of some gopherhole, then it can be easily displayed using this feature. Just download the raw menu into the index.bin and it can be served somewhere else. # Converter Types ## Dynamic You can choose to have some index.cgi, which searches the filesystem on request and generates the output. This is for example necessary on some gophernicus conversation, which knows dynamic script execution in gophermap files. ## Static Static converters take some old format and generate new raw or gph output files, then easily served by geomyidae. This is to be considered, when there is no dynamic execution in the content served. Then bandwidth is saved and of course less likely there are remote execution problems, when you take unchecked user input. ## Example See gopher://shroom.party/1/code/gophermap2gph/file/gophermap2gph/main.py.gph for how simple such a converter can be. It is no big buzz or framework required, just basic file I/O. I hope to have been clear enough in the description and showed the simplicity of how to easily create content for geomyidae. It is just outputting from stdout, line-wise and done in less than five minutes for most projects. I hope someone got some interest in helping out to preserve the old gopherspace and write converters so old content can be reused (and maybe adapted to modern days). If anyone has questions, just let me know. Sincerely, Christoph Lohmann