zboxutil

package
v1.16.6 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 37 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ALLOCATION_ENDPOINT          = "/allocation"
	UPLOAD_ENDPOINT              = "/v1/file/upload/"
	RENAME_ENDPOINT              = "/v1/file/rename/"
	COPY_ENDPOINT                = "/v1/file/copy/"
	MOVE_ENDPOINT                = "/v1/file/move/"
	LIST_ENDPOINT                = "/v1/file/list/"
	REFERENCE_ENDPOINT           = "/v1/file/referencepath/"
	CONNECTION_ENDPOINT          = "/v1/connection/details/"
	COMMIT_ENDPOINT              = "/v1/connection/commit/"
	DOWNLOAD_ENDPOINT            = "/v1/file/download/"
	LATEST_READ_MARKER           = "/v1/readmarker/latest"
	FILE_META_ENDPOINT           = "/v1/file/meta/"
	FILE_STATS_ENDPOINT          = "/v1/file/stats/"
	OBJECT_TREE_ENDPOINT         = "/v1/file/objecttree/"
	REFS_ENDPOINT                = "/v1/file/refs/"
	RECENT_REFS_ENDPOINT         = "/v1/file/refs/recent/"
	COLLABORATOR_ENDPOINT        = "/v1/file/collaborator/"
	CALCULATE_HASH_ENDPOINT      = "/v1/file/calculatehash/"
	SHARE_ENDPOINT               = "/v1/marketplace/shareinfo/"
	DIR_ENDPOINT                 = "/v1/dir/"
	PLAYLIST_LATEST_ENDPOINT     = "/v1/playlist/latest/"
	PLAYLIST_FILE_ENDPOINT       = "/v1/playlist/file/"
	WM_LOCK_ENDPOINT             = "/v1/writemarker/lock/"
	CREATE_CONNECTION_ENDPOINT   = "/v1/connection/create/"
	LATEST_WRITE_MARKER_ENDPOINT = "/v1/file/latestwritemarker/"
	ROLLBACK_ENDPOINT            = "/v1/connection/rollback/"
	REDEEM_ENDPOINT              = "/v1/connection/redeem/"

	// CLIENT_SIGNATURE_HEADER represents http request header contains signature.
	CLIENT_SIGNATURE_HEADER    = "X-App-Client-Signature"
	CLIENT_SIGNATURE_HEADER_V2 = "X-App-Client-Signature-V2"
	ALLOCATION_ID_HEADER       = "ALLOCATION-ID"
)
View Source
const EncryptedFolderName = "encrypted"
View Source
const MAX_RETRIES = 5
View Source
const SC_REST_API_URL = "v1/screst/"
View Source
const SLEEP_BETWEEN_RETRIES = 5

Variables

View Source
var (
	Client         HttpClient
	FastHttpClient FastClient
)
View Source
var DefaultTransport = &http.Transport{
	Proxy: envProxy.Proxy,
	DialContext: (&net.Dialer{
		Timeout:   3 * time.Minute,
		KeepAlive: 45 * time.Second,
		DualStack: true,
	}).DialContext,
	MaxIdleConns:          100,
	IdleConnTimeout:       90 * time.Second,
	TLSHandshakeTimeout:   45 * time.Second,
	ExpectContinueTimeout: 1 * time.Second,
	MaxIdleConnsPerHost:   25,
}

Functions

func Decrypt

func Decrypt(key, text []byte) ([]byte, error)

func DeleteCollaboratorRequest

func DeleteCollaboratorRequest(baseUrl string, allocationID string, allocationTx string, query *url.Values) (*http.Request, error)

func Encrypt

func Encrypt(key, text []byte) ([]byte, error)

func GetActiveBlobbers added in v1.8.6

func GetActiveBlobbers(dirMask uint32, blobbers []*blockchain.StorageNode) []*blockchain.StorageNode

func GetCollaboratorsRequest

func GetCollaboratorsRequest(baseUrl string, allocationID string, allocationTx string, query *url.Values) (*http.Request, error)

func GetErrorMessageCode added in v1.8.16

func GetErrorMessageCode(errorMsg string) (string, error)

Returns the error message code, message should be strictly of the format: ".... err: {"code" : <return_this>, ...}, ..."

func GetFastHTTPClient added in v1.15.9

func GetFastHTTPClient() *fasthttp.Client

func GetFastRateLimitValue added in v1.13.0

func GetFastRateLimitValue(r *fasthttp.Response) (int, error)

func GetFileContentType

func GetFileContentType(ext string, out io.ReadSeeker) (string, error)

func GetFullRemotePath

func GetFullRemotePath(localPath, remotePath string) string

func GetLogger added in v1.10.0

func GetLogger() *logger.Logger

func GetRateLimitValue added in v1.8.9

func GetRateLimitValue(r *http.Response) (int, error)

func GetRefsHash added in v1.3.0

func GetRefsHash(r []byte) string

func HttpDo

func HttpDo(ctx context.Context, cncl context.CancelFunc, req *http.Request, f func(*http.Response, error) error) error

func IsRemoteAbs

func IsRemoteAbs(path string) bool

func MajorError added in v1.8.16

func MajorError(errors []error) error

func MakeSCRestAPICall

func MakeSCRestAPICall(scAddress string, relativePath string, params map[string]string, handler SCRestAPIHandler) ([]byte, error)

func NewAllocationRequest

func NewAllocationRequest(baseUrl, allocationID, allocationTx string) (*http.Request, error)

func NewCalculateHashRequest

func NewCalculateHashRequest(baseUrl, allocationID string, allocationTx string, paths []string) (*http.Request, error)

func NewCollaboratorRequest

func NewCollaboratorRequest(baseUrl string, allocationID string, allocationTx string, body io.Reader) (*http.Request, error)

func NewCommitRequest

func NewCommitRequest(baseUrl, allocationID string, allocationTx string, body io.Reader) (*http.Request, error)

func NewConnectionId

func NewConnectionId() string

NewConnectionId generate new connection id

func NewConnectionRequest added in v1.8.17

func NewConnectionRequest(baseUrl, allocationID string, allocationTx string, body io.Reader) (*http.Request, error)

func NewCopyRequest

func NewCopyRequest(baseUrl, allocationID string, allocationTx string, body io.Reader) (*http.Request, error)

func NewCreateDirRequest

func NewCreateDirRequest(baseUrl, allocationID string, allocationTx string, body io.Reader) (*http.Request, error)

func NewDeleteRequest

func NewDeleteRequest(baseUrl, allocationID string, allocationTx string, query *url.Values) (*http.Request, error)

func NewDownloadRequest

func NewDownloadRequest(baseUrl, allocationID, allocationTx string) (*http.Request, error)

func NewFastDownloadRequest added in v1.13.0

func NewFastDownloadRequest(baseUrl, allocationID, allocationTx string) (*fasthttp.Request, error)

func NewFastUploadRequest added in v1.13.0

func NewFastUploadRequest(baseURL, allocationID string, allocationTx string, body []byte, method string) (*fasthttp.Request, error)

func NewFileMetaRequest

func NewFileMetaRequest(baseUrl string, allocationID string, allocationTx string, body io.Reader) (*http.Request, error)

func NewFileStatsRequest

func NewFileStatsRequest(baseUrl string, allocationID string, allocationTx string, body io.Reader) (*http.Request, error)

func NewHTTPRequest

func NewHTTPRequest(method string, url string, data []byte) (*http.Request, context.Context, context.CancelFunc, error)

func NewListRequest

func NewListRequest(baseUrl, allocationID, allocationTx, path, pathHash, auth_token string, list bool, offset, pageLimit int) (*http.Request, error)

func NewMoveRequest added in v1.8.10

func NewMoveRequest(baseUrl, allocationID string, allocationTx string, body io.Reader) (*http.Request, error)

func NewObjectTreeRequest

func NewObjectTreeRequest(baseUrl, allocationID string, allocationTx string, path string) (*http.Request, error)

func NewRecentlyAddedRefsRequest added in v1.8.7

func NewRecentlyAddedRefsRequest(bUrl, allocID, allocTx string, fromDate, offset int64, pageLimit int) (*http.Request, error)

func NewRedeemRequest added in v1.8.17

func NewRedeemRequest(baseUrl, allocationID, allocationTx string) (*http.Request, error)

func NewReferencePathRequest

func NewReferencePathRequest(baseUrl, allocationID string, allocationTx string, paths []string) (*http.Request, error)

func NewRefsRequest added in v1.3.0

func NewRefsRequest(baseUrl, allocationID, allocationTx, path, pathHash, authToken, offsetPath, updatedDate, offsetDate, fileType, refType string, level, pageLimit int) (*http.Request, error)

func NewRenameRequest

func NewRenameRequest(baseUrl, allocationID string, allocationTx string, body io.Reader) (*http.Request, error)

func NewRevokeShareRequest

func NewRevokeShareRequest(baseUrl, allocationID string, allocationTx string, query *url.Values) (*http.Request, error)

func NewRollbackRequest added in v1.8.17

func NewRollbackRequest(baseUrl, allocationID string, allocationTx string, body io.Reader) (*http.Request, error)

func NewShareRequest

func NewShareRequest(baseUrl, allocationID string, allocationTx string, body io.Reader) (*http.Request, error)

func NewUploadRequest

func NewUploadRequest(baseUrl, allocationID string, allocationTx string, body io.Reader, update bool) (*http.Request, error)

func NewUploadRequestWithMethod added in v1.2.88

func NewUploadRequestWithMethod(baseURL, allocationID string, allocationTx string, body io.Reader, method string) (*http.Request, error)

NewUploadRequestWithMethod create a http request of upload

func NewWriteMarkerLockRequest added in v1.8.9

func NewWriteMarkerLockRequest(
	baseURL, allocationID, allocationTx, connID string) (*http.Request, error)

func NewWriteMarkerUnLockRequest added in v1.8.9

func NewWriteMarkerUnLockRequest(
	baseURL, allocationID, allocationTx, connID, requestTime string) (*http.Request, error)

func NewWritemarkerRequest added in v1.8.17

func NewWritemarkerRequest(baseUrl, allocationID, allocationTx string) (*http.Request, error)

func RemoteClean

func RemoteClean(path string) string

func ScryptDecrypt added in v1.8.15

func ScryptDecrypt(key, ciphertext []byte) ([]byte, error)

func ScryptEncrypt added in v1.8.15

func ScryptEncrypt(key, text []byte) ([]byte, error)

func Transpose added in v1.8.17

Returns transpose of 2-D slice Example: Given matrix [[a, b], [c, d], [e, f]] returns [[a, c, e], [b, d, f]]

Types

type DownloadBuffer added in v1.12.1

type DownloadBuffer interface {
	RequestChunk(ctx context.Context, num int) []byte
	ReleaseChunk(num int)
	ClearBuffer()
}

type DownloadBufferWithChan added in v1.13.0

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

func NewDownloadBufferWithChan added in v1.13.0

func NewDownloadBufferWithChan(size, numBlocks, effectiveBlockSize int) *DownloadBufferWithChan

func (*DownloadBufferWithChan) ClearBuffer added in v1.13.7

func (r *DownloadBufferWithChan) ClearBuffer()

func (*DownloadBufferWithChan) ReleaseChunk added in v1.13.0

func (r *DownloadBufferWithChan) ReleaseChunk(num int)

func (*DownloadBufferWithChan) RequestChunk added in v1.13.0

func (r *DownloadBufferWithChan) RequestChunk(ctx context.Context, num int) []byte

type DownloadBufferWithMask added in v1.13.0

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

func NewDownloadBufferWithMask added in v1.13.0

func NewDownloadBufferWithMask(size, numBlocks, effectiveBlockSize int) *DownloadBufferWithMask

func (*DownloadBufferWithMask) ClearBuffer added in v1.13.7

func (r *DownloadBufferWithMask) ClearBuffer()

func (*DownloadBufferWithMask) ReleaseChunk added in v1.13.0

func (r *DownloadBufferWithMask) ReleaseChunk(num int)

func (*DownloadBufferWithMask) RequestChunk added in v1.13.0

func (r *DownloadBufferWithMask) RequestChunk(ctx context.Context, num int) []byte

func (*DownloadBufferWithMask) SetNumBlocks added in v1.13.14

func (r *DownloadBufferWithMask) SetNumBlocks(numBlocks int)

type FastClient added in v1.13.0

type FastClient interface {
	DoTimeout(req *fasthttp.Request, resp *fasthttp.Response, timeout time.Duration) error
}

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type SCRestAPIHandler

type SCRestAPIHandler func(response map[string][]byte, numSharders int, err error)

type Uint128

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

func NewUint128

func NewUint128(x uint64) Uint128

func (Uint128) Add

func (x Uint128) Add(y Uint128) Uint128

Add returns x+y.

func (Uint128) Add64

func (x Uint128) Add64(y uint64) Uint128

Add64 returns x+y.

func (Uint128) And

func (x Uint128) And(v Uint128) Uint128

And returns x&y.

func (Uint128) And64

func (x Uint128) And64(y uint64) Uint128

And64 returns x&y.

func (Uint128) CountOnes

func (x Uint128) CountOnes() int

CountOnes return num of 1 bits in x.

func (Uint128) Equals

func (x Uint128) Equals(y Uint128) bool

Equals returns true if x == y.

func (Uint128) Equals64

func (x Uint128) Equals64(y uint64) bool

Equals64 returns true if x == y.

func (Uint128) Lsh

func (x Uint128) Lsh(y uint64) Uint128

Lsh returns x<<y.

func (Uint128) Not

func (x Uint128) Not() Uint128

Not returns ^x.

func (Uint128) Or

func (x Uint128) Or(v Uint128) Uint128

Or returns x|y.

func (Uint128) Sub

func (x Uint128) Sub(y Uint128) Uint128

Sub returns x-y.

func (Uint128) Sub64

func (x Uint128) Sub64(y uint64) Uint128

Sub64 returns x-y.

func (Uint128) TrailingZeros

func (x Uint128) TrailingZeros() int

TrailingZeros returns the number of trailing zero bits in x; the result is 128 for x == 0.

func (Uint128) Xor

func (x Uint128) Xor(v Uint128) Uint128

Xor returns x^y.

Jump to

Keyboard shortcuts

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