util

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuccessCode = 200
	ServerError = 500

	GetLocationError           = 3000
	GetCpAccountError          = 3001
	GeResourceError            = 3002
	JsonError                  = 4000
	BadParamError              = 4001
	SignatureError             = 4002
	SpaceParseResourceUriError = 4003
	CheckResourcesError        = 4004
	SpaceCheckWhiteListError   = 4005
	NoAvailableResourcesError  = 4006
	FoundJobEntityError        = 4007
	NotFoundJobEntityError     = 4008
	SaveJobEntityError         = 4009
	FoundWhiteListError        = 4010
	FoundBlackListError        = 4011
	SpaceCheckBlackListError   = 4012
	CheckBalanceError          = 4013
	RejectZkTaskError          = 4014
	DownloadResourceError      = 4015
	PortNoAvailableError       = 4016
	GenerateRsaError           = 4017
	SaveRsaKeyError            = 4018
	ReadRsaKeyError            = 4019
	CheckNodePortError         = 4020
	CheckResourceLimitError    = 4021
	NotAcceptNodePortError     = 4022
	RpcConnectError            = 4023
	CheckPriceError            = 4024
	BelowPriceError            = 4025
	ReadPriceError             = 4026
	ReadLogError               = 4027

	ProofParamError   = 7001
	ProofReadLogError = 7002
	ProofError        = 7003

	UbiTaskParamError    = 8001
	UbiTaskContractError = 8002
	FoundTaskEntityError = 8003
	SaveTaskEntityError  = 8004
	SubmitProofError     = 8005
)
View Source
const (
	RSA_DIR_NAME    = "dcc"
	RSA_PUBLIC_KEY  = "public_key.pem"
	RSA_PRIVATE_KEY = "private_key.pem"
)

Variables

This section is empty.

Functions

func CheckPortAvailability added in v0.7.0

func CheckPortAvailability(usedPort map[int32]struct{}) bool

func CheckVersion added in v1.1.1

func CheckVersion(targetVersionStr, versionStr string) error

func DecryptAES256CFB added in v0.6.4

func DecryptAES256CFB(encryptedData, key []byte, iv []byte) ([]byte, error)

func DecryptData added in v0.6.4

func DecryptData(filename string, ciphertext []byte) ([]byte, error)

func EncryptData added in v0.6.4

func EncryptData(filename string, plaintext []byte) ([]byte, error)

func GenerateRSAKeyPair added in v0.6.4

func GenerateRSAKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)

func IsPortAvailable added in v1.0.0

func IsPortAvailable(port int) bool

func MonitorShutdown

func MonitorShutdown(triggerCh <-chan struct{}, handlers ...ShutdownHandler) <-chan struct{}

func ReadPrivateKey added in v0.6.4

func ReadPrivateKey(filename string) ([]byte, error)

func ReadPublicKey added in v0.6.4

func ReadPublicKey(filename string) ([]byte, error)

func ReqContext

func ReqContext() context.Context

func RunPythonScript

func RunPythonScript(scriptPath ...string) (string, error)

func SavePrivateEMKey added in v0.6.4

func SavePrivateEMKey(filename string, key *rsa.PrivateKey) error

func SavePublicPEMKey added in v0.6.4

func SavePublicPEMKey(filename string, pubkey *rsa.PublicKey) error

func StreamPythonScriptOutput

func StreamPythonScriptOutput(wg *sync.WaitGroup, scriptPath ...string)

Types

type BasicResponse

type BasicResponse struct {
	Status  string      `json:"status"`
	Code    int         `json:"code"`
	Data    interface{} `json:"data,omitempty"`
	Message string      `json:"message,omitempty"`
}

func CreateErrorResponse

func CreateErrorResponse(code int, errMsg ...string) BasicResponse

func CreateSuccessResponse

func CreateSuccessResponse(_data interface{}) BasicResponse

type ShutdownHandler

type ShutdownHandler struct {
	Component string
	StopFunc  StopFunc
}

type StopFunc

type StopFunc func(context.Context) error

func ServeHttp

func ServeHttp(h http.Handler, name string, addr string, ssl bool) (StopFunc, error)

Jump to

Keyboard shortcuts

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