backend

package
v0.0.0-...-b446b8c Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TableCENKeys stores the mapping between CENKeys and CENReports.
	TableCENKeys = "CENKeys"

	// TableCENKeys stores the mapping between CENKeys and CENReports.
	TableCENReport = "CENReport"

	// Default Conn String
	DefaultConnString = "[change this to your server]"
)

Variables

This section is empty.

Functions

func Computehash

func Computehash(data ...[]byte) []byte

Computehash returns the hash of its inputs

Types

type Backend

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

Backend holds a client to connect to the BigTable backend

func NewBackend

func NewBackend(mysqlConnectionString string) (backend *Backend, err error)

NewBackend sets up a client connection to BigTable to manage incoming payloads

func (*Backend) ProcessCENReport

func (backend *Backend) ProcessCENReport(cenReport *CENReport) (err error)

ProcessCENReport manages the API Endpoint to POST /cenreport

Input: CENReport
Output: error
Behavior: write report bytes to "report" table; write row for each CENKey with reportID

func (*Backend) ProcessGetCENKeys

func (backend *Backend) ProcessGetCENKeys(timestamp uint64) (cenKeys []string, err error)

ProcessGetCENKeys manages the GET API endpoint /cenkeys

Input: timestamp
Output: array of CENKeys (in string form) for the last hour

func (*Backend) ProcessGetCENReport

func (backend *Backend) ProcessGetCENReport(cenKey string) (reports []*CENReport, err error)

ProcessGetCENReport manages the POST API endpoint /cenreport

Input: cenKey
Output: array of CENReports

type CENReport

type CENReport struct {
	ReportID        string `json:"reportID,omitempty"`
	Report          []byte `json:"report,omitempty"`  // this is expected to be a JSON blob but the server doesn't need to parse it
	CENKeys         string `json:"cenKeys,omitempty"` // comma separated list of hex AES-128 Keys (COMMENT WAS: base64 AES Keys)
	ReportMimeType  string `json:"reportMimeType,omitempty"`
	ReportTimeStamp uint64 `json:"reportTimeStamp,omitempty"`
}

CENReport payload is sent by client to /cenreport when user reports symptoms

func GetSampleCENReportAndCENKeys

func GetSampleCENReportAndCENKeys(nKeys int) (cenReport *CENReport, cenKeys []string)

GetSampleCENReportAndCENKeys generates a CENReport and an array of CENKeys (in string form)

Jump to

Keyboard shortcuts

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