Documentation ¶
Index ¶
- Variables
- func ArchiveMimetype(mimetype string) bool
- func AudioMimetype(mimetype string) bool
- func CalendarMimetype(mimetype string) bool
- func CertFilename(filename string) bool
- func CertMimetype(mimetype string) bool
- func ContainsCensorWords(str string) bool
- func CutAny(s string, chars string) (before string, after string, found bool)
- func DirFS(name string) fs.FS
- func DocumentMimetype(mimetype string) bool
- func DotFilename(filename string) bool
- func FilenameToGopherItemtype(filename string) rune
- func GetTitleFromGemtext(reader io.Reader) string
- func InsertParamsIntoRouteString(route string, params map[string]string, globString string, reverse bool) string
- func MimetypeGetsLangParam(mt_string string) bool
- func MimetypeToGopherItemtype(mt_string string, mt_parent_string string) rune
- func PrintRoute(node *RouteNode, indent int)
- func PrivacySensitiveFilename(filename string) bool
- func PrivacySensitiveMimetype(mimetype string) bool
- func ProtocolIsTLS(protocol ProtocolType) bool
- func ProtocolToName(protocol ProtocolType) string
- func VideoMimetype(mimetype string) bool
- type BindPortHostnameCertificate
- type CertInfo
- type Log
- type PortListener
- type PortListenerKey
- type ProtocolType
- type RateLimitListItem
- type Request
- func (r *Request) Abstract(mimetype string, data string) error
- func (r *Request) BadRequest(format string, elem ...any) error
- func (r *Request) Bytes(mimetype string, data []byte) error
- func (r *Request) ClearScrollMetadataResponse()
- func (r *Request) ClientCertNotAuthorized(format string, elem ...any) error
- func (r *Request) DisableConvertMode()
- func (r *Request) EnableConvertMode()
- func (r *Request) File(filePath string) error
- func (r *Request) FileMimetype(mimetype string, filePath string) error
- func (r *Request) Fragment() string
- func (r *Request) Gemini(text string) error
- func (r *Request) GetParam(name string) string
- func (r *Request) GetUploadData() ([]byte, error)
- func (r *Request) Gophermap(text string) error
- func (r *Request) GophermapLine(linetype string, name string, selector string, hostname string, port string) error
- func (r *Request) Host() string
- func (r *Request) Hostname() string
- func (r *Request) IPHash() string
- func (r *Request) Markdown(text string) error
- func (r *Request) NexListing(text string) error
- func (r *Request) NotFound(format string, elem ...any) error
- func (r *Request) Path() string
- func (r *Request) PlainText(format string, elem ...any) error
- func (r *Request) PromptLine(link string, text string) error
- func (r *Request) Query() (string, error)
- func (r *Request) RawFragment() string
- func (r *Request) RawPath() string
- func (r *Request) RawQuery() (string, error)
- func (r *Request) Redirect(format string, elem ...any)
- func (r *Request) RequestClientCert(format string, elem ...any) error
- func (r *Request) RequestInput(format string, elem ...any) error
- func (r *Request) RouteLink(route string, name string) error
- func (r *Request) Scroll(text string) error
- func (r *Request) SendAbstract(mimetype string) error
- func (r *Request) ServerUnavailable(format string, elem ...any) error
- func (r *Request) SetLanguage(lang string)
- func (r *Request) SetNoLanguage()
- func (r *Request) SetScrollMetadataResponse(metadata ScrollMetadata)
- func (r *Request) SetSpartanQueryLimit(bytesize int64)
- func (r *Request) Spartan(text string) error
- func (r *Request) Stream(mimetype string, reader io.Reader) error
- func (r *Request) StreamBuffer(mimetype string, reader io.Reader, buf []byte) error
- func (r *Request) TemporaryFailure(format string, elem ...any) error
- func (r *Request) TextWithMimetype(mimetype string, text string) error
- func (r *Request) UserCertHash_Gemini() string
- func (r *Request) UserCertHash_Misfin() string
- func (r *Request) UserCert_MD5Hash() string
- func (r *Request) UserCert_SHA256Hash() string
- type RequestHandler
- type RequestHeader
- type RouteListItem
- type RouteNode
- type Router
- type SISContext
- func (context *SISContext) AddServer(server Server) ServerHandle
- func (context *SISContext) AddServerRoute(BindAddress string, Port string, Protocol ProtocolType, Hostname string, ...)
- func (context *SISContext) AdminServer() *Server
- func (context *SISContext) AllowIP(ip string)
- func (context *SISContext) BlockIP(ip string)
- func (context *SISContext) EnterMaintenanceMode_All()
- func (context *SISContext) FindServerByName(name string) ServerHandle
- func (context *SISContext) FullRestart()
- func (context *SISContext) GetOrCreatePortListener(BindAddress string, Port string) *PortListener
- func (context *SISContext) GetPortListener(BindAddress string, Port string) *PortListener
- func (context *SISContext) IsIPBlocked(ip string) bool
- func (context *SISContext) Log(serverType ServerType, label string, msgFormat string, args ...any)
- func (context *SISContext) SaveConfiguration() error
- func (context *SISContext) SetUpdateLink(link string)
- func (context *SISContext) ShutdownPortListeners()
- func (context *SISContext) ShutdownSIS()
- func (context *SISContext) Start()
- func (context *SISContext) UpdateAndRestart(data []byte) string
- type ScrollMetadata
- type Server
- func (s *Server) AddCertificate(filepath string)
- func (s *Server) AddDirectory(p string, directoryPath string)
- func (s *Server) AddEmbedDirectory(p string, content embed.FS, directoryPath string)
- func (s *Server) AddEmbedFile(p string, content embed.FS, filePath string)
- func (s *Server) AddFile(p string, filePath string)
- func (s *Server) AddProxyRoute(p string, proxyRoute string, gopherItemType rune)
- func (s *Server) AddRoute(p string, handler RequestHandler)
- func (s *Server) AddUploadRoute(p string, handler RequestHandler)
- func (s *Server) CleanupRateLimiting()
- func (s *Server) GetHandle() ServerHandle
- func (s *Server) IPRateLimit_ClearRedirectPath(ip string)
- func (s *Server) IPRateLimit_ExpectRedirectPath(ip string, redirectPath string)
- func (s *Server) IPRateLimit_IsExpectingRedirect(ip string) bool
- func (s *Server) IpRateLimit_GetExpectedRedirectPath(ip string) string
- func (s *Server) IsIPRateLimited(ip string) bool
- func (s *Server) LoadRoutes() error
- func (s *Server) SaveRoutes() error
- func (s *Server) Scheme() string
- func (s *Server) UploadScheme() string
- type ServerDirFS
- func (dir ServerDirFS) Lstat(name string) (fs.FileInfo, error)
- func (dir ServerDirFS) MkSymlink(name, target string) error
- func (dir ServerDirFS) Mkdir(name string, perm fs.FileMode) error
- func (dir ServerDirFS) Open(name string) (fs.File, error)
- func (dir ServerDirFS) OpenFile(name string, flag int, perm fs.FileMode) (fs.File, error)
- func (dir ServerDirFS) ReadDir(name string) ([]fs.DirEntry, error)
- func (dir ServerDirFS) ReadFile(name string) ([]byte, error)
- func (dir ServerDirFS) Readlink(name string) (string, error)
- func (dir ServerDirFS) Stat(name string) (fs.FileInfo, error)
- func (dir ServerDirFS) WriteFile(name string, data []byte, perm fs.FileMode) error
- type ServerFS
- type ServerHandle
- func (handle *ServerHandle) AddCertificate(filePath string)
- func (handle *ServerHandle) AddDirectory(p string, directoryPath string)
- func (handle *ServerHandle) AddFile(p string, filePath string)
- func (handle *ServerHandle) AddProxyRoute(p string, proxyRoute string, gopherItemType rune)
- func (handle *ServerHandle) AddRoute(p string, handler RequestHandler)
- func (handle *ServerHandle) AddUploadRoute(p string, handler RequestHandler)
- func (handle *ServerHandle) BindAddress() string
- func (handle *ServerHandle) CleanupRateLimiting()
- func (handle *ServerHandle) DefaultLanguage() string
- func (handle *ServerHandle) Directory() string
- func (handle *ServerHandle) FS() ServerFS
- func (handle *ServerHandle) GetServer() *Server
- func (handle *ServerHandle) Hostname() string
- func (handle *ServerHandle) IsIPRateLimited(ip string) bool
- func (handle *ServerHandle) LoadRoutes() error
- func (handle *ServerHandle) MaxConcurrentConnections() int
- func (handle *ServerHandle) Name() string
- func (handle *ServerHandle) Port() string
- func (handle *ServerHandle) Pubnix() bool
- func (handle *ServerHandle) RateLimitDuration() time.Duration
- func (handle *ServerHandle) Router() Router
- func (handle *ServerHandle) SIS() *SISContext
- func (handle *ServerHandle) SaveRoutes() error
- func (handle *ServerHandle) Scheme() string
- func (handle *ServerHandle) ServerHandler() ServerHandlerFunc
- func (handle *ServerHandle) ServerTLSCert() []byte
- func (handle *ServerHandle) ServerTLSCertFilename() string
- func (handle *ServerHandle) SetBindAddress(v string)
- func (handle *ServerHandle) SetHostname(v string)
- func (handle *ServerHandle) SetMaxConcurrentConnections(v int)
- func (handle *ServerHandle) SetName(v string)
- func (handle *ServerHandle) SetPort(v string)
- func (handle *ServerHandle) SetPubnix(v bool)
- func (handle *ServerHandle) SetRateLimitDuration(v time.Duration)
- func (handle *ServerHandle) SetRouter(v Router)
- func (handle *ServerHandle) SetSIS(v *SISContext)
- func (handle *ServerHandle) SetServerHandler(v ServerHandlerFunc)
- func (handle *ServerHandle) SetServerTLSCertFilename(v string)
- func (handle *ServerHandle) SetType(v ServerType)
- func (handle *ServerHandle) Type() ServerType
- type ServerHandlerFunc
- type ServerRouteMapKey
- type ServerType
Constants ¶
This section is empty.
Variables ¶
var OID_CN = asn1.ObjectIdentifier{2, 5, 4, 3}
var OID_USER_ID = asn1.ObjectIdentifier{0, 9, 2342, 19200300, 100, 1, 1}
var TOFUMap map[string]string
Maps address to fingerprint. Shared between all servers
var Version string = "0.1"
Functions ¶
func ArchiveMimetype ¶
func AudioMimetype ¶
func CalendarMimetype ¶
func CertFilename ¶
func CertMimetype ¶
func ContainsCensorWords ¶
func CutAny ¶
CutAny slices s around any Unicode code point from chars, returning the text before and after it. The found result reports whether any Unicode code point was appears in s. If it does not appear in s, CutAny returns s, "", false.
func DocumentMimetype ¶
Where do markup language files get placed?
func DotFilename ¶
func FilenameToGopherItemtype ¶
Use when you cannot get the file's mimetype, like if converting URLs
func GetTitleFromGemtext ¶
Scans until it sees a level-1 heading, and then stops scanning and returns it Works with gemtext, scrolltext, and markdown
func InsertParamsIntoRouteString ¶
func InsertParamsIntoRouteString(route string, params map[string]string, globString string, reverse bool) string
Reverse will insert params into components starting with ":". Otherwise, params will be inserted into components starting with "$"
func MimetypeGetsLangParam ¶
func PrintRoute ¶
func ProtocolIsTLS ¶
func ProtocolIsTLS(protocol ProtocolType) bool
func ProtocolToName ¶
func ProtocolToName(protocol ProtocolType) string
func VideoMimetype ¶
Types ¶
type BindPortHostnameCertificate ¶
type BindPortHostnameCertificate struct {
// contains filtered or unexported fields
}
A certificate for a given BindAddr+Port+Hostname Pair
type PortListener ¶
type PortListener struct { SIS *SISContext BindAddress string Port string MaxConcurrentConnections int // contains filtered or unexported fields }
func NewPortListener ¶
func NewPortListener(SIS *SISContext, BindAddress string, Port string) *PortListener
Create new PortListener
func (*PortListener) AddCertificate ¶
func (l *PortListener) AddCertificate(Hostname string, certFilepath string)
Adds and loads the certificate into the respective PortListener
func (*PortListener) GetCertificate ¶
func (l *PortListener) GetCertificate(Hostname string) BindPortHostnameCertificate
func (*PortListener) HasCertificate ¶
func (l *PortListener) HasCertificate(Hostname string) bool
func (*PortListener) Start ¶
func (l *PortListener) Start(wg *sync.WaitGroup)
type PortListenerKey ¶
type ProtocolType ¶
type ProtocolType int
const ProtocolType_Gemini ProtocolType = 1
const ProtocolType_Gopher ProtocolType = 4
const ProtocolType_Gopher_SSL ProtocolType = 5 // TODO
const ProtocolType_Misfin_A ProtocolType = 6 // Deprecated
const ProtocolType_Misfin_B ProtocolType = 7
const ProtocolType_Misfin_C ProtocolType = 8
const ProtocolType_NPS ProtocolType = 3
const ProtocolType_Nex ProtocolType = 2
const ProtocolType_Scroll ProtocolType = 11
const ProtocolType_Spartan ProtocolType = 10
const ProtocolType_Titan ProtocolType = 9
const ProtocolType_Unknown ProtocolType = 0
type RateLimitListItem ¶
type RateLimitListItem struct {
// contains filtered or unexported fields
}
type Request ¶
type Request struct { // Request Data Type ServerType // TODO: Change this to ProtocolType instead Upload bool // true if request supports reading uploaded data GlobString string // Set to the path components of the glob part of the route // Upload Data DataSize int64 // Expected Size for upload (-1 for any size until connection close) DataMime string // Used for Titan and other protocols that support upload with mimetype. For Spartan, it is usually empty or "text/plain" if proxying to Spartan servers from servers that use queries. // More Request Data UserCert *x509.Certificate // Used for protocols that support TLS Client Certs (Misfin and Gemini) IP string Proxied bool Server ServerHandle // Used for Scroll Protocol ScrollMetadataRequested bool ScrollRequestedLanguages []string // contains filtered or unexported fields }
func (*Request) ClearScrollMetadataResponse ¶
func (r *Request) ClearScrollMetadataResponse()
func (*Request) ClientCertNotAuthorized ¶
func (*Request) DisableConvertMode ¶
func (r *Request) DisableConvertMode()
func (*Request) EnableConvertMode ¶
func (r *Request) EnableConvertMode()
func (*Request) File ¶
Reads whole file into memory, automatically determins the correct mimetype, and sends it over (converting if in convert mode). If file not found or error on opening file, returns with error without sending anything back to the connection. Prefer FileMimetype() if you know the mimetype beforehand.
func (*Request) FileMimetype ¶
func (*Request) GetUploadData ¶
Get Titan or Spartan raw data.
func (*Request) GophermapLine ¶
func (r *Request) GophermapLine(linetype string, name string, selector string, hostname string, port string) error
Enter empty strings for hostname and port to use the server's hostname and port. TODO: Handle URL: links and cross-server links
func (*Request) Hostname ¶
TODO: Reconsider how this works... Gets the requested hostname for protocols that use those in requests If not used in request, then gets the hostname of the server.
func (*Request) NexListing ¶
Send Next text. TODO: This is unfinished.
func (*Request) Path ¶
Gets the requested path, removing hostname and scheme information for protocols that use those in requests Path is unescaped if part of URL (for protocols that use URL requests). Unescaping is unnecessary for Nex and Gopher.
func (*Request) PromptLine ¶
Uses a regular link linetype for Gemini and Nex, and a prompt/search linetype for Spartan and Gopher. The link should be in standard url format, even for gopher servers.
func (*Request) Query ¶
Gets the query for protocols that support queries in requests. The returned query is unescaped. If Spartan, it gets the *raw* uploaded data (if there is any) as text. To get it query escaped, use request.RawQuery() If data is longer than Spartan Query Limit, then this method will return an error.
func (*Request) RawFragment ¶
NOTE: Should almost never be used
func (*Request) RawPath ¶
Gets the requested path, removing hostname and scheme information for protocols that use those in requests Path is escaped if part of URL (for protocols that use URL requests). NOTE: Nex and Gopher requests are not escaped.
func (*Request) RawQuery ¶
Gets the escaped query for protocols that support queries in requests. If Spartan, it gets the uploaded data (if there is any) as text and escapes it. If data is longer than Spartan Query Limit, then this method will return an error.
func (*Request) RequestClientCert ¶
func (*Request) RequestInput ¶
TODO: When proxying gopher to gemini, translate the gopher input requested message/error to a gemini input request.
func (*Request) RouteLink ¶
Sends a link to a particular route on the given server. Route links can reference other servers by prefixing the route path with "$ServerName". You can reference the current request's params by prefixing them with "$" in the route path.
func (*Request) SendAbstract ¶
Will send the abstract that is already stored in the scroll metadata
func (*Request) ServerUnavailable ¶
func (*Request) SetLanguage ¶
Used for all protocols that send a mimetype in the response
func (*Request) SetNoLanguage ¶
func (r *Request) SetNoLanguage()
Forces the response to have no lang parameter
func (*Request) SetScrollMetadataResponse ¶
func (r *Request) SetScrollMetadataResponse(metadata ScrollMetadata)
func (*Request) SetSpartanQueryLimit ¶
Limits the number of bytes of uploaded data to read when you call request.Query() or request.RawQuery(). The default is 1024 to (somewhat) match Gemini. This only applies to .RawQuery() and .Query() calls. It does not apply to .GetUploadData() calls.
func (*Request) Stream ¶
TODO: Use a buffer bool and provide a 32KB buffer from the pool. Streams a file, using a 32KB buffer by default. If you want to control the buffer size, use StreamBuffer.
func (*Request) StreamBuffer ¶
Provide a buffer to handle the copy. This allows you to control your own buffer size to increase performance. For big files, create a big buffer (at the cost of memory). For small files, create a smaller buffer.
func (*Request) TemporaryFailure ¶
func (*Request) TextWithMimetype ¶
TODO
func (*Request) UserCertHash_Gemini ¶
func (*Request) UserCertHash_Misfin ¶
func (*Request) UserCert_MD5Hash ¶
MD5 Hash of User Cert - usually used for Gemini and Titan. Returns empty string when there's no user cert.
func (*Request) UserCert_SHA256Hash ¶
SHA256 Hash of User Cert - usually used for Misfin. Returns empty string when there's no user cert.
type RequestHandler ¶
type RequestHandler func(request Request)
TODO: Ability to return errors (especially NotFound, which redirects to the NotFoundHandler)
type RequestHeader ¶
type RequestHeader struct { Protocol ProtocolType Request string // The Selector/Path or URL that is requested Hostname string // Used for Gemini, Misfin, and Titan ContentLength int64 // Used for Titan, Misfin, and Spartan. If Titan protocol and 0, it's a titan delete request. If Spartan and 0, no upload data is expected. Token string // Used for Titan Mime string // Used for Titan UserCert *x509.Certificate // For TLS protocols MetadataRequest bool // Used for Scroll protocol Languages []string // Used for Scroll protocol }
type RouteListItem ¶
type RouteListItem struct {
// contains filtered or unexported fields
}
type RouteNode ¶
type RouteNode struct { Component string // If equal to "*", then it's a blob and matches with everything. Handler RequestHandler // If nil, no handler Parent *RouteNode Children *RouteNode // Linked List of Children // Linked List Info Next *RouteNode // contains filtered or unexported fields }
func (*RouteNode) ChildrenLength ¶
func (*RouteNode) GetRouteAncestry ¶
Gets array of route nodes from root to last component
func (*RouteNode) GetRoutePath ¶
Gets the route path string
type Router ¶
type Router struct { NotFoundHandler RequestHandler // contains filtered or unexported fields }
Uses a tree to store routes, and matches using a breadth-first search algorithm.
func (*Router) GetRoutesList ¶
func (router *Router) GetRoutesList() []RouteListItem
Flattens routes tree into a list of routes. Returns an array of strings.
func (*Router) PrintRouteTree ¶
func (router *Router) PrintRouteTree()
type SISContext ¶
type SISContext struct {
// contains filtered or unexported fields
}
func InitSIS ¶
func InitSIS(directory string) (*SISContext, error)
func (*SISContext) AddServer ¶
func (context *SISContext) AddServer(server Server) ServerHandle
TODO: Make loadSISConfig use this function? When directory is empty, creates subdirectory under SIS directory named with the server's name.
func (*SISContext) AddServerRoute ¶
func (context *SISContext) AddServerRoute(BindAddress string, Port string, Protocol ProtocolType, Hostname string, server ServerHandle)
func (*SISContext) AdminServer ¶
func (context *SISContext) AdminServer() *Server
Get the Admin server, which will let you customize it (like by adding routes and handlers).
func (*SISContext) AllowIP ¶
func (context *SISContext) AllowIP(ip string)
func (*SISContext) BlockIP ¶
func (context *SISContext) BlockIP(ip string)
func (*SISContext) EnterMaintenanceMode_All ¶
func (context *SISContext) EnterMaintenanceMode_All()
Enters maintenance mode for all portListeners
func (*SISContext) FindServerByName ¶
func (context *SISContext) FindServerByName(name string) ServerHandle
func (*SISContext) FullRestart ¶
func (context *SISContext) FullRestart()
func (*SISContext) GetOrCreatePortListener ¶
func (context *SISContext) GetOrCreatePortListener(BindAddress string, Port string) *PortListener
func (*SISContext) GetPortListener ¶
func (context *SISContext) GetPortListener(BindAddress string, Port string) *PortListener
func (*SISContext) IsIPBlocked ¶
func (context *SISContext) IsIPBlocked(ip string) bool
func (*SISContext) Log ¶
func (context *SISContext) Log(serverType ServerType, label string, msgFormat string, args ...any)
Concurrent-safe
func (*SISContext) SaveConfiguration ¶
func (context *SISContext) SaveConfiguration() error
Saves SIS Config File TODO: Mutex?
func (*SISContext) SetUpdateLink ¶
func (context *SISContext) SetUpdateLink(link string)
Set a gemini link to update the server
func (*SISContext) ShutdownPortListeners ¶
func (context *SISContext) ShutdownPortListeners()
Shuts down all Port Listeners, but does not shut down SIS
func (*SISContext) UpdateAndRestart ¶
func (context *SISContext) UpdateAndRestart(data []byte) string
You must have the new subprocess delete the renamed filename (which is returned by the function). You can do this by redirecting to a route that deletes the old file. By the time the redirect happens, the server would have been updated. You can pass in the data of the executable instead of downloading the data from the update link.
type ScrollMetadata ¶
type Server ¶
type Server struct { Name string Type ServerType BindAddress string Port string UploadPort string // Port to listen on for uploads (usually the same port for gemini+titan, misfin+titan+gemini, and Spartan). Used internally for Nex+NPS. MaxConcurrentConnections int // -1 for unlimited Directory string // Defaults to SIS Directory, unless configured to elsewhere via sis.conf file in code. FS ServerFS ServerHandler ServerHandlerFunc // For custom servers DefaultLanguage string Hostname string // TODO Pubnix bool ServerTLSCertFilename string ServerTLSCert []byte // TODO: Unused Router Router // For Downloads UploadRouter Router // For Uploads (if applicable) RateLimitDuration time.Duration SIS *SISContext // contains filtered or unexported fields }
NOTE: Usually accessed through a ServerHandle. See server_handle.go
func (*Server) AddCertificate ¶
func (*Server) AddDirectory ¶
AddDirectory adds a directory that's either absolute, or relative to the server's directory Remember that a server's directory, when not specified, defaults to a subdirectory named after the server's name under the SIS directory.
func (*Server) AddEmbedDirectory ¶
func (*Server) AddEmbedFile ¶
func (*Server) AddProxyRoute ¶
Proxy routes will proxy the handler from a different server to this server and will automatically set the request to convert mode.
func (*Server) AddRoute ¶
func (s *Server) AddRoute(p string, handler RequestHandler)
func (*Server) AddUploadRoute ¶
func (s *Server) AddUploadRoute(p string, handler RequestHandler)
func (*Server) CleanupRateLimiting ¶
func (s *Server) CleanupRateLimiting()
Removes all IPs that are passed the rate-limit duration. There's no need to call this too often, but do not wait so long that the ip list becomes too big.
func (*Server) GetHandle ¶
func (s *Server) GetHandle() ServerHandle
func (*Server) IPRateLimit_ClearRedirectPath ¶
func (*Server) IPRateLimit_ExpectRedirectPath ¶
When a redirection occurs, let server know to expect another request immediately following the previous one so that the rate-limiting can be bypassed
func (*Server) IPRateLimit_IsExpectingRedirect ¶
func (*Server) IpRateLimit_GetExpectedRedirectPath ¶
func (*Server) IsIPRateLimited ¶
If not rate-limited, set ip to current time and return false. If last access time is within duration, set ip to current time and return true. Otherwise, set ip to current time and return false
func (*Server) LoadRoutes ¶
Located in server's directory (which defaults to the SIS directory)
func (*Server) SaveRoutes ¶
func (*Server) UploadScheme ¶
type ServerDirFS ¶
type ServerDirFS string
func (ServerDirFS) MkSymlink ¶
func (dir ServerDirFS) MkSymlink(name, target string) error
NOTE: The target is *not* relative to the dirFS
type ServerFS ¶
type ServerFS interface { fs.FS fs.ReadFileFS fs.ReadDirFS fsx.FS fsx.FSSupportingWrite fsx.FSSupportingMkSymlink fsx.FSSupportingReadlink fsx.FSSupportingStat WriteFile(name string, data []byte, perm fs.FileMode) error }
Extends go-fsx/osfs to add ReadDir and ReadFile methods
type ServerHandle ¶
type ServerHandle struct {
// contains filtered or unexported fields
}
Handle value for servers
func (*ServerHandle) AddCertificate ¶
func (handle *ServerHandle) AddCertificate(filePath string)
func (*ServerHandle) AddDirectory ¶
func (handle *ServerHandle) AddDirectory(p string, directoryPath string)
func (*ServerHandle) AddFile ¶
func (handle *ServerHandle) AddFile(p string, filePath string)
func (*ServerHandle) AddProxyRoute ¶
func (handle *ServerHandle) AddProxyRoute(p string, proxyRoute string, gopherItemType rune)
func (*ServerHandle) AddRoute ¶
func (handle *ServerHandle) AddRoute(p string, handler RequestHandler)
func (*ServerHandle) AddUploadRoute ¶
func (handle *ServerHandle) AddUploadRoute(p string, handler RequestHandler)
func (*ServerHandle) BindAddress ¶
func (handle *ServerHandle) BindAddress() string
func (*ServerHandle) CleanupRateLimiting ¶
func (handle *ServerHandle) CleanupRateLimiting()
func (*ServerHandle) DefaultLanguage ¶
func (handle *ServerHandle) DefaultLanguage() string
func (*ServerHandle) Directory ¶
func (handle *ServerHandle) Directory() string
func (*ServerHandle) FS ¶
func (handle *ServerHandle) FS() ServerFS
func (*ServerHandle) GetServer ¶
func (handle *ServerHandle) GetServer() *Server
func (*ServerHandle) Hostname ¶
func (handle *ServerHandle) Hostname() string
func (*ServerHandle) IsIPRateLimited ¶
func (handle *ServerHandle) IsIPRateLimited(ip string) bool
func (*ServerHandle) LoadRoutes ¶
func (handle *ServerHandle) LoadRoutes() error
func (*ServerHandle) MaxConcurrentConnections ¶
func (handle *ServerHandle) MaxConcurrentConnections() int
func (*ServerHandle) Name ¶
func (handle *ServerHandle) Name() string
func (*ServerHandle) Port ¶
func (handle *ServerHandle) Port() string
func (*ServerHandle) Pubnix ¶
func (handle *ServerHandle) Pubnix() bool
func (*ServerHandle) RateLimitDuration ¶
func (handle *ServerHandle) RateLimitDuration() time.Duration
func (*ServerHandle) Router ¶
func (handle *ServerHandle) Router() Router
func (*ServerHandle) SIS ¶
func (handle *ServerHandle) SIS() *SISContext
func (*ServerHandle) SaveRoutes ¶
func (handle *ServerHandle) SaveRoutes() error
func (*ServerHandle) Scheme ¶
func (handle *ServerHandle) Scheme() string
func (*ServerHandle) ServerHandler ¶
func (handle *ServerHandle) ServerHandler() ServerHandlerFunc
func (*ServerHandle) ServerTLSCert ¶
func (handle *ServerHandle) ServerTLSCert() []byte
func (*ServerHandle) ServerTLSCertFilename ¶
func (handle *ServerHandle) ServerTLSCertFilename() string
func (*ServerHandle) SetBindAddress ¶
func (handle *ServerHandle) SetBindAddress(v string)
func (*ServerHandle) SetHostname ¶
func (handle *ServerHandle) SetHostname(v string)
func (*ServerHandle) SetMaxConcurrentConnections ¶
func (handle *ServerHandle) SetMaxConcurrentConnections(v int)
func (*ServerHandle) SetName ¶
func (handle *ServerHandle) SetName(v string)
func (*ServerHandle) SetPort ¶
func (handle *ServerHandle) SetPort(v string)
func (*ServerHandle) SetPubnix ¶
func (handle *ServerHandle) SetPubnix(v bool)
func (*ServerHandle) SetRateLimitDuration ¶
func (handle *ServerHandle) SetRateLimitDuration(v time.Duration)
func (*ServerHandle) SetRouter ¶
func (handle *ServerHandle) SetRouter(v Router)
func (*ServerHandle) SetSIS ¶
func (handle *ServerHandle) SetSIS(v *SISContext)
func (*ServerHandle) SetServerHandler ¶
func (handle *ServerHandle) SetServerHandler(v ServerHandlerFunc)
func (*ServerHandle) SetServerTLSCertFilename ¶
func (handle *ServerHandle) SetServerTLSCertFilename(v string)
func (*ServerHandle) SetType ¶
func (handle *ServerHandle) SetType(v ServerType)
func (*ServerHandle) Type ¶
func (handle *ServerHandle) Type() ServerType
type ServerHandlerFunc ¶
type ServerHandlerFunc func(s *Server)
type ServerRouteMapKey ¶
type ServerRouteMapKey struct { Protocol ProtocolType Hostname string // Empty for default/none }
Every Bind Address + Port + Protocol key has one server, but a server can be attached to multiple keys. Servers that use multiple protocols will be registered under multiple keys.
type ServerType ¶
type ServerType int
const ServerType_Admin ServerType = 4 // Gemini + Titan
const ServerType_Gemini ServerType = 0 // Gemini + Titan
const ServerType_Gopher ServerType = 2 // Gopher
const ServerType_Misfin ServerType = 3 // Misfin(B) + Misfin(C) + Gemini
const ServerType_Nex ServerType = 1 // Nex + NPS
const ServerType_Scroll ServerType = 6
const ServerType_Spartan ServerType = 5
const ServerType_Unknown ServerType = 7