Documentation ¶
Overview ¶
* Package "controllers" provides Dots API controllers.
Index ¶
- func ActivateDataChannelACL(customer *models.Customer, clientIdentifier string) error
- func CheckConfictWithDataChannelAcceptList(customer *models.Customer, cuid string, sourceAddressList []string) (bool, error)
- func CreateMitigation(body *messages.MitigationRequest, customer *models.Customer, ...) (*models.ConflictInformation, error)
- func DeActivateDataChannelACL(customerID int, clientIdentifier string) error
- func DefaultSessionConfiguration() (sessionConfig models.SignalSessionConfiguration)
- func DeleteMitigation(customerId int, cuid string, mid int, mitigationScopeId int64) (err error)
- func GetOtherActiveMitigations(currentMitigationScopeId *int64) (scopes []models.MitigationScope, err error)
- func GetSessionConfig(customer *models.Customer) (*models.SignalSessionConfiguration, error)
- func ManageExpiredMitigation(lifetimeInterval int)
- func ManageExpiredSessionMaxAge(context *libcoap.Context, lifetimeInterval int)
- func RecheckIpRangeForMitigations(customer *models.Customer) error
- func TriggerMitigation(customer *models.Customer) error
- func UpdateMitigationStatus(customerId int, cuid string, mid int, mitigationScopeId int64, newStatus int, ...) error
- func ValidateAndCheckOverlap(customer *models.Customer, requestScope *models.MitigationScope, ...) (*models.ConflictInformation, error)
- type Controller
- func (c *Controller) HandleDelete(req Request, customer *models.Customer) (Response, error)
- func (c *Controller) HandleGet(req Request, customer *models.Customer) (Response, error)
- func (c *Controller) HandlePost(req Request, customer *models.Customer) (Response, error)
- func (c *Controller) HandlePut(req Request, customer *models.Customer) (Response, error)
- type ControllerInterface
- type Error
- type MitigationRequest
- func (m *MitigationRequest) HandleDelete(request Request, customer *models.Customer) (res Response, err error)
- func (m *MitigationRequest) HandleGet(request Request, customer *models.Customer) (res Response, err error)
- func (m *MitigationRequest) HandlePut(request Request, customer *models.Customer) (res Response, err error)
- type PrefixFilter
- func (p *PrefixFilter) HandleDelete(req Request, customer *models.Customer) (res Response, err error)
- func (p *PrefixFilter) HandleGet(req Request, customer *models.Customer) (res Response, err error)
- func (p *PrefixFilter) HandlePost(req Request, customer *models.Customer) (res Response, err error)
- func (p *PrefixFilter) HandlePut(req Request, customer *models.Customer) (res Response, err error)
- type Request
- type Response
- type ServiceMethod
- type SessionConfiguration
- func (m *SessionConfiguration) HandleDelete(newRequest Request, customer *models.Customer) (res Response, err error)
- func (m *SessionConfiguration) HandleGet(request Request, customer *models.Customer) (res Response, err error)
- func (m *SessionConfiguration) HandlePut(newRequest Request, customer *models.Customer) (res Response, err error)
- type SignalChannel
- func (p *SignalChannel) HandleDelete(req Request, customer *models.Customer) (res Response, err error)
- func (p *SignalChannel) HandleGet(req Request, customer *models.Customer) (res Response, err error)
- func (p *SignalChannel) HandlePost(req Request, customer *models.Customer) (res Response, err error)
- func (p *SignalChannel) HandlePut(req Request, customer *models.Customer) (res Response, err error)
- type TelemetryPreMitigationRequest
- func (t *TelemetryPreMitigationRequest) HandleDelete(request Request, customer *models.Customer) (res Response, err error)
- func (t *TelemetryPreMitigationRequest) HandleGet(request Request, customer *models.Customer) (res Response, err error)
- func (t *TelemetryPreMitigationRequest) HandlePut(request Request, customer *models.Customer) (res Response, err error)
- type TelemetrySetupRequest
- func (t *TelemetrySetupRequest) HandleDelete(request Request, customer *models.Customer) (res Response, err error)
- func (t *TelemetrySetupRequest) HandleGet(request Request, customer *models.Customer) (res Response, err error)
- func (t *TelemetrySetupRequest) HandlePut(request Request, customer *models.Customer) (res Response, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActivateDataChannelACL ¶
* Activate data channel acl with activationType = 'activate-when-mitigating'
func CheckConfictWithDataChannelAcceptList ¶
func CheckConfictWithDataChannelAcceptList(customer *models.Customer, cuid string, sourceAddressList []string) (bool, error)
* Check conflict with data channel acl accept list * return * true: if existed Acl contains action is accept and source prefix same with source prefix of call home * false: if Acl doesn't contain action is accept and source prefix same with source prefix of call home
func CreateMitigation ¶
func CreateMitigation(body *messages.MitigationRequest, customer *models.Customer, currentScope *models.MitigationScope, isIfMatchOption bool) (*models.ConflictInformation, error)
* Create or update a mitigation from client PUT request * Create mitigation: * Have no any mitigation in DB that match with request customerId, cuid and mid. * If request trigger-mitigation is true (active) -> activate mitigation else not activate * Update mitigation: * Have a mitigation in DB that match with request customerId, cuid and mid. * Compare value between request trigger-mitigation and current mitigation status to activate or deactivate the mitigation * parameter: * body the request body data * customer the customer * currentScope the current mitigation * isIfMatchOption the boolead of presenting if-match option * return: * conflictInformation the conflict information in case collision * error the error
func DeActivateDataChannelACL ¶
* DeActivate data channel acl
func DefaultSessionConfiguration ¶
func DefaultSessionConfiguration() (sessionConfig models.SignalSessionConfiguration)
* Set default configured values to session config and return
func DeleteMitigation ¶
* Delete mitigation out of DB after terminating process * parameter: * customerId the customer id * cuid the client identifier * mid the mitigation id * mitigationScopeId the mitigation scope id * return: * err the error
func GetOtherActiveMitigations ¶
func GetOtherActiveMitigations(currentMitigationScopeId *int64) (scopes []models.MitigationScope, err error)
* Get all active mitigations with appended alias data (if have) * return: * scopes: list of active mitigations scope * err: error
func GetSessionConfig ¶
func GetSessionConfig(customer *models.Customer) (*models.SignalSessionConfiguration, error)
* Get session config by customer
func ManageExpiredMitigation ¶
func ManageExpiredMitigation(lifetimeInterval int)
func ManageExpiredSessionMaxAge ¶
* Reset to default values for session configuration that are expired * Params: * lifetimeInterval the interval time for checking session configuration
func RecheckIpRangeForMitigations ¶
* Re-check ip-address range for mitigation requests by customer id * parameter: * customerId the id of updated customer * return: * err error
func TriggerMitigation ¶
* Trigger mitigation mechanism: activate all pre-configured mitigations (status = 8: triggered) when session lost * parameter: * customer current requesting client
func UpdateMitigationStatus ¶
func UpdateMitigationStatus(customerId int, cuid string, mid int, mitigationScopeId int64, newStatus int, isCheckActiveProtection bool) error
* Update mitigation status (active -> inactive: Cancel protection, inactive -> active: call Blocker) * Active status: 1: InProgress, 2: SuccessfullyMitigated, 3: Stopped, 4: ActiveButTerminating * Inactive status: 6: Terminated, 7: Withdrawn, 8: Triggered * parameter: * customerId the customer id * cuid the client identifier * mid the mitigation id * mitigationScopeId the mitigation scope id * newStatus the mitigation status to update * isCheckActiveProtection the isCheckActiveProtection * return: * error the error
func ValidateAndCheckOverlap ¶
func ValidateAndCheckOverlap(customer *models.Customer, requestScope *models.MitigationScope, currentScope *models.MitigationScope, aliases types.Aliases, blockerType string) (*models.ConflictInformation, error)
* Validate request mitigation scope and check overlap for it with other active mitigations * parameter: * customer current requesting client * requestScope request mitigation scope * currentScope current mitigation scope that has the same ids (customer-id, cuid, mid) with request mitigation * aliases list of alias scope data received from data channel * return: * bool result of validating and checking process * ConflictInformation conflict information when overlap occur * err error
Types ¶
type Controller ¶
type Controller struct { }
* Controller super class.
func (*Controller) HandleDelete ¶
* Handles CoAP Delete requests.
func (*Controller) HandlePost ¶
* Handles CoAP Post requests.
type ControllerInterface ¶
type ControllerInterface interface { // Service methods HandleGet(Request, *models.Customer) (Response, error) HandlePost(Request, *models.Customer) (Response, error) HandleDelete(Request, *models.Customer) (Response, error) HandlePut(Request, *models.Customer) (Response, error) }
* Controller API interface. * It provides function interfaces correspondent to CoAP methods.
func NewPrefixFilter ¶
func NewPrefixFilter(path string, controller ControllerInterface) ControllerInterface
type Error ¶
type Error struct { Code dots_common.Code Type dots_common.Type Body interface{} }
* Error API response
type MitigationRequest ¶
type MitigationRequest struct {
Controller
}
* Controller for the mitigationRequest API.
func (*MitigationRequest) HandleDelete ¶
func (m *MitigationRequest) HandleDelete(request Request, customer *models.Customer) (res Response, err error)
* Handles createIdentifiers DELETE requests. * It terminates all the mitigations invoked by a customer.
func (*MitigationRequest) HandleGet ¶
func (m *MitigationRequest) HandleGet(request Request, customer *models.Customer) (res Response, err error)
* Handles mitigationRequest GET requests.
func (*MitigationRequest) HandlePut ¶
func (m *MitigationRequest) HandlePut(request Request, customer *models.Customer) (res Response, err error)
* Handles mitigationRequest PUT requests and start the mitigation. * 1. receive a blocker object from the blockerservice * 2. register a mitigation scope to the blocker and receive the protection object generated from the scope. * 3. invoke the mitigation process by passsing the protection object to the same blocker object. * * parameter: * request request message * customer request source Customer * return: * res response message * err error
type PrefixFilter ¶
type PrefixFilter struct { Controller // contains filtered or unexported fields }
func (*PrefixFilter) HandleDelete ¶
func (*PrefixFilter) HandlePost ¶
type Request ¶
type Request struct { Code libcoap.Code Type libcoap.Type Uri []string // Full request URI PathInfo []string // URI-Paths after with prefix Queries []string // Uri-Queries Body interface{} Options []libcoap.Option }
* Regular API request
type Response ¶
type Response struct { Code dots_common.Code Type dots_common.Type // not used Options []libcoap.Option Body interface{} }
* Regular API response
func HandleControlFiltering ¶
func HandleControlFiltering(customer *models.Customer, cuid string, mid *int, aclList []messages.ACL) (*Response, error)
* Handle Signal Channel Control Filtering * parameter: * customer the client * cuid the id of the client * aclList list of acl that need to be updated * return: * res the response * err error
type ServiceMethod ¶
type SessionConfiguration ¶
type SessionConfiguration struct {
Controller
}
* Controller for the session_configuration API.
func (*SessionConfiguration) HandleDelete ¶
func (*SessionConfiguration) HandlePut ¶
func (m *SessionConfiguration) HandlePut(newRequest Request, customer *models.Customer) (res Response, err error)
* Handles session_configuration PUT requests and start the mitigation. * 1. Validate the received session configuration requests. * 2. return the validation results. * * parameter: * request request message * customer request source Customer * return: * res response message * err error
type SignalChannel ¶
type SignalChannel struct {
Controller
}
* Parent controller for the mitigationRequest and sessionConfiguration APIs
func (*SignalChannel) HandleDelete ¶
func (p *SignalChannel) HandleDelete(req Request, customer *models.Customer) (res Response, err error)
* Handles mitigationRequest, sessionConfiguration DELETE requests.
func (*SignalChannel) HandlePost ¶
func (p *SignalChannel) HandlePost(req Request, customer *models.Customer) (res Response, err error)
* Handles mitigationRequest, sessionConfiguration POST requests.
type TelemetryPreMitigationRequest ¶
type TelemetryPreMitigationRequest struct {
Controller
}
* Controller for the telemetryPreMitigationRequest API.
func (*TelemetryPreMitigationRequest) HandleDelete ¶
func (t *TelemetryPreMitigationRequest) HandleDelete(request Request, customer *models.Customer) (res Response, err error)
* Handles telemetry pre-mitigation DELETE request * 1. The Delete all telemetry pre-mitigation when the uri-path doesn't contain 'tmid' * 2. The Delete one telemetry pre-mitigation when the uri-path contains 'tmid' * * parameter: * request request message * customer request source Customer * return: * res response message * err error *
func (*TelemetryPreMitigationRequest) HandleGet ¶
func (t *TelemetryPreMitigationRequest) HandleGet(request Request, customer *models.Customer) (res Response, err error)
* Handles telemetry pre-mitigation GET request * 1. The Get all telemetry pre-mitigation when the uri-path doesn't contain 'tmid' * 2. The Get one telemetry pre-mitigation when the uri-path contains 'tmid' * * parameter: * request request message * customer request source Customer * return: * res response message * err error *
func (*TelemetryPreMitigationRequest) HandlePut ¶
func (t *TelemetryPreMitigationRequest) HandlePut(request Request, customer *models.Customer) (res Response, err error)
* Handles telemetry pre-mitigation PUT request * 1. The PUT create telemetry pre-mitigation * 2. The PUT update telemetry pre-mitigation * * parameter: * request request message * customer request source Customer * return: * res response message * err error
type TelemetrySetupRequest ¶
type TelemetrySetupRequest struct {
Controller
}
* Controller for the telemetryRequest API.
func (*TelemetrySetupRequest) HandleDelete ¶
func (t *TelemetrySetupRequest) HandleDelete(request Request, customer *models.Customer) (res Response, err error)
* Handles telemetry DELETE request * 1. The Delete all telemetry setup configuration when the uri-path doesn't contain 'tsid' * 2. The Delete one telemetry setup configuration when the uri-path contains 'tsid' * * parameter: * request request message * customer request source Customer * return: * res response message * err error *
func (*TelemetrySetupRequest) HandleGet ¶
func (t *TelemetrySetupRequest) HandleGet(request Request, customer *models.Customer) (res Response, err error)
* Handles telemetry GET request * 1. The Get all telemetry setup configuration when the uri-path doesn't contain 'tsid' * 2. The Get one telemetry setup configuration when the uri-path contains 'tsid' * * parameter: * request request message * customer request source Customer * return: * res response message * err error *
func (*TelemetrySetupRequest) HandlePut ¶
func (t *TelemetrySetupRequest) HandlePut(request Request, customer *models.Customer) (res Response, err error)
* Handles telemetry PUT request * 1. The PUT telemetry_configuration * 2. The PUT total_pipe_capacity * 3. The PUT basline * * parameter: * request request message * customer request source Customer * return: * res response message * err error