protocol

package
v0.0.0-...-73d3301 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2016 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package protocol describes the REST protocol

Package protocol describes the REST protocol

Package protocol describes the REST protocol

Package protocol describes the REST protocol

Package protocol describes the REST protocol

Package protocol describes the REST protocol

Package protocol describes the REST protocol

Package protocol describes the REST protocol

Package protocol describes the REST protocol

Package protocol describes the REST protocol

Package protocol describes the REST protocol

Index

Constants

View Source
const (
	DefaultDigestType = model.DSDigestTypeSHA256
)

When converting a DNSKEY into a DS we need to choose wich digest type are we going to use, as we don't want to bother the user asking this information we assume a default digest type

Variables

View Source
var (
	// Error returned when trying to convert a DS with an unknown DS algorithm number
	ErrInvalidDSAlgorithm = errors.New("DS algorithm invalid or not supported")
	// Error returned when trying to convert a DS with an unknown DS dogest type number
	ErrInvalidDSDigestType = errors.New("DS digest type invalid or not supported")
)

List of possible errors that can occur when calling methods from this object

View Source
var (
	// Error returned when trying to merge to domain objects with different FQDNs
	ErrDomainsFQDNDontMatch = errors.New("Cannot merge domains with different FQDNs")
)

List of possible errors that can occur when calling methods from this object. Other erros can also occurs from low level layers

View Source
var (
	// Error returned when trying to convert a DNSKEY into a DS
	ErrInvalidDNSKEY = errors.New("DNSKEY data is invalid to generate DS")
)

List of possible errors that can occur when calling methods from this object

View Source
var (
	// Error returned when trying to convert an invalid IP address
	ErrInvalidIP = errors.New("IP address is not in a valid format")
)

List of possible errors that can occur when calling methods from this object. Other erros can also occurs from low level layers

View Source
var (
	// Error when an invalid language is given. List of possible values can be found in IANA
	// website
	ErrInvalidLanguage = errors.New("Invalid owner language")
)

List of possible errors that can occur when calling methods from this object. Other erros can also occurs from low level layers

View Source
var (
	// When the JSON time doesn't have quotes or doesn't have a valid sequence of characters
	// this error will be throw
	ErrPreciseTimeFormat = errors.New("JSON time has an invalid format")
)

Functions

func Merge

func Merge(domain model.Domain, domainRequest DomainRequest) (model.Domain, error)

Merge is used to merge a domain request object sent by the user into a domain object of the database. It can return errors related to merge problems that are problem caused by data format of the user input

Types

type DNSKEYRequest

type DNSKEYRequest struct {
	Flags     uint16 `json:"flags,omitempty"`     // RFC 4034 - 2.1.1 (SEP, ZONE, ...)
	Algorithm uint8  `json:"algorithm,omitempty"` // RFC 4034 - Appendix A.1
	PublicKey string `json:"publicKey,omitempty"` // Base64 enconded string of the public key
}

DNSKEY object from the protocol used to simplify the user lifes. The system will convert automatically DNSKEY objects into DS objects

type DSRequest

type DSRequest struct {
	Keytag     uint16 `json:"keytag,omitempty"`     // DNSKEY's identification number
	Algorithm  uint8  `json:"algorithm,omitempty"`  // DNSKEY's algorithm
	Digest     string `json:"digest,omitempty"`     // Hash of the DNSKEY content
	DigestType uint8  `json:"digestType,omitempty"` // Hash type decided by user when generating the DS
}

DS object used in the protocol to determinate what the user can update

type DSResponse

type DSResponse struct {
	Keytag      uint16    `json:"keytag,omitempty"`      // DNSKEY's identification number
	Algorithm   uint8     `json:"algorithm,omitempty"`   // DNSKEY's algorithm
	Digest      string    `json:"digest,omitempty"`      // Hash of the DNSKEY content
	DigestType  uint8     `json:"digestType,omitempty"`  // Hash type decided by user when generating the DS
	ExpiresAt   time.Time `json:"expiresAt,omitempty"`   // DNSKEY's signature expiration date
	LastStatus  string    `json:"lastStatus,omitempty"`  // Result of the last configuration check
	LastCheckAt time.Time `json:"lastCheckAt,omitempty"` // Time of the last configuration check
	LastOKAt    time.Time `json:"lastOKAt,omitempty"`    // Last time that the DNSSEC configuration was OK
}

DS object used in the protocol to determinate what the user can see. The status was converted to text format for easy interpretation

type DomainRequest

type DomainRequest struct {
	FQDN        string              `json:"-"`                     // Actual domain name
	Nameservers []NameserverRequest `json:"nameservers,omitempty"` // Nameservers that asnwer with authority for this domain
	DSSet       []DSRequest         `json:"dsset,omitempty"`       // Records for the DNS tree chain of trust
	DNSKEYS     []DNSKEYRequest     `json:"dnskeys,omitempty"`     // Records that can be converted into DS records
	Owners      []OwnerRequest      `json:"owners,omitempty"`      // E-mails that will be alerted on any problem
}

Domain object from the protocol used to determinate what the user can update

type DomainResponse

type DomainResponse struct {
	FQDN        string               `json:"fqdn"`                  // Actual domain name
	Nameservers []NameserverResponse `json:"nameservers,omitempty"` // Nameservers that asnwer with authority for this domain
	DSSet       []DSResponse         `json:"dsset,omitempty"`       // Records for the DNS tree chain of trust
	Owners      []OwnerResponse      `json:"owners,omitempty"`      // E-mails that will be alerted on any problem
	Links       []Link               `json:"links,omitempty"`       // Links to manipulate object
}

Domain object from the protocol used to determinate what the user can see. The last modified field is not here because it is sent in HTTP header field as it is with revision (ETag)

func ToDomainResponse

func ToDomainResponse(domain model.Domain, persisted bool) DomainResponse

Convert the domain system object to a limited information user format. We have a persisted flag to known when the object exists in our database or not to choose when we need to add the object links or not

type DomainsResponse

type DomainsResponse struct {
	Page          int              `json:"page"`              // Current page selected
	PageSize      int              `json:"pageSize"`          // Number of domains in a page
	NumberOfPages int              `json:"numberOfPages"`     // Total number of pages for the result set
	NumberOfItems int              `json:"numberOfItems"`     // Total number of domains in the result set
	Domains       []DomainResponse `json:"domains,omitempty"` // List of domain objects for the current page
	Links         []Link           `json:"links,omitempty"`   // Links for pagination managment
}

DomainsResponse store multiple domains objects with pagination support

func ToDomainsResponse

func ToDomainsResponse(
	domains []model.Domain,
	pagination dao.DomainDAOPagination,
	expand bool,
	filter string,
) DomainsResponse

Convert a list of domain objects into protocol format with pagination support

type Link struct {
	Types []LinkType `json:"types,omitempty"` // List of link types that can be applied for the same URI
	HRef  string     `json:"href,omitempty"`  // URI for the link
}

Link structure was created to relate resources in the system. A link can have multiple types according to W3C in http://www.w3.org/TR/html401/struct/links.html

type LinkType

type LinkType string

LinkType is a string that represents the type of the link used in the protocol

const (
	LinkTypeAbout              LinkType = "about"
	LinkTypeAlternate          LinkType = "alternate"
	LinkTypeAppendix           LinkType = "appendix"
	LinkTypeArchives           LinkType = "archives"
	LinkTypeAuthor             LinkType = "author"
	LinkTypeBookmark           LinkType = "bookmark"
	LinkTypeCanonical          LinkType = "canonical"
	LinkTypeChapter            LinkType = "chapter"
	LinkTypeCollection         LinkType = "collection"
	LinkTypeContents           LinkType = "contents"
	LinkTypeCopyright          LinkType = "copyright"
	LinkTypeCreateForm         LinkType = "create-form"
	LinkTypeCurrent            LinkType = "current"
	LinkTypeDescribedby        LinkType = "describedby"
	LinkTypeDescribes          LinkType = "describes"
	LinkTypeDisclosure         LinkType = "disclosure"
	LinkTypeDuplicate          LinkType = "duplicate"
	LinkTypeEdit               LinkType = "edit"
	LinkTypeEditForm           LinkType = "edit-form"
	LinkTypeEditMedia          LinkType = "edit-media"
	LinkTypeEnclosure          LinkType = "enclosure"
	LinkTypeFirst              LinkType = "first"
	LinkTypeGlossary           LinkType = "glossary"
	LinkTypeHelp               LinkType = "help"
	LinkTypeHosts              LinkType = "hosts"
	LinkTypeHub                LinkType = "hub"
	LinkTypeIcon               LinkType = "icon"
	LinkTypeIndex              LinkType = "index"
	LinkTypeItem               LinkType = "item"
	LinkTypeLast               LinkType = "last"
	LinkTypeLatestVersion      LinkType = "latest-version"
	LinkTypeLicense            LinkType = "license"
	LinkTypeLrdd               LinkType = "lrdd"
	LinkTypeMemento            LinkType = "memento"
	LinkTypeMonitor            LinkType = "monitor"
	LinkTypeMonitorGroup       LinkType = "monitor-group"
	LinkTypeNext               LinkType = "next"
	LinkTypeNextArchive        LinkType = "next-archive"
	LinkTypeNofollow           LinkType = "nofollow"
	LinkTypeNoreferrer         LinkType = "noreferrer"
	LinkTypeOriginal           LinkType = "original"
	LinkTypePayment            LinkType = "payment"
	LinkTypePredecessorVersion LinkType = "predecessor-version"
	LinkTypePrefetch           LinkType = "prefetch"
	LinkTypePrev               LinkType = "prev"
	LinkTypePreview            LinkType = "preview"
	LinkTypePrevious           LinkType = "previous"
	LinkTypePrevArchive        LinkType = "prev-archive"
	LinkTypePrivacyPolicy      LinkType = "privacy-policy"
	LinkTypeProfile            LinkType = "profile"
	LinkTypeRelated            LinkType = "related"
	LinkTypeReplies            LinkType = "replies"
	LinkTypeSearch             LinkType = "search"
	LinkTypeSection            LinkType = "section"
	LinkTypeSelf               LinkType = "self"
	LinkTypeService            LinkType = "service"
	LinkTypeStart              LinkType = "start"
	LinkTypeStylesheet         LinkType = "stylesheet"
	LinkTypeSubsection         LinkType = "subsection"
	LinkTypeSuccessorVersion   LinkType = "successor-version"
	LinkTypeTag                LinkType = "tag"
	LinkTypeTermsOfService     LinkType = "terms-of-service"
	LinkTypeTimegate           LinkType = "timegate"
	LinkTypeTimemap            LinkType = "timemap"
	LinkTypeType               LinkType = "type"
	LinkTypeUp                 LinkType = "up"
	LinkTypeVersionHistory     LinkType = "version-history"
	LinkTypeVia                LinkType = "via"
	LinkTypeWorkingCopy        LinkType = "working-copy"
	LinkTypeWorkingCopyOf      LinkType = "working-copy-of"
)

List of link type obtained from IANA at http://www.iana.org/assignments/link-relations/link-relations.xml For specific details from each link type visit the IANA website and check the RFC related to the link type

type MessageResponse

type MessageResponse struct {
	Id      string `json:"id,omitempty"`      // Code for integration systems to automatically solve the problem
	Message string `json:"message,omitempty"` // Message in the user's desired language
	Links   []Link `json:"links,omitempty"`   // Links associating this message with other resources
}

MessageResponse struct was created to return a message to the user with more information to easy integrate and solve problems

func NewMessageResponse

func NewMessageResponse(
	id string, roid string,
	language *messages.LanguagePack,
) (*MessageResponse, error)

type NameserverRequest

type NameserverRequest struct {
	Host string `json:"host,omitempty"` // Nameserver's name
	IPv4 string `json:"ipv4,omitempty"` // Host's IPv4 (optional when don't need glue)
	IPv6 string `json:"ipv6,omitempty"` // Host's IPv6 (optional)
}

Nameserver object used in the protocol to determinate what the user can update

type NameserverResponse

type NameserverResponse struct {
	Host        string    `json:"host,omitempty"`        // Nameserver's name
	IPv4        string    `json:"ipv4,omitempty"`        // Host's IPv4 (optional when don't need glue)
	IPv6        string    `json:"ipv6,omitempty"`        // Host's IPv6 (optional)
	LastStatus  string    `json:"lastStatus,omitempty"`  // Result of the last configuration check
	LastCheckAt time.Time `json:"lastCheckAt,omitempty"` // Time of the last configuration check
	LastOKAt    time.Time `json:"lastOKAt,omitempty"`    // Last time that the DNS configuration was OK
}

Namerserver object used in the protocol to determinate what the user can see. The status was converted to text format for easy interpretation

type OwnerRequest

type OwnerRequest struct {
	Email    string `json:"email,omitempty"`    // E-mail that the owner wants to be alerted
	Language string `json:"language,omitempty"` // Language that the owner wants to receive the messages
}

Owner object used in the protocol to determinate what the user can update, for this case, everything

type OwnerResponse

type OwnerResponse struct {
	Email    string `json:"email,omitempty"`    // E-mail that the owner wants to be alerted
	Language string `json:"language,omitempty"` // Language that the owner wants to receive the messages
}

Owner object used in the protocol to determinate what the user can see

type PreciseTime

type PreciseTime struct {
	time.Time
}

PreciseTime structure created to add milliseconds to the string representation of the dates on the system when exposing to the user via JSON protocol

func (*PreciseTime) MarshalJSON

func (p *PreciseTime) MarshalJSON() ([]byte, error)

Implementing encoding/json interface to transform a time into string representation

func (*PreciseTime) UnmarshalJSON

func (p *PreciseTime) UnmarshalJSON(data []byte) error

Implementing encoding/json interface to transform a string into a time object

type ScanResponse

type ScanResponse struct {
	Status                   string            `json:"status"`                             // Current scan situation
	ScheduledAt              PreciseTime       `json:"scheduledAt,omitempty"`              // Scheduled date and time that the scan will be executed
	StartedAt                PreciseTime       `json:"startedAt,omitempty"`                // Start date and time of the scan, is also used to identify the scan
	FinishedAt               PreciseTime       `json:"finishedAt,omitempty"`               // Finish date and time of the scan
	DomainsToBeScanned       uint64            `json:"domainsToBeScanned,omitempty"`       // Number of domains to verify (scan is executing)
	DomainsScanned           uint64            `json:"domainsScanned,omitempty"`           // Number of domains already verified
	DomainsWithDNSSECScanned uint64            `json:"domainsWithDNSSECScanned,omitempty"` // Number of domains with DNSSEC already verified
	NameserverStatistics     map[string]uint64 `json:"nameserverStatistics,omitempty"`     // Domains' nameservers statistics (status and quantity)
	DSStatistics             map[string]uint64 `json:"dsStatistics,omitempty"`             // Domains' DS records statistics (status and quantity)
	Links                    []Link            `json:"links,omitempty"`                    // Links to move around the scans
}

ScanResponse structure represents the system Scan object to be returned via protocol. With this object the user can retrieve information about executed scans or current progress of a specific scan

func CurrentScanToScanResponse

func CurrentScanToScanResponse(currentScan model.CurrentScan) ScanResponse

Convert a current scan object data being executed of the system into a format easy to interpret by the user

func ScanToScanResponse

func ScanToScanResponse(scan model.Scan) ScanResponse

Convert a scan object data of the system into a format easy to interpret by the user

type ScansResponse

type ScansResponse struct {
	Page          int            `json:"page"`            // Current page selected
	PageSize      int            `json:"pageSize"`        // Number of scans in a page
	NumberOfPages int            `json:"numberOfPages"`   // Total number of pages for the result set
	NumberOfItems int            `json:"numberOfItems"`   // Total number of scans in the result set
	Scans         []ScanResponse `json:"scans,omitempty"` // List of scan objects for the current page
	Links         []Link         `json:"links,omitempty"` // Links for pagination managment
}

ScansResponse store multiple scans objects with pagination support

func CurrentScanToScansResponse

func CurrentScanToScansResponse(currentScan model.CurrentScan,
	pagination dao.ScanDAOPagination) ScansResponse

Convert a current scan object data being executed of the system into a format easy to interpret by the user

func ScansToScansResponse

func ScansToScansResponse(scans []model.Scan, pagination dao.ScanDAOPagination) ScansResponse

Convert a list of scan objects into protocol format with pagination support

Jump to

Keyboard shortcuts

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