common

package
v0.0.0-...-0991925 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPV4_DEFAULT_PREFIX  = "0.0.0.0"
	IPV4_DEFAULT_NETMASK = 32
	IPV4_DEFAULT_GATEWAY = "0.0.0.0"
	IPV6_DEFAULT_PREFIX  = "::"
	IPV6_DEFAULT_NETMASK = 128
	IPV6_DEFAULT_GATEWAY = "::"
)
View Source
const (
	VROUTER_STATE_RUNNING = 7
	WAN_IP_ISP            = 7
	PUBLIC_NETWORK_LCUUID = "ffffffff-ffff-ffff-ffff-ffffffffffff"
)

Variables

Functions

func CIDRToPreNetMask

func CIDRToPreNetMask(cidr string) (string, string, error)

func ElementsSame

func ElementsSame[T constraints.Ordered](s1, s2 []T) bool

func FmtORGID

func FmtORGID(id int) string

func FormatIP

func FormatIP(ip string) string

func IntSliceToString

func IntSliceToString(s []int) string

func LogAdd

func LogAdd(resourceType string) string

func LogDelete

func LogDelete(resourceType string) string

func LogUpdate

func LogUpdate(resourceType string) string

func StringToIntSlice

func StringToIntSlice(str string) []int

Types

type DomainInfo

type DomainInfo struct {
	mysql.Domain
}

type Logger

type Logger struct {
	DomainName    string
	SubDomainName string
	MsgPre        string
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(orgID int) *Logger

func (*Logger) AddPre

func (l *Logger) AddPre(format string, a ...any) string

func (*Logger) Copy

func (l *Logger) Copy() *Logger

func (*Logger) GetMsgPre

func (l *Logger) GetMsgPre() string

func (*Logger) InitMsgPre

func (l *Logger) InitMsgPre()

func (*Logger) SetDomainName

func (l *Logger) SetDomainName(n string)

func (*Logger) SetSubDomainName

func (l *Logger) SetSubDomainName(n string)

type Metadata

type Metadata struct {
	ORGID     int       // org id
	DB        *mysql.DB // org database connection
	Logger    *Logger   // log controller
	Domain    *DomainInfo
	SubDomain *SubDomainInfo
}

func NewMetadata

func NewMetadata(orgID int) (*Metadata, error)

func (*Metadata) Copy

func (m *Metadata) Copy() *Metadata

func (*Metadata) GetORGID

func (m *Metadata) GetORGID() int

func (*Metadata) Log

func (m *Metadata) Log(format string) string

func (*Metadata) Logf

func (m *Metadata) Logf(format string, a ...any) string

Logf adds org id, domain info, sub_domain info to logs

func (*Metadata) SetDomain

func (m *Metadata) SetDomain(domain mysql.Domain)

func (*Metadata) SetSubDomain

func (m *Metadata) SetSubDomain(subDomain mysql.SubDomain)

type ORG

type ORG struct {
	ID     int       // org id
	DB     *mysql.DB // org database connection
	Logger *Logger   // log controller
}

func NewORG

func NewORG(id int) (*ORG, error)

func (*ORG) Log

func (o *ORG) Log(format string) string

func (*ORG) Logf

func (o *ORG) Logf(format string, a ...any) string

Logf adds org id, domain info, sub_domain info to logs

type SubDomainInfo

type SubDomainInfo struct {
	mysql.SubDomain
}

Jump to

Keyboard shortcuts

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