handler

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2020 License: BSD-3-Clause Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrJobNotFound = errors.New("job not found")

ErrJobNotFound did not found the job in the DB

Functions

func AcceptTaskHandler

func AcceptTaskHandler(c *gin.Context)

AcceptTaskHandler mark a task as accepted

func AddJob

func AddJob(db *sqlx.DB, jd JobData, s *sched.Scheduler) (string, error)

AddJob adds a job to the database and run it

func AddJobHandler

func AddJobHandler(c *gin.Context)

AddJobHandler adds a job to the job DB

func CollectorsHandler

func CollectorsHandler(c *gin.Context)

CollectorsHandler returns the list of requested collectors

func DeleteJob

func DeleteJob(jobID string, db *sqlx.DB, s *sched.Scheduler) error

DeleteJob mark the job as deleted

func DeleteJobHandler

func DeleteJobHandler(c *gin.Context)

DeleteJobHandler deletes a job

func DoneTaskHandler

func DoneTaskHandler(c *gin.Context)

DoneTaskHandler mark a certain task as done

func GetTaskHandler

func GetTaskHandler(c *gin.Context)

GetTaskHandler get a specific task

func GetTasksForUser

func GetTasksForUser(uID string, since string,
	db *sqlx.DB) ([]sched.TaskData, error)

GetTasksForUser lists all the tasks a user has

func ListJobsHandler

func ListJobsHandler(c *gin.Context)

ListJobsHandler lists the jobs in the database

func ListTasksHandler

func ListTasksHandler(c *gin.Context)

ListTasksHandler lists all the tasks for a user

func PsiphonConfigHandler added in v0.3.1

func PsiphonConfigHandler(c *gin.Context)

PsiphonConfigHandler returns the psiphon configuration.

func RejectTaskHandler

func RejectTaskHandler(c *gin.Context)

RejectTaskHandler reject a certain task

func TestHelpersHandler

func TestHelpersHandler(c *gin.Context)

TestHelpersHandler returns the list of requested test helpers

func TorTargetsHandler added in v0.3.2

func TorTargetsHandler(c *gin.Context)

TorTargetsHandler returns the targets for the tor nettest.

func URLsHandler

func URLsHandler(c *gin.Context)

URLsHandler returns the list of requested URLs

Types

type CollectorInfo

type CollectorInfo struct {
	Type    string `json:"type"`
	Address string `json:"address"`
}

CollectorInfo holds the type and address of a collector

func GetCollectors

func GetCollectors(types string, db *sqlx.DB) ([]CollectorInfo, error)

GetCollectors returns the list of collectors available

type DomainFrontedCollector

type DomainFrontedCollector struct {
	Domain string `json:"domain"`
	Front  string `json:"front"`
}

DomainFrontedCollector is a {"domain": "a", "front": "b"} map

type JobData

type JobData struct {
	ID        string           `json:"id"`
	Schedule  string           `json:"schedule" binding:"required"`
	Delay     int64            `json:"delay"`
	Comment   string           `json:"comment" binding:"required"`
	TaskData  *sched.TaskData  `json:"task"`
	AlertData *sched.AlertData `json:"alert"`
	Target    Target           `json:"target"`
	State     string           `json:"state"`

	CreationTime time.Time `json:"creation_time"`
}

JobData struct for containing all Job metadata (both alert and tasks)

func ListJobs

func ListJobs(db *sqlx.DB, showDeleted bool) ([]JobData, error)

ListJobs list all the jobs present in the database

type Target

type Target struct {
	Countries []string `json:"countries"`
	Platforms []string `json:"platforms"`
}

Target is the target country

type TestHelperInfo

type TestHelperInfo struct {
	Name    string `json:"name"`
	Type    string `json:"type"`
	Address string `json:"address"`
}

TestHelperInfo holds the name, type and address of a test helper

func GetTestHelpers

func GetTestHelpers(names string, db *sqlx.DB) ([]TestHelperInfo, error)

GetTestHelpers returns a list of test helpers

type URLInfo

type URLInfo struct {
	CategoryCode string `json:"category_code"`
	URL          string `json:"url"`
	CountryCode  string `json:"country_code"`
}

URLInfo holds the name, type and address of a test helper

func GetURLs

func GetURLs(q URLsQuery, db *sqlx.DB) ([]URLInfo, error)

GetURLs returns a slice of test inputs

type URLTestArg

type URLTestArg struct {
	GlobalCategories  []string `json:"global_categories"`
	CountryCategories []string `json:"country_categories"`
	URLs              []string `json:"urls"`
}

URLTestArg are the URL arguments for the test

type URLsQuery

type URLsQuery struct {
	Limit         int64  `form:"limit"`
	CountryCode   string `form:"country_code"`
	CategoryCodes string `form:"category_codes"`
}

URLsQuery is the user issued request for URLs

func (URLsQuery) MakeMetadata

func (q URLsQuery) MakeMetadata() map[string]interface{}

MakeMetadata generates the metadata for the request

Jump to

Keyboard shortcuts

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