Documentation ¶
Index ¶
- Constants
- Variables
- func AllMimeTypes() map[string]string
- func DecryptString(secret string, data string) (string, error)
- func EncryptString(secret string, data string) (string, error)
- func EnforceDirectory(path string) string
- func GenerateID(ctx *App) string
- func GenerateMachineID() string
- func GetAbsolutePath(p string) string
- func GetCurrentDir() string
- func GetMimeType(p string) string
- func HTTPFriendlyStatus(n int) string
- func Hash(str string, n int) string
- func HashStream(r io.Reader, n int) string
- func InitSecretDerivate(secret string)
- func IsDirectory(path string) bool
- func JoinPath(base, file string) string
- func NewBool(t bool) *bool
- func NewBoolFromInterface(val interface{}) bool
- func NewError(message string, status int) error
- func NewInt(t int) *int
- func NewInt64pFromInterface(val interface{}) *int64
- func NewNilLogger() *slog.Logger
- func NewReadCloserFromBytes(t []byte) io.ReadCloser
- func NewReadCloserFromReader(r io.Reader) io.ReadCloser
- func NewString(t string) *string
- func NewStringFromInterface(val interface{}) string
- func NewStringpFromInterface(val interface{}) *string
- func NewTransormedTransport(transport http.Transport) http.RoundTripper
- func Page(stuff string) string
- func PrettyPrint(json_dirty []byte) []byte
- func PrintMemUsage()
- func QuickHash(str string, n int) string
- func QuickString(n int) string
- func RandomString(n int) string
- func ReversedBaseChange(alphabet []rune, i int) string
- func SendErrorResult(res http.ResponseWriter, err error)
- func SendSuccessResult(res http.ResponseWriter, data interface{})
- func SendSuccessResultWithEtagAndGzip(res http.ResponseWriter, req *http.Request, data interface{})
- func SendSuccessResults(res http.ResponseWriter, data interface{})
- func SendSuccessResultsWithMetadata(res http.ResponseWriter, data interface{}, p interface{})
- type APIErrorMessage
- type APISuccessResult
- type APISuccessResults
- type APISuccessResultsWithMetadata
- type AdminToken
- type App
- type AppCache
- type AppError
- type ChangeListener
- type Configuration
- func (this Configuration) Bool() bool
- func (this *Configuration) Debug() *FormElement
- func (this *Configuration) Default(value interface{}) *Configuration
- func (this Configuration) Export() interface{}
- func (this *Configuration) Get(key string) *Configuration
- func (this *Configuration) Initialise()
- func (this Configuration) Int() int
- func (this Configuration) Interface() interface{}
- func (this *Configuration) ListenForChange() ChangeListener
- func (this *Configuration) Load()
- func (this Configuration) MarshalJSON() ([]byte, error)
- func (this Configuration) Save() Configuration
- func (this *Configuration) Schema(fn func(*FormElement) *FormElement) *Configuration
- func (this *Configuration) Set(value interface{}) *Configuration
- func (this Configuration) String() string
- func (this *Configuration) UnlistenForChange(c ChangeListener)
- type Driver
- type File
- type Form
- type FormElement
- type FormIterator
- type Get
- type IBackend
- type JSONIterator
- type KeyValueStore
- type Metadata
- type Nothing
- func (b Nothing) Cat(path string) (io.ReadCloser, error)
- func (b Nothing) Init(params map[string]string, app *App) (IBackend, error)
- func (b Nothing) LoginForm() Form
- func (b Nothing) Ls(path string) ([]os.FileInfo, error)
- func (b Nothing) Mkdir(path string) error
- func (b Nothing) Mv(from string, to string) error
- func (b Nothing) Rm(path string) error
- func (b Nothing) Save(path string, file io.Reader) error
- func (b Nothing) Touch(path string) error
- type Plugin
- type Register
- type Share
- type TransformedTransport
Constants ¶
View Source
const ( APP_VERSION = "v0.4rc" LOG_PATH = "data/state/log/" CONFIG_PATH = "data/state/config/" DB_PATH = "data/state/db/" FTS_PATH = "data/state/search/" CERT_PATH = "data/state/certs/" TMP_PATH = "data/cache/tmp/" COOKIE_NAME_AUTH = "auth" COOKIE_NAME_PROOF = "proof" COOKIE_NAME_ADMIN = "admin" COOKIE_PATH_ADMIN = "/admin/api/" COOKIE_PATH = "/api/" FILE_INDEX = "./data/public/index.html" FILE_ASSETS = "./data/public/" URL_SETUP = "/admin/setup" RGW_ENABLED = true )
View Source
const ( PluginTypeBackend = "backend" PluginTypeMiddleware = "middleware" )
View Source
const (
ADMIN_CLAIM = "ADMIN"
)
View Source
const BACKEND_NIL = "_nothing_"
View Source
const OverrideVideoSourceMapper = "/overrides/video-transcoder.js"
View Source
const PASSWORD_DUMMY = "{{PASSWORD}}"
Variables ¶
View Source
var ( BUILD_REF string BUILD_DATE string SECRET_KEY string SECRET_KEY_DERIVATE_FOR_PROOF string SECRET_KEY_DERIVATE_FOR_ADMIN string SECRET_KEY_DERIVATE_FOR_USER string SECRET_KEY_DERIVATE_FOR_HASH string )
View Source
var ( ErrNotFound error = NewError("Not Found", 404) ErrNotAllowed error = NewError("Not Allowed", 403) ErrPermissionDenied error = NewError("Permission Denied", 403) ErrNotValid error = NewError("Not Valid", 405) ErrConflict error = NewError("Already exist", 409) ErrNotReachable error = NewError("Cannot Reach Destination", 502) ErrInvalidPassword = NewError("Invalid Password", 403) ErrNotImplemented = NewError("Not Implemented", 501) ErrNotSupported = NewError("This feature is not supported", 501) ErrFilesystemError = NewError("Can't use filesystem", 503) ErrMissingDependency = NewError("Missing dependency", 424) ErrNotAuthorized = NewError("Not authorized", 401) ErrCongestion = NewError("Traffic congestion, try again later", 500) ErrTimeout = NewError("Timeout", 500) )
View Source
var Backend = NewDriver()
View Source
var DefaultTLSConfig = tls.Config{ MinVersion: tls.VersionTLS12, CipherSuites: []uint16{ tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, }, PreferServerCipherSuites: true, CurvePreferences: []tls.CurveID{ tls.CurveP256, tls.X25519, }, }
View Source
var HTTP = http.Client{ Timeout: 10000 * time.Millisecond, Transport: NewTransormedTransport(http.Transport{ Dial: (&net.Dialer{ Timeout: 5000 * time.Millisecond, KeepAlive: 5000 * time.Millisecond, }).Dial, TLSHandshakeTimeout: 5000 * time.Millisecond, IdleConnTimeout: 5000 * time.Millisecond, ResponseHeaderTimeout: 5000 * time.Millisecond, }), }
View Source
var HTTPClient = http.Client{ Timeout: 5 * time.Hour, Transport: NewTransormedTransport(http.Transport{ Dial: (&net.Dialer{ Timeout: 10 * time.Second, KeepAlive: 10 * time.Second, }).Dial, TLSHandshakeTimeout: 5 * time.Second, IdleConnTimeout: 60 * time.Second, ResponseHeaderTimeout: 60 * time.Second, }), }
View Source
var Letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
View Source
var Log = func() log { l := log{} l.Enable(true) return l }()
View Source
var MOCK_CURRENT_DIR string
View Source
var MimeTypes map[string]string = map[string]string{
"txt": "text/plain",
"svg": "image/svg+xml",
"png": "image/png",
"woff2": "font/woff2",
"js": "application/javascript",
"json": "application/json",
}
View Source
var USER_AGENT = fmt.Sprintf("Filestash/%s.%s (http://filestash.app)", APP_VERSION, BUILD_DATE)
Functions ¶
func AllMimeTypes ¶
func EnforceDirectory ¶
func GenerateID ¶
Create a unique ID that can be use to identify different session
func GetAbsolutePath ¶
func GetCurrentDir ¶
func GetCurrentDir() string
func GetMimeType ¶
func HTTPFriendlyStatus ¶
func InitSecretDerivate ¶
func InitSecretDerivate(secret string)
* Improve security by calculating derivative of the secret key to restrict the attack surface * in the worst case scenario with one compromise secret key
func IsDirectory ¶
func NewBoolFromInterface ¶
func NewBoolFromInterface(val interface{}) bool
func NewInt64pFromInterface ¶
func NewInt64pFromInterface(val interface{}) *int64
func NewNilLogger ¶
func NewReadCloserFromBytes ¶
func NewReadCloserFromBytes(t []byte) io.ReadCloser
func NewReadCloserFromReader ¶
func NewReadCloserFromReader(r io.Reader) io.ReadCloser
func NewStringFromInterface ¶
func NewStringFromInterface(val interface{}) string
func NewStringpFromInterface ¶
func NewStringpFromInterface(val interface{}) *string
func NewTransormedTransport ¶
func NewTransormedTransport(transport http.Transport) http.RoundTripper
func PrettyPrint ¶
func PrintMemUsage ¶
func PrintMemUsage()
func QuickString ¶
func RandomString ¶
func ReversedBaseChange ¶
func SendErrorResult ¶
func SendErrorResult(res http.ResponseWriter, err error)
func SendSuccessResult ¶
func SendSuccessResult(res http.ResponseWriter, data interface{})
func SendSuccessResultWithEtagAndGzip ¶
func SendSuccessResultWithEtagAndGzip(res http.ResponseWriter, req *http.Request, data interface{})
func SendSuccessResults ¶
func SendSuccessResults(res http.ResponseWriter, data interface{})
func SendSuccessResultsWithMetadata ¶
func SendSuccessResultsWithMetadata(res http.ResponseWriter, data interface{}, p interface{})
Types ¶
type APIErrorMessage ¶
type APISuccessResult ¶
type APISuccessResult struct { Status string `json:"status"` Result interface{} `json:"result,omitempty"` }
type APISuccessResults ¶
type APISuccessResults struct { Status string `json:"status"` Results interface{} `json:"results"` }
type APISuccessResultsWithMetadata ¶
type APISuccessResultsWithMetadata struct { Status string `json:"status"` Results interface{} `json:"results"` Metadata interface{} `json:"metadata,omitempty"` }
type AdminToken ¶
func NewAdminToken ¶
func NewAdminToken() AdminToken
func (AdminToken) IsAdmin ¶
func (this AdminToken) IsAdmin() bool
func (AdminToken) IsValid ¶
func (this AdminToken) IsValid() bool
type ChangeListener ¶
type ChangeListener struct { Id string Listener chan interface{} }
type Configuration ¶
type Configuration struct { Conn []map[string]interface{} // contains filtered or unexported fields }
var (
Config Configuration
)
func NewConfiguration ¶
func NewConfiguration() Configuration
func (Configuration) Bool ¶
func (this Configuration) Bool() bool
func (*Configuration) Debug ¶
func (this *Configuration) Debug() *FormElement
func (*Configuration) Default ¶
func (this *Configuration) Default(value interface{}) *Configuration
func (Configuration) Export ¶
func (this Configuration) Export() interface{}
func (*Configuration) Get ¶
func (this *Configuration) Get(key string) *Configuration
func (*Configuration) Initialise ¶
func (this *Configuration) Initialise()
func (Configuration) Int ¶
func (this Configuration) Int() int
func (Configuration) Interface ¶
func (this Configuration) Interface() interface{}
func (*Configuration) ListenForChange ¶
func (this *Configuration) ListenForChange() ChangeListener
func (*Configuration) Load ¶
func (this *Configuration) Load()
func (Configuration) MarshalJSON ¶
func (this Configuration) MarshalJSON() ([]byte, error)
func (Configuration) Save ¶
func (this Configuration) Save() Configuration
func (*Configuration) Schema ¶
func (this *Configuration) Schema(fn func(*FormElement) *FormElement) *Configuration
func (*Configuration) Set ¶
func (this *Configuration) Set(value interface{}) *Configuration
func (Configuration) String ¶
func (this Configuration) String() string
func (*Configuration) UnlistenForChange ¶
func (this *Configuration) UnlistenForChange(c ChangeListener)
type File ¶
type File struct { FName string `json:"name"` FType string `json:"type"` FTime int64 `json:"time"` FSize int64 `json:"size"` FPath string `json:"path,omitempty"` CanRename *bool `json:"can_rename,omitempty"` CanMove *bool `json:"can_move_directory,omitempty"` CanDelete *bool `json:"can_delete,omitempty"` }
type Form ¶
type Form struct { Title string Form []Form Elmnts []FormElement }
func (*Form) Iterator ¶
func (this *Form) Iterator() []FormIterator
func (Form) MarshalJSON ¶
type FormElement ¶
type FormElement struct { Id string `json:"id,omitempty"` Name string `json:"label"` Type string `json:"type"` Description string `json:"description,omitempty"` Placeholder string `json:"placeholder,omitempty"` Opts []string `json:"options,omitempty"` Target []string `json:"target,omitempty"` ReadOnly bool `json:"readonly"` Default interface{} `json:"default"` Value interface{} `json:"value"` MultiValue bool `json:"multi,omitempty"` Datalist []string `json:"datalist,omitempty"` Order int `json:"-"` Required bool `json:"required"` }
type FormIterator ¶
type FormIterator struct { Path string *FormElement }
type Get ¶
type Get struct{}
func (Get) FrontendOverrides ¶
func (Get) ProcessFileContentBeforeSend ¶
func (this Get) ProcessFileContentBeforeSend() []func(io.ReadCloser, *App, *http.ResponseWriter, *http.Request) (io.ReadCloser, error)
type IBackend ¶
type IBackend interface { Init(params map[string]string, app *App) (IBackend, error) Ls(path string) ([]os.FileInfo, error) Cat(path string) (io.ReadCloser, error) Mkdir(path string) error Rm(path string) error Mv(from string, to string) error Save(path string, file io.Reader) error Touch(path string) error LoginForm() Form }
type JSONIterator ¶
type JSONIterator struct { Path string Value interface{} }
func JsonIterator ¶
func JsonIterator(json string) []JSONIterator
type KeyValueStore ¶
func NewKeyValueStore ¶
func NewKeyValueStore() KeyValueStore
func (*KeyValueStore) Clear ¶
func (this *KeyValueStore) Clear()
func (*KeyValueStore) Get ¶
func (this *KeyValueStore) Get(key string) interface{}
func (*KeyValueStore) Set ¶
func (this *KeyValueStore) Set(key string, value interface{})
type Metadata ¶
type Metadata struct { CanSee *bool `json:"can_read,omitempty"` CanCreateFile *bool `json:"can_create_file,omitempty"` CanCreateDirectory *bool `json:"can_create_directory,omitempty"` CanRename *bool `json:"can_rename,omitempty"` CanMove *bool `json:"can_move,omitempty"` CanUpload *bool `json:"can_upload,omitempty"` CanDelete *bool `json:"can_delete,omitempty"` HideExtension *bool `json:"hide_extension,omitempty"` RefreshOnCreate *bool `json:"refresh_on_create,omitempty"` Expire *time.Time `json:"-"` }
type Register ¶
type Register struct{}
func (Register) FrontendOverrides ¶
func (Register) ProcessFileContentBeforeSend ¶
func (this Register) ProcessFileContentBeforeSend(fn func(io.ReadCloser, *App, *http.ResponseWriter, *http.Request) (io.ReadCloser, error))
type TransformedTransport ¶
type TransformedTransport struct {
Orig http.RoundTripper
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.