models

package
v0.0.0-...-86b787e Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2020 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerConfig     = "server.json"
	SensorConfig     = "sensor.json"
	DataDir          = "data"
	StateProduction  = "production"
	StateTest        = "test"
	StateDevelopment = "development"
)
View Source
const DefaultTeam = "Default"
View Source
const LEFailed = "fail"
View Source
const LEPending = "pending"
View Source
const LESuccess = "success"
View Source
const ZeroUUID = "00000000-0000-0000-0000-000000000000"

Variables

This section is empty.

Functions

func DecodeKey

func DecodeKey(s string) (*[32]byte, error)

func DoesExist

func DoesExist(name string) bool

func GenerateSecureKey

func GenerateSecureKey() string

func IsAdminSetup

func IsAdminSetup(db *storm.DB) bool

func Reindex

func Reindex(db *storm.DB) error

On startup reindex is called, though a bit dangerous, this is required should we change our datastructures, we want that change reflected in our data storage

func SensorCfgFile

func SensorCfgFile(dir string) string

func ServerCfgFile

func ServerCfgFile(dir string) string

func Strip

func Strip(s string) string

strip it all, no html

func Wd

func Wd() string

Wd returns the acting current working directory this path can change for certain configs

Types

type ARecord

type ARecord struct {
	Test bool
	Err  error
}

type CanDooer

type CanDooer struct {
	UUID uuid.UUID
	Pub  *otrbox.Pub
	Prv  *otrbox.Prv
}

func (*CanDooer) Sanity

func (cd *CanDooer) Sanity()

type Clone

type Clone struct {
	ID       int64     `storm:"id,increment,index"`
	FQDN     string    `storm:"index,unique"`
	Hostname string    `storm:"index,unique"`
	Depth    int       `storm:"index"`
	Updated  time.Time `storm:"index" json:"updated"`
	Created  time.Time `storm:"index" json:"created"`
}

func NewClone

func NewClone() *Clone

type Domain

type Domain struct {
	FQDN   string `json:"fqdn"`
	LETest *LETest
}

type EnvVars

type EnvVars struct {
	Name  string
	Value string
}

type FQDN

type FQDN struct {
	Port80  *Port80
	Port443 *Port443
	ARecord *ARecord
	IPMatch *IPMatch

	ExternalIP net.IP
}

func NewFQDN

func NewFQDN() *FQDN

func (*FQDN) BuildExternalIP

func (fqdn *FQDN) BuildExternalIP()

func (*FQDN) GetOutboundIP

func (fqdn *FQDN) GetOutboundIP() (net.IP, error)

Get preferred outbound ip of this machine

func (*FQDN) Test

func (fqdn *FQDN) Test(domain string)

func (*FQDN) TestARecord

func (fqdn *FQDN) TestARecord(domain string) (bool, error)

func (*FQDN) TestIP

func (fqdn *FQDN) TestIP() (bool, error)

func (*FQDN) TestPort443

func (fqdn *FQDN) TestPort443() (bool, error)

func (*FQDN) TestPort80

func (fqdn *FQDN) TestPort80() (bool, error)

type Https

type Https struct {
	Provider challenge.Provider
	DnsType  int
	Email    string
}

type IPMatch

type IPMatch struct {
	Test bool
	Err  error
}

type LE

type LE struct {
	Magic  *certmagic.Config
	Domain Domain
	DB     *storm.DB
}

func NewLE

func NewLE(path string, domain Domain, db *storm.DB) LE

func NewStageLE

func NewStageLE(email, path string, domain Domain, db *storm.DB) LE

type LETest

type LETest struct {
	ID           int64  `storm:"id,increment,index"`
	FQDN         string `storm:"index"`
	State        string `storm:"index"`
	StateMsg     string
	IsTestRecent bool // if not, don't allow
	Created      time.Time
}

type Port443

type Port443 struct {
	Test bool
	Err  error
}

type Port80

type Port80 struct {
	Test bool
	Err  error
}

type ProxyQueue

type ProxyQueue struct {
	ID       int64     `storm:"id,increment,index"`
	Honeypot string    `storm:"honeypot,increment,index"`
	Updated  time.Time `storm:"index" json:"updated"`
	Created  time.Time `storm:"index" json:"created"`
}

type Sensor

type Sensor struct {
	ID      int64        `storm:"id,increment,index"`
	TeamID  int64        `storm:"id,index" json:"team_id"`
	Name    string       `storm:"index,unique" json:"name"`
	Note    string       `storm:"index" json:"note"`
	ApiKey  string       `storm:"index,unique" json:"api_key"`
	Cfgs    []ServiceCfg `storm:"index" json:"service_configs`
	Updated time.Time    `storm:"index" json:"updated"`
	Created time.Time    `storm:"index" json:"created"`
}

func NewSensor

func NewSensor(name, note string, teamid int64) *Sensor

func (*Sensor) ValidateCreate

func (s *Sensor) ValidateCreate() error

func (*Sensor) Wash

func (s *Sensor) Wash()

type SensorAuth

type SensorAuth struct {
	Key  string `json:"key"`
	Host string `json:"host"`
}

type Service

type Service interface {
	Handle(ctx context.Context, conn net.Conn) error
}

type ServiceCfg

type ServiceCfg struct {
	UUID     uuid.UUID `storm:"index,unique" json:"uuid"`
	SensorID int64     `storm:"index" json:"sensor_id"`
	Port     int       `storm:"index" json:"port"`
	Type     string    `storm:"index" json:"type"`

	Service interface{}
}

func NewServiceCfg

func NewServiceCfg() (ServiceCfg, error)

type Settings

type Settings struct {
	SessionHash  []byte `json:"session_hash"`
	SessionBlock []byte `json:"session_block"`
	CsrfHash     []byte `json:"csrf_hash"`
	BindAddr     string `json:"bind_addr"`
	URI          string `json:"base_uri"`
	LeEnabled    bool   `json:"lets_encrypt"`
	Host         string `json:"-"`
	Port         string `json:"-"`
	Scheme       string `json:"-"`
	FQDN         string `json:"-"`
}

func InitSettings

func InitSettings(dir string) (*Settings, error)

func NewSettings

func NewSettings(dir string) (*Settings, error)

func (*Settings) BuildBaseURI

func (s *Settings) BuildBaseURI() string

func (*Settings) BuildBindAddr

func (s *Settings) BuildBindAddr()

func (*Settings) CreateIfNew

func (s *Settings) CreateIfNew()

func (*Settings) WriteSettings

func (s *Settings) WriteSettings(dir string) error

type Smtp

type Smtp struct {
	ID       int64 `storm:"id,increment,index"`
	Sender   string
	Email    string
	Host     string
	Port     string
	Username string
	Password string
}

func NewSmtp

func NewSmtp() *Smtp

func (Smtp) ValidateSmtp

func (s Smtp) ValidateSmtp() error

func (*Smtp) Wash

func (s *Smtp) Wash()

type State

type State struct {
	IsAuthd      bool
	AdminIsSetup bool
	SmtpIsSetup  bool
	Version      string
	// contains filtered or unexported fields
}

func NewState

func NewState(u *User, ver string, db *storm.DB) *State

type Team

type Team struct {
	ID        int64  `storm:"id,increment,index"`
	Name      string `storm:"index,unique" json:"name"`
	IsDeleted bool   `storm:"index" json:"is_deleted"`
	Members   []string

	MemberToAdd string
}

func NewTeam

func NewTeam() *Team

func (*Team) ValidateAddMember

func (t *Team) ValidateAddMember(newmember string) error

func (*Team) ValidateCreate

func (t *Team) ValidateCreate() error

func (*Team) Wash

func (t *Team) Wash()

type Token

type Token struct {
	ID     int64  `storm:"id,increment,index"`
	Name   string `storm:"index,unique" json:"name"`
	TeamID int64  `storm:"index" json:"team_id"`
	Key    string `storm:"unique" json:"key"`
	URL    string `storm:"unique" json:"url"`
	Note   string `storm:"index" json:"note"`
	Type   string `storm:"index" json:"type"` // Weblink, Pdf, Docx

	TokenContext interface{}
}

func NewToken

func NewToken() *Token

func (*Token) ValidateCreate

func (t *Token) ValidateCreate() error

func (*Token) Wash

func (t *Token) Wash()

type User

type User struct {
	ID              int64  `storm:"id,increment,index"`
	Email           string `storm:"index,unique" json:"email"`
	Password        string `json:"-"`
	PasswordConfirm string `json:"-"`
	IsDisabled      bool   `storm:"index" json:"is_disabled"`
	Hash            string
}

func NewUser

func NewUser() *User

func (*User) Authenticate

func (u *User) Authenticate(password string) error

func (*User) Create

func (user *User) Create(db *storm.DB) error

func (*User) CreateAdmin

func (user *User) CreateAdmin(db *storm.DB) error

func (*User) Delete

func (user *User) Delete(db *storm.DB) error

func (*User) HashPassword

func (u *User) HashPassword() error

func (User) ValidateCreateUser

func (u User) ValidateCreateUser() error

func (User) ValidateLogin

func (u User) ValidateLogin() error

func (User) ValidateSetup

func (u User) ValidateSetup() error

func (*User) Wash

func (u *User) Wash()

Jump to

Keyboard shortcuts

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