Documentation ¶
Index ¶
- Constants
- func CheckAuthorize(cli chain.Chainer, c *gin.Context, pkey []byte) error
- func CheckChainSt(cli chain.Chainer, c *gin.Context) error
- func CheckFileType(cli chain.Chainer, fid string, account string) (string, error)
- func CheckFilename(c *gin.Context, filename string) error
- func CheckMinerLocation(cli chain.Chainer, puk []byte) (float64, float64, error)
- func CheckPermissionsMdl(account string, accessmode string, priority, blackwhite []string) bool
- func CheckTerritory(cli chain.Chainer, c *gin.Context, pkey []byte, territoryName string) (uint64, error)
- func CreateTmpPath(c *gin.Context, dir, account string) (string, string, error)
- func DownloadFileFromGW(url, fpath, account, message, signature string) (uint64, error)
- func FindFileFromGW(cli chain.Chainer, fid string, fpath string) (uint64, error)
- func FindLocalFile(fid string, dirs ...string) (uint64, string, error)
- func GetCoordinate(addr string) (coordinate.Coordinate, error)
- func GetGWVersion(url string) error
- func InitMiddlewares() []gin.HandlerFunc
- func IsComplete(index int, completeInfo []schain.CompleteInfo) (string, bool)
- func IsStoraged(account string, complete []string) bool
- func OtherHeader(c *gin.Context, fname string)
- func ParseCity(addr string) (float64, float64, bool)
- func ReturnFileRangeStream(c *gin.Context, rng string, content_type string, file string) error
- func ReturnFileStream(c *gin.Context, reader io.Reader, fid, contenttype, format string, size int64)
- func ReturnJSON(c *gin.Context, code int, msg string, data any)
- func VerifyEthSign(message string, sign string) (string, error)
- func VerifySignatureMdl(c *gin.Context) (string, []byte, bool)
- func VerifySignatureMdl2(account, ethAccount, message, signature string) (string, []byte, bool)
- func VideoAndAudioHeader(c *gin.Context, fname string)
- type DuplicateType
- type FileHandler
- func (f *FileHandler) DeleteFileHandle(c *gin.Context)
- func (f *FileHandler) DownloadFileHandle(c *gin.Context)
- func (f *FileHandler) GetLocationhandle(c *gin.Context)
- func (f *FileHandler) GetMetadataHandle(c *gin.Context)
- func (f *FileHandler) OpenFileHandle(c *gin.Context)
- func (f *FileHandler) RegisterRoutes(server *gin.Engine)
- func (f *FileHandler) UploadFormFileHandle(c *gin.Context)
- type FilesHandler
- type Handler
- type Location
- type Metadata
- type MultiFormFiles
- type Node
- func (n *Node) AccessControl(account string) error
- func (n *Node) InitCache()
- func (n *Node) InitChainClient()
- func (n *Node) InitChainclient(cli chain.Chainer)
- func (n *Node) InitLRUCache(lru *lru.LRUCache)
- func (n *Node) InitLogger(lg logger.Logger)
- func (n *Node) InitLogs()
- func (n *Node) InitMinerRecord(r record.MinerRecorder)
- func (n *Node) InitNode() *Node
- func (n *Node) InitServer(s *gin.Engine)
- func (n *Node) InitTracker(t tracker.Tracker)
- func (n *Node) InitWebServer(mdls []gin.HandlerFunc, hdl *Handler)
- func (n *Node) InitWorkspace(ws string)
- func (n *Node) RefreshBlacklist(ch chan<- bool)
- func (n *Node) RefreshMiner(ch chan<- bool)
- func (n *Node) RefreshSelf() error
- func (n *Node) Start()
- func (n *Node) StoragePartAssignment(ch chan<- bool, data StorageDataType, assignments []string)
- func (n *Node) StoragePartFixed(data StorageDataType, assignments []string) (StorageDataType, error)
- func (n *Node) StorageRangeAssignment(ch chan<- bool, data StorageDataType)
- func (n *Node) TrackerV2()
- func (n *Node) UploadFragmentToMiner(addr, fid, fragmentHash, fragmentPath string) error
- func (n *Node) VerifyAccountSignature(account, msg, signature string) ([]byte, error)
- type NodeInfo
- type ObjectHandler
- type RespType
- type ResumeHandler
- type RtnUserBrief
- type StorageDataType
- type StorageType
Constants ¶
View Source
const ( MSG_OK = "ok" ERR_SystemErr = "system error" ERR_ServerBusy = "Server busy" ERR_InvalidFormFile = "invalid form file" ERR_NoPermission = "No permission" ERR_InvalidFid = "invalid fid" ERR_InvalidRangeValue = "invalid range value" ERR_InvalidRangeStart = "invalid range start" ERR_InvalidRangeEnd = "invalid range end" ERR_ReceiveData = "network error" ERR_UnknownFileFormat = "Unknown file format" )
View Source
const ( HTTPHeader_Territory = "Territory" HTTPHeader_Account = "Account" HTTPHeader_EthAccount = "EthAcc" HTTPHeader_Message = "Message" HTTPHeader_Signature = "Signature" HTTPHeader_Miner = "Miner" HTTPHeader_Longitude = "Longitude" HTTPHeader_Latitude = "Latitude" HTTPHeader_Fid = "Fid" HTTPHeader_Cipher = "Cipher" HTTPHeader_Filename = "Filename" HTTPHeader_Format = "Format" HTTPHeader_Range = "Range" HTTPHeader_X_Forwarded_For = "X_Forwarded_For" )
HTTP HEADER
View Source
const ( Active = iota Calculate Missing Recovery )
View Source
const ( HTTP_ParameterName = "name" HTTP_ParameterName_Fid = "fid" )
View Source
const ( INFO_PutRequest = "PutRequest" INFO_PostRestoreRequest = "PostRestoreRequest" INFO_GetRequest = "GetRequest" INFO_GetRestoreRequest = "GetRestoreRequest" INFO_DelRequest = "DelRequest" ERR_DuplicateOrder = "duplicate order" ERR_MissToken = "InvalidHead.MissToken" ERR_EmptySeed = "InvalidProfile.EmptySeed" ERR_MissingAccount = "InvalidHead.MissingAccount" ERR_InvalidAccount = "InvalidHead.Account" ERR_InvalidToken = "InvalidHead.Token" ERR_InvalidName = "InvalidParameter.Name" ERR_InvalidFilehash = "InvalidParameter.FileHash" ERR_InvalidParaBucketName = "InvalidParameter.BucketName" ERR_InvalidBucketName = "InvalidHead.BucketName" ERR_EmptyBucketName = "Invalid.EmptyBucketName" ERR_EmptyFile = "InvalidBody.EmptyFile" ERR_EmptyBody = "InvalidBody.EmptyBody" ERR_ReadBody = "InvalidBody.ReadErr" ERR_ParseBody = "InvalidBody.ParseErr" ERR_NotEnoughSpace = "not enough account space" ERR_InsufficientTerritorySpace = "insufficient territory space" ERR_InternalServer = "Internal system error" ERR_FileNameTooLang = "The file name length cannot exceed 63 characters" ERR_FileNameTooShort = "The file name must be at least 3 characters long" ERR_NoSpace = "please purchase space first" ERR_NoTerritory = "please purchase territory first" ERR_MissingContentRange = "Content-Range is missing from the request header" ERR_IllegalContentRange = "Illegal Content-Range content" ERR_FailedToRecvData = "Failed to receive data" ERR_RPCConnection = "Failed to connect to rpc, please try again later." ERR_RPCSyncing = "Syncing the latest blocks" ERR_EmptyFileName = "Empty file name" )
View Source
const ( ERR_Authorization = "HeaderErr_Invalid_Authorization" ERR_HeadOperation = "HeaderErr_Invalid_Operation" ERR_NotFound = "Not found" ERR_Forbidden = "no permission" ERR_BodyFormat = "BodyErr_InvalidDataFormat" ERR_BodyFieldAccount = "BodyErr_InvalidField_account" ERR_BodyFieldMessage = "BodyErr_InvalidField_message" ERR_BodyFieldSignature = "BodyErr_InvalidField_signature" ERR_BodyEmptyFile = "BodyErr_EmptyFile" ERR_HeaderFieldBucketName = "HeaderErr_InvalidBucketName" ERR_AccountNotExist = "account does not exist" ERR_RpcFailed = "rpc connection failed" ERR_SpaceExpiresSoon = "space expires soon" ERR_TerritoryExpiresSoon = "territory will expire soon" ERR_SpaceNotAuth = "space is not authorized" ERR_DeviceSpaceNoLeft = "no space left on the server device" ERR_SysMemNoLeft = "server unsupported file size" ERR_ReceiveFile = "InternalError" )
View Source
const ( Cache_SyncBlock = "syncblock" Cache_UserFiles = "userfiles:" Cache_UserDeleteFiles = "userdeletefiles:" Cache_WantFiles = "wantfiles:" )
View Source
const MaxMemUsed = 512 << 20
Variables ¶
This section is empty.
Functions ¶
func CheckAuthorize ¶ added in v0.4.0
func CheckFileType ¶ added in v0.4.0
func CheckMinerLocation ¶ added in v0.4.0
func CheckPermissionsMdl ¶ added in v0.4.0
func CheckTerritory ¶ added in v0.4.0
func CreateTmpPath ¶ added in v0.4.0
string: tmp dir string: tmp file path error: error
func DownloadFileFromGW ¶ added in v0.4.0
func FindFileFromGW ¶ added in v0.4.0
func FindLocalFile ¶ added in v0.4.0
func GetCoordinate ¶ added in v0.4.0
func GetCoordinate(addr string) (coordinate.Coordinate, error)
func GetGWVersion ¶ added in v0.4.0
func InitMiddlewares ¶ added in v0.4.0
func InitMiddlewares() []gin.HandlerFunc
func IsComplete ¶ added in v0.4.0
func IsComplete(index int, completeInfo []schain.CompleteInfo) (string, bool)
func IsStoraged ¶ added in v0.4.0
func OtherHeader ¶ added in v0.3.7
func ReturnFileRangeStream ¶ added in v0.4.0
func ReturnFileStream ¶ added in v0.4.0
func VerifyEthSign ¶ added in v0.3.6
func VerifySignatureMdl ¶ added in v0.4.0
func VerifySignatureMdl2 ¶ added in v0.4.0
func VideoAndAudioHeader ¶ added in v0.3.7
Types ¶
type DuplicateType ¶ added in v0.3.7
type DuplicateType uint8
const ( // not duplicate Duplicate0 DuplicateType = 0 // not in file.owners Duplicate1 DuplicateType = 1 // in file.owners Duplicate2 DuplicateType = 2 )
type FileHandler ¶ added in v0.4.0
type FileHandler struct { chain.Chainer workspace.Workspace tracker.Tracker logger.Logger *confile.Config *rate.Limiter *lru.LRUCache }
func NewFileHandler ¶ added in v0.4.0
func (*FileHandler) DeleteFileHandle ¶ added in v0.4.0
func (f *FileHandler) DeleteFileHandle(c *gin.Context)
func (*FileHandler) DownloadFileHandle ¶ added in v0.4.0
func (f *FileHandler) DownloadFileHandle(c *gin.Context)
func (*FileHandler) GetLocationhandle ¶ added in v0.4.0
func (f *FileHandler) GetLocationhandle(c *gin.Context)
func (*FileHandler) GetMetadataHandle ¶ added in v0.4.0
func (f *FileHandler) GetMetadataHandle(c *gin.Context)
func (*FileHandler) OpenFileHandle ¶ added in v0.4.0
func (f *FileHandler) OpenFileHandle(c *gin.Context)
func (*FileHandler) RegisterRoutes ¶ added in v0.4.0
func (f *FileHandler) RegisterRoutes(server *gin.Engine)
func (*FileHandler) UploadFormFileHandle ¶ added in v0.4.0
func (f *FileHandler) UploadFormFileHandle(c *gin.Context)
type FilesHandler ¶ added in v0.4.0
type FilesHandler struct { chain.Chainer workspace.Workspace tracker.Tracker logger.Logger *confile.Config *rate.Limiter *lru.LRUCache }
func NewFilesHandler ¶ added in v0.4.0
func (*FilesHandler) RegisterRoutes ¶ added in v0.4.0
func (f *FilesHandler) RegisterRoutes(server *gin.Engine)
func (*FilesHandler) UploadFormFilesHandle ¶ added in v0.4.0
func (f *FilesHandler) UploadFormFilesHandle(c *gin.Context)
type Handler ¶ added in v0.4.0
type Handler struct { *FileHandler *ResumeHandler *ObjectHandler *FilesHandler }
func NewHandler ¶ added in v0.4.0
func (*Handler) RegisterRoutes ¶ added in v0.4.0
type Metadata ¶ added in v0.3.7
type Metadata struct { Fid string `json:"fid"` Size uint64 `json:"size"` Owner []RtnUserBrief `json:"owner"` }
file meta info
type MultiFormFiles ¶ added in v0.4.0
type Node ¶
type Node struct { *confile.Config *lru.LRUCache *gin.Engine chain.Chainer workspace.Workspace logger.Logger record.MinerRecorder tracker.Tracker }
func NewEmptyNode ¶ added in v0.4.0
func NewEmptyNode() *Node
func NewNodeWithConfig ¶ added in v0.4.0
func (*Node) AccessControl ¶ added in v0.3.3
func (*Node) InitChainClient ¶ added in v0.4.0
func (n *Node) InitChainClient()
func (*Node) InitChainclient ¶ added in v0.4.0
func (*Node) InitLRUCache ¶ added in v0.4.0
func (*Node) InitLogger ¶ added in v0.4.0
func (*Node) InitMinerRecord ¶ added in v0.4.0
func (n *Node) InitMinerRecord(r record.MinerRecorder)
func (*Node) InitServer ¶ added in v0.4.0
func (*Node) InitTracker ¶ added in v0.4.0
func (*Node) InitWebServer ¶ added in v0.4.0
func (n *Node) InitWebServer(mdls []gin.HandlerFunc, hdl *Handler)
func (*Node) InitWorkspace ¶ added in v0.4.0
func (*Node) RefreshBlacklist ¶ added in v0.4.0
func (*Node) RefreshMiner ¶ added in v0.3.7
func (*Node) RefreshSelf ¶ added in v0.3.7
func (*Node) StoragePartAssignment ¶ added in v0.4.0
func (n *Node) StoragePartAssignment(ch chan<- bool, data StorageDataType, assignments []string)
func (*Node) StoragePartFixed ¶ added in v0.4.0
func (n *Node) StoragePartFixed(data StorageDataType, assignments []string) (StorageDataType, error)
func (*Node) StorageRangeAssignment ¶ added in v0.4.0
func (n *Node) StorageRangeAssignment(ch chan<- bool, data StorageDataType)
func (*Node) UploadFragmentToMiner ¶ added in v0.4.0
type ObjectHandler ¶ added in v0.4.0
type ObjectHandler struct { chain.Chainer workspace.Workspace tracker.Tracker logger.Logger *confile.Config *rate.Limiter *lru.LRUCache }
func NewObjectHandler ¶ added in v0.4.0
func (*ObjectHandler) RegisterRoutes ¶ added in v0.4.0
func (o *ObjectHandler) RegisterRoutes(server *gin.Engine)
func (*ObjectHandler) UploadObjectHandle ¶ added in v0.4.0
func (o *ObjectHandler) UploadObjectHandle(c *gin.Context)
type ResumeHandler ¶ added in v0.4.0
type ResumeHandler struct { chain.Chainer workspace.Workspace tracker.Tracker logger.Logger *confile.Config *rate.Limiter }
func NewResumeHandler ¶ added in v0.4.0
func (*ResumeHandler) RegisterRoutes ¶ added in v0.4.0
func (r *ResumeHandler) RegisterRoutes(server *gin.Engine)
func (*ResumeHandler) ResumeHandle ¶ added in v0.4.0
func (r *ResumeHandler) ResumeHandle(c *gin.Context)
type RtnUserBrief ¶
type StorageDataType ¶ added in v0.4.0
type StorageDataType struct { Fid string Complete []string Data [][]string StorageType StorageType Assignments []string Range coordinate.Range }
type StorageType ¶ added in v0.4.0
type StorageType uint8
const ( Storage_NoAssignment StorageType = iota Storage_PartAssignment Storage_FullAssignment Storage_RangeAssignment )
Click to show internal directories.
Click to hide internal directories.