httpserver

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 39 Imported by: 0

Documentation

Overview

Package httpserver will contain the main httpserver functionality of goshs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateQRCode added in v1.1.0

func GenerateQRCode(uri string) string

func GenerateToken added in v1.1.0

func GenerateToken() string

func GetClientIP added in v1.0.9

func GetClientIP(r *http.Request, whitelist *Whitelist) string

Types

type CustomMux added in v1.0.4

type CustomMux struct {
	// contains filtered or unexported fields
}

func NewCustomMux added in v1.0.4

func NewCustomMux() *CustomMux

NewCustomMux creates a new CustomMux instance.

func (*CustomMux) Handle added in v1.0.4

func (cm *CustomMux) Handle(pattern string, handler http.Handler)

Handle registers a new route with the CustomMux, applying all middleware in reverse order.

func (*CustomMux) HandleFunc added in v1.0.4

func (cm *CustomMux) HandleFunc(pattern string, handler http.HandlerFunc)

HandleFunc registers a new route with the CustomMux, applying all middleware in reverse order.

func (*CustomMux) ServeHTTP added in v1.0.4

func (cm *CustomMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface, allowing the CustomMux to be used as an HTTP server.

func (*CustomMux) Use added in v1.0.4

func (cm *CustomMux) Use(mw Middleware)

Use simulates the behavior of http.ServeMux.Use, allowing you to add middleware to the CustomMux.

type DownloadEntry added in v1.1.0

type DownloadEntry struct {
	DownloadURL string
	QRCode      template.URL
}

type FileServer

type FileServer struct {
	IP             string
	Port           int
	CLI            bool
	WebdavPort     int
	Webroot        string
	UploadFolder   string
	SSL            bool
	SelfSigned     bool
	LetsEncrypt    bool
	MyKey          string
	MyCert         string
	MyP12          string
	P12NoPass      bool
	User           string
	Pass           string
	CACert         string
	DropUser       string
	Version        string
	Fingerprint256 string
	Fingerprint1   string
	UploadOnly     bool
	ReadOnly       bool
	NoClipboard    bool
	NoDelete       bool
	Silent         bool
	Embedded       bool
	Verbose        bool
	Webhook        webhook.Webhook
	Hub            *ws.Hub
	Clipboard      *clipboard.Clipboard
	Whitelist      *Whitelist
	SharedLinks    map[string]SharedLink
}

FileServer holds the fileserver information

func (*FileServer) AddCertAuth added in v0.4.1

func (files *FileServer) AddCertAuth(server *http.Server)

func (*FileServer) BasicAuthMiddleware

func (fs *FileServer) BasicAuthMiddleware(next http.Handler) http.Handler

BasicAuthMiddleware is a middleware to handle the basic auth

func (*FileServer) CreateShareHandler added in v1.1.0

func (fs *FileServer) CreateShareHandler(w http.ResponseWriter, r *http.Request)

func (*FileServer) DeleteShareHandler added in v1.1.0

func (fs *FileServer) DeleteShareHandler(w http.ResponseWriter, r *http.Request)

func (*FileServer) IPWhitelistMiddleware added in v1.0.9

func (fs *FileServer) IPWhitelistMiddleware(next http.Handler) http.Handler

IPWhitelistMiddleware checks if the request's IP is in the whitelist

func (*FileServer) PrintEmbeddedFiles added in v0.3.9

func (files *FileServer) PrintEmbeddedFiles()

func (*FileServer) ServerHeaderMiddleware added in v1.0.3

func (fs *FileServer) ServerHeaderMiddleware(next http.Handler) http.Handler

ServerHeaderMiddleware sets a custom Server header for all responses

func (*FileServer) SetupMux added in v0.4.2

func (fs *FileServer) SetupMux(mux *CustomMux, what string) string

func (*FileServer) ShareHandler added in v1.1.0

func (fs *FileServer) ShareHandler(w http.ResponseWriter, r *http.Request)

func (*FileServer) Start

func (fs *FileServer) Start(what string)

Start will start the file server

func (*FileServer) StartListener added in v0.4.2

func (fs *FileServer) StartListener(server *http.Server, what string, listener net.Listener)

type Middleware added in v1.0.4

type Middleware func(http.Handler) http.Handler
type SharedLink struct {
	FilePath        string
	IsDir           bool
	Expires         time.Time
	DownloadLimit   int
	DownloadEntries []DownloadEntry
}

type Whitelist added in v1.0.9

type Whitelist struct {
	Networks       []*net.IPNet
	TrustedProxies []*net.IPNet
	Enabled        bool
}

func NewIPWhitelist added in v1.0.9

func NewIPWhitelist(cidrs string, enabled bool, trustedProxies string) (*Whitelist, error)

func (*Whitelist) IsAllowed added in v1.0.9

func (w *Whitelist) IsAllowed(ipStr string) bool

func (*Whitelist) IsTrustedProxy added in v1.0.9

func (w *Whitelist) IsTrustedProxy(ipStr string) bool

Jump to

Keyboard shortcuts

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