💾 Archived View for zaibatsu.circumlunar.space › ~krixano › phlog › zeronet_gopher.txt captured on 2020-09-24 at 01:35:36.
-=-=-=-=-=-=-
---------------------------------- Gopher for ZeroNet ---------------------------------- Basics of ZeroNet Zites ZeroNet is an alternative to the web that offers decentralized and distributed dynamic websites. Basically, anyone can create a "zite" (ZeroNet Site) and a public bitcoin address is associated with it so that users can visit it. A public bitcoin address is used because there's also a private key that goes with it which allows the zite owner to create a certificate to let users know that the zite and it's files are verified. When a person goes to the address of a zite, they download the whole zite from peers. This means every zite a person has is seeded to other peers. Unlike Freenet, ZeroNet does not require you to download or seed all zites on the network. Instead, you seed the zites you use. Getting a dynamic system for this is a little more complicated but not by much. The way ZeroNet handles dynamic user content is by providing user directories inside of the zite's directory. This allows each user to modify the content inside their own directory. However, to ensure unwanted content is not on the zite, the zite owner can define the max size limit and the file types that are allowed. So, typically user content is added to a json file called data.json. The user also creates a signature using their private key. Then, the information in these data.json files is aggregated per-client into an sqlite database. Every time a user updates their data.json file, the update is published to 5 peers, who then download it, verify it, and send it to more peers. When the file is downloaded, this tells the ZeroNet client to update the database. However, ZeroNet needs to know which content goes where in the database. Basically, the zite owner can define database tables and maps to map the json information to the database. Then, zites are able to query from this database to show user content on the zite. ZeroNet specifies its own protocol to handle the transferring and sharing of the files. It also has components in the ZeroNet client to handle the database and users. There's ZeroFrame which is an API exposed to zites via a Websockets server. And finally, there's a locally running HTTP server that serves up the files of a zite via HTTP. Gopher for ZeroNet and Zopherholes This leads me to a realization. The main ZeroNet client and structure doesn't have to apply only to HTTP - it can be used with other protocols like Gopher. So, me and Ivanq (aka gitcenter on the network) started creating a plugin to ZeroNet that will run a Gopher server that will serve up files and gopher menus from ZeroNet "zite" directories to a gopher client. If a directory was specified, then it would autogenerate a gopher menu of all the files and folders in that directory, of course. However, since ZeroNet relies on these data.json files and the database for a lot of content, we wanted to be able to show this content to gopher clients. So, we decided to create a gopher.json file that acts like a gophermap. This gopher.json file lets you specify "virtual directories" where the url doesn't go to an existing directory (it's virtual) and the content of the gopher menu can be dynamically generated based on what's in the database by using a syntax like this: { "rules": [ "phlog": [ "My Phlog", ["1", "Circumlunar phlog", "~krixano/phlog", "circumlunar.space"], "", {"sql": "SELECT 'i', title || " - " || date_added FROM posts ORDER BY date_added DESC"} ] ] } HTTP Proxy for Gopher for ZeroNet Later on, we realized that we may not want to require users to download a Gopher client, so we created an HTTP proxy for Gopher for ZeroNet. We were able to use the same port as the Gopher server and just detect which protocol is being used. Later on, we decided that it should be an HTTP proxy for all of Gopher, not just Gopher for ZeroNet, so we supported putting a full gopher url into the url for the HTTP proxy. This was finished today. Currently, there are ZeroNet proxies that let you use ZeroNet from the internet/clearnet. However, none of these proxies have this Gopher plugin. However, you can find ZeroNet on the ZeroNet website[1], and the Gopher plugin on GitHub[2]. [1] https://www.zeronet.io [2] https://github.com/imachug/Plugin-Gopher