Documentation ¶
Index ¶
- Constants
- Variables
- func InitServer()
- func ParseConfig(filePath string)
- func Start()
- type FileInfo
- type FileInfoResult
- type FileLog
- type FileResult
- type GlobalConfig
- type HttpHandler
- type HttpProxyHandler
- type JsonResult
- type Mail
- type Proxy
- type Server
- func (c *Server) AppendToDownloadQueue(fileInfo *FileInfo)
- func (c *Server) AppendToQueue(fileInfo *FileInfo)
- func (c *Server) AutoRepair(forceRepair bool)
- func (c *Server) BackUp(w http.ResponseWriter, r *http.Request)
- func (c *Server) BackUpMetaDataByDate(date string)
- func (c *Server) BenchMark(w http.ResponseWriter, r *http.Request)
- func (c *Server) BuildFileResult(fileInfo *FileInfo, r *http.Request) FileResult
- func (c *Server) CheckAuth(w http.ResponseWriter, r *http.Request) bool
- func (c *Server) CheckClusterStatus()
- func (c *Server) CheckDownloadAuth(w http.ResponseWriter, r *http.Request) (bool, error)
- func (c *Server) CheckFileAndSendToPeer(date string, filename string, isForceUpload bool)
- func (c *Server) CheckFileExist(w http.ResponseWriter, r *http.Request)
- func (c *Server) CheckFileExistByInfo(md5s string, fileInfo *FileInfo) bool
- func (c *Server) CheckFilesExist(w http.ResponseWriter, r *http.Request)
- func (c *Server) CheckScene(scene string) (bool, error)
- func (c *Server) CleanAndBackUp()
- func (c *Server) CleanEmptyFolders()
- func (c *Server) CleanLogLevelDBByDate(date string, filename string)
- func (c *Server) ConsumerDownLoad()
- func (c *Server) ConsumerLog()
- func (c *Server) ConsumerPostToPeer()
- func (c *Server) ConsumerUpload()
- func (c *Server) CrossOrigin(w http.ResponseWriter, r *http.Request)
- func (c *Server) Download(w http.ResponseWriter, r *http.Request)
- func (c *Server) DownloadFileToResponse(url string, w http.ResponseWriter, r *http.Request)
- func (c *Server) DownloadFromPeer(peer string, fileInfo *FileInfo)
- func (c *Server) DownloadNormalFileByURI(w http.ResponseWriter, r *http.Request) (bool, error)
- func (c *Server) DownloadNotFound(w http.ResponseWriter, r *http.Request)
- func (c *Server) DownloadSmallFileByURI(w http.ResponseWriter, r *http.Request) (bool, error)
- func (c *Server) FormatStatInfo()
- func (c *Server) GenGoogleCode(w http.ResponseWriter, r *http.Request)
- func (c *Server) GenGoogleSecret(w http.ResponseWriter, r *http.Request)
- func (c *Server) GetClusterNotPermitMessage(r *http.Request) string
- func (c *Server) GetFileInfo(w http.ResponseWriter, r *http.Request)
- func (c *Server) GetFileInfoFromLevelDB(key string) (*FileInfo, error)
- func (c *Server) GetFilePathByInfo(fileInfo *FileInfo, withDocker bool) string
- func (c *Server) GetFilePathFromRequest(w http.ResponseWriter, r *http.Request) (string, string)
- func (c *Server) GetMd5File(w http.ResponseWriter, r *http.Request)
- func (c *Server) GetMd5sByDate(date string, filename string) (mapset.Set, error)
- func (c *Server) GetMd5sForWeb(w http.ResponseWriter, r *http.Request)
- func (c *Server) GetMd5sMapByDate(date string, filename string) (*goutil.CommonMap, error)
- func (c *Server) GetRealIp(r *http.Request) string
- func (c *Server) GetServerURI(r *http.Request) string
- func (c *Server) GetSmallFileByURI(w http.ResponseWriter, r *http.Request) ([]byte, bool, error)
- func (c *Server) GetStat() []StatDateFileInfo
- func (c *Server) HeartBeat(w http.ResponseWriter, r *http.Request)
- func (c *Server) Index(w http.ResponseWriter, r *http.Request)
- func (c *Server) IsExistFromLevelDB(key string, db *leveldb.DB) (bool, error)
- func (c *Server) IsPeer(r *http.Request) bool
- func (c *Server) ListDir(w http.ResponseWriter, r *http.Request)
- func (c *Server) LoadFileInfoByDate(date string, filename string) (mapset.Set, error)
- func (c *Server) LoadQueueSendToPeer()
- func (c *Server) LoadSearchDict()
- func (c *Server) NotPermit(w http.ResponseWriter, r *http.Request)
- func (c *Server) ParseSmallFile(filename string) (string, int64, int, error)
- func (c *Server) ReceiveMd5s(w http.ResponseWriter, r *http.Request)
- func (c *Server) RegisterExit()
- func (c *Server) Reload(w http.ResponseWriter, r *http.Request)
- func (c *Server) RemoveDownloading()
- func (c *Server) RemoveEmptyDir(w http.ResponseWriter, r *http.Request)
- func (c *Server) RemoveFile(w http.ResponseWriter, r *http.Request)
- func (c *Server) RemoveKeyFromLevelDB(key string, db *leveldb.DB) error
- func (c *Server) Repair(w http.ResponseWriter, r *http.Request)
- func (c *Server) RepairFileInfo(w http.ResponseWriter, r *http.Request)
- func (c *Server) RepairFileInfoFromFile()
- func (c *Server) RepairStatByDate(date string) StatDateFileInfo
- func (c *Server) RepairStatWeb(w http.ResponseWriter, r *http.Request)
- func (c *Server) Report(w http.ResponseWriter, r *http.Request)
- func (c *Server) ResizeImage(w http.ResponseWriter, fullpath string, width, height uint)
- func (c *Server) ResizeImageByBytes(w http.ResponseWriter, data []byte, width, height uint)
- func (c *Server) SaveFileInfoToLevelDB(key string, fileInfo *FileInfo, db *leveldb.DB) (*FileInfo, error)
- func (c *Server) SaveFileMd5Log(fileInfo *FileInfo, filename string)
- func (c *Server) SaveSearchDict()
- func (c *Server) SaveSmallFile(fileInfo *FileInfo) error
- func (c *Server) SaveStat()
- func (c *Server) SaveUploadFile(file multipart.File, header *multipart.FileHeader, fileInfo *FileInfo, ...) (*FileInfo, error)
- func (c *Server) Search(w http.ResponseWriter, r *http.Request)
- func (c *Server) SearchDict(kw string) []FileInfo
- func (c *Server) SendToMail(to, subject, body, mailtype string) error
- func (c *Server) SetDownloadHeader(w http.ResponseWriter, r *http.Request, isSmall bool)
- func (c *Server) Start()
- func (c *Server) Stat(w http.ResponseWriter, r *http.Request)
- func (c *Server) Status(w http.ResponseWriter, r *http.Request)
- func (c *Server) Sync(w http.ResponseWriter, r *http.Request)
- func (c *Server) SyncFileInfo(w http.ResponseWriter, r *http.Request)
- func (c *Server) TrimFileNameSpecialChar(str string) string
- func (c *Server) Upload(w http.ResponseWriter, r *http.Request)
- func (c *Server) VerifyGoogleCode(secret string, code string, discrepancy int64) bool
- func (c *Server) WatchFilesChange()
- type StatDateFileInfo
- type WrapReqResp
Constants ¶
View Source
const ( STORE_DIR_NAME = "files" LOG_DIR_NAME = "log" DATA_DIR_NAME = "data" CONF_DIR_NAME = "conf" STATIC_DIR_NAME = "static" CONST_STAT_FILE_COUNT_KEY = "fileCount" CONST_BIG_UPLOAD_PATH_SUFFIX = "/big/upload/" CONST_STAT_FILE_TOTAL_SIZE_KEY = "totalSize" CONST_Md5_ERROR_FILE_NAME = "errors.md5" CONST_Md5_QUEUE_FILE_NAME = "queue.md5" CONST_FILE_Md5_FILE_NAME = "files.md5" CONST_REMOME_Md5_FILE_NAME = "removes.md5" CONST_SMALL_FILE_SIZE = 1024 * 1024 CONST_MESSAGE_CLUSTER_IP = "Can only be called by the cluster ip or 127.0.0.1 or admin_ips(cfg.json),current ip:%s" )
Variables ¶
View Source
var ( FileName string DOCKER_DIR = "" STORE_DIR = STORE_DIR_NAME CONF_DIR = CONF_DIR_NAME LOG_DIR = LOG_DIR_NAME DATA_DIR = DATA_DIR_NAME STATIC_DIR = STATIC_DIR_NAME LARGE_DIR_NAME = "haystack" LARGE_DIR = STORE_DIR + "/haystack" CONST_LEVELDB_FILE_NAME = DATA_DIR + "/fileserver.db" CONST_LOG_LEVELDB_FILE_NAME = DATA_DIR + "/log.db" CONST_STAT_FILE_NAME = DATA_DIR + "/stat.json" CONST_CONF_FILE_NAME = CONF_DIR + "/cfg.json" CONST_SERVER_CRT_FILE_NAME = CONF_DIR + "/server.crt" CONST_SERVER_KEY_FILE_NAME = CONF_DIR + "/server.key" CONST_SEARCH_FILE_NAME = DATA_DIR + "/search.txt" CONST_UPLOAD_COUNTER_KEY = "__CONST_UPLOAD_COUNTER_KEY__" )
View Source
var ( VERSION string BUILD_TIME string GO_VERSION string GIT_VERSION string )
View Source
var CONST_QUEUE_SIZE = 10000
View Source
var FOLDERS = []string{DATA_DIR, STORE_DIR, CONF_DIR, STATIC_DIR}
Functions ¶
func InitServer ¶
func InitServer()
func ParseConfig ¶
func ParseConfig(filePath string)
Types ¶
type FileInfo ¶
type FileInfo struct { Name string `json:"name"` ReName string `json:"rename"` Path string `json:"path"` Md5 string `json:"md5"` Size int64 `json:"size"` Peers []string `json:"peers"` Scene string `json:"scene"` TimeStamp int64 `json:"timeStamp"` OffSet int64 `json:"offset"` // contains filtered or unexported fields }
type FileInfoResult ¶
type FileResult ¶
type FileResult struct { Url string `json:"url"` Md5 string `json:"md5"` Path string `json:"path"` Domain string `json:"domain"` Scene string `json:"scene"` Size int64 `json:"size"` ModTime int64 `json:"mtime"` //Just for Compatibility Scenes string `json:"scenes"` RetMsg string `json:"retmsg"` RetCode int `json:"retcode"` Src string `json:"src"` }
type GlobalConfig ¶
type GlobalConfig struct { Addr string `json:"addr"` Peers []string `json:"peers"` EnableHttps bool `json:"enable_https"` Group string `json:"group"` RenameFile bool `json:"rename_file"` ShowDir bool `json:"show_dir"` Extensions []string `json:"extensions"` RefreshInterval int `json:"refresh_interval"` EnableWebUpload bool `json:"enable_web_upload"` DownloadDomain string `json:"download_domain"` EnableCustomPath bool `json:"enable_custom_path"` Scenes []string `json:"scenes"` AlarmReceivers []string `json:"alarm_receivers"` DefaultScene string `json:"default_scene"` Mail Mail `json:"mail"` AlarmUrl string `json:"alarm_url"` DownloadUseToken bool `json:"download_use_token"` DownloadTokenExpire int `json:"download_token_expire"` QueueSize int `json:"queue_size"` AutoRepair bool `json:"auto_repair"` Host string `json:"host"` FileSumArithmetic string `json:"file_sum_arithmetic"` PeerId string `json:"peer_id"` SupportGroupManage bool `json:"support_group_manage"` AdminIps []string `json:"admin_ips"` AdminKey string `json:"admin_key"` EnableMergeSmallFile bool `json:"enable_merge_small_file"` EnableMigrate bool `json:"enable_migrate"` EnableDistinctFile bool `json:"enable_distinct_file"` ReadOnly bool `json:"read_only"` EnableCrossOrigin bool `json:"enable_cross_origin"` EnableGoogleAuth bool `json:"enable_google_auth"` AuthUrl string `json:"auth_url"` EnableDownloadAuth bool `json:"enable_download_auth"` DefaultDownload bool `json:"default_download"` EnableTus bool `json:"enable_tus"` SyncTimeout int64 `json:"sync_timeout"` EnableFsNotify bool `json:"enable_fsnotify"` EnableDiskCache bool `json:"enable_disk_cache"` ConnectTimeout bool `json:"connect_timeout"` ReadTimeout int `json:"read_timeout"` WriteTimeout int `json:"write_timeout"` IdleTimeout int `json:"idle_timeout"` ReadHeaderTimeout int `json:"read_header_timeout"` SyncWorker int `json:"sync_worker"` UploadWorker int `json:"upload_worker"` UploadQueueSize int `json:"upload_queue_size"` RetryCount int `json:"retry_count"` SyncDelay int64 `json:"sync_delay"` WatchChanSize int `json:"watch_chan_size"` ImageMaxWidth int `json:"image_max_width"` ImageMaxHeight int `json:"image_max_height"` Proxies []Proxy `json:"proxies"` EnablePprofDebug bool `json:"enable_pprof_debug"` EnableTrimFileNameSpecialChar bool `json:"enable_trim_file_name_special_char"` }
func Config ¶
func Config() *GlobalConfig
type HttpHandler ¶
type HttpHandler struct{}
func (HttpHandler) ServeHTTP ¶
func (HttpHandler) ServeHTTP(res http.ResponseWriter, req *http.Request)
type HttpProxyHandler ¶
type HttpProxyHandler struct {
Proxy Proxy
}
func (*HttpProxyHandler) ServeHTTP ¶
func (h *HttpProxyHandler) ServeHTTP(res http.ResponseWriter, req *http.Request)
type JsonResult ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) AppendToDownloadQueue ¶
func (*Server) AppendToQueue ¶
func (*Server) AutoRepair ¶
func (*Server) BackUpMetaDataByDate ¶
func (*Server) BuildFileResult ¶
func (c *Server) BuildFileResult(fileInfo *FileInfo, r *http.Request) FileResult
func (*Server) CheckClusterStatus ¶
func (c *Server) CheckClusterStatus()
func (*Server) CheckDownloadAuth ¶
func (*Server) CheckFileAndSendToPeer ¶
func (*Server) CheckFileExist ¶
func (c *Server) CheckFileExist(w http.ResponseWriter, r *http.Request)
func (*Server) CheckFileExistByInfo ¶
func (*Server) CheckFilesExist ¶
func (c *Server) CheckFilesExist(w http.ResponseWriter, r *http.Request)
func (*Server) CleanAndBackUp ¶
func (c *Server) CleanAndBackUp()
func (*Server) CleanEmptyFolders ¶ added in v1.4.6
func (c *Server) CleanEmptyFolders()
func (*Server) CleanLogLevelDBByDate ¶
func (*Server) ConsumerDownLoad ¶
func (c *Server) ConsumerDownLoad()
func (*Server) ConsumerLog ¶
func (c *Server) ConsumerLog()
func (*Server) ConsumerPostToPeer ¶
func (c *Server) ConsumerPostToPeer()
func (*Server) ConsumerUpload ¶
func (c *Server) ConsumerUpload()
func (*Server) CrossOrigin ¶
func (c *Server) CrossOrigin(w http.ResponseWriter, r *http.Request)
func (*Server) DownloadFileToResponse ¶
func (*Server) DownloadFromPeer ¶
func (*Server) DownloadNormalFileByURI ¶
func (*Server) DownloadNotFound ¶
func (c *Server) DownloadNotFound(w http.ResponseWriter, r *http.Request)
func (*Server) DownloadSmallFileByURI ¶
func (*Server) FormatStatInfo ¶
func (c *Server) FormatStatInfo()
func (*Server) GenGoogleCode ¶
func (c *Server) GenGoogleCode(w http.ResponseWriter, r *http.Request)
func (*Server) GenGoogleSecret ¶
func (c *Server) GenGoogleSecret(w http.ResponseWriter, r *http.Request)
func (*Server) GetClusterNotPermitMessage ¶
func (*Server) GetFileInfo ¶
func (c *Server) GetFileInfo(w http.ResponseWriter, r *http.Request)
func (*Server) GetFileInfoFromLevelDB ¶
func (*Server) GetFilePathByInfo ¶
func (*Server) GetFilePathFromRequest ¶
func (*Server) GetMd5File ¶
func (c *Server) GetMd5File(w http.ResponseWriter, r *http.Request)
func (*Server) GetMd5sByDate ¶
func (*Server) GetMd5sForWeb ¶
func (c *Server) GetMd5sForWeb(w http.ResponseWriter, r *http.Request)
func (*Server) GetMd5sMapByDate ¶
func (*Server) GetSmallFileByURI ¶
func (*Server) GetStat ¶
func (c *Server) GetStat() []StatDateFileInfo
func (*Server) IsExistFromLevelDB ¶
func (*Server) LoadFileInfoByDate ¶
func (*Server) LoadQueueSendToPeer ¶
func (c *Server) LoadQueueSendToPeer()
func (*Server) LoadSearchDict ¶
func (c *Server) LoadSearchDict()
func (*Server) ParseSmallFile ¶
func (*Server) ReceiveMd5s ¶
func (c *Server) ReceiveMd5s(w http.ResponseWriter, r *http.Request)
func (*Server) RegisterExit ¶
func (c *Server) RegisterExit()
func (*Server) RemoveDownloading ¶
func (c *Server) RemoveDownloading()
func (*Server) RemoveEmptyDir ¶
func (c *Server) RemoveEmptyDir(w http.ResponseWriter, r *http.Request)
func (*Server) RemoveFile ¶
func (c *Server) RemoveFile(w http.ResponseWriter, r *http.Request)
func (*Server) RemoveKeyFromLevelDB ¶
func (*Server) RepairFileInfo ¶
func (c *Server) RepairFileInfo(w http.ResponseWriter, r *http.Request)
func (*Server) RepairFileInfoFromFile ¶
func (c *Server) RepairFileInfoFromFile()
func (*Server) RepairStatByDate ¶
func (c *Server) RepairStatByDate(date string) StatDateFileInfo
func (*Server) RepairStatWeb ¶
func (c *Server) RepairStatWeb(w http.ResponseWriter, r *http.Request)
func (*Server) ResizeImage ¶
func (c *Server) ResizeImage(w http.ResponseWriter, fullpath string, width, height uint)
func (*Server) ResizeImageByBytes ¶
func (c *Server) ResizeImageByBytes(w http.ResponseWriter, data []byte, width, height uint)
func (*Server) SaveFileInfoToLevelDB ¶
func (*Server) SaveFileMd5Log ¶
func (*Server) SaveSearchDict ¶
func (c *Server) SaveSearchDict()
func (*Server) SaveSmallFile ¶
func (*Server) SaveUploadFile ¶
func (*Server) Search ¶
func (c *Server) Search(w http.ResponseWriter, r *http.Request)
Notice: performance is poor,just for low capacity,but low memory , if you want to high performance,use searchMap for search,but memory ....
func (*Server) SearchDict ¶
func (*Server) SendToMail ¶
func (*Server) SetDownloadHeader ¶
func (*Server) SyncFileInfo ¶
func (c *Server) SyncFileInfo(w http.ResponseWriter, r *http.Request)
func (*Server) TrimFileNameSpecialChar ¶ added in v1.4.5
func (*Server) VerifyGoogleCode ¶
func (*Server) WatchFilesChange ¶
func (c *Server) WatchFilesChange()
type StatDateFileInfo ¶
type WrapReqResp ¶
type WrapReqResp struct {
// contains filtered or unexported fields
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.