types

package
Version: v0.0.0-...-0bc30a8 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorReset  = "\033[0m"
	ColorRed    = "\033[0;31m"
	ColorGreen  = "\033[0;32m"
	ColorYellow = "\033[0;33m"
	ColorCyan   = "\033[0;36m"
	ColorWhite  = "\033[0;97m"
)

Variables

This section is empty.

Functions

func Logger

func Logger(customLogger zerolog.Logger)

Types

type AuthHandler

type AuthHandler bool
const (
	Blocking    AuthHandler = true
	NonBlocking AuthHandler = false
)

type BaseWorker

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

BaseWorker implements the standard functionality every worker has e.g. the behavior of Shutdown and Alive.

func (BaseWorker) Alive

func (worker BaseWorker) Alive() bool

func (BaseWorker) BlockedBy

func (BaseWorker) BlockedBy() []WorkerName

func (BaseWorker) GracefulShutdown

func (worker BaseWorker) GracefulShutdown() bool

func (*BaseWorker) ID

func (worker *BaseWorker) ID() string

func (*BaseWorker) Shutdown

func (worker *BaseWorker) Shutdown() error

func (*BaseWorker) Start

func (worker *BaseWorker) Start()

func (BaseWorker) Started

func (worker BaseWorker) Started() bool

func (*BaseWorker) Stop

func (worker *BaseWorker) Stop() error

func (BaseWorker) Test

func (BaseWorker) Test() error

func (*BaseWorker) WaitForShutdown

func (worker *BaseWorker) WaitForShutdown()

type ChanStat

type ChanStat struct {
	Channel            string
	Started, Processed uint
}

ChanStat holds information on how often a certain go channel was called. Only if the call succeeded ChanStat.Processed will be increased.

type ChanStats

type ChanStats []ChanStat

type ConfigurationData

type ConfigurationData interface {
	Merge(JsonString) JsonString
}

type ConfigurationKey

type ConfigurationKey string

ConfigurationKey represents the keys for the available system configuration

const (
	WhiteListConfiguration         ConfigurationKey = "whitelist"
	IPTablesConfiguration          ConfigurationKey = "iptables"
	PortalConfiguration            ConfigurationKey = "portal"
	PatternConfiguration           ConfigurationKey = "pattern"
	NetworkConfiguration           ConfigurationKey = "network"
	NetworkDNSConfiguration        ConfigurationKey = "network_dns"
	NetworkDHCPClientConfiguration ConfigurationKey = "network_dhcp_client"
	NetworkDHCPServerConfiguration ConfigurationKey = "network_dhcp_server"
	HWDetectConfiguration          ConfigurationKey = "hw_detect"
	WifiSTAConfiguration           ConfigurationKey = "wifi_sta"
	WifiAPConfiguration            ConfigurationKey = "wifi_ap"
)

func (ConfigurationKey) String

func (key ConfigurationKey) String() string

String returns the string representative of ConfigurationKey

type ConfigurationPortalData

type ConfigurationPortalData struct {
	Fingerprint  string `json:"fingerprint" binding:"fingerprint"`
	Notification *bool  `json:"notification"`
	Exception    *bool  `json:"exception"`
	Profile      *bool  `json:"profile"`
	Enabled      bool   `json:"enabled" binding:"required"`
	PoolUuid     string `json:"poolUuid" binding:"uuid"`
}

func (ConfigurationPortalData) Merge

func (data ConfigurationPortalData) Merge(dbJson JsonString) JsonString

type ConfigurationWhiteListData

type ConfigurationWhiteListData struct {
	Entries []string `json:"entries" binding:"iporcidr"`
}

func (ConfigurationWhiteListData) Merge

type ConfigurationWifiData

type ConfigurationWifiData struct {
	SSID       string `json:"ssid" binding:"min=2"`
	Passphrase string `json:"passphrase" binding:"min=12"`
	Enabled    *bool  `json:"enabled,omitempty" binding:"required"`

	ExtraConfiguration map[string]string `json:"extraConfiguration"`
}

func (ConfigurationWifiData) Merge

func (data ConfigurationWifiData) Merge(dbJson JsonString) JsonString

type HandlerJSONResponse

type HandlerJSONResponse struct {
	Type    HandlerJSONResponseType `json:"type"`
	Message string                  `json:"msg,omitempty"`
	Data    interface{}             `json:"data,omitempty"`
}

type HandlerJSONResponseType

type HandlerJSONResponseType string
const (
	HandlerErrorType   HandlerJSONResponseType = "error"
	HandlerSuccessType HandlerJSONResponseType = "success"
)

type IP

type IP struct {
	Raw net.IP
}

IP represents net.IP with a custom scanner interface for sqlx and json

func (IP) MarshalJSON

func (ip IP) MarshalJSON() ([]byte, error)

func (*IP) Scan

func (ip *IP) Scan(src interface{}) error

func (IP) String

func (ip IP) String() string

func (*IP) UnmarshalJSON

func (ip *IP) UnmarshalJSON(data []byte) error

func (IP) Value

func (ip IP) Value() (driver.Value, error)

type IPNet

type IPNet struct {
	Raw net.IPNet
}

IP represents net.IPNet with a custom scanner interface for sqlx and json

func (IPNet) Contains

func (ipnet IPNet) Contains(address net.IP) bool

func (IPNet) MarshalJSON

func (ipnet IPNet) MarshalJSON() ([]byte, error)

func (*IPNet) Scan

func (ipnet *IPNet) Scan(src interface{}) error

func (IPNet) String

func (ipnet IPNet) String() string

func (*IPNet) UnmarshalJSON

func (ipnet *IPNet) UnmarshalJSON(data []byte) error

func (IPNet) Value

func (ipnet IPNet) Value() (driver.Value, error)

type Ints

type Ints []int

Ints sortable integer array. The highest number is at position zero

func (Ints) Len

func (i Ints) Len() int

func (Ints) Less

func (i Ints) Less(x, xx int) bool

func (Ints) Swap

func (i Ints) Swap(x, xx int)

type IpRange

type IpRange struct {
	Start, End string
}

IpRange represents a range within a subnet. This is used for dhcpd configuration.

type JsonString

type JsonString string

JsonString is a special string and should contain only valid JSON. It is used for interacting with the sqlx library

func (JsonString) MarshalJSON

func (jsonString JsonString) MarshalJSON() ([]byte, error)

NOTE normally json stops marshalling if it is a string but in this case we save JSON data as string in a database WARNING if the string is not valid json this will make trouble

func (*JsonString) UnmarshalJSON

func (jsonString *JsonString) UnmarshalJSON(b []byte) error

type MigrateLogger

type MigrateLogger struct{ Logger zerolog.Logger }

MigrateLogger is used to display migration results via the zerolog channel

func (MigrateLogger) Printf

func (m MigrateLogger) Printf(format string, v ...interface{})

func (MigrateLogger) Verbose

func (MigrateLogger) Verbose() bool

type NFQActionType

type NFQActionType byte

NFQActionType is used to give feedback about which component was responsible for dropping traffic

const (
	NFQActionDefault                     = 0x00
	PacketDroppedByProfile NFQActionType = 0x10 // profiling ML
)

func (*NFQActionType) Scan

func (action *NFQActionType) Scan(src interface{}) error

func (NFQActionType) String

func (action NFQActionType) String() string

String will return the string representation of the nfq action type

func (NFQActionType) Value

func (action NFQActionType) Value() (driver.Value, error)

type PortalEventType

type PortalEventType uint

PortalEventType represents the portal event message type

const (
	PortalMembershipRequest PortalEventType = 0
	PortalNotification      PortalEventType = 1
	PortalException         PortalEventType = 2
	// generic portal event
	PortalGenericEvent PortalEventType = 100
)

type ReportDate

type ReportDate struct {
	time.Time
}

ReportDate is a special formatted database timestamp

func (*ReportDate) Scan

func (reportDate *ReportDate) Scan(src interface{}) error

func (ReportDate) Value

func (reportDate ReportDate) Value() (driver.Value, error)

type SentryLogHook

type SentryLogHook struct{}

func (SentryLogHook) Run

func (SentryLogHook) Run(event *zerolog.Event, level zerolog.Level, message string)

type StatisticKey

type StatisticKey string

StatisticKey represents the keys for the available statistics

const (
	DNSPatternStatistic StatisticKey = "DNSPatternStatistic"
	IPPatternStatistic  StatisticKey = "IPPatternStatistic"
	// what is active right now
	ActiveIPPatternStatistic  StatisticKey = "ActiveIPPatternStatistic"
	ActiveDNSPatternStatistic StatisticKey = "ActiveDNSPatternStatistic"

	NetworkDeviceStatistic      StatisticKey = "NetworkDeviceStatistic"
	DroppedConnectionsStatistic StatisticKey = "DroppedConnectionsStatistic"
)

type Worker

type Worker interface {
	ID() string
	Name() WorkerName
	Alive() bool
	Started() bool
	Shutdown() error
	GracefulShutdown() bool
	Logger(zerolog.Logger)
	BlockedBy() []WorkerName
	Run()
	Test() error
}

Worker is the minimum functionality a worker struct has to implement

type WorkerLogger

type WorkerLogger struct {
	// if IsError is nil the log level will be debug,
	// if IsError is false the log level will be info
	// if IsError is true the log level will be error
	IsError *bool
	zerolog.Logger
}

WorkerLogger is the wrapper interface to e.g. the DHCP client and server log messages

func (WorkerLogger) Debug

func (wlogger WorkerLogger) Debug(format string, v ...interface{})

func (WorkerLogger) Error

func (wlogger WorkerLogger) Error(format string, v ...interface{})

func (WorkerLogger) Info

func (wlogger WorkerLogger) Info(format string, v ...interface{})

func (WorkerLogger) PrintMessage

func (wlogger WorkerLogger) PrintMessage(prefix string, message *dhcpv4.DHCPv4)

func (WorkerLogger) Printf

func (wlogger WorkerLogger) Printf(format string, v ...interface{})

func (WorkerLogger) Write

func (wlogger WorkerLogger) Write(p []byte) (n int, err error)

type WorkerName

type WorkerName string

WorkerName represents the name from a worker. This is used to identify individuals

const (
	ConfdWorker      WorkerName = "CONFD"
	DhcpClientWorker WorkerName = "DHCPCLIENT"
	DhcpServerWorker WorkerName = "DHCPSERVER"
	DnsWorker        WorkerName = "DNS"
	FrontendWorker   WorkerName = "FRONTEND"
	HWDetectWorker   WorkerName = "HWDETECT"
	IPTablesWorker   WorkerName = "IPTABLES"
	NFQWorker        WorkerName = "NFQ"
	PortalWorker     WorkerName = "PORTAL"
	ProfilerWorker   WorkerName = "PROFILER"
	WatcherWorker    WorkerName = "WATCHER"
	WifiAPWorker     WorkerName = "WIFIAP"
	WifiSTAWorker    WorkerName = "WIFISTA"
)

func (WorkerName) String

func (name WorkerName) String() string

Jump to

Keyboard shortcuts

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