gopher

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Unlicense Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TextFileType      types.Status = '0'
	MenuType          types.Status = '1'
	CSOPhoneBookType  types.Status = '2'
	ErrorType         types.Status = '3'
	MacBinHexType     types.Status = '4'
	DosBinType        types.Status = '5'
	UuencodedType     types.Status = '6'
	SearchType        types.Status = '7'
	TelnetSessionType types.Status = '8'
	BinaryFileType    types.Status = '9'
	MirrorServerType  types.Status = '+'
	GifFileType       types.Status = 'g'
	ImageFileType     types.Status = 'I'
	Telnet3270Type    types.Status = 'T'
)

The Canonical gopher item types.

View Source
const (
	BitmapType    types.Status = ':'
	MovieFileType types.Status = ';'
	SoundFileType types.Status = '<'
)

The gopher+ types.

View Source
const (
	DocumentType     types.Status = 'd'
	HTMLType         types.Status = 'h'
	InfoMessageType  types.Status = 'i'
	PngImageFileType types.Status = 'p'
	RtfDocumentType  types.Status = 'r'
	WavSoundFileType types.Status = 's'
	PdfDocumentType  types.Status = 'P'
	XmlDocumentType  types.Status = 'X'
)

The various non-canonical gopher types.

Variables

View Source
var ServerProtocol types.ServerProtocol = proto{}

Functions

func File

func File(status types.Status, contents io.Reader) *types.Response

File builds a minimal response delivering a file's contents.

Meta is nil in this response.

func GuessItemType added in v1.3.0

func GuessItemType(filepath string) types.Status

GuessItemType attempts to find the best gopher item type for a file based on its name.

func NewResponseReader

func NewResponseReader(response *types.Response) types.ResponseReader

NewResponseReader produces a reader which supports reading gopher protocol responses.

func NewServer

func NewServer(
	ctx context.Context,
	hostname string,
	network string,
	address string,
	handler types.Handler,
	baseLog logging.Logger,
) (types.Server, error)

NewServer builds a gopher server.

func NewTLSServer added in v1.5.0

func NewTLSServer(
	ctx context.Context,
	hostname string,
	network string,
	address string,
	handler types.Handler,
	baseLog logging.Logger,
	tlsConfig *tls.Config,
) (types.Server, error)

NewTLSServer builds a gopher server which serves gopher over tls-encrypted connections.

func ParseRequest

func ParseRequest(rdr io.Reader) (*types.Request, error)

ParseRequest parses a gopher protocol request into a sliderule.Request object.

Types

type Client

type Client struct{}

Client is used for sending gopher requests and producing the responses.

It carries no state and is reusable simultaneously by multiple goroutines.

The zero value is immediately usable.

func (Client) Fetch added in v1.1.0

func (c Client) Fetch(ctx context.Context, url string) (*types.Response, error)

Fetch parses a URL string and fetches the gopher resource.

func (Client) IsRedirect added in v1.1.0

func (c Client) IsRedirect(_ *types.Response) bool

func (Client) RoundTrip

func (c Client) RoundTrip(ctx context.Context, request *types.Request) (*types.Response, error)

RoundTrip sends a single gopher request and returns its response.

type MapDocument

type MapDocument []MapItem

MapDocument is a list of map items which can print out a full gophermap document.

func (MapDocument) Response

func (md MapDocument) Response() *types.Response

Response builds a gopher response containing the gophermap.

Meta will be the MapDocument itself.

func (MapDocument) String

func (md MapDocument) String() string

String serializes the document into gophermap format.

type MapItem

type MapItem struct {
	Type     types.Status
	Display  string
	Selector string
	Hostname string
	Port     string
}

MapItem is a single item in a gophermap.

func Error

func Error(err error) *MapItem

Error builds an error message MapItem.

func (*MapItem) Response

func (mi *MapItem) Response() *types.Response

Response builds a response which contains just this single MapItem.

Meta in the response will be a pointer to the MapItem.

func (MapItem) String

func (mi MapItem) String() string

String serializes the item into a gophermap CRLF-terminated text line.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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