Documentation
¶
Index ¶
- Constants
- 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 GenerateSelfSignedCertificateAndPrivateKey(keyType KeyType, common_name string, hosts []string, user_id string, ...) (*x509.Certificate, error)
- 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 ProtocolHasDownload(protocol ProtocolType) bool
- func ProtocolHasUpload(protocol ProtocolType) bool
- func ProtocolIsTLS(protocol ProtocolType) bool
- func ProtocolToName(protocol ProtocolType) string
- func ScanUpToTitle(reader io.ReadSeeker) string
- func UDCToSuccessResponse(value ScrollResponseUDC) int
- func VideoMimetype(mimetype string) bool
- type BindPortHostnameCertificate
- type CertConnection
- type CertID
- type CertInfo
- type CertificateManager
- func (m *CertificateManager) AddCertificateConnection(filepath string, bindaddress string, bindport string, hostname string) CertID
- func (m *CertificateManager) AddServerHostMapping(bindaddress string, bindport string, hostname string, port string, upload bool, ...)
- func (m *CertificateManager) GetCertificate(bindaddress string, bindport string, hostname string) (*BindPortHostnameCertificate, bool)
- func (m *CertificateManager) GetCertificateFromID(id CertID) (*BindPortHostnameCertificate, bool)
- func (m *CertificateManager) GetCertificateFromServerHost(key ServerHost) (*BindPortHostnameCertificate, bool)
- func (m *CertificateManager) GetCertificatesForPortListener(bindaddress string, bindport string) map[string]*BindPortHostnameCertificate
- func (m *CertificateManager) GetCertificatesWithNoConnections() []*BindPortHostnameCertificate
- func (m *CertificateManager) GetDefaultCertForPortListener(l *PortListener) *BindPortHostnameCertificate
- func (m *CertificateManager) GetHostsOfHostname(hostname string) []ServerHost
- func (m *CertificateManager) GetHostsOfHostnameAndPort(hostname string, port string) []ServerHost
- func (m *CertificateManager) GetHostsOfHostnameOnPortListener(bindaddress string, bindport string, hostname string) []ServerHost
- func (m *CertificateManager) GetHostsOnPortListener(bindaddress string, bindport string) []ServerHost
- func (m *CertificateManager) GetNonTLSHostsOnPortListener(bindaddress string, bindport string) []ServerHost
- func (m *CertificateManager) GetOrAddCertificate(id CertID) *BindPortHostnameCertificate
- func (m *CertificateManager) GetServerCertificates(handle VirtualServerHandle) []*BindPortHostnameCertificate
- func (m *CertificateManager) GetServerFromHostMapping(bindaddress string, bindport string, hostname string, port string, upload bool, ...) (ServerHostMapping, bool)
- func (m *CertificateManager) GetServerHosts(handle VirtualServerHandle) []ServerHost
- func (m *CertificateManager) GetServerHostsOnPortListener(bindaddress string, bindport string, handle VirtualServerHandle) []ServerHost
- func (m *CertificateManager) GetServerHostsWithServePortOnPortListener(bindaddress string, bindport string, serveport string, ...) []ServerHost
- func (m *CertificateManager) PortListenerHasServerHostNotOfProtocol(bindaddress string, bindport string, protocol ProtocolType) bool
- func (m *CertificateManager) PortListenerHasServerHostOfProtocol(bindaddress string, bindport string, protocol ProtocolType) bool
- func (m *CertificateManager) RemoveCertificate(id CertID)
- func (m *CertificateManager) RemoveCertificateConnection(bindaddress string, bindport string, hostname string)
- func (m *CertificateManager) RemoveCertificateConnections(id CertID)
- func (m *CertificateManager) RemoveCertificatesWithNoConnections()
- func (m *CertificateManager) RemoveHostname(bindaddress string, bindport string, hostname string)
- func (m *CertificateManager) RemoveHostnameAndPort(bindaddress string, bindport string, hostname string, port string)
- func (m *CertificateManager) RemoveServer(handle VirtualServerHandle)
- func (m *CertificateManager) RemoveServerHostMapping(bindaddress string, bindport string, hostname string, port string, upload bool, ...)
- func (m *CertificateManager) RemoveServerHosts(handle VirtualServerHandle)
- func (m *CertificateManager) RemoveServerHostsOfHostname(bindaddress string, bindport string, hostname string)
- func (m *CertificateManager) RemoveServerHostsOfHostnameAndPort(bindaddress string, bindport string, hostname string, port string)
- type ClientCertificate
- type HostConfig
- type KeyType
- type Log
- type MaybeTLSListener
- type MisfinCertInfo
- type PortListener
- type PortListenerID
- type PortListenerProperties
- 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) CGIFailure(format string, elem ...any) error
- func (r *Request) ClearClassification(classification ScrollResponseUDC)
- func (r *Request) ClearScrollMetadataResponse()
- func (r *Request) ClientCertNotAuthorized(format string, elem ...any) error
- func (r *Request) DataStream(filename string, reader io.ReadSeeker) (err 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) GetAbstractWithInlineMetadata(data string) (abstractData string)
- 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) HasUserCert() bool
- func (r *Request) Hostname() string
- func (r *Request) HostnamePort() string
- func (r *Request) IPHash() string
- func (r *Request) Link(link string, text string) error
- func (r *Request) LinkAbs(link string, text string) error
- 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) PromptLineAbs(link string, text string) error
- func (r *Request) Proxied() bool
- func (r *Request) Query() (string, error)
- func (r *Request) RawFragment() string
- func (r *Request) RawLink(link string, text string) error
- 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) Scheme() string
- func (r *Request) Scroll(text string) error
- func (r *Request) ScrollMetadataRequested() bool
- func (r *Request) SendAbstract(mimetype string) error
- func (r *Request) ServerUnavailable(format string, elem ...any) error
- func (r *Request) SetClassification(classification ScrollResponseUDC)
- func (r *Request) SetKeepAliveConfig(config net.KeepAliveConfig) 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) Upload() bool
- func (r *Request) UserCertHash() string
- func (r *Request) UserCertOldGeminiHash() string
- type RequestFlag
- type RequestHandler
- type RequestHeader
- type RouteGroup
- func (prefix RouteGroup) AddCGIRoute(p string, filePath string)
- func (prefix RouteGroup) AddDirectory(p string, directoryPath string)
- func (prefix RouteGroup) AddFile(p string, filePath string)
- func (prefix RouteGroup) AddProxyRoute(p string, proxyRoute string, gopherItemType rune)
- func (prefix RouteGroup) AddRoute(p string, handler RequestHandler)
- func (prefix RouteGroup) AddSCGIRoute(p string, address string)
- func (prefix RouteGroup) AddUploadRoute(p string, handler RequestHandler)
- func (prefix RouteGroup) Group(p string) RouteGroup
- type RouteListItem
- type RouteNode
- type Router
- type SISContext
- func (context *SISContext) AddServer(server VirtualServer, hosts ...HostConfig) (VirtualServerHandle, error)
- func (context *SISContext) AddServerHostMapping(BindAddress string, BindPort string, Hostname string, ServePort string, ...)
- func (context *SISContext) AdminServer() *VirtualServer
- func (context *SISContext) AllowIP(ip string)
- func (context *SISContext) BlockIP(ip string)
- func (context *SISContext) CreateServer(t ServerType, name string, defaultLanguage string, hosts ...HostConfig) (VirtualServerHandle, error)
- func (context *SISContext) EnterMaintenanceMode_All()
- func (context *SISContext) FindServerByName(name string) VirtualServerHandle
- func (context *SISContext) FullRestart()
- func (context *SISContext) GetOrAddCertificateConnection(certFilepath string, bindaddress string, bindport string, hostname string) CertID
- func (context *SISContext) GetOrCreatePortListener(BindAddress string, BindPort string) *PortListener
- func (context *SISContext) GetPortListener(BindAddress string, Port string) *PortListener
- func (context *SISContext) GetTor() *tor.Tor
- 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 ScrollResponseUDC
- type ServeMux
- 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 ServerHandlerFunc
- type ServerHost
- type ServerHostMapping
- type ServerType
- type VirtualServer
- func (s *VirtualServer) AddCGIRoute(p string, filePath string)
- func (s *VirtualServer) AddDirectory(p string, directoryPath string)
- func (s *VirtualServer) AddEmbedDirectory(p string, content embed.FS, directoryPath string)
- func (s *VirtualServer) AddEmbedFile(p string, content embed.FS, filePath string)
- func (s *VirtualServer) AddFile(p string, filePath string)
- func (s *VirtualServer) AddHosts(hosts ...HostConfig)
- func (s *VirtualServer) AddProxyRoute(p string, proxyRoute string, gopherItemType rune)
- func (s *VirtualServer) AddRoute(p string, handler RequestHandler)
- func (s *VirtualServer) AddSCGIRoute(p string, address string)
- func (s *VirtualServer) AddServerProxyRoute(p string, server VirtualServerHandle)
- func (s *VirtualServer) AddUploadRoute(p string, handler RequestHandler)
- func (s *VirtualServer) CleanupRateLimiting()
- func (s *VirtualServer) GetHandle() VirtualServerHandle
- func (s *VirtualServer) GetHostOfPortListener(protocol ProtocolType, upload bool, bind_addr string, bind_port string, ...) ServerHost
- func (s *VirtualServer) GetPreferredHost(protocol ProtocolType, upload bool, scgi bool) ServerHost
- func (s *VirtualServer) GetPreferredHostOfPortListener(protocol ProtocolType, upload bool, bind_addr string, bind_port string, ...) ServerHost
- func (s *VirtualServer) Group(p string) RouteGroup
- func (s *VirtualServer) HasNonTLSProtocol() bool
- func (s *VirtualServer) HasTLSProtocol() bool
- func (s *VirtualServer) HasUploadProtocol() bool
- func (s *VirtualServer) IPRateLimit_ClearRedirectPath(ip string)
- func (s *VirtualServer) IPRateLimit_ExpectRedirectPath(ip string, redirectPath string)
- func (s *VirtualServer) IPRateLimit_IsExpectingRedirect(ip string) bool
- func (s *VirtualServer) IpRateLimit_GetExpectedRedirectPath(ip string) string
- func (s *VirtualServer) IsIPRateLimited(ip string) bool
- func (s *VirtualServer) LoadRoutes() error
- func (s *VirtualServer) SaveRoutes() error
- func (s *VirtualServer) Scheme() string
- func (s *VirtualServer) UploadScheme() string
- type VirtualServerHandle
- func (handle VirtualServerHandle) AddCGIRoute(p string, filePath string)
- func (handle VirtualServerHandle) AddDirectory(p string, directoryPath string)
- func (handle VirtualServerHandle) AddFile(p string, filePath string)
- func (handle VirtualServerHandle) AddHosts(hosts ...HostConfig)
- func (handle VirtualServerHandle) AddProxyRoute(p string, proxyRoute string, gopherItemType rune)
- func (handle VirtualServerHandle) AddRoute(p string, handler RequestHandler)
- func (handle VirtualServerHandle) AddSCGIRoute(p string, address string)
- func (handle VirtualServerHandle) AddUploadRoute(p string, handler RequestHandler)
- func (handle VirtualServerHandle) CleanupRateLimiting()
- func (handle VirtualServerHandle) DefaultLanguage() string
- func (handle VirtualServerHandle) Directory() string
- func (handle VirtualServerHandle) FS() ServerFS
- func (handle VirtualServerHandle) GetData(key string) (interface{}, bool)
- func (handle VirtualServerHandle) GetPreferredHost(protocol ProtocolType, upload bool, scgi bool) ServerHost
- func (handle VirtualServerHandle) GetPreferredHostOfPortListener(protocol ProtocolType, upload bool, bind_addr string, bind_port string, ...) ServerHost
- func (handle VirtualServerHandle) GetServer() *VirtualServer
- func (handle VirtualServerHandle) Group(p string) RouteGroup
- func (handle VirtualServerHandle) HasNonTLSProtocol() bool
- func (handle VirtualServerHandle) HasTLSProtocol() bool
- func (handle VirtualServerHandle) HasUploadProtocol() bool
- func (handle VirtualServerHandle) IsIPRateLimited(ip string) bool
- func (handle VirtualServerHandle) LoadRoutes() error
- func (handle VirtualServerHandle) MaxConcurrentConnections() int
- func (handle VirtualServerHandle) Name() string
- func (handle VirtualServerHandle) Protocols() *bitset.BitSet[ProtocolType, ProtocolType]
- func (handle VirtualServerHandle) Pubnix() bool
- func (handle VirtualServerHandle) RateLimitDuration() time.Duration
- func (handle VirtualServerHandle) Router() *Router
- func (handle VirtualServerHandle) SIS() *SISContext
- func (handle VirtualServerHandle) SaveRoutes() error
- func (handle VirtualServerHandle) Scheme() string
- func (handle VirtualServerHandle) ServerHandler() ServerHandlerFunc
- func (handle VirtualServerHandle) SetData(key string, value interface{})
- func (handle VirtualServerHandle) SetMaxConcurrentConnections(v int)
- func (handle VirtualServerHandle) SetName(v string)
- func (handle VirtualServerHandle) SetPubnix(v bool)
- func (handle VirtualServerHandle) SetRateLimitDuration(v time.Duration)
- func (handle VirtualServerHandle) SetSIS(v *SISContext)
- func (handle VirtualServerHandle) SetServerHandler(v ServerHandlerFunc)
- func (handle VirtualServerHandle) SetType(v ServerType)
- func (handle VirtualServerHandle) Type() ServerType
Constants ¶
const ( ScrollResponseUDC_Class4 ScrollResponseUDC = iota ScrollResponseUDC_Class0 // Knowledge, General Science, Docs, RFCs, Software, Data ScrollResponseUDC_Class1 ScrollResponseUDC_Class2 ScrollResponseUDC_Class3 ScrollResponseUDC_Class5 ScrollResponseUDC_Class6 ScrollResponseUDC_Class7 ScrollResponseUDC_Class8 ScrollResponseUDC_Class9 ScrollResponseUDC_GeneralKnowledge = ScrollResponseUDC_Class0 ScrollResponseUDC_Docs = ScrollResponseUDC_Class0 ScrollResponseUDC_Data = ScrollResponseUDC_Class0 ScrollResponseUDC_GeneralScience = ScrollResponseUDC_Class0 ScrollResponseUDC_Reference = ScrollResponseUDC_Class0 ScrollResponseUDC_CompSci = ScrollResponseUDC_Class0 ScrollResponseUDC_News = ScrollResponseUDC_Class0 ScrollResponseUDC_ComputerTechnology = ScrollResponseUDC_Class0 ScrollResponseUDC_Philosophy = ScrollResponseUDC_Class1 ScrollResponseUDC_Psychology = ScrollResponseUDC_Class1 ScrollResponseUDC_Religion = ScrollResponseUDC_Class2 ScrollResponseUDC_Theology = ScrollResponseUDC_Class2 ScrollResponseUDC_Scripture = ScrollResponseUDC_Class2 ScrollResponseUDC_SocialScience = ScrollResponseUDC_Class3 ScrollResponseUDC_Politics = ScrollResponseUDC_Class3 ScrollResponseUDC_Unclassed = ScrollResponseUDC_Class4 ScrollResponseUDC_Aggregator = ScrollResponseUDC_Class4 ScrollResponseUDC_Directory = ScrollResponseUDC_Class4 ScrollResponseUDC_Index_Menu = ScrollResponseUDC_Class4 ScrollResponseUDC_Misc = ScrollResponseUDC_Class4 ScrollResponseUDC_Mathematics = ScrollResponseUDC_Class5 ScrollResponseUDC_NaturalScience = ScrollResponseUDC_Class5 ScrollResponseUDC_AppliedScience = ScrollResponseUDC_Class6 ScrollResponseUDC_Medicine = ScrollResponseUDC_Class6 ScrollResponseUDC_Health = ScrollResponseUDC_Class6 ScrollResponseUDC_GeneralTechnology = ScrollResponseUDC_Class6 ScrollResponseUDC_Engineering = ScrollResponseUDC_Class6 ScrollResponseUDC_Business = ScrollResponseUDC_Class6 ScrollResponseUDC_Accountancy = ScrollResponseUDC_Class6 ScrollResponseUDC_Art = ScrollResponseUDC_Class7 ScrollResponseUDC_Fashion = ScrollResponseUDC_Class7 ScrollResponseUDC_Entertainment = ScrollResponseUDC_Class7 ScrollResponseUDC_Music = ScrollResponseUDC_Class7 ScrollResponseUDC_GamingVideos = ScrollResponseUDC_Class7 ScrollResponseUDC_FictionalMovies = ScrollResponseUDC_Class7 ScrollResponseUDC_FictionalAnimation = ScrollResponseUDC_Class7 ScrollResponseUDC_FictionalTVShows = ScrollResponseUDC_Class7 ScrollResponseUDC_Sport = ScrollResponseUDC_Class7 ScrollResponseUDC_Fitness = ScrollResponseUDC_Class7 ScrollResponseUDC_Recreation = ScrollResponseUDC_Class7 ScrollResponseUDC_Linguistics = ScrollResponseUDC_Class8 ScrollResponseUDC_Literature = ScrollResponseUDC_Class8 ScrollResponseUDC_LiteraryCriticism = ScrollResponseUDC_Class8 ScrollResponseUDC_Memoir = ScrollResponseUDC_Class8 ScrollResponseUDC_PersonalLog = ScrollResponseUDC_Class8 ScrollResponseUDC_BookReview = ScrollResponseUDC_Class8 ScrollResponseUDC_MovieReview = ScrollResponseUDC_Class8 ScrollResponseUDC_VideoReview = ScrollResponseUDC_Class8 ScrollResponseUDC_MusicReview = ScrollResponseUDC_Class8 ScrollResponseUDC_History = ScrollResponseUDC_Class9 ScrollResponseUDC_Geography = ScrollResponseUDC_Class9 ScrollResponseUDC_Biography = ScrollResponseUDC_Class9 )
Variables ¶
var OID_CN = asn1.ObjectIdentifier{2, 5, 4, 3}
OID_CN represents the Object Identifier for the Common Name (CN) attribute in X.500 directory services. It is commonly used to store the name of an entity (e.g., a person, organization, or domain) in X.509 certificates.
var OID_MISFIN = "2.25.276466666638671594291857646440529523315.0" // 2.25.276466666638671594291857646440529523315.0
var OID_USER_ID = asn1.ObjectIdentifier{0, 9, 2342, 19200300, 100, 1, 1}
OID_USER_ID represents the Object Identifier for the userId attribute in X.500 directory services. It is commonly used to store a user's login name or username in X.509 certificates.
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 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 ProtocolHasDownload ¶
func ProtocolHasDownload(protocol ProtocolType) bool
func ProtocolHasUpload ¶
func ProtocolHasUpload(protocol ProtocolType) bool
func ProtocolIsTLS ¶
func ProtocolIsTLS(protocol ProtocolType) bool
func ProtocolToName ¶
func ProtocolToName(protocol ProtocolType) string
func ScanUpToTitle ¶
func ScanUpToTitle(reader io.ReadSeeker) string
Returns the header data (everything up to but excluding the first title of the document)
func UDCToSuccessResponse ¶
func UDCToSuccessResponse(value ScrollResponseUDC) int
func VideoMimetype ¶
Types ¶
type BindPortHostnameCertificate ¶
type BindPortHostnameCertificate struct { CertFilepath CertID Certificate *x509.Certificate PrivateKey crypto.PrivateKey PrivateKeyPemBytes []byte }
A certificate for a given BindAddr+Port+Hostname Pair
func (*BindPortHostnameCertificate) GetInfo ¶
func (c *BindPortHostnameCertificate) GetInfo() CertInfo
TODO: Return empty CertInfo if cannot load cert file and cert is empty.
func (*BindPortHostnameCertificate) GetTLSCertificate ¶
func (c *BindPortHostnameCertificate) GetTLSCertificate() *tls.Certificate
TODO: Return nil if cannot load cert file and cert is empty.
func (*BindPortHostnameCertificate) IsEmpty ¶
func (c *BindPortHostnameCertificate) IsEmpty() bool
type CertConnection ¶
type CertificateManager ¶
type CertificateManager struct { CertIDs map[CertID]*BindPortHostnameCertificate CertConnections map[CertConnection]*BindPortHostnameCertificate ServerHostMappings map[ServerHost]ServerHostMapping PortListenerProperties map[PortListenerID]PortListenerProperties // TODO: Deal with this map when port listeners and server handles are deleted. }
Manages Certificates, their connections to BindPortHostnames, as well as Server Routes.
func NewCertManager ¶
func NewCertManager() *CertificateManager
func (*CertificateManager) AddCertificateConnection ¶
func (*CertificateManager) AddServerHostMapping ¶
func (m *CertificateManager) AddServerHostMapping(bindaddress string, bindport string, hostname string, port string, upload bool, scgi bool, handle VirtualServerHandle)
func (*CertificateManager) GetCertificate ¶
func (m *CertificateManager) GetCertificate(bindaddress string, bindport string, hostname string) (*BindPortHostnameCertificate, bool)
func (*CertificateManager) GetCertificateFromID ¶
func (m *CertificateManager) GetCertificateFromID(id CertID) (*BindPortHostnameCertificate, bool)
GetCertificateFromID gets the certificate given the certificate ID. Use GetOrAddCertificate() to get a certificate and add it if it hasn't already been added.
func (*CertificateManager) GetCertificateFromServerHost ¶
func (m *CertificateManager) GetCertificateFromServerHost(key ServerHost) (*BindPortHostnameCertificate, bool)
func (*CertificateManager) GetCertificatesForPortListener ¶
func (m *CertificateManager) GetCertificatesForPortListener(bindaddress string, bindport string) map[string]*BindPortHostnameCertificate
func (*CertificateManager) GetCertificatesWithNoConnections ¶
func (m *CertificateManager) GetCertificatesWithNoConnections() []*BindPortHostnameCertificate
GetCertificatesWithNoConnections gets orphaned certificates that have no connectins to hostnames.
func (*CertificateManager) GetDefaultCertForPortListener ¶
func (m *CertificateManager) GetDefaultCertForPortListener(l *PortListener) *BindPortHostnameCertificate
func (*CertificateManager) GetHostsOfHostname ¶
func (m *CertificateManager) GetHostsOfHostname(hostname string) []ServerHost
GetHostsOfHostname gets all Hosts of a hostname attached to any bind address and bind port.
func (*CertificateManager) GetHostsOfHostnameAndPort ¶
func (m *CertificateManager) GetHostsOfHostnameAndPort(hostname string, port string) []ServerHost
GetHostsOfHostnameAndPort gets all Hosts of a hostname and port attached to any bind address and bind port.
func (*CertificateManager) GetHostsOfHostnameOnPortListener ¶
func (m *CertificateManager) GetHostsOfHostnameOnPortListener(bindaddress string, bindport string, hostname string) []ServerHost
GetHostsOfHostname gets all Hosts of a hostname attached to any bind address and bind port.
func (*CertificateManager) GetHostsOnPortListener ¶
func (m *CertificateManager) GetHostsOnPortListener(bindaddress string, bindport string) []ServerHost
func (*CertificateManager) GetNonTLSHostsOnPortListener ¶
func (m *CertificateManager) GetNonTLSHostsOnPortListener(bindaddress string, bindport string) []ServerHost
func (*CertificateManager) GetOrAddCertificate ¶
func (m *CertificateManager) GetOrAddCertificate(id CertID) *BindPortHostnameCertificate
func (*CertificateManager) GetServerCertificates ¶
func (m *CertificateManager) GetServerCertificates(handle VirtualServerHandle) []*BindPortHostnameCertificate
GetServerCertificates gets the certificates of the server's hosts.
func (*CertificateManager) GetServerFromHostMapping ¶
func (m *CertificateManager) GetServerFromHostMapping(bindaddress string, bindport string, hostname string, port string, upload bool, scgi bool) (ServerHostMapping, bool)
func (*CertificateManager) GetServerHosts ¶
func (m *CertificateManager) GetServerHosts(handle VirtualServerHandle) []ServerHost
GetServerHosts gets all Hosts of a particular server.
func (*CertificateManager) GetServerHostsOnPortListener ¶
func (m *CertificateManager) GetServerHostsOnPortListener(bindaddress string, bindport string, handle VirtualServerHandle) []ServerHost
GetServerHosts gets all Hosts of a particular server.
func (*CertificateManager) GetServerHostsWithServePortOnPortListener ¶
func (m *CertificateManager) GetServerHostsWithServePortOnPortListener(bindaddress string, bindport string, serveport string, handle VirtualServerHandle) []ServerHost
GetServerHosts gets all Hosts of a particular server.
func (*CertificateManager) PortListenerHasServerHostNotOfProtocol ¶
func (m *CertificateManager) PortListenerHasServerHostNotOfProtocol(bindaddress string, bindport string, protocol ProtocolType) bool
func (*CertificateManager) PortListenerHasServerHostOfProtocol ¶
func (m *CertificateManager) PortListenerHasServerHostOfProtocol(bindaddress string, bindport string, protocol ProtocolType) bool
func (*CertificateManager) RemoveCertificate ¶
func (m *CertificateManager) RemoveCertificate(id CertID)
func (*CertificateManager) RemoveCertificateConnection ¶
func (m *CertificateManager) RemoveCertificateConnection(bindaddress string, bindport string, hostname string)
func (*CertificateManager) RemoveCertificateConnections ¶
func (m *CertificateManager) RemoveCertificateConnections(id CertID)
func (*CertificateManager) RemoveCertificatesWithNoConnections ¶
func (m *CertificateManager) RemoveCertificatesWithNoConnections()
RemoveCertificatesWithNoConnections removes orphaned certificates that have no connections to hostnames.
func (*CertificateManager) RemoveHostname ¶
func (m *CertificateManager) RemoveHostname(bindaddress string, bindport string, hostname string)
RemoveHostname removes the server routes of the given hostname and its certificate connections.
func (*CertificateManager) RemoveHostnameAndPort ¶
func (m *CertificateManager) RemoveHostnameAndPort(bindaddress string, bindport string, hostname string, port string)
RemoveHostname removes the server routes of the given hostname and port on a given bind address and bind port, as well as the certificate connections if no server routes of the hostname exist with other ports.
func (*CertificateManager) RemoveServer ¶
func (m *CertificateManager) RemoveServer(handle VirtualServerHandle)
TODO: RemoveServer removes the certificate connections and server routes of the given server handle. Does not remove the certificates or cert connections of hostnames used on other servers.
func (*CertificateManager) RemoveServerHostMapping ¶
func (*CertificateManager) RemoveServerHosts ¶
func (m *CertificateManager) RemoveServerHosts(handle VirtualServerHandle)
RemoveServerRoutes removes just the routes of the given server handle. Will not remove any certificates or certificate connections associated with the server's hosts. For that, use RemoveServer().
func (*CertificateManager) RemoveServerHostsOfHostname ¶
func (m *CertificateManager) RemoveServerHostsOfHostname(bindaddress string, bindport string, hostname string)
RemoveServerHostsOfHostnameAndPort removes all Hosts of a given Hostname on a given PortListener.
func (*CertificateManager) RemoveServerHostsOfHostnameAndPort ¶
func (m *CertificateManager) RemoveServerHostsOfHostnameAndPort(bindaddress string, bindport string, hostname string, port string)
RemoveServerHostsOfHostnameAndPort removes all Hosts of a given Hostname and Port on a given PortListener.
type ClientCertificate ¶
type ClientCertificate struct { SerialNumber string // Certificate Serial Number Hash string HashType string // Usually SHA256 if Hash given from SIS itself. Could be empty if hash was given to SCGI Application Server by different server software. MD5Hash string // NOTE: Added as a workaround to upgrade AuraGem's database user hashes to SHA256. Empty if not available. NotBefore time.Time NotAfter time.Time Subject string // Subject CN Issuer string // Issuer CN SubjectUserID string // OID_USER_ID }
func ClientCertificateFromCertificate ¶
func ClientCertificateFromCertificate(cert *x509.Certificate) ClientCertificate
type HostConfig ¶
type MaybeTLSListener ¶
type MisfinCertInfo ¶
type MisfinCertInfo struct { IsCA bool // contains filtered or unexported fields }
type PortListener ¶
type PortListener struct { SIS *SISContext BindAddress string BindPort string MaxConcurrentConnections int TorServer VirtualServerHandle TorKey crypto.PrivateKey // contains filtered or unexported fields }
func NewPortListener ¶
func NewPortListener(SIS *SISContext, BindAddress string, Port string) *PortListener
Create new PortListener
func (*PortListener) DefaultServer ¶
func (l *PortListener) DefaultServer() VirtualServerHandle
func (*PortListener) ID ¶
func (l *PortListener) ID() PortListenerID
func (*PortListener) SetTorKey ¶
func (l *PortListener) SetTorKey(key crypto.PrivateKey)
func (*PortListener) SetTorServerRoute ¶
func (l *PortListener) SetTorServerRoute(server VirtualServerHandle)
func (*PortListener) Start ¶
func (l *PortListener) Start(wg *sync.WaitGroup)
type PortListenerID ¶
type PortListenerProperties ¶
type PortListenerProperties struct {
// contains filtered or unexported fields
}
type ProtocolType ¶
type ProtocolType uint
const ProtocolType_Gemini ProtocolType = 1
const ProtocolType_Gopher ProtocolType = 4
const ProtocolType_Gopher_SSL ProtocolType = 5 // TODO
const ProtocolType_Guppy ProtocolType = 12 // 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_Scorpion ProtocolType = 13 // TODO: Has both TLS and Non-TLS?
const ProtocolType_Scroll ProtocolType = 11
const ProtocolType_Spartan ProtocolType = 10
const ProtocolType_Titan ProtocolType = 9
const ProtocolType_Unknown ProtocolType = 0
func NameToProtocol ¶
func NameToProtocol(name string) ProtocolType
type RateLimitListItem ¶
type RateLimitListItem struct {
// contains filtered or unexported fields
}
type Request ¶
type Request struct { Type ProtocolType // The expected protocol. When proxied, this will be the protocol being proxied to. Use proxyFromType for the protocol being proxied from. Host ServerHost // The Host information of the current request GlobString string // Set to the path components of the glob part of the route 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. UserCert ClientCertificate // Used for protocols that support TLS Client Certs (Misfin and Gemini) IP string RemotePort string // Remote Port of client host ProxiedUnder string // The path being proxied under. This is necessary to proxy gemini and nex over to gopher, because gopher requires links be absolute to originating server. It is also used for SCGI application servers, where it is set to the SCRIPT_NAME environment variable. Server VirtualServerHandle ScrollRequestedLanguages []string // contains filtered or unexported fields }
func (*Request) ClearClassification ¶
func (r *Request) ClearClassification(classification ScrollResponseUDC)
func (*Request) ClearScrollMetadataResponse ¶
func (r *Request) ClearScrollMetadataResponse()
func (*Request) ClientCertNotAuthorized ¶
func (*Request) DataStream ¶
func (r *Request) DataStream(filename string, reader io.ReadSeeker) (err error)
If filename is empty, the mimetype will still be detected from the content of the data.
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) GetAbstractWithInlineMetadata ¶
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) HasUserCert ¶
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) HostnamePort ¶
Hostname + Port. Port is excluded if it's the default of the protocol.
func (*Request) Link ¶
Sends a link via the current expected protocol, prepending the proxied path if applicable. The link must be manually handled; it will not take into account routes that were created with a RoutePrefix. If you want to send over an absolute link, use LinkAbs to make relative links absolute, which *will* automatically handle routes created with a RoutePrefix.
func (*Request) LinkAbs ¶
LinkAbs turns relative links absolute by joining them with the current path of request, also prepending the proxied path if applicable. This can be used to take into account routes that were created with a RoutePrefix.
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. The proxied path is auto-prepended if applicable. The link must be manually handled; it will not take into account routes that were created with a RoutePrefix. If you want to send over an absolute link, use PromptLineAbs to make relative links absolute, which *will* automatically handle routes created with a RoutePrefix.
func (*Request) PromptLineAbs ¶
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. The proxied path is auto-prepended if applicable. PromptLineAbs turns relative links absolute by joining them with the current path of request, also prepending the proxied path if applicable. This can be used to take into account routes that were created with a RoutePrefix.
func (*Request) Proxied ¶
Proxied returns true if request is being proxied, or if the request is going through an SCGI application server.
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) RawLink ¶
Sends a link without any conversion, RouteGroup prefix, or proxy correction.
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) ScrollMetadataRequested ¶
func (*Request) SendAbstract ¶
Will send the abstract that is already stored in the scroll metadata
func (*Request) ServerUnavailable ¶
func (*Request) SetClassification ¶
func (r *Request) SetClassification(classification ScrollResponseUDC)
func (*Request) SetKeepAliveConfig ¶
func (r *Request) SetKeepAliveConfig(config net.KeepAliveConfig) error
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 ¶
func (*Request) UserCertOldGeminiHash ¶
type RequestFlag ¶
type RequestFlag byte
NOTE: If more are added, RequestFlag needs to be expanded to uin16 or above
const ( RequestFlag_Upload RequestFlag = iota // Set if request supports upload. RequestFlag_HeaderSent // Set if the response header has already been sent (for protocols that use response headers). RequestFlag_ConvertMode // Set to convert from given format to default format of protocol. RequestFlag_Proxied // Set if request is proxied, or if an SCGI application server. RequestFlag_AllowServeCert // Set to allow serving cert/key files. Will be set to the route's security setting. RequestFlag_AllowServeDotFiles // Set to allow serving dot (and hidden) files. Will be set to the route's security setting. RequestFlag_ScrollMetadataRequested // Set if request is asking for Metadata from the Scroll protocol. )
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. Includes the query string. Hostname string // Used for Gemini, Misfin, and Titan Port string // aka. ServePort, the public-facing port. 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 ClientCertificate // For TLS protocols MetadataRequest bool // Used for Scroll protocol Languages []string // Used for Scroll protocol SCGI bool SCGI_SERVER_NAME string SCGI_REMOTE_ADDR string SCGI_REMOTE_PORT string SCGI_REMOTE_HOST string // FQDN of client, or empty. SCGI_SCRIPT_NAME string SCGI_PATH_INFO string // TODO }
type RouteGroup ¶
type RouteGroup struct {
// contains filtered or unexported fields
}
Attach a prefix to routes.
func (RouteGroup) AddCGIRoute ¶
func (prefix RouteGroup) AddCGIRoute(p string, filePath string)
func (RouteGroup) AddDirectory ¶
func (prefix RouteGroup) AddDirectory(p string, directoryPath string)
func (RouteGroup) AddFile ¶
func (prefix RouteGroup) AddFile(p string, filePath string)
func (RouteGroup) AddProxyRoute ¶
func (prefix RouteGroup) AddProxyRoute(p string, proxyRoute string, gopherItemType rune)
func (RouteGroup) AddRoute ¶
func (prefix RouteGroup) AddRoute(p string, handler RequestHandler)
func (RouteGroup) AddSCGIRoute ¶
func (prefix RouteGroup) AddSCGIRoute(p string, address string)
func (RouteGroup) AddUploadRoute ¶
func (prefix RouteGroup) AddUploadRoute(p string, handler RequestHandler)
func (RouteGroup) Group ¶
func (prefix RouteGroup) Group(p string) RouteGroup
Group creates a prefix to be automatically prepended to all routes created on the RouteGroup. It will also ensure all absolute links in the responses of the attached routes will be prepended with the group prefix.
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 InitConfiglessMode ¶
func InitConfiglessMode() (*SISContext, error)
Initialize SIS in configless mode, without an admin server. This is primarily for using SIS as a library to create one-off servers, especially for SCGI servers.
func InitSIS ¶
func InitSIS(directory string) (*SISContext, error)
func (*SISContext) AddServer ¶
func (context *SISContext) AddServer(server VirtualServer, hosts ...HostConfig) (VirtualServerHandle, error)
When directory is empty, creates subdirectory under SIS directory named with the server's name. TODO: Take in a ServerConfig, rather than a Server that gets copied TODO: Make loadSISConfig use this function?
func (*SISContext) AddServerHostMapping ¶
func (context *SISContext) AddServerHostMapping(BindAddress string, BindPort string, Hostname string, ServePort string, Upload bool, scgi bool, server VirtualServerHandle)
func (*SISContext) AdminServer ¶
func (context *SISContext) AdminServer() *VirtualServer
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) CreateServer ¶
func (context *SISContext) CreateServer(t ServerType, name string, defaultLanguage string, hosts ...HostConfig) (VirtualServerHandle, error)
TODO: Other settings one might want to specify include Directory, FS, Pubnix, and MaxConcurrentConnections
func (*SISContext) EnterMaintenanceMode_All ¶
func (context *SISContext) EnterMaintenanceMode_All()
Enters maintenance mode for all portListeners
func (*SISContext) FindServerByName ¶
func (context *SISContext) FindServerByName(name string) VirtualServerHandle
func (*SISContext) FullRestart ¶
func (context *SISContext) FullRestart()
func (*SISContext) GetOrAddCertificateConnection ¶
func (*SISContext) GetOrCreatePortListener ¶
func (context *SISContext) GetOrCreatePortListener(BindAddress string, BindPort string) *PortListener
func (*SISContext) GetPortListener ¶
func (context *SISContext) GetPortListener(BindAddress string, Port string) *PortListener
func (*SISContext) GetTor ¶
func (context *SISContext) GetTor() *tor.Tor
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 ScrollResponseUDC ¶
type ScrollResponseUDC uint8
func ClassificationStringToUDC ¶
func ClassificationStringToUDC(value string) ScrollResponseUDC
func GetInlineMetadataFromGemtext ¶
func GetInlineMetadataFromGemtext(reader io.Reader) (title string, author string, publishdate time.Time, modificationdate time.Time, language string, classification ScrollResponseUDC)
Scans until it sees a level-1 heading, and then stops scanning and returns it Works with gemtext, scrolltext, and markdown
type ServeMux ¶
type ServeMux interface { AddRoute(p string, handler RequestHandler) AddUploadRoute(p string, handler RequestHandler) AddDirectory(p string, directoryPath string) AddCGIRoute(p string, filePath string) AddSCGIRoute(p string, address string) AddProxyRoute(p string, proxyRoute string, gopherItemType rune) AddFile(p string, filePath string) // Group creates a prefix to be automatically prepended to all routes created on the RouteGroup. Group(p string) RouteGroup }
Provides methods to add routes to a VirtualServer or RouteGroup
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 ServerHandlerFunc ¶
type ServerHandlerFunc func(s *VirtualServer)
type ServerHost ¶
type ServerHost struct { BindAddress string BindPort string Hostname string Port string // aka. ServePort, the public facing port. Should be empty for nex, nps, gopher, and spartan. // TODO //Protocol ProtocolType Upload bool SCGI bool }
func ParseHostString ¶
func ParseHostString(host string) ServerHost
func (*ServerHost) IsEmpty ¶
func (s *ServerHost) IsEmpty() bool
func (*ServerHost) ToString ¶
func (s *ServerHost) ToString() string
type ServerHostMapping ¶
type ServerHostMapping struct { ServePort string // The public-facing port. For nex, nps, gopher, and spartan, should be what was set in the config file. Handle VirtualServerHandle }
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 + Titan
const ServerType_Nex ServerType = 1 // Nex + NPS
const ServerType_Scroll ServerType = 6 // Scroll + Titan
const ServerType_Spartan ServerType = 5 // Spartan
const ServerType_Unknown ServerType = 7
type VirtualServer ¶
type VirtualServer struct { Name string Type ServerType Protocols bitset.BitSet[ProtocolType, ProtocolType] KeyValStore cmap.ConcurrentMap[string, interface{}] // To store data that can be used in request handlers. 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 Pubnix bool 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 (*VirtualServer) AddCGIRoute ¶
func (s *VirtualServer) AddCGIRoute(p string, filePath string)
func (*VirtualServer) AddDirectory ¶
func (s *VirtualServer) AddDirectory(p string, directoryPath string)
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 (*VirtualServer) AddEmbedDirectory ¶
func (s *VirtualServer) AddEmbedDirectory(p string, content embed.FS, directoryPath string)
func (*VirtualServer) AddEmbedFile ¶
func (s *VirtualServer) AddEmbedFile(p string, content embed.FS, filePath string)
func (*VirtualServer) AddFile ¶
func (s *VirtualServer) AddFile(p string, filePath string)
Adds a file that's either absolute, or relative to the server's directory
func (*VirtualServer) AddHosts ¶
func (s *VirtualServer) AddHosts(hosts ...HostConfig)
func (*VirtualServer) AddProxyRoute ¶
func (s *VirtualServer) AddProxyRoute(p string, proxyRoute string, gopherItemType rune)
Proxy routes will proxy the handler from a different server to this server and will automatically set the request to convert mode.
func (*VirtualServer) AddRoute ¶
func (s *VirtualServer) AddRoute(p string, handler RequestHandler)
func (*VirtualServer) AddSCGIRoute ¶
func (s *VirtualServer) AddSCGIRoute(p string, address string)
func (*VirtualServer) AddServerProxyRoute ¶
func (s *VirtualServer) AddServerProxyRoute(p string, server VirtualServerHandle)
Proxies an entire (Virtual)Server underneath the given route.
func (*VirtualServer) AddUploadRoute ¶
func (s *VirtualServer) AddUploadRoute(p string, handler RequestHandler)
func (*VirtualServer) CleanupRateLimiting ¶
func (s *VirtualServer) 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 (*VirtualServer) GetHandle ¶
func (s *VirtualServer) GetHandle() VirtualServerHandle
func (*VirtualServer) GetHostOfPortListener ¶
func (s *VirtualServer) GetHostOfPortListener(protocol ProtocolType, upload bool, bind_addr string, bind_port string, hostname string, port string, scgi bool) ServerHost
func (*VirtualServer) GetPreferredHost ¶
func (s *VirtualServer) GetPreferredHost(protocol ProtocolType, upload bool, scgi bool) ServerHost
TODO: This doesn't work correctly (because it uses maps). We need to store what the preferred host should be (and if it changes, it should change).
func (*VirtualServer) GetPreferredHostOfPortListener ¶
func (s *VirtualServer) GetPreferredHostOfPortListener(protocol ProtocolType, upload bool, bind_addr string, bind_port string, scgi bool) ServerHost
TODO: This doesn't work correctly (because it uses maps)
func (*VirtualServer) Group ¶
func (s *VirtualServer) Group(p string) RouteGroup
Group creates a prefix to be automatically prepended to all routes created on the RouteGroup. It will also ensure all absolute links in the responses of the attached routes will be prepended with the group prefix.
func (*VirtualServer) HasNonTLSProtocol ¶
func (s *VirtualServer) HasNonTLSProtocol() bool
func (*VirtualServer) HasTLSProtocol ¶
func (s *VirtualServer) HasTLSProtocol() bool
func (*VirtualServer) HasUploadProtocol ¶
func (s *VirtualServer) HasUploadProtocol() bool
func (*VirtualServer) IPRateLimit_ClearRedirectPath ¶
func (s *VirtualServer) IPRateLimit_ClearRedirectPath(ip string)
func (*VirtualServer) IPRateLimit_ExpectRedirectPath ¶
func (s *VirtualServer) IPRateLimit_ExpectRedirectPath(ip string, redirectPath string)
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 (*VirtualServer) IPRateLimit_IsExpectingRedirect ¶
func (s *VirtualServer) IPRateLimit_IsExpectingRedirect(ip string) bool
func (*VirtualServer) IpRateLimit_GetExpectedRedirectPath ¶
func (s *VirtualServer) IpRateLimit_GetExpectedRedirectPath(ip string) string
func (*VirtualServer) IsIPRateLimited ¶
func (s *VirtualServer) IsIPRateLimited(ip string) bool
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 (*VirtualServer) LoadRoutes ¶
func (s *VirtualServer) LoadRoutes() error
Located in server's directory (which defaults to the SIS directory)
func (*VirtualServer) SaveRoutes ¶
func (s *VirtualServer) SaveRoutes() error
func (*VirtualServer) Scheme ¶
func (s *VirtualServer) Scheme() string
Gets the default/download protocol Scheme
func (*VirtualServer) UploadScheme ¶
func (s *VirtualServer) UploadScheme() string
type VirtualServerHandle ¶
type VirtualServerHandle struct {
// contains filtered or unexported fields
}
Handle value for servers
func (VirtualServerHandle) AddCGIRoute ¶
func (handle VirtualServerHandle) AddCGIRoute(p string, filePath string)
func (VirtualServerHandle) AddDirectory ¶
func (handle VirtualServerHandle) AddDirectory(p string, directoryPath string)
func (VirtualServerHandle) AddFile ¶
func (handle VirtualServerHandle) AddFile(p string, filePath string)
func (VirtualServerHandle) AddHosts ¶
func (handle VirtualServerHandle) AddHosts(hosts ...HostConfig)
func (VirtualServerHandle) AddProxyRoute ¶
func (handle VirtualServerHandle) AddProxyRoute(p string, proxyRoute string, gopherItemType rune)
func (VirtualServerHandle) AddRoute ¶
func (handle VirtualServerHandle) AddRoute(p string, handler RequestHandler)
func (VirtualServerHandle) AddSCGIRoute ¶
func (handle VirtualServerHandle) AddSCGIRoute(p string, address string)
func (VirtualServerHandle) AddUploadRoute ¶
func (handle VirtualServerHandle) AddUploadRoute(p string, handler RequestHandler)
func (VirtualServerHandle) CleanupRateLimiting ¶
func (handle VirtualServerHandle) CleanupRateLimiting()
func (VirtualServerHandle) DefaultLanguage ¶
func (handle VirtualServerHandle) DefaultLanguage() string
func (VirtualServerHandle) Directory ¶
func (handle VirtualServerHandle) Directory() string
func (VirtualServerHandle) FS ¶
func (handle VirtualServerHandle) FS() ServerFS
func (VirtualServerHandle) GetData ¶
func (handle VirtualServerHandle) GetData(key string) (interface{}, bool)
func (VirtualServerHandle) GetPreferredHost ¶
func (handle VirtualServerHandle) GetPreferredHost(protocol ProtocolType, upload bool, scgi bool) ServerHost
func (VirtualServerHandle) GetPreferredHostOfPortListener ¶
func (handle VirtualServerHandle) GetPreferredHostOfPortListener(protocol ProtocolType, upload bool, bind_addr string, bind_port string, scgi bool) ServerHost
func (VirtualServerHandle) GetServer ¶
func (handle VirtualServerHandle) GetServer() *VirtualServer
func (VirtualServerHandle) Group ¶
func (handle VirtualServerHandle) Group(p string) RouteGroup
Group creates a prefix to be automatically prepended to all routes created on the RouteGroup. It will also ensure all absolute links in the responses of the attached routes will be prepended with the group prefix.
func (VirtualServerHandle) HasNonTLSProtocol ¶
func (handle VirtualServerHandle) HasNonTLSProtocol() bool
func (VirtualServerHandle) HasTLSProtocol ¶
func (handle VirtualServerHandle) HasTLSProtocol() bool
func (VirtualServerHandle) HasUploadProtocol ¶
func (handle VirtualServerHandle) HasUploadProtocol() bool
func (VirtualServerHandle) IsIPRateLimited ¶
func (handle VirtualServerHandle) IsIPRateLimited(ip string) bool
func (VirtualServerHandle) LoadRoutes ¶
func (handle VirtualServerHandle) LoadRoutes() error
func (VirtualServerHandle) MaxConcurrentConnections ¶
func (handle VirtualServerHandle) MaxConcurrentConnections() int
func (VirtualServerHandle) Name ¶
func (handle VirtualServerHandle) Name() string
func (VirtualServerHandle) Protocols ¶
func (handle VirtualServerHandle) Protocols() *bitset.BitSet[ProtocolType, ProtocolType]
func (VirtualServerHandle) Pubnix ¶
func (handle VirtualServerHandle) Pubnix() bool
func (VirtualServerHandle) RateLimitDuration ¶
func (handle VirtualServerHandle) RateLimitDuration() time.Duration
func (VirtualServerHandle) Router ¶
func (handle VirtualServerHandle) Router() *Router
func (VirtualServerHandle) SIS ¶
func (handle VirtualServerHandle) SIS() *SISContext
func (VirtualServerHandle) SaveRoutes ¶
func (handle VirtualServerHandle) SaveRoutes() error
func (VirtualServerHandle) Scheme ¶
func (handle VirtualServerHandle) Scheme() string
func (VirtualServerHandle) ServerHandler ¶
func (handle VirtualServerHandle) ServerHandler() ServerHandlerFunc
func (VirtualServerHandle) SetData ¶
func (handle VirtualServerHandle) SetData(key string, value interface{})
func (VirtualServerHandle) SetMaxConcurrentConnections ¶
func (handle VirtualServerHandle) SetMaxConcurrentConnections(v int)
func (VirtualServerHandle) SetName ¶
func (handle VirtualServerHandle) SetName(v string)
func (VirtualServerHandle) SetPubnix ¶
func (handle VirtualServerHandle) SetPubnix(v bool)
func (VirtualServerHandle) SetRateLimitDuration ¶
func (handle VirtualServerHandle) SetRateLimitDuration(v time.Duration)
func (VirtualServerHandle) SetSIS ¶
func (handle VirtualServerHandle) SetSIS(v *SISContext)
func (VirtualServerHandle) SetServerHandler ¶
func (handle VirtualServerHandle) SetServerHandler(v ServerHandlerFunc)
func (VirtualServerHandle) SetType ¶
func (handle VirtualServerHandle) SetType(v ServerType)
func (VirtualServerHandle) Type ¶
func (handle VirtualServerHandle) Type() ServerType
Source Files
¶
- admin_server.go
- cert_store.go
- convert.go
- filetypes.go
- gemini_server.go
- gopher_server.go
- maybeTLSListener.go
- misfin_geminimail_server.go
- misfin_server.go
- nex_server.go
- peekedConn.go
- port_listener.go
- request.go
- route_group.go
- router.go
- scgi_server.go
- scroll_server.go
- server_fs.go
- sis_config.go
- sis_context.go
- spartan_server.go
- tls.go
- util.go
- virtual_server.go
- virtual_server_handle.go