happydns

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2025 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOG_CRIT = iota
	LOG_FATAL
	LOG_ERR2
	LOG_ERR
	LOG_STRONG_WARN
	LOG_WARN
	LOG_WEIRD
	LOG_NACK
	LOG_INFO
	LOG_ACK
	LOG_DEBUG
)
View Source
const (
	SERVICE_FAMILY_ABSTRACT = "abstract"
	SERVICE_FAMILY_HIDDEN   = "hidden"
	SERVICE_FAMILY_PROVIDER = "provider"
)
View Source
const (
	FIELDHINT_HIDE = iota
	FIELDHINT_TOOLTIP
	FIELDHINT_FOCUSED
	FIELDHINT_ALWAYS
)
View Source
const (
	ZONEVIEW_GRID = iota
	ZONEVIEW_LIST
	ZONEVIEW_RECORDS
)
View Source
const IDENTIFIER_LEN = 16
View Source
const TXT_SEGMENT_LEN = 255
View Source
const TryAgainErr = "Sorry, we are currently unable to sent email validation link. Please try again later."

Variables

View Source
var (
	ErrAuthUserNotFound  = errors.New("user not found")
	ErrDomainNotFound    = errors.New("domain not found")
	ErrDomainLogNotFound = errors.New("domain log not found")
	ErrProviderNotFound  = errors.New("provider not found")
	ErrSessionNotFound   = errors.New("session not found")
	ErrUserNotFound      = errors.New("user not found")
	ErrUserAlreadyExist  = errors.New("user already exists")
	ErrZoneNotFound      = errors.New("zone not found")
)
View Source
var (
	// DoneForm is the error raised when there is no more step to display, and edition is OK.
	DoneForm = errors.New("Done")

	// CancelForm is the error raised when there is no more step to display and should redirect to the previous page.
	CancelForm = errors.New("Cancel")
)

Functions

func ApiResponse added in v0.4.0

func ApiResponse(c *gin.Context, data interface{}, err error)

Types

type AccountRecoveryForm added in v0.4.1

type AccountRecoveryForm struct {
	// Key is the secret sent by email to the user.
	Key string

	// Password is the new password to use with this account.
	Password string
}

type AddressValidationForm added in v0.4.0

type AddressValidationForm struct {
	// Key able to validate the email address.
	Key string
}

type ApplyZoneForm added in v0.4.0

type ApplyZoneForm struct {
	WantedCorrections []Identifier `json:"wantedCorrections"`
	CommitMsg         string       `json:"commitMessage"`
}

type AuthUserUsecase added in v0.4.0

type AuthUserUsecase interface {
	CanRegister(UserRegistration) error
	CheckPassword(*UserAuth, ChangePasswordForm) error
	ChangePassword(*UserAuth, string) error
	CreateAuthUser(UserRegistration) (*UserAuth, error)
	DeleteAuthUser(*UserAuth, string) error
	GenerateRecoveryLink(*UserAuth) (string, error)
	GenerateValidationLink(*UserAuth) string
	GetAuthUser(Identifier) (*UserAuth, error)
	GetAuthUserByEmail(string) (*UserAuth, error)
	ResetPassword(*UserAuth, AccountRecoveryForm) error
	SendRecoveryLink(*UserAuth) error
	SendValidationLink(*UserAuth) error
	ValidateEmail(*UserAuth, AddressValidationForm) error
}

type AuthenticationUsecase added in v0.4.0

type AuthenticationUsecase interface {
	AuthenticateUserWithPassword(request LoginRequest) (*User, error)
	CompleteAuthentication(uinfo UserInfo) (*User, error)
}

type Backup added in v0.4.0

type Backup struct {
	Version     int
	Domains     []*Domain
	DomainsLogs map[string][]*DomainLog
	Errors      []string
	Providers   []*ProviderMessage
	Sessions    []*Session
	Users       []*User
	UsersAuth   UserAuths
	Zones       []*ZoneMessage
}

type ChangePasswordForm added in v0.4.0

type ChangePasswordForm struct {
	Current         string
	Password        string
	PasswordConfirm string
}

type Correction added in v0.4.0

type Correction struct {
	F    func() error   `json:"-"`
	Id   Identifier     `json:"id,omitempty"`
	Msg  string         `json:"msg"`
	Kind CorrectionKind `json:"kind,omitempty"`
}

type CorrectionKind added in v0.4.0

type CorrectionKind uint8
const (
	CorrectionKindAddition CorrectionKind
	CorrectionKindUpdate
	CorrectionKindDeletion
	CorrectionKindOther = 99
)

type CustomError added in v0.4.1

type CustomError struct {
	Err      error
	UserLink string
	Status   int
}

func (CustomError) Error added in v0.4.1

func (err CustomError) Error() string

func (CustomError) HTTPStatus added in v0.4.1

func (err CustomError) HTTPStatus() int

func (CustomError) ToErrorResponse added in v0.4.1

func (err CustomError) ToErrorResponse() ErrorResponse

type CustomForm added in v0.4.0

type CustomForm struct {
	// BeforeText is the text presented before the fields.
	BeforeText string `json:"beforeText,omitempty"`

	// SideText is displayed in the sidebar, after any already existing text. When a sidebar is avaiable.
	SideText string `json:"sideText,omitempty"`

	// AfterText is the text presented after the fields and before the buttons
	AfterText string `json:"afterText,omitempty"`

	// Fields are the fields presented to the User.
	Fields []*Field `json:"fields"`

	// NextButtonText is the next button content.
	NextButtonText string `json:"nextButtonText,omitempty"`

	// NextEditButtonText is the next button content when updating the settings (if not set, NextButtonText is used instead).
	NextEditButtonText string `json:"nextEditButtonText,omitempty"`

	// PreviousButtonText is previous/cancel button content.
	PreviousButtonText string `json:"previousButtonText,omitempty"`

	// PreviousEditButtonText is the previous/cancel button content when updating the settings (if not set, NextButtonText is used instead).
	PreviousEditButtonText string `json:"previousEditButtonText,omitempty"`

	// NextButtonLink is the target of the next button, exclusive with NextButtonState.
	NextButtonLink string `json:"nextButtonLink,omitempty"`

	// NextButtonState is the step number asked when submiting the form.
	NextButtonState int32 `json:"nextButtonState,omitempty"`

	// PreviousButtonState is the step number to go when hitting the previous button.
	PreviousButtonState int32 `json:"previousButtonState,omitempty"`
}

CustomForm is used to create a form with several steps when creating or updating provider's settings.

type CustomSettingsForm added in v0.4.0

type CustomSettingsForm interface {
	// DisplaySettingsForm generates the CustomForm corresponding to the asked target state.
	DisplaySettingsForm(int32, GenRecallID, FormUsecase) (*CustomForm, map[string]interface{}, error)
}

CustomSettingsForm are functions to declare when we want to display a custom user experience when asking for Source's settings.

type DNSMsg added in v0.4.0

type DNSMsg struct {
	// Question is the Question section of the DNS response.
	Question []DNSQuestion

	// Answer is the list of Answer records in the DNS response.
	Answer []interface{} `swaggertype:"object"`

	// Ns is the list of Authoritative records in the DNS response.
	Ns []interface{} `swaggertype:"object"`

	// Extra is the list of extra records in the DNS response.
	Extra []interface{} `swaggertype:"object"`
}

DNSMsg is the documentation struct corresponding to dns.Msg

type DNSQuestion added in v0.4.0

type DNSQuestion struct {
	// Name is the domain name researched.
	Name string

	// Qtype is the type of record researched.
	Qtype uint16

	// Qclass is the class of record researched.
	Qclass uint16
}

type Domain

type Domain struct {
	// Id is the Domain's identifier in the database.
	Id Identifier `json:"id" swaggertype:"string"`

	// Owner is the identifier of the Domain's Owner.
	Owner Identifier `json:"id_owner" swaggertype:"string"`

	// ProviderId is the identifier of the Provider used to access and edit the
	// Domain.
	ProviderId Identifier `json:"id_provider" swaggertype:"string"`

	// DomainName is the FQDN of the managed Domain.
	DomainName string `json:"domain"`

	// Group is a hint string aims to group domains.
	Group string `json:"group,omitempty"`

	// ZoneHistory are the identifiers to the Zone attached to the current
	// Domain.
	ZoneHistory []Identifier `json:"zone_history" swaggertype:"array,string"`
}

Domain holds information about a domain name own by a User.

func NewDomain

func NewDomain(user *User, name string, providerID Identifier) (*Domain, error)

func (*Domain) HasZone

func (d *Domain) HasZone(zoneId Identifier) (found bool)

HasZone checks if the given Zone's identifier is part of this Domain history.

type DomainCreationInput added in v0.4.1

type DomainCreationInput struct {
	// ProviderId is the identifier of the Provider used to access and edit the
	// Domain.
	ProviderId Identifier `json:"id_provider" swaggertype:"string"`

	// DomainName is the FQDN of the managed Domain.
	DomainName string `json:"domain"`
}

DomainCreationInput is used for swagger documentation as Domain add.

type DomainLog

type DomainLog struct {
	// Id is the Log's identifier in the database.
	Id Identifier `json:"id" swaggertype:"string"`

	// IdUser is the identifier of the person responsible for the action.
	IdUser Identifier `json:"id_user" swaggertype:"string"`

	// Date is the date of the action.
	Date time.Time `json:"date"`

	// Content is the description of the action logged.
	Content string `json:"content"`

	// Level reports the criticity level of the action logged.
	Level int8 `json:"level"`
}

func NewDomainLog

func NewDomainLog(u *User, level int8, content string) *DomainLog

type DomainLogUsecase added in v0.4.0

type DomainLogUsecase interface {
	AppendDomainLog(*Domain, *DomainLog) error
	ListDomainLogs(*Domain) ([]*DomainLog, error)
}

type DomainLogWithDomainId added in v0.4.1

type DomainLogWithDomainId struct {
	DomainLog
	DomainId Identifier
}

type DomainUsecase added in v0.4.0

type DomainUsecase interface {
	CreateDomain(*User, *Domain) error
	DeleteDomain(Identifier) error
	ExtendsDomainWithZoneMeta(*Domain) (*DomainWithZoneMetadata, error)
	GetUserDomain(*User, Identifier) (*Domain, error)
	GetUserDomainByFQDN(*User, string) ([]*Domain, error)
	ListUserDomains(*User) ([]*Domain, error)
	UpdateDomain(Identifier, *User, func(*Domain)) error
}

type DomainWithZoneMetadata added in v0.4.0

type DomainWithZoneMetadata struct {
	*Domain
	ZoneMeta map[string]*ZoneMeta `json:"zone_meta"`
}

type EmailValidationUsecase added in v0.4.1

type EmailValidationUsecase interface {
	GenerateLink(user *UserAuth) string
	SendLink(user *UserAuth) error
	Validate(user *UserAuth, form AddressValidationForm) error
}

type ErrorResponse added in v0.4.0

type ErrorResponse struct {
	// Message describe the error to display to the user.
	Message string `json:"errmsg"`

	// Link is a link that can help the user to fix the error.
	Link string `json:"href,omitempty"`
}

type Field added in v0.4.0

type Field struct {
	// Id is the field identifier.
	Id string `json:"id"`

	// Type is the string representation of the field's type.
	Type string `json:"type"`

	// Label is the title given to the field, displayed as <label> tag on the interface.
	Label string `json:"label,omitempty"`

	// Placeholder is the placeholder attribute of the corresponding <input> tag.
	Placeholder string `json:"placeholder,omitempty"`

	// Default is the preselected value or the default value in case the field is not filled by the user.
	Default interface{} `json:"default,omitempty"`

	// Choices holds the differents choices shown to the user in <select> tag.
	Choices []string `json:"choices,omitempty"`

	// Required indicates whether the field has to be filled or not.
	Required bool `json:"required,omitempty"`

	// Secret indicates if the field contains sensitive information such as API key, in order to hide
	// the field when not needed. When typing, it doesn't hide characters like in password input.
	Secret bool `json:"secret,omitempty"`

	// Hide indicates if the field should be hidden to the user.
	Hide bool `json:"hide,omitempty"`

	// Textarea indicates that a large field is expected.
	Textarea bool `json:"textarea,omitempty"`

	// Description stores an helpfull sentence describing the field.
	Description string `json:"description,omitempty"`
}

Field

type ForbiddenError added in v0.4.1

type ForbiddenError struct {
	Msg string
}

func (ForbiddenError) Error added in v0.4.1

func (err ForbiddenError) Error() string

func (ForbiddenError) HTTPStatus added in v0.4.1

func (err ForbiddenError) HTTPStatus() int

func (ForbiddenError) ToErrorResponse added in v0.4.1

func (err ForbiddenError) ToErrorResponse() ErrorResponse

type FormState added in v0.4.0

type FormState struct {
	// Id for an already existing element.
	Id *Identifier `json:"_id,omitempty" swaggertype:"string"`

	// User defined name of the element.
	Name string `json:"_comment"`

	// State is the desired form to shows next (starting at 0).
	State int32 `json:"state"`

	// Recall is the identifier for a saved FormState you want to retrieve.
	Recall string `json:"recall,omitempty"`
}

type FormUsecase added in v0.4.0

type FormUsecase interface {
	GetBaseURL() string
}

type GenRecallID added in v0.4.0

type GenRecallID func() string

GenRecallID

type HTTPError added in v0.4.1

type HTTPError interface {
	ToErrorResponse() ErrorResponse
	HTTPStatus() int
}

type HexaString

type HexaString []byte

func (*HexaString) MarshalJSON

func (hs *HexaString) MarshalJSON() (dst []byte, err error)

func (*HexaString) UnmarshalJSON

func (hs *HexaString) UnmarshalJSON(b []byte) (err error)

type Identifier

type Identifier []byte

func NewIdentifierFromString

func NewIdentifierFromString(src string) (id Identifier, err error)

func NewRandomIdentifier

func NewRandomIdentifier() (id Identifier, err error)

func (Identifier) Equals

func (i Identifier) Equals(other Identifier) bool

func (*Identifier) IsEmpty

func (i *Identifier) IsEmpty() bool

func (Identifier) MarshalJSON

func (i Identifier) MarshalJSON() (dst []byte, err error)

func (*Identifier) String

func (i *Identifier) String() string

func (*Identifier) UnmarshalJSON

func (i *Identifier) UnmarshalJSON(src []byte) error

type Insights added in v0.4.0

type Insights struct {
	InsightsID string          `json:"id"`
	Version    VersionResponse `json:"version"`
	Build      struct {
		// build settings used by the Go compiler
		Settings  map[string]string `json:"settings"`
		GoVersion string            `json:"goVersion"`
	} `json:"build"`
	OS struct {
		Type   string `json:"type"`
		Arch   string `json:"arch"`
		NumCPU int    `json:"numCPU"`
	} `json:"os"`
	Config struct {
		DisableEmbeddedLogin bool   `json:"disableEmbeddedLogin,omitempty"`
		DisableProviders     bool   `json:"disableProviders,omitempty"`
		DisableRegistration  bool   `json:"disableRegistration,omitempty"`
		HasBaseURL           bool   `json:"hasBaseURL,omitempty"`
		HasDevProxy          bool   `json:"hasDevProxy,omitempty"`
		HasExternalAuth      bool   `json:"hasExternalAuth,omitempty"`
		HasListmonkURL       bool   `json:"hasListmonkURL,omitempty"`
		LocalBind            bool   `json:"localBind,omitempty"`
		NbOidcProviders      int    `json:"nbOidcProviders,omitempty"`
		NoAuthActive         bool   `json:"noAuthActive,omitempty"`
		NoMail               bool   `json:"noMail,omitempty"`
		NonUnixAdminBind     bool   `json:"nonUnixAdminBind,omitempty"`
		StorageEngine        string `json:"storageEngine,omitempty"`
	} `json:"config"`
	Database struct {
		Version     int            `json:"schemaVersion"`
		NbAuthUsers int            `json:"nbAuthUsers"`
		NbDomains   int            `json:"nbDomains"`
		Providers   map[string]int `json:"providers"`
		NbUsers     int            `json:"nbUsers"`
		NbZones     int            `json:"nbZones"`
	} `json:"db"`
	UserSettings struct {
		Languages   map[string]int `json:"languages"`
		Newsletter  int            `json:"newsletter"`
		FieldHints  map[int]int    `json:"field_hints"`
		ZoneView    map[int]int    `json:"zone_view"`
		ShowRRTypes int            `json:"showrrtypes"`
	} `json:"user_settings"`
}

type InternalError added in v0.4.0

type InternalError struct {
	Err         error
	UserMessage string
	UserLink    string
}

func (InternalError) Error added in v0.4.0

func (err InternalError) Error() string

func (InternalError) HTTPStatus added in v0.4.0

func (err InternalError) HTTPStatus() int

func (InternalError) ToErrorResponse added in v0.4.0

func (err InternalError) ToErrorResponse() ErrorResponse

type Iterator added in v0.4.1

type Iterator[T any] interface {
	// Next advances the iterator to the next item.
	// Returns true if there is a next item, false otherwise.
	Next() bool

	// NextWithError advances the iterator to the next item, on decode error it doesn't continue to the next item.
	// Returns true if there is a next item, false otherwise.
	NextWithError() bool

	// Item returns the current item in the iteration.
	// Should be called only after a successful call to Next().
	Item() *T

	// DropItem deletes the current item pointed to by the iterator.
	// Must be called only after a successful call to Next().
	DropItem() error

	// Raw returns the raw (non-decoded) value at the current iterator position.
	// Should only be called after a successful call to Next().
	Raw() []byte

	// Err returns the first error encountered during iteration, if any.
	Err() error

	// Close releases any resources associated with the iterator.
	Close()
}

Iterator defines a generic interface for iterating over a sequence of items of type T.

type LoginRequest added in v0.4.0

type LoginRequest struct {
	Email    string `json:"email" binding:"required,email"`
	Password string `json:"password" binding:"required"`
}

type Mailer added in v0.4.1

type Mailer interface {
	SendMail(to *mail.Address, subject, content string) error
}

type NewsletterSubscriptor added in v0.4.0

type NewsletterSubscriptor interface {
	SubscribeToNewsletter(uinfo UserInfo) error
}

type NotFoundError added in v0.4.1

type NotFoundError struct {
	Msg string
}

func (NotFoundError) Error added in v0.4.1

func (err NotFoundError) Error() string

func (NotFoundError) HTTPStatus added in v0.4.1

func (err NotFoundError) HTTPStatus() int

func (NotFoundError) ToErrorResponse added in v0.4.1

func (err NotFoundError) ToErrorResponse() ErrorResponse

type OIDCSettings added in v0.4.1

type OIDCSettings struct {
	ClientID     string
	ClientSecret string
	ProviderURL  url.URL
}

type Options added in v0.4.1

type Options struct {
	// AdminBind is the address:port or unix socket used to serve the admin
	// API.
	AdminBind string

	// Bind is the address:port used to bind the main interface with API.
	Bind string

	// BasePath is the relative path where begins the root of the app.
	BasePath string

	// DevProxy is the URL that override static assets.
	DevProxy string

	// DefaultNameServer is the NS server suggested by default.
	DefaultNameServer string

	// DisableProviders should disallow all actions on provider (add/edit/delete) through public API.
	DisableProviders bool

	// DisableRegistration forbids all new registration using the public form/API.
	DisableRegistration bool

	// DisableEmbeddedLogin disables the internal user/password login in favor of ExternalAuth or OIDC.
	DisableEmbeddedLogin bool

	// ExternalAuth is the URL of the login form to use instead of the embedded one.
	ExternalAuth url.URL

	// ExternalURL keeps the URL used in communications (such as email,
	// ...), when it needs to use complete URL, not only relative parts.
	ExternalURL url.URL

	// JWTSecretKey stores the private key to sign and verify JWT tokens.
	JWTSecretKey []byte

	// JWTSigningMethod is the signing method to check token signature.
	JWTSigningMethod string

	// NoAuth controls if there is user access control or not.
	NoAuth bool

	// OptOutInsights disable the anonymous usage statistics report.
	OptOutInsights bool

	// StorageEngine points to the storage engine used.
	StorageEngine string

	ListmonkURL url.URL
	ListmonkId  int

	// MailFrom holds the content of the From field for all e-mails that
	// will be send.
	MailFrom mail.Address

	NoMail               bool
	MailSMTPHost         string
	MailSMTPPort         uint
	MailSMTPUsername     string
	MailSMTPPassword     string
	MailSMTPTLSSNoVerify bool

	OIDCClients []OIDCSettings
}

Options stores the configuration of the software.

func (*Options) GetAuthURL added in v0.4.1

func (o *Options) GetAuthURL() *url.URL

func (*Options) GetBaseURL added in v0.4.1

func (o *Options) GetBaseURL() string

GetBaseURL returns the full url to the absolute ExternalURL, including BaseURL.

type Origin added in v0.4.1

type Origin string

type Provider

type Provider struct {
	ProviderMeta
	Provider ProviderBody
}

ProviderCombined combined ProviderMeta + Provider

func (*Provider) InstantiateProvider added in v0.4.0

func (p *Provider) InstantiateProvider() (ProviderActuator, error)

func (*Provider) Meta added in v0.4.0

func (p *Provider) Meta() *ProviderMeta

func (*Provider) ToMessage added in v0.4.0

func (p *Provider) ToMessage() (msg ProviderMessage, err error)

type ProviderActuator added in v0.4.0

type ProviderActuator interface {
	CanCreateDomain() bool
	CanListZones() bool
	CreateDomain(fqdn string) error
	GetZoneRecords(domain string) ([]Record, error)
	GetZoneCorrections(domain string, wantedRecords []Record) ([]*Correction, error)
	ListZones() ([]string, error)
}

type ProviderBody added in v0.4.0

type ProviderBody interface {
	InstantiateProvider() (ProviderActuator, error)
}

ProviderBody is where Domains and Zones can be managed.

type ProviderCreator added in v0.4.0

type ProviderCreator struct {
	Creator ProviderCreatorFunc
	Infos   ProviderInfos
}

Provider aggregates way of create a Provider and information about it.

type ProviderCreatorFunc added in v0.4.0

type ProviderCreatorFunc func() ProviderBody

ProviderCreatorFunc abstract the instanciation of a Provider

type ProviderInfos added in v0.4.0

type ProviderInfos struct {
	// Name is the name displayed.
	Name string `json:"name"`

	// Description is a brief description of what the provider is.
	Description string `json:"description"`

	// Capabilites is a list of special ability of the provider (automatically filled).
	Capabilities []string `json:"capabilities,omitempty"`

	// HelpLink is the link to the documentation of the provider configuration.
	HelpLink string `json:"helplink,omitempty"`
}

ProviderInfos describes the purpose of a user usable provider.

type ProviderMessage added in v0.4.0

type ProviderMessage struct {
	ProviderMeta
	Provider json.RawMessage
}

ProviderMessage combined ProviderMeta + Provider in a parsable way

func (*ProviderMessage) Meta added in v0.4.0

func (msg *ProviderMessage) Meta() *ProviderMeta

type ProviderMessages added in v0.4.0

type ProviderMessages []*ProviderMessage

func (*ProviderMessages) Metas added in v0.4.0

func (pms *ProviderMessages) Metas() (ret []*ProviderMeta)

type ProviderMeta

type ProviderMeta struct {
	// Type is the string representation of the Provider's type.
	Type string `json:"_srctype"`

	// Id is the Provider's identifier.
	Id Identifier `json:"_id" swaggertype:"string"`

	// Owner is the User's identifier for the current Provider.
	Owner Identifier `json:"_ownerid" swaggertype:"string"`

	// Comment is a string that helps user to distinguish the Provider.
	Comment string `json:"_comment,omitempty"`
}

ProviderMeta holds the metadata associated to a Provider.

type ProviderMinimal

type ProviderMinimal struct {
	// Type is the string representation of the Provider's type.
	Type string `json:"_srctype"`

	Provider Provider

	// Comment is a string that helps user to distinguish the Provider.
	Comment string `json:"_comment,omitempty"`
}

ProviderMinimal is used for swagger documentation as Provider add.

type ProviderSettingsResponse added in v0.4.0

type ProviderSettingsResponse struct {
	Provider *Provider              `json:"Provider,omitempty" swaggertype:"object"`
	Values   map[string]interface{} `json:"values,omitempty"`
	Form     *CustomForm            `json:"form,omitempty"`
}

type ProviderSettingsState added in v0.4.0

type ProviderSettingsState struct {
	FormState
	ProviderBody `json:"Provider" swaggertype:"object"`
}

type ProviderSettingsUsecase added in v0.4.0

type ProviderSettingsUsecase interface {
	NextProviderSettingsState(*ProviderSettingsState, string, *User) (*Provider, *ProviderSettingsResponse, error)
}

type ProviderSpecs added in v0.4.0

type ProviderSpecs struct {
	// Fields describes the settings needed to configure the provider.
	Fields []*Field `json:"fields,omitempty"`

	// Capabilities exposes what the provider can do.
	Capabilities []string `json:"capabilities,omitempty"`
}

type ProviderSpecsUsecase added in v0.4.0

type ProviderSpecsUsecase interface {
	ListProviders() map[string]ProviderInfos
	GetProviderIcon(string) ([]byte, error)
	GetProviderSpecs(string) (*ProviderSpecs, error)
}

type ProviderUsecase added in v0.4.0

type ProviderUsecase interface {
	CreateProvider(*User, *ProviderMessage) (*Provider, error)
	CreateDomainOnProvider(*Provider, string) error
	DeleteProvider(*User, Identifier) error
	GetUserProvider(*User, Identifier) (*Provider, error)
	GetUserProviderMeta(*User, Identifier) (*ProviderMeta, error)
	ListHostedDomains(*Provider) ([]string, error)
	ListUserProviders(*User) ([]*ProviderMeta, error)
	ListZoneCorrections(provider *Provider, domain *Domain, records []Record) ([]*Correction, error)
	RetrieveZone(*Provider, string) ([]Record, error)
	TestDomainExistence(*Provider, string) error
	UpdateProvider(Identifier, *User, func(*Provider)) error
	UpdateProviderFromMessage(Identifier, *User, *ProviderMessage) error
}

type Record added in v0.4.0

type Record interface {
	Header() *dns.RR_Header
	String() string
}

type RegisterProviderFunc added in v0.4.0

type RegisterProviderFunc func(ProviderCreatorFunc, ProviderInfos)

RegisterProviderFunc abstract the registration of a Provider

type RemoteZoneImporterUsecase added in v0.4.1

type RemoteZoneImporterUsecase interface {
	Import(*User, *Domain) (*Zone, error)
}

type ResolverRequest added in v0.4.0

type ResolverRequest struct {
	// Resolver is the name of the resolver to use (or local or custom).
	Resolver string `json:"resolver"`

	// Custom is the address to the recursive server to use.
	Custom string `json:"custom,omitempty"`

	// DomainName is the FQDN to resolve.
	DomainName string `json:"domain"`

	// Type is the type of record to retrieve.
	Type string `json:"type"`
}

ResolverRequest holds the resolution parameters

type ResolverUsecase added in v0.4.0

type ResolverUsecase interface {
	ResolveQuestion(ResolverRequest) (*dns.Msg, error)
}

type SPF added in v0.4.0

type SPF struct {
	Hdr dns.RR_Header
	Txt string
}

TXT is an abstraction of TXT record, with a whole string.

func NewSPF added in v0.4.0

func NewSPF(rr *dns.SPF) *SPF

func (*SPF) Header added in v0.4.0

func (rr *SPF) Header() *dns.RR_Header

func (*SPF) String added in v0.4.0

func (rr *SPF) String() string

func (*SPF) ToRR added in v0.4.0

func (rr *SPF) ToRR() dns.RR

type Service

type Service struct {
	ServiceMeta
	Service ServiceBody
}

func (*Service) Meta added in v0.4.0

func (msg *Service) Meta() *ServiceMeta

type ServiceBody added in v0.4.0

type ServiceBody interface {
	// GetNbResources get the number of main Resources contains in the Service.
	GetNbResources() int

	// GenComment sum up the content of the Service, in a small usefull string.
	GenComment() string

	// GetRecords retrieves underlying RRs.
	GetRecords(domain string, ttl uint32, origin string) ([]Record, error)
}

ServiceBody represents a service provided by one or more DNS record.

type ServiceCreator added in v0.4.0

type ServiceCreator func() ServiceBody

type ServiceInfos added in v0.4.0

type ServiceInfos struct {
	Name         string              `json:"name"`
	Type         string              `json:"_svctype"`
	Icon         string              `json:"_svcicon,omitempty"`
	Description  string              `json:"description"`
	Family       string              `json:"family"`
	Categories   []string            `json:"categories"`
	RecordTypes  []uint16            `json:"record_types"`
	Tabs         bool                `json:"tabs,omitempty"`
	Restrictions ServiceRestrictions `json:"restrictions,omitempty"`
}

type ServiceMessage added in v0.4.0

type ServiceMessage struct {
	ServiceMeta
	Service json.RawMessage
}

ServiceCombined combined ServiceMeta + Service

func (*ServiceMessage) Meta added in v0.4.0

func (msg *ServiceMessage) Meta() *ServiceMeta

type ServiceMeta

type ServiceMeta struct {
	// Type is the string representation of the Service's type.
	Type string `json:"_svctype"`

	// Id is the Service's identifier.
	Id Identifier `json:"_id,omitempty" swaggertype:"string"`

	// OwnerId is the User's identifier for the current Service.
	OwnerId Identifier `json:"_ownerid,omitempty" swaggertype:"string"`

	// Domain contains the abstract domain where this Service relates.
	Domain string `json:"_domain"`

	// Ttl contains the specific TTL for the underlying Resources.
	Ttl uint32 `json:"_ttl"`

	// Comment is a string that helps user to distinguish the Service.
	Comment string `json:"_comment,omitempty"`

	// UserComment is a supplementary string defined by the user to
	// distinguish the Service.
	UserComment string `json:"_mycomment,omitempty"`

	// Aliases exposes the aliases defined on this Service.
	Aliases []string `json:"_aliases,omitempty"`

	// NbResources holds the number of Resources stored inside this Service.
	NbResources int `json:"_tmp_hint_nb"`
}

ServiceMeta holds the metadata associated to a Service.

type ServiceNotFoundError added in v0.4.0

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

func NewServiceNotFoundError added in v0.4.0

func NewServiceNotFoundError(name string) *ServiceNotFoundError

func (ServiceNotFoundError) Error added in v0.4.0

func (err ServiceNotFoundError) Error() string

type ServiceRecord added in v0.4.0

type ServiceRecord struct {
	Type   string `json:"type"`
	String string `json:"str"`
	RR     Record `json:"rr,omitempty"`
}

func RecordToServiceRecord added in v0.4.0

func RecordToServiceRecord(rr Record) *ServiceRecord

type ServiceRestrictions added in v0.4.0

type ServiceRestrictions struct {
	// Alone restricts the service to be the only one for a given subdomain.
	Alone bool `json:"alone,omitempty"`

	// ExclusiveRR restricts the service to be present along with others given types.
	ExclusiveRR []string `json:"exclusive,omitempty"`

	// GLUE allows a service to be present under Leaf, as GLUE record.
	GLUE bool `json:"glue,omitempty"`

	// Leaf restricts the creation of subdomains under this kind of service (blocks NearAlone).
	Leaf bool `json:"leaf,omitempty"`

	// NearAlone allows a service to be present along with Alone restricted services (eg. services that will create sub-subdomain from their given subdomain).
	NearAlone bool `json:"nearAlone,omitempty"`

	// NeedTypes restricts the service to sources that are compatibles with ALL the given types.
	NeedTypes []uint16 `json:"needTypes,omitempty"`

	// RootOnly restricts the service to be present at the root of the domain only.
	RootOnly bool `json:"rootOnly,omitempty"`

	// Single restricts the service to be present only once per subdomain.
	Single bool `json:"single,omitempty"`
}

type ServiceSpecs added in v0.4.0

type ServiceSpecs struct {
	Fields []Field `json:"fields,omitempty"`
}

type ServiceSpecsUsecase added in v0.4.0

type ServiceSpecsUsecase interface {
	ListServices() map[string]ServiceInfos
	GetServiceIcon(string) ([]byte, error)
	GetServiceSpecs(reflect.Type) (*ServiceSpecs, error)
}

type ServiceUsecase added in v0.4.0

type ServiceUsecase interface {
	ListRecords(*Domain, *Zone, *Service) ([]Record, error)
	ValidateService(ServiceBody, Subdomain, Origin) ([]byte, error)
}

type Session

type Session struct {
	// Id is the Session's identifier.
	Id string `json:"id"`

	// IdUser is the User's identifier of the Session.
	IdUser Identifier `json:"login" swaggertype:"string"`

	// Description is a user defined string aims to identify each session.
	Description string `json:"description"`

	// IssuedAt holds the creation date of the Session.
	IssuedAt time.Time `json:"time"`

	// ExpiresOn holds the expirate date of the Session.
	ExpiresOn time.Time `json:"exp"`

	// ModifiedOn is the last time the session has been updated.
	ModifiedOn time.Time `json:"upd"`

	// Content stores data filled by other modules.
	Content string `json:"content,omitempty"`
}

Session holds informatin about a User's currently connected.

func (*Session) ClearSession

func (s *Session) ClearSession()

ClearSession removes all content from the Session.

type SessionCloserUsecase added in v0.4.1

type SessionCloserUsecase interface {
	CloseAll(user UserInfo) error
	ByID(userID Identifier) error
}

type SessionUsecase added in v0.4.0

type SessionUsecase interface {
	CloseUserSessions(user *User) error
	CreateUserSession(*User, string) (*Session, error)
	DeleteUserSession(*User, string) error
	GetUserSession(*User, string) (*Session, error)
	ListUserSessions(*User) ([]*Session, error)
	UpdateUserSession(*User, string, func(*Session)) error
}

type SubServiceCreator added in v0.4.0

type SubServiceCreator func() interface{}

type Subdomain added in v0.4.1

type Subdomain string

type TXT added in v0.4.0

type TXT struct {
	Hdr dns.RR_Header
	Txt string
}

TXT is an abstraction of TXT record, with a whole string.

func NewTXT added in v0.4.0

func NewTXT(rr *dns.TXT) *TXT

func (*TXT) Header added in v0.4.0

func (rr *TXT) Header() *dns.RR_Header

func (*TXT) String added in v0.4.0

func (rr *TXT) String() string

func (*TXT) ToRR added in v0.4.0

func (rr *TXT) ToRR() dns.RR

type TidyUpUseCase added in v0.4.1

type TidyUpUseCase interface {
	TidyAll() error
	TidyAuthUsers() error
	TidyDomains() error
	TidyDomainLogs() error
	TidyProviders() error
	TidySessions() error
	TidyUsers() error
	TidyZones() error
}

type UsecaseDependancies added in v0.4.0

type UsecaseDependancies interface {
	AuthenticationUsecase() AuthenticationUsecase
	AuthUserUsecase() AuthUserUsecase
	DomainUsecase() DomainUsecase
	DomainLogUsecase() DomainLogUsecase
	ProviderUsecase(secure bool) ProviderUsecase
	ProviderSettingsUsecase() ProviderSettingsUsecase
	ProviderSpecsUsecase() ProviderSpecsUsecase
	RemoteZoneImporterUsecase() RemoteZoneImporterUsecase
	ResolverUsecase() ResolverUsecase
	ServiceUsecase() ServiceUsecase
	ServiceSpecsUsecase() ServiceSpecsUsecase
	SessionUsecase() SessionUsecase
	UserUsecase() UserUsecase
	ZoneCorrectionApplierUsecase() ZoneCorrectionApplierUsecase
	ZoneImporterUsecase() ZoneImporterUsecase
	ZoneServiceUsecase() ZoneServiceUsecase
	ZoneUsecase() ZoneUsecase
}

type User

type User struct {
	// Id is the User's identifier.
	Id Identifier `json:"id"`

	// Email is the User's login and means of contact.
	Email string `json:"email"`

	// CreatedAt is the time when the User logs in for the first time.
	CreatedAt time.Time `json:"created_at,omitempty"`

	// LastSeen is the time when the User used happyDNS for the last time (in a 12h frame).
	LastSeen time.Time `json:"last_seen,omitempty"`

	// Settings holds the settings for an account.
	Settings UserSettings `json:"settings,omitempty"`
}

User represents an account.

func (*User) GetEmail added in v0.4.1

func (u *User) GetEmail() string

func (*User) GetUserId added in v0.4.1

func (u *User) GetUserId() Identifier

func (*User) JoinNewsletter added in v0.4.1

func (u *User) JoinNewsletter() bool

type UserAuth

type UserAuth struct {
	// Id is the User's identifier.
	Id Identifier

	// Email is the User's login and mean of contact.
	Email string

	// EmailVerification is the time when the User verify its email address.
	EmailVerification *time.Time

	// Password is hashed.
	Password []byte

	// PasswordRecoveryKey is a string generated when User asks to recover its account.
	PasswordRecoveryKey []byte `json:",omitempty"`

	// CreatedAt is the time when the User has register is account.
	CreatedAt time.Time

	// LastLoggedIn is the time when the User has logged in for the last time.
	LastLoggedIn *time.Time

	// AllowCommercials stores the user preference regarding email contacts.
	AllowCommercials bool
}

UserAuth represents an account used for authentication (not used in case of external auth).

func NewUserAuth

func NewUserAuth(email string, password string) (u *UserAuth, err error)

NewUserAuth fills a new UserAuth structure.

func (*UserAuth) CheckPassword added in v0.4.0

func (u *UserAuth) CheckPassword(password string) bool

CheckPassword compares the given password to the hashed one in the UserAuth struct.

func (*UserAuth) DefinePassword

func (u *UserAuth) DefinePassword(password string) (err error)

DefinePassword erases the current UserAuth's password by the new one given.

func (*UserAuth) GetEmail added in v0.4.0

func (u *UserAuth) GetEmail() string

func (*UserAuth) GetUserId added in v0.4.0

func (u *UserAuth) GetUserId() Identifier

func (*UserAuth) JoinNewsletter added in v0.4.0

func (u *UserAuth) JoinNewsletter() bool

type UserAuths

type UserAuths []*UserAuth

UserAuths is a group of UserAuth.

type UserInfo added in v0.4.0

type UserInfo interface {
	GetUserId() Identifier
	GetEmail() string
	JoinNewsletter() bool
}

UserInfo is an object that permit user creation after authentication.

type UserProfile added in v0.4.0

type UserProfile struct {
	UserId    []byte    `json:"userid"`
	Name      string    `json:"username"`
	CreatedAt time.Time `json:"created_at"`
}

UserProfile is a profile to include in authentication token.

func (*UserProfile) GetEmail added in v0.4.0

func (u *UserProfile) GetEmail() string

func (*UserProfile) GetUserId added in v0.4.0

func (u *UserProfile) GetUserId() Identifier

func (*UserProfile) JoinNewsletter added in v0.4.0

func (u *UserProfile) JoinNewsletter() bool

type UserRegistration added in v0.4.0

type UserRegistration struct {
	Email      string
	Password   string
	Language   string `json:"lang,omitempty"`
	Newsletter bool   `json:"wantReceiveUpdate,omitempty"`
}

UserRegistration contains all the informations required to perform a plain registration.

type UserSettings

type UserSettings struct {
	// Language saves the locale defined by the user.
	Language string `json:"language,omitempty"`

	// Newsletter indicates wether the user wants to receive the newsletter or not.
	Newsletter bool `json:"newsletter,omitempty"`

	// FieldHint stores the way form hints are displayed.
	FieldHint int `json:"fieldhint"`

	// ZoneView keeps the view of the zone wanted by the user.
	ZoneView int `json:"zoneview"`

	// ShowRRTypes tells if we show equivalent RRTypes in interface (for advanced users).
	ShowRRTypes bool `json:"showrrtypes,omitempty"`
}

UserSettings represents the settings for an account.

func DefaultUserSettings

func DefaultUserSettings() *UserSettings

type UserSpecialAction added in v0.4.0

type UserSpecialAction struct {
	// Kind of special action to perform: "recovery" or "validation".
	Kind string

	// Email on which to perform actions.
	Email string
}

type UserUsecase added in v0.4.0

type UserUsecase interface {
	ChangeUserSettings(*User, UserSettings) error
	CreateUser(UserInfo) (*User, error)
	DeleteUser(Identifier) error
	GenerateUserAvatar(*User, int, io.Writer) error
	GetUser(Identifier) (*User, error)
	GetUserByEmail(string) (*User, error)
	UpdateUser(Identifier, func(*User)) error
}

type ValidationError added in v0.4.1

type ValidationError struct {
	Msg string
}

func (ValidationError) Error added in v0.4.1

func (err ValidationError) Error() string

func (ValidationError) HTTPStatus added in v0.4.1

func (err ValidationError) HTTPStatus() int

func (ValidationError) ToErrorResponse added in v0.4.1

func (err ValidationError) ToErrorResponse() ErrorResponse

type VersionResponse added in v0.4.0

type VersionResponse struct {
	Version    string `json:"version"`
	LastCommit string `json:"last-commit"`
	DirtyBuild bool   `json:"dirty-build"`
}

type Zone

type Zone struct {
	ZoneMeta
	Services map[Subdomain][]*Service `json:"services"`
}

Zone contains ZoneMeta + map of services by subdomains.

func (*Zone) DerivateNew

func (z *Zone) DerivateNew() *Zone

DerivateNew creates a new Zone from the current one, by copying all fields.

func (*Zone) EraseService

func (zone *Zone) EraseService(subdomain Subdomain, id []byte, s *Service) error

EraseService overwrites the Service identified by the given id, under the given subdomain. The the new service is nil, it removes the existing Service instead of overwrite it.

func (*Zone) EraseServiceWithoutMeta

func (zone *Zone) EraseServiceWithoutMeta(subdomain Subdomain, id []byte, s ServiceBody) error

func (*Zone) FindService

func (z *Zone) FindService(id []byte) (Subdomain, *Service)

FindService finds the Service identified by the given id.

func (*Zone) FindSubdomainService

func (z *Zone) FindSubdomainService(subdomain Subdomain, id []byte) (int, *Service)

FindSubdomainService finds the Service identified by the given id, only under the given subdomain.

type ZoneCorrectionApplierUsecase added in v0.4.1

type ZoneCorrectionApplierUsecase interface {
	Apply(*User, *Domain, *Zone, *ApplyZoneForm) (*Zone, error)
	List(*User, *Domain, *Zone) ([]*Correction, error)
}

type ZoneImporterUsecase added in v0.4.1

type ZoneImporterUsecase interface {
	Import(*User, *Domain, []Record) (*Zone, error)
}

type ZoneMessage added in v0.4.0

type ZoneMessage struct {
	ZoneMeta
	Services map[Subdomain][]*ServiceMessage `json:"services"`
}

ZoneMessage is the intermediate struct for parsing zones.

type ZoneMeta

type ZoneMeta struct {
	// Id is the Zone's identifier.
	Id Identifier `json:"id" swaggertype:"string"`

	// IdAuthor is the User's identifier for the current Zone.
	IdAuthor Identifier `json:"id_author" swaggertype:"string"`

	// ParentZone identifies the parental zone of this one.
	ParentZone *Identifier `json:"parent,omitempty" swaggertype:"string"`

	// DefaultTTL is the TTL to use when no TTL has been defined for a record in this Zone.
	DefaultTTL uint32 `json:"default_ttl"`

	// LastModified holds the time when the last modification has been made on this Zone.
	LastModified time.Time `json:"last_modified,omitempty"`

	// CommitMsg is a message defined by the User to give a label to this Zone revision.
	CommitMsg *string `json:"commit_message,omitempty"`

	// CommitDate is the time when the commit has been made.
	CommitDate *time.Time `json:"commit_date,omitempty"`

	// Published indicates whether the Zone has already been published or not.
	Published *time.Time `json:"published,omitempty"`
}

ZoneMeta holds the metadata associated to a Zone.

type ZoneServiceUsecase added in v0.4.1

type ZoneServiceUsecase interface {
	ActionOnEditableZone(*User, *Domain, *Zone, func(*Zone) error) (*Zone, error)
	AddServiceToZone(*User, *Domain, *Zone, Subdomain, Origin, *Service) (*Zone, error)
	RemoveServiceFromZone(user *User, domain *Domain, zone *Zone, subdomain Subdomain, serviceid Identifier) (*Zone, error)
	UpdateZoneService(user *User, domain *Domain, zone *Zone, subdomain Subdomain, serviceid Identifier, newservice *Service) (*Zone, error)
}

type ZoneServices added in v0.4.0

type ZoneServices struct {
	Services []*Service `json:"services"`
}

type ZoneUsecase added in v0.4.0

type ZoneUsecase interface {
	CreateZone(*Zone) error
	DeleteZone(Identifier) error
	DiffZones(*Domain, *Zone, Identifier) ([]*Correction, error)
	FlattenZoneFile(*Domain, *Zone) (string, error)
	GenerateRecords(*Domain, *Zone) ([]Record, error)
	GetZone(Identifier) (*Zone, error)
	GetZoneMeta(Identifier) (*ZoneMeta, error)
	LoadZoneFromId(domain *Domain, id Identifier) (*Zone, error)
	UpdateZone(Identifier, func(*Zone)) error
}

Source Files

  • api.go
  • auth_user.go
  • authentication.go
  • backup.go
  • change_password.go
  • config.go
  • correction.go
  • domain.go
  • errors.go
  • form.go
  • hexastring.go
  • identifier.go
  • insight.go
  • iterators.go
  • login.go
  • logs.go
  • mailer.go
  • newsletter.go
  • oidc.go
  • orchestrator.go
  • provider.go
  • provider_settings.go
  • provider_specs.go
  • record.go
  • resolver.go
  • service.go
  • service_specs.go
  • session.go
  • tidy.go
  • usecase.go
  • user.go
  • userclaim.go
  • userinfo.go
  • userregistration.go
  • usersettings.go
  • userspecialaction.go
  • version.go
  • zone.go
  • zone_service.go

Jump to

Keyboard shortcuts

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