monochromatic

monochromatic blog: http://blog.z3bra.org
git clone git://z3bra.org/monochromatic
Log | Files | Refs

do-you-gopher.txt (4653B)


      1 # [Do you gopher ?](#)
      2 ## — 03 February, 2015
      3 
      4 > Pocket gophers, commonly referred to as gophers, are burrowing rodents of the
      5 > family Geomyidae.[3] There are approximately 35 species of gopher living in
      6 > Central and North America.[4] They are commonly known for their extensive
      7 > tunneling activities. Gophers are endemic to North and Central America.
      8 >
      9 > -- wikipedia
     10 
     11 This article is not about them.
     12 
     13 The gopher I'll cover here is the TCP/IP protocol. It is a simple protocol used
     14 to share resources across the internet. The goal is to make the all internet
     15 look like a giant filesystem, where everything is read-only.
     16 
     17 How does it looks?
     18 
     19     $ curl -s gopher://z3bra.org
     20     iYou found me. Happy browsing !	Err	z3bra.org	70
     21     i==============================	Err	z3bra.org	70
     22     i	Err	z3bra.org	70
     23     0prolog	/prolog.txt	z3bra.org	70
     24     1notes	/notes	z3bra.org	70
     25     1ascii	/ascii	z3bra.org	70
     26     1images	/img	z3bra.org	70
     27     hhttp://blog.z3bra.org	URL:http://blog.z3bra.org	z3bra.org	70
     28     .
     29 
     30 We'll come back on this later. First, how does it works?
     31 
     32 ### gopher indexes
     33 
     34 Gopher is a text based protocol, where each line either points to an index
     35 (directory), or an item (items being files).
     36 The items will either be files or text (see file types later). To understand
     37 what the indexes are, let's assume we have the following filesystem:
     38 
     39     /var/gopher/
     40     ├── img
     41     │   ├── index.gph
     42     │   ├── dad.png
     43     │   ├── mom.png
     44     │   └── son.png
     45     ├── index.gph
     46     ├── notes
     47     │   ├── index.gph
     48     │   ├── memories.txt
     49     │   └── tricks.txt
     50     └── hello.txt
     51 
     52     2 directories, 9 files
     53 
     54 The files `index.gph` are the equivalent for `index.html` for most HTTP servers.
     55 In this case, each `index.gph` lists the content of the directory, so from a
     56 gopher client, we'll see:
     57 
     58     /
     59     ├── img [index]
     60     │   ├── dad.png [file]
     61     │   ├── mom.png [file]
     62     │   └── son.png [file]
     63     ├── hello.txt [file]
     64     └── notes [index]
     65         ├── memories.txt [file]
     66         └── tricks.txt [file]
     67 
     68 Pretty simple. You could however create a more difficult architecture by making
     69 `.gph` point to other files not in their directories and such.. but that's not
     70 the point here.
     71 
     72 ### the protocol
     73 
     74 To put it simply, each gopher "line" is composed of 5 distinct parts:
     75 
     76     <type><description>	<path>	<server>	<port>
     77 
     78 So each line is a link to another file, which could be on any server.
     79 
     80 * &lt;type&gt; : type of the line, usualy the type of the file pointed to
     81 * &lt;description&gt; : just text, to describe what the link points to
     82 * &lt;path&gt; : path to the item, from gopher's server root
     83 * &lt;server&gt; : the server which hosts the file
     84 * &lt;port&gt; : the port on which the server is listenning
     85 
     86 A gopher index is then just a list of links, each one pointing to a file which
     87 can be anywhere accross the world. And you don't need any unreadable markup
     88 language for this!
     89 
     90 ### file types
     91 
     92 The gopher protocol implements a rudimentary filetype thingy, by putting a
     93 character at the beginning of each line, indicating what the "item" points to.
     94 For example:
     95 
     96     0this is a file	/path/to/the/file	domain.tld	port
     97     1this is an index	path/to/the/index	domain.tld	port
     98     9this is a binary file	/path/to/the/binary	domain.tld	port
     99     Ithis is an image	/path/to/the/image	domain.tld	port
    100 
    101 There is also a special type: 'i', which doesn't point to anything, so it is
    102 only used to display text:
    103 
    104     iThe following is a set of cat pictures	Err	domain.tld	port
    105     Icat1.png	/img/cats/1.png	domain.tld	port
    106     Icat2.png	/img/cats/2.png	domain.tld	port
    107     Icat3.png	/img/cats/3.png	domain.tld	port
    108     Icat4.png	/img/cats/4.png	domain.tld	port
    109 
    110 ### gopher holes
    111 
    112 Gopher spaces are commonly named "holes". All you need now is a gopher to crawl
    113 this huge gallery. Here are a few I recommend:
    114 
    115 * gopher - http://gopher.quux.org:70/give-me-gopher/
    116 * cgo - https://github.com/kieselsteini/cgo
    117 
    118 Or you could use an HTTP proxy : http://gopher.floodgap.com/gopher/
    119 
    120 ### final thoughs
    121 
    122 As you might have noticed (or not), I run my own gopher hole. I first wanted to
    123 move this whole blog over gopher, but finally decided to keep it as is (because
    124 I'm kind of attached to it after all!), and use my gopher space to share some
    125 quick thoughs & notes about POSIX systems and other IT related subjects.
    126 
    127 Because of this, I might reduce the freequency of posts I publish here, in favor
    128 of more notes on my gopher space. So see you there!
    129 
    130     gopher://z3bra.org
    131     
    132 <!-- vim: set ft=markdown ts=4 et tw=80: -->