gopher

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2019 License: LGPL-3.0 Imports: 9 Imported by: 0

README

Go Gopher

go-gopher is a simple library for Go that implement an idiomatic client and server API and a fileserver command.

Documentation

Index

Constants

View Source
const (
	TextItem            = '0'
	SubmenuItem         = '1'
	CCSONameserverItem  = '2'
	ErrorItem           = '3'
	BinHexItem          = '4'
	DOSFileItem         = '5'
	UuencodedFileItem   = '6'
	FullTextSearchItem  = '7'
	TelnetItem          = '8'
	BinaryFileItem      = '9'
	MirrorServerItem    = '+'
	AlternateServerItem = '+'
	GIFFileItem         = 'g'
	ImageItem           = 'I'
	Telnet3270Item      = 'T'
	HTMLItem            = 'h'
	InfoMessage         = 'i'
	SoundItem           = 's'
)

constants of all the standard and common item types

View Source
const (
	UserDisplayStringColumn = 0
	SelectorColumn          = 1
	DomainColumn            = 2
	PortColumn              = 3
	AdditionalColumns       = 4
)

constants of all the defined columns in the gopher protocol

View Source
const (
	ForbiddenError      = "Forbidden"
	NotFoundError       = "Not Found"
	InternalServerError = "Internal Server Error"
)

constants of all the possible server errors (not defined in the gopher RFC)

Variables

This section is empty.

Functions

func Query

func Query(serverAddr string, selector string) (io.Reader, error)

Query a server and return the page content

func ServeAndListen

func ServeAndListen(addr string, handler Handler) error

ServeAndListen create a TCP server on the specified addr and pass new connections to the handler.

Types

type FileServerHandler

type FileServerHandler struct {
	IP        string
	Port      uint16
	Directory string

	// if ShowDotFiles is true, the server will also list and serve files
	// beginning with a dot (hidden files in UNIX systems).
	ShowDotFiles bool
}

A FileServerHandler is a simple handler that serve static files from a directory. An empty FileServerHandler is a valid handler that will serve the current directory.

func (FileServerHandler) Handle

func (srv FileServerHandler) Handle(r Request) Response

Handle the file server requests and return the file

type Handler

type Handler interface {
	Handle(r Request) Response
}

An Handler define the interface required for a server handler

type Item

type Item struct {
	Type              rune
	DisplayName       string
	Selector          string
	ServerAddr        string
	AdditionalColumns []string
}

Item represent an item on a gopher server

func List

func List(serverAddr string, selector string) ([]Item, error)

List items in the server at the given selector

type Request

type Request struct {
	Selector string
	IP       string
}

A Request is a struct that contain data about the client request

type Response

type Response io.Reader

A Response is an interface that the handler must return

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL