integration

package module
v0.0.0-...-c669621 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ApiVersion = "v1"

* Important

View Source
const ErrorServer = "server.error"
View Source
const StandardKeySize = 2048
View Source
const StatusError = 2
View Source
const StatusOffline = 1
View Source
const StatusOnline = 0

Variables

View Source
var BasePath = "http://localhost:3000"
View Source
var ClusterID uint = 0
View Source
var FilePath = ""
View Source
var JwtSecret = ""
View Source
var Log = log.New(os.Stdout, "node-integration ", log.Flags())
View Source
var NODE_ID uint = 0
View Source
var NODE_TOKEN = ""
View Source
var NodePrivateKey *rsa.PrivateKey // Private key for current node

* Credentials for this node

View Source
var NodePublicKey *rsa.PublicKey // Public key for current node
View Source
var Protocol = "http://"
View Source
var ServerPublicKey *rsa.PublicKey // Public key from the backend server
View Source
var Testing = false
View Source
var TestingToken = ""

Functions

func BodyParser

func BodyParser(c *fiber.Ctx, data interface{}) error

Parse encrypted json

func DecryptAES

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

Decrypt decrypts the given ciphertext using AES-GCM.

func DecryptRSA

func DecryptRSA(privateKey *rsa.PrivateKey, ciphertext []byte) ([]byte, error)

Decrypt a message with a private key. (can't be infinitely long)

func EncryptAES

func EncryptAES(key, plaintext []byte) ([]byte, error)

Encrypt encrypts the given plaintext using AES-GCM.

func EncryptRSA

func EncryptRSA(publicKey *rsa.PublicKey, message []byte) ([]byte, error)

Encrypt a message with a public key. (can't be infinitely long)

func FailedRequest

func FailedRequest(c *fiber.Ctx, message string, err error) error

func GenerateRSAKey

func GenerateRSAKey(keySize int) (*rsa.PrivateKey, *rsa.PublicKey, error)

Generate a new RSA key pair.

func GenerateToken

func GenerateToken(tkLength int32) string

func GetCurrent

func GetCurrent() (id int64, token string, app uint, domain string)

func InvalidRequest

func InvalidRequest(c *fiber.Ctx, message string) error

func NewAESKey

func NewAESKey() ([]byte, error)

func PackageRSAPrivateKey

func PackageRSAPrivateKey(privateKey *rsa.PrivateKey) string

PackageRSAPrivateKey packages a private key into our own format. Packaging order: modulus, public exponent, private exponent, p, q

func PackageRSAPublicKey

func PackageRSAPublicKey(publicKey *rsa.PublicKey) string

PackageRSAPublicKey packages a public key into our own format. Packaging order: modulus, public exponent

func PostRequest

func PostRequest(url string, body map[string]interface{}) (map[string]interface{}, error)

Send a post request (with TC protection encryption)

func PostRequestNoTC

func PostRequestNoTC(url string, body map[string]interface{}) (map[string]interface{}, error)

Send a post request (without TC encryption and custom URL)

func ReportOffline

func ReportOffline(node pipes.Node)

func ReturnJSON

func ReturnJSON(c *fiber.Ctx, data interface{}) error

Return encrypted json

func SetOnline

func SetOnline() map[string]interface{}

func Setup

func Setup() bool

func SignRSA

func SignRSA(privateKey *rsa.PrivateKey, message string) (string, error)

Sign a message with a private key.

func SuccessfulRequest

func SuccessfulRequest(c *fiber.Ctx) error

func TestAES

func TestAES()

func UnpackageRSAPrivateKey

func UnpackageRSAPrivateKey(priv string) (*rsa.PrivateKey, error)

Unpackage private key (in our own format that is kinda crappy but who cares)

func UnpackageRSAPublicKey

func UnpackageRSAPublicKey(pub string) (*rsa.PublicKey, error)

Unpackage public key (in our own format that is kinda crappy but who cares)

func VerifyRSASignature

func VerifyRSASignature(signature string, publicKey *rsa.PublicKey, message string) error

Verify a signature with a public key. (valid signature = nil error)

Types

type NormalResponse

type NormalResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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