Documentation ¶
Index ¶
- Variables
- func GenShareHash(userName, itmPath string) string
- type AllowedShare
- type Auth
- type CaptchaConfig
- type GlobalConfig
- func (cfg *GlobalConfig) AddUser(u *UserConfig) error
- func (cfg *GlobalConfig) CopyConfig() *GlobalConfig
- func (cfg *GlobalConfig) DeleteUser(username string) error
- func (cfg *GlobalConfig) GetAdmin() *UserConfig
- func (cfg *GlobalConfig) GetDavPath(userName string) string
- func (cfg *GlobalConfig) GetExternal(hash string) (res *ShareItem, usr *UserConfig)
- func (cfg *GlobalConfig) GetKeyBytes() ([]byte, error)
- func (cfg *GlobalConfig) GetSharePreviewPath(url string) (res string)
- func (cfg *GlobalConfig) GetUserByIp(ip string) (*UserConfig, bool)
- func (cfg *GlobalConfig) GetUserByUsername(username string) (*UserConfig, bool)
- func (cfg *GlobalConfig) GetUserHomePath(userName string) string
- func (cfg *GlobalConfig) GetUserPreviewPath(userName string) string
- func (cfg *GlobalConfig) GetUserSharesPath(userName string) string
- func (cfg *GlobalConfig) GetUserSharexPath(userName string) string
- func (cfg *GlobalConfig) GetUsers() (res []*UserConfig)
- func (cfg *GlobalConfig) ReadConfigFile()
- func (cfg *GlobalConfig) RefreshUserRam()
- func (cfg *GlobalConfig) SetKey(k []byte)
- func (cfg *GlobalConfig) Update(u *UserConfig) error
- func (cfg *GlobalConfig) UpdateConfig(u *GlobalConfig)
- func (cfg *GlobalConfig) UpdatePassword(u *UserConfig) error
- func (cfg *GlobalConfig) Verify()
- func (cfg *GlobalConfig) WriteConfig()
- type ListenConf
- type PreviewConf
- type ShareItem
- type TContext
- type UserConfig
Constants ¶
This section is empty.
Variables ¶
var DavLogger func(r *http.Request, err error)
Functions ¶
func GenShareHash ¶ added in v0.8.3
Types ¶
type AllowedShare ¶
type AllowedShare struct {}
type CaptchaConfig ¶
type GlobalConfig ¶
type GlobalConfig struct { Users []*UserConfig `json:"users"` Http *ListenConf `json:"http"` Tls *ListenConf `json:"https"` Log string `json:"log"` TLSKey string `json:"tlsKey"` TLSCert string `json:"tlsCert"` // Scope is the Path the user has access to. FilesPath string `json:"filesPath"` *CaptchaConfig `json:"captchaConfig"` *Auth `json:"auth"` *PreviewConf `json:"preview"` ExternalShareHost string `json:"externalShareHost"` //Path to config file Path string `json:"-"` }
Single config for everything. update automatically
func (*GlobalConfig) AddUser ¶ added in v0.8.6
func (cfg *GlobalConfig) AddUser(u *UserConfig) error
func (*GlobalConfig) DeleteUser ¶ added in v0.8.6
func (cfg *GlobalConfig) DeleteUser(username string) error
delete user by username
func (*GlobalConfig) GetAdmin ¶
func (cfg *GlobalConfig) GetAdmin() *UserConfig
func (*GlobalConfig) GetDavPath ¶ added in v0.8.3
func (cfg *GlobalConfig) GetDavPath(userName string) string
~/<<cfg_PATH>>/<<username>>/
func (*GlobalConfig) GetExternal ¶ added in v0.8.3
func (cfg *GlobalConfig) GetExternal(hash string) (res *ShareItem, usr *UserConfig)
since we sure that this method will not modify, just return original
func (*GlobalConfig) GetKeyBytes ¶
func (cfg *GlobalConfig) GetKeyBytes() ([]byte, error)
returns salt key in bytes, err in case key missed
func (*GlobalConfig) GetSharePreviewPath ¶ added in v0.8.3
func (cfg *GlobalConfig) GetSharePreviewPath(url string) (res string)
take the user from url, find it, after return user preview
func (*GlobalConfig) GetUserByIp ¶ added in v0.8.6
func (cfg *GlobalConfig) GetUserByIp(ip string) (*UserConfig, bool)
func (*GlobalConfig) GetUserByUsername ¶ added in v0.8.6
func (cfg *GlobalConfig) GetUserByUsername(username string) (*UserConfig, bool)
func (*GlobalConfig) GetUserHomePath ¶ added in v0.1.8
func (cfg *GlobalConfig) GetUserHomePath(userName string) string
~/<<cfg_PATH>>/<<username>>/files
func (*GlobalConfig) GetUserPreviewPath ¶ added in v0.1.8
func (cfg *GlobalConfig) GetUserPreviewPath(userName string) string
~/<<cfg_PATH>>/<<username>>/preview
func (*GlobalConfig) GetUserSharesPath ¶ added in v0.8.3
func (cfg *GlobalConfig) GetUserSharesPath(userName string) string
~/<<cfg_PATH>>/<<username>>/shares
func (*GlobalConfig) GetUserSharexPath ¶ added in v0.8.7
func (cfg *GlobalConfig) GetUserSharexPath(userName string) string
~/<<cfg_PATH>>/<<username>>/sharex
func (*GlobalConfig) GetUsers ¶
func (cfg *GlobalConfig) GetUsers() (res []*UserConfig)
func (*GlobalConfig) ReadConfigFile ¶
func (cfg *GlobalConfig) ReadConfigFile()
read and initiate global config, if file missed, one will be created with default settings.
func (*GlobalConfig) RefreshUserRam ¶ added in v0.8.3
func (cfg *GlobalConfig) RefreshUserRam()
should not be called directly
func (*GlobalConfig) Update ¶
func (cfg *GlobalConfig) Update(u *UserConfig) error
func (*GlobalConfig) UpdateConfig ¶
func (cfg *GlobalConfig) UpdateConfig(u *GlobalConfig)
deep update config
func (*GlobalConfig) UpdatePassword ¶ added in v0.8.3
func (cfg *GlobalConfig) UpdatePassword(u *UserConfig) error
func (*GlobalConfig) Verify ¶
func (cfg *GlobalConfig) Verify()
func (*GlobalConfig) WriteConfig ¶ added in v0.1.8
func (cfg *GlobalConfig) WriteConfig()
type ListenConf ¶ added in v0.8.3
type ListenConf struct { Port int `json:"port"` IP string `json:"ip"` // Define if which of the following authentication mechansims should be used: // - 'default', which requires a user and a password. // - 'proxy', which requires a valid user and the user name has to be provided through an // web header. // - 'none', which allows anyone to access the filebrowser instance. // If 'Method' is set to 'proxy' the header configured below is used to identify the user. AuthMethod string `json:"authMethod"` }
type PreviewConf ¶
type PreviewConf struct { //enable preview generating by call .sh ScriptPath string `json:"scriptPath"` Threads int `json:"threads"` FirstRun bool `json:"previewOnFirstRun"` }
Auth settings.
type ShareItem ¶
type ShareItem struct { bool `json:"allowExternal"` AllowLocal bool `json:"allowLocal"` AllowUsers []string `json:"allowedUsers"` Hash string `json:"-"` }AllowExternal
presents 1 share Path in filesystem, and access rules
func (*ShareItem) ResolveSymlinkName ¶ added in v0.8.6
will create correct symlink name, err in case hash empty
type TContext ¶ added in v0.8.6
type TContext struct { ConfigPath string Usr1 *UserConfig Usr2 *UserConfig Guest *UserConfig User1FS utils.Dir User1FSPreview utils.Dir User2FS utils.Dir AdminFS utils.Dir *GlobalConfig Srv *httptest.Server Tr *http.Transport Token string }
helper struct for testing only
func (*TContext) InitWithUsers ¶ added in v0.8.6
setup filesystem in ram for users, will create empty test files
func (*TContext) MakeUser ¶ added in v0.8.6
func (tc *TContext) MakeUser(name string) *UserConfig
type UserConfig ¶
type UserConfig struct { FirstRun bool `json:"hashPasswordFirstRun"` // Tells if this user is an admin. Admin bool `json:"admin"` // These indicate if the user can perform certain actions. AllowEdit bool `json:"allowEdit"` // Edit/rename files AllowNew bool `json:"allowNew"` // Create files and folders // Prevents the user to change its password. LockPassword bool `json:"lockPassword"` // Locale is the language of the user. Locale string `json:"locale"` // The hashed password. This never reaches the front-end because it's temporarily // emptied during JSON marshall. Password string `json:"password"` // Username is the user username used to login. Username string `json:"username"` // User view mode for files and folders. ViewMode string `json:"viewMode"` //authenticate by IP, need to change auth.method IpAuth []string `json:"ipAuth"` DavHandler *webdav.Handler `json:"-"` //create files/folders according this ownership UID int `json:"uid"` GID int `json:"gid"` }
User contains the configuration for each user.
func (*UserConfig) AddShare ¶
func (u *UserConfig) AddShare(shr *ShareItem) (res bool)
true in case share added
func (*UserConfig) DeleteShare ¶
func (u *UserConfig) DeleteShare(relPath string) (res bool)
true in case share deleted
func (*UserConfig) GetShares ¶ added in v0.8.3
func (u *UserConfig) GetShares(relPath string, del bool) (res []*ShareItem)
func (*UserConfig) IsGuest ¶ added in v0.8.3
func (u *UserConfig) IsGuest() bool