Documentation ¶
Overview ¶
Package gopherhole implements a gopher server.
Example usage:
// Any omitted config setting will use // the default noted below. // Prefer absolute paths. // config := gopherhole.NewConfiguration() loads the defaults. // // View the README for more details on configuration options. config := gopherhole.Configuration{ RootDirectory: "/var/gopherhole", Host: "localhost", Port: 70, MaxConnections: 0, // 0 means no maximum. MapFileName: "gophermap", LogFile: "", // An empty string prints to STDOUT IdleTimeout: 60, // The number of seconds a client has after connecting // to make a query. } server := gopherhole.NewServer(config) server.Run()
Additionally, the configuration can be stored as JSON in a file:
{ "Host": "localhost", // ... }
The absolute path can be specified when building a new configuration:
config := gopherhole.NewConfigurationFromFile("/path/to/config.json")
Index ¶
Constants ¶
View Source
const ( ROOT_DIRECTORY = "/var/gopherhole" PORT = 70 MAX_CONNECTIONS = 0 HOST = "localhost" MAP_FILE_NAME = "gophermap" LOG_DISABLED = false LOG_FILE = "" IDLE_TIMEOUT = 60 DEFAULT_MIME_TYPE = "text/plain" )
View Source
const ( CR_CHAR = '\r' END_CHAR = '.' LF_CHAR = '\n' TAB_CHAR = '\t' NOPATH = "(NOTHING)" NOHOST = "nohost" NOPORT = 0 )
View Source
const (
CONNECTION_FREED_BUFFER_SIZE = 10
)
Variables ¶
View Source
var AllEntities = [...]EntityType{ TextFileEntity, DirectoryEntity, CsoNameServerEntity, ErrorEntity, MacBinaryEntity, DosBinaryEntity, UnixUUEncodedEntity, SearchServiceEntity, TelnetEntity, BinaryEntity, CalendarEntity, EventEntity, GifEntity, HtmlEntity, InlineTextEntity, SoundEntity, ImageEntity, MIMEEntity, TN3270Entity, }
View Source
var Listen = func(network, address string) (net.Listener, error) { ln, err := net.Listen(network, address) return ln, err }
View Source
var MimeTypeEntities = map[string]EntityType{ "audio/": SoundEntity, "application/": BinaryEntity, "application/binhex": MacBinaryEntity, "application/mac-binhex40": MacBinaryEntity, "application/mac-binhex": MacBinaryEntity, "application/x-msdos-program": DosBinaryEntity, "image/": ImageEntity, "image/gif": GifEntity, "multipart/": MIMEEntity, "text/": TextFileEntity, "text/calendar": CalendarEntity, "text/x-vcalendar": CalendarEntity, "text/html": HtmlEntity, "video/": BinaryEntity, }
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { RootDirectory string Host string Port int MaxConnections int MapFileName string LogDisabled bool LogFile string IdleTimeout int DefaultMimeType string MimeTypeIgnoreList []string }
func NewConfiguration ¶
func NewConfiguration() Configuration
func NewConfigurationFromFile ¶
func NewConfigurationFromFile(pathToFile string) (config Configuration, err error)
type EntityType ¶
type EntityType byte
const ( TextFileEntity EntityType = '0' DirectoryEntity EntityType = '1' CsoNameServerEntity EntityType = '2' ErrorEntity EntityType = '3' MacBinaryEntity EntityType = '4' DosBinaryEntity EntityType = '5' UnixUUEncodedEntity EntityType = '6' SearchServiceEntity EntityType = '7' TelnetEntity EntityType = '8' BinaryEntity EntityType = '9' CalendarEntity EntityType = 'c' EventEntity EntityType = 'e' GifEntity EntityType = 'g' HtmlEntity EntityType = 'h' InlineTextEntity EntityType = 'i' SoundEntity EntityType = 's' ImageEntity EntityType = 'I' MIMEEntity EntityType = 'M' TN3270Entity EntityType = 'T' )
func EntityForMimeType ¶
func EntityForMimeType(mime string) (entity EntityType, ok bool)
Click to show internal directories.
Click to hide internal directories.