utils

package
v0.16.0-unstable61 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: Apache-2.0 Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GUEST = 0
	USER  = 1
	ADMIN = 2
)
View Source
const (
	DEBUG   = 0
	INFO    = 1
	WARNING = 2
	ERROR   = 3
)
View Source
const (
	STRICT  = 1
	NORMAL  = 2
	LENIENT = 3
)

Variables

View Source
var AlphaNumRunes = []rune("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
View Source
var BannedIPs = sync.Map{}
View Source
var Blue = "\033[34m"
View Source
var CONFIGFOLDER = "/var/lib/cosmos/"
View Source
var CheckDockerNetworkMode func() string
View Source
var ConfigLock sync.Mutex
View Source
var ConfigLockInternal sync.Mutex
View Source
var Cyan = "\033[36m"
View Source
var DBContainerName string
View Source
var DBStatus bool
View Source
var DefaultConfig = Config{
	LoggingLevel:     "INFO",
	NewInstall:       true,
	AutoUpdate:       true,
	BlockedCountries: []string{},
	HTTPConfig: HTTPConfig{
		HTTPSCertificateMode:    "DISABLED",
		GenerateMissingAuthCert: true,
		HTTPPort:                "80",
		HTTPSPort:               "443",
		Hostname:                "0.0.0.0",
		PublishMDNS:             true,
		ProxyConfig: ProxyConfig{
			Routes: []ProxyRouteConfig{},
		},
	},
	DockerConfig: DockerConfig{
		DefaultDataPath: "/usr",
	},
	MarketConfig: MarketConfig{
		Sources: []MarketSource{},
	},
	ConstellationConfig: ConstellationConfig{
		Enabled:     false,
		DNSDisabled: false,
		DNSFallback: "8.8.8.8:53",
		DNSAdditionalBlocklists: []string{
			"https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt",
			"https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt",
			"https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts",
			"https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-only/hosts",
		},
	},
	MonitoringAlerts: map[string]Alert{
		"Anti Crypto-Miner": {
			Name:           "Anti Crypto-Miner",
			Enabled:        false,
			Period:         "daily",
			TrackingMetric: "cosmos.system.docker.cpu.*",
			LastTriggered:  time.Time{},
			Condition: AlertCondition{
				Operator: "gt",
				Value:    80,
				Percent:  false,
			},
			Actions: []AlertAction{
				AlertAction{
					Type:   "notification",
					Target: "",
				},
				AlertAction{
					Type:   "email",
					Target: "",
				},
				AlertAction{
					Type:   "stop",
					Target: "",
				},
			},
			Throttled: false,
			Severity:  "warn",
		},
		"Anti Memory Leak": {
			Name:           "Anti Memory Leak",
			Enabled:        false,
			Period:         "daily",
			TrackingMetric: "cosmos.system.docker.ram.*",
			LastTriggered:  time.Time{},
			Condition: AlertCondition{
				Operator: "gt",
				Value:    80,
				Percent:  true,
			},
			Actions: []AlertAction{
				{
					Type:   "notification",
					Target: "",
				},
				{
					Type:   "email",
					Target: "",
				},
				{
					Type:   "stop",
					Target: "",
				},
			},
			Throttled: false,
			Severity:  "warn",
		},
		"Disk Health": {
			Name:           "Disk Health",
			Enabled:        true,
			Period:         "latest",
			TrackingMetric: "system.disk-health.temperature.*",
			LastTriggered:  time.Time{},
			Condition: AlertCondition{
				Operator: "gt",
				Value:    50,
				Percent:  false,
			},
			Actions: []AlertAction{
				{
					Type:   "notification",
					Target: "",
				},
			},
			Throttled: true,
			Severity:  "warn",
		},
		"Disk Full Notification": {
			Name:           "Disk Full Notification",
			Enabled:        true,
			Period:         "latest",
			TrackingMetric: "cosmos.system.disk./",
			LastTriggered:  time.Time{},
			Condition: AlertCondition{
				Operator: "gt",
				Value:    95,
				Percent:  true,
			},
			Actions: []AlertAction{
				{
					Type:   "notification",
					Target: "",
				},
			},
			Throttled: true,
			Severity:  "warn",
		},
	},
}
View Source
var DoesContainerExist func(string) bool
View Source
var GetContainerIPByName func(string) (string, error)

var ReBootstrapContainer func(string) error

View Source
var Gray = "\033[37m"
View Source
var Green = "\033[32m"
View Source
var HTTPSCertModeList = map[string]string{
	"DISABLED":    "DISABLED",
	"PROVIDED":    "PROVIDED",
	"SELFSIGNED":  "SELFSIGNED",
	"LETSENCRYPT": "LETSENCRYPT",
}
View Source
var IsHTTPS = false
View Source
var IsHostNetwork = false
View Source
var IsInsideContainer = false
View Source
var LetsEncryptErrors = []string{}
View Source
var LoggingLevelLabels = map[LoggingLevel]int{
	"DEBUG":   DEBUG,
	"INFO":    INFO,
	"WARNING": WARNING,
	"ERROR":   ERROR,
}
View Source
var NeedsRestart = false
View Source
var NewVersionAvailable = false
View Source
var ProxyModeList = map[string]string{
	"PROXY":    "PROXY",
	"SPA":      "SPA",
	"STATIC":   "STATIC",
	"SERVAPP":  "SERVAPP",
	"REDIRECT": "REDIRECT",
}
View Source
var Purple = "\033[35m"
View Source
var PushShieldMetrics func(string)
View Source
var Red = "\033[31m"
View Source
var Reset = "\033[0m"
View Source
var RestartHTTPServer = func() {}
View Source
var ResyncConstellationNodes = func() {}
View Source
var Template = `` /* 1110-byte string literal not displayed */
View Source
var UpdateAvailable = map[string]bool{}
View Source
var Validate = validator.New()
View Source
var White = "\033[97m"
View Source
var Yellow = "\033[33m"

Functions

func AcceptHeader

func AcceptHeader(accept string) func(next http.Handler) http.Handler

func AdminOnly

func AdminOnly(w http.ResponseWriter, req *http.Request) error

func AdminOnlyMiddleware added in v0.15.0

func AdminOnlyMiddleware(next http.Handler) http.Handler

func AdminOnlyWithRedirect

func AdminOnlyWithRedirect(w http.ResponseWriter, req *http.Request) error

func AdminOrItselfOnly

func AdminOrItselfOnly(w http.ResponseWriter, req *http.Request, nickname string) error

func BandwithLimiterMiddleware

func BandwithLimiterMiddleware(max int64) func(next http.Handler) http.Handler

func BlockBannedIPs added in v0.12.0

func BlockBannedIPs(next http.Handler) http.Handler

func BlockByCountryMiddleware

func BlockByCountryMiddleware(blockedCountries []string, CountryBlacklistIsWhitelist bool) func(http.Handler) http.Handler

BlockByCountryMiddleware returns a middleware function that blocks requests from specified countries.

func BlockPostWithoutReferer

func BlockPostWithoutReferer(next http.Handler) http.Handler

blockPostWithoutReferer blocks POST requests without a Referer header

func BufferedDBWrite added in v0.12.0

func BufferedDBWrite(collectionName string, object map[string]interface{})

func CORSHeader

func CORSHeader(origin string) func(next http.Handler) http.Handler

func CheckDNS

func CheckDNS(url string) error

func CheckHostNetwork added in v0.14.0

func CheckHostNetwork()

func CheckInternet

func CheckInternet()

func CheckPassword added in v0.15.0

func CheckPassword(nickname, password string) error

func CleanBannedIPs added in v0.12.0

func CleanBannedIPs()

func CleanupByDate added in v0.12.0

func CleanupByDate(collectionName string)

func CloseEmbeddedDB

func CloseEmbeddedDB()

func CompareSemver added in v0.14.0

func CompareSemver(v1, v2 string) (int, error)

compareSemver compares two semantic version strings. Returns:

 0 if v1 == v2
 1 if v1 > v2
-1 if v1 < v2
 error if there's a problem parsing either version string

func ContentTypeMiddleware added in v0.15.0

func ContentTypeMiddleware(contentType string) func(next http.Handler) http.Handler

func CreateDefaultConfigFileIfNecessary

func CreateDefaultConfigFileIfNecessary() bool

func DB

func DB() error

func Debug

func Debug(message string)

func DisconnectDB

func DisconnectDB()

func DoErr added in v0.11.0

func DoErr(format string, a ...interface{}) string

func DoLetsEncrypt

func DoLetsEncrypt() (string, string)

func DoSuccess added in v0.11.0

func DoSuccess(format string, a ...interface{}) string

func DoWarn added in v0.11.0

func DoWarn(format string, a ...interface{}) string

func DownloadFile added in v0.10.0

func DownloadFile(url string) (string, error)

func EnsureHostname

func EnsureHostname(next http.Handler) http.Handler

func EnsureHostnameCosmosAPI added in v0.12.6

func EnsureHostnameCosmosAPI(next http.Handler) http.Handler

func Error

func Error(message string, err error)

func Exec added in v0.15.0

func Exec(cmd string, args ...string) (string, error)

func Fatal

func Fatal(message string, err error)

func FileExists

func FileExists(path string) bool

func GenerateEd25519Certificates

func GenerateEd25519Certificates() (string, string)

func GenerateRSAWebCertificates

func GenerateRSAWebCertificates(domains []string) (string, string)

func GenerateRandomString

func GenerateRandomString(n int) string

func GetAllHostnames

func GetAllHostnames(applyWildCard bool, removePorts bool) []string

func GetAllTunnelHostnames

func GetAllTunnelHostnames() map[string]string

TODO

func GetAvailableRAM

func GetAvailableRAM() uint64

func GetCPUUsage

func GetCPUUsage() []float64

func GetClientIP added in v0.9.17

func GetClientIP(req *http.Request) string

func GetCollection

func GetCollection(applicationId string, collection string) (*mongo.Collection, error)

func GetConfigFileName

func GetConfigFileName() string

func GetEmbeddedCollection added in v0.14.0

func GetEmbeddedCollection(applicationId string, collection string) (lungo.ICollection, func(), error)

func GetIPLocation

func GetIPLocation(ip string) (string, error)

GetIPLocation returns the ISO country code for a given IP address.

func GetPrivateAuthKey

func GetPrivateAuthKey() string

func GetPublicAuthKey

func GetPublicAuthKey() string

func GetRAMUsage

func GetRAMUsage() uint64

func GetRootAppId

func GetRootAppId() string

func GetServerURL

func GetServerURL(overwriteHostname string) string

func GetWriteBuffer added in v0.15.0

func GetWriteBuffer() map[string][]map[string]interface{}

func GetWriteBufferLength added in v0.15.0

func GetWriteBufferLength() int

func HTTPError

func HTTPError(w http.ResponseWriter, message string, code int, userCode string)

func HasAnyNewItem

func HasAnyNewItem(after []string, before []string) bool

func IPInRange added in v0.10.0

func IPInRange(ipStr, cidrStr string) (bool, error)

func ImageToBase64

func ImageToBase64(path string) (string, error)

func IncrementIPAbuseCounter added in v0.12.0

func IncrementIPAbuseCounter(ip string)

func InitDBBuffers added in v0.12.0

func InitDBBuffers()

func InitFBL

func InitFBL()

func IsAdmin

func IsAdmin(req *http.Request) bool

func IsConstellationIP

func IsConstellationIP(ip string) bool

func IsDomain added in v0.10.0

func IsDomain(domain string) bool

func IsEmailEnabled

func IsEmailEnabled() bool

func IsLocalIP added in v0.15.7

func IsLocalIP(ip string) bool

func IsLoggedIn added in v0.12.6

func IsLoggedIn(req *http.Request) bool

func IsNotifyLoginEmailEnabled

func IsNotifyLoginEmailEnabled() bool

func IsValidHostname

func IsValidHostname(hostname string) bool

func LetsEncryptValidOnly

func LetsEncryptValidOnly(hostnames []string, acceptWildcard bool) []string

func ListIps

func ListIps(skipNebula bool) ([]string, error)

func LoadBaseMainConfig

func LoadBaseMainConfig(config Config)

func Log

func Log(message string)

func LoggedInOnly

func LoggedInOnly(w http.ResponseWriter, req *http.Request) error

func LoggedInOnlyWithRedirect

func LoggedInOnlyWithRedirect(w http.ResponseWriter, req *http.Request) error

func LoggedInWeakOnly

func LoggedInWeakOnly(w http.ResponseWriter, req *http.Request) error

func MajorError added in v0.12.0

func MajorError(message string, err error)

func MarkAsRead added in v0.12.0

func MarkAsRead(w http.ResponseWriter, req *http.Request)

func Max

func Max(x, y int) int

func MiddlewareTimeout

func MiddlewareTimeout(timeout time.Duration) func(next http.Handler) http.Handler

func NotifGet added in v0.12.0

func NotifGet(w http.ResponseWriter, req *http.Request)

func PublicCORS added in v0.12.0

func PublicCORS(next http.Handler) http.Handler

func RemovePIDFile

func RemovePIDFile()

func RemoveStringFromSlice

func RemoveStringFromSlice(slice []string, s string) []string

func RestartServer

func RestartServer()

func Restrictions added in v0.10.0

func Restrictions(RestrictToConstellation bool, WhitelistInboundIPs []string) func(next http.Handler) http.Handler

func SPAHandler added in v0.15.0

func SPAHandler(targetFolder string) http.Handler

func Sanitize

func Sanitize(s string) string

func SanitizeSafe

func SanitizeSafe(s string) string

func SaveConfigTofile

func SaveConfigTofile(config Config)

func SendEmail

func SendEmail(recipients []string, subject string, body string) error

func SetBaseMainConfig

func SetBaseMainConfig(config Config)

func SetSecurityHeaders

func SetSecurityHeaders(next http.Handler) http.Handler

func SplitIP

func SplitIP(ipPort string) (string, string)

func StringArrayContains

func StringArrayContains(a []string, b string) bool

func StringArrayEquals

func StringArrayEquals(a []string, b []string) bool

func TriggerEvent added in v0.12.0

func TriggerEvent(eventId string, label string, level string, object string, data map[string]interface{})

func Values added in v0.15.0

func Values[M ~map[K]V, K comparable, V any](m M) []V

func Warn

func Warn(message string)

func WriteNotification added in v0.12.0

func WriteNotification(notification Notification)

func WriteToDatabase added in v0.12.0

func WriteToDatabase(collection *mongo.Collection, objects []map[string]interface{}) error

Types

type AddionalFiltersConfig added in v0.9.9

type AddionalFiltersConfig struct {
	Type  string `yaml:"type"`
	Name  string `yaml:"name"`
	Value string `yaml:"value"`
}

type Alert added in v0.12.0

type Alert struct {
	Name           string
	Enabled        bool
	Period         string
	TrackingMetric string
	Condition      AlertCondition
	Actions        []AlertAction
	LastTriggered  time.Time
	Throttled      bool
	Severity       string
}

type AlertAction added in v0.12.0

type AlertAction struct {
	Type   string
	Target string
}

type AlertCondition added in v0.12.0

type AlertCondition struct {
	Operator string
	Value    int
	Percent  bool
}

type AlertMetricTrack added in v0.12.0

type AlertMetricTrack struct {
	Key    string
	Object string
	Max    uint64
}

type CRONConfig added in v0.15.0

type CRONConfig struct {
	Enabled   bool
	Name      string
	Crontab   string
	Command   string
	Container string
}

type CertUser

type CertUser struct {
	Email        string
	Registration *registration.Resource
	// contains filtered or unexported fields
}

func (*CertUser) GetEmail

func (u *CertUser) GetEmail() string

func (*CertUser) GetPrivateKey

func (u *CertUser) GetPrivateKey() crypto.PrivateKey

func (CertUser) GetRegistration

func (u CertUser) GetRegistration() *registration.Resource

type CleanupObject added in v0.12.0

type CleanupObject struct {
	Date time.Time
}

type Config

type Config struct {
	LoggingLevel                LoggingLevel `required,validate:"oneof=DEBUG INFO WARNING ERROR"`
	MongoDB                     string
	Database                    DatabaseConfig `validate:"dive"`
	DisableUserManagement       bool
	NewInstall                  bool        `validate:"boolean"`
	HTTPConfig                  HTTPConfig  `validate:"required,dive,required"`
	EmailConfig                 EmailConfig `validate:"required,dive,required"`
	DockerConfig                DockerConfig
	BlockedCountries            []string
	CountryBlacklistIsWhitelist bool
	ServerCountry               string
	RequireMFA                  bool
	AutoUpdate                  bool
	OpenIDClients               []OpenIDClient
	MarketConfig                MarketConfig
	HomepageConfig              HomepageConfig
	ThemeConfig                 ThemeConfig
	ConstellationConfig         ConstellationConfig
	MonitoringDisabled          bool
	MonitoringAlerts            map[string]Alert
	BackupOutputDir             string
	DisableHostModeWarning      bool
	AdminWhitelistIPs           []string
	AdminConstellationOnly      bool
	Storage                     StorageConfig
	CRON                        map[string]CRONConfig
	Licence                     string
	ServerToken                 string
}
var BaseMainConfig Config
var MainConfig Config

func GetBaseMainConfig

func GetBaseMainConfig() Config

func GetMainConfig

func GetMainConfig() Config

func ReadConfigFromFile

func ReadConfigFromFile() Config

type ConstellationConfig added in v0.10.0

type ConstellationConfig struct {
	Enabled                 bool
	SlaveMode               bool
	DoNotSyncNodes          bool
	PrivateNode             bool
	DNSDisabled             bool
	DNSPort                 string
	DNSFallback             string
	DNSBlockBlacklist       bool
	DNSAdditionalBlocklists []string
	CustomDNSEntries        []ConstellationDNSEntry
	NebulaConfig            NebulaConfig
	ConstellationHostname   string
	Tunnels                 []ProxyRouteConfig
}

type ConstellationDNSEntry added in v0.10.0

type ConstellationDNSEntry struct {
	Type  string
	Key   string
	Value string
}

type ConstellationDevice added in v0.10.0

type ConstellationDevice struct {
	Nickname       string `json:"nickname" bson:"Nickname"`
	DeviceName     string `json:"deviceName" bson:"DeviceName"`
	PublicKey      string `json:"publicKey" bson:"PublicKey"`
	IP             string `json:"ip" bson:"IP"`
	IsLighthouse   bool   `json:"isLighthouse" bson:"IsLighthouse"`
	IsRelay        bool   `json:"isRelay" bson:"IsRelay"`
	PublicHostname string `json:"publicHostname" bson:"PublicHostname"`
	Port           string `json:"port" bson:"Port"`
	Blocked        bool   `json:"blocked" bson:"Blocked"`
	Fingerprint    string `json:"fingerprint" 	bson:"Fingerprint"`
	APIKey         string `json:"-" bson:"APIKey"`
}

type DatabaseConfig added in v0.14.0

type DatabaseConfig struct {
	PuppetMode   bool
	Hostname     string
	DbVolume     string
	ConfigVolume string
	Version      string
	Username     string
	Password     string
}

type Device added in v0.10.0

type Device struct {
	DeviceName string `json:"deviceName"validate:"required,min=3,max=32,alphanum",bson:"DeviceName"`
	Nickname   string `json:"nickname",validate:"required,min=3,max=32,alphanum",bson:"Nickname"`
	PublicKey  string `json:"publicKey",omitempty,bson:"PublicKey"`
	PrivateKey string `json:"privateKey",omitempty,bson:"PrivateKey"`
	IP         string `json:"ip",validate:"required,ipv4",bson:"IP"`
}

type DiskStatus

type DiskStatus struct {
	Path       string
	TotalBytes uint64
	UsedBytes  uint64
}

func GetDiskUsage

func GetDiskUsage() []DiskStatus

type DockerConfig

type DockerConfig struct {
	SkipPruneNetwork bool
	SkipPruneImages  bool
	DefaultDataPath  string
}

type EmailConfig

type EmailConfig struct {
	Enabled          bool
	Host             string
	Port             string
	Username         string
	Password         string
	From             string
	UseTLS           bool
	AllowInsecureTLS bool
	NotifyLogin      bool
}

type FileStats

type FileStats struct {
	Name    string      `json:"name"`
	Path    string      `json:"path"`
	Size    int64       `json:"size"`
	Mode    os.FileMode `json:"mode"`
	ModTime time.Time   `json:"modTime"`
	IsDir   bool        `json:"isDir"`
}

type FirebaseApiSdk

type FirebaseApiSdk struct {
	BaseURL     string
	LValid      bool
	ServerToken string
}
var FBL *FirebaseApiSdk

func NewFirebaseApiSdk

func NewFirebaseApiSdk(baseURL string) *FirebaseApiSdk

func (*FirebaseApiSdk) CreateClientLicense

func (sdk *FirebaseApiSdk) CreateClientLicense(clientID string) (string, error)

func (*FirebaseApiSdk) RenewLicense

func (sdk *FirebaseApiSdk) RenewLicense(oldToken string) (string, int, error)

type HTTPConfig

type HTTPConfig struct {
	TLSCert                      string `validate:"omitempty,contains=\n`
	TLSKey                       string
	TLSKeyHostsCached            []string
	TLSValidUntil                time.Time
	AuthPrivateKey               string
	AuthPublicKey                string
	GenerateMissingAuthCert      bool
	HTTPSCertificateMode         string
	DNSChallengeProvider         string
	ForceHTTPSCertificateRenewal bool
	HTTPPort                     string `validate:"required,containsany=0123456789,min=1,max=6"`
	HTTPSPort                    string `validate:"required,containsany=0123456789,min=1,max=6"`
	ProxyConfig                  ProxyConfig
	Hostname                     string `validate:"required,excludesall=0x2C/ "`
	AllowHTTPLocalIPAccess       bool   `validate:"omitempty"`
	SSLEmail                     string `validate:"omitempty,email"`
	UseWildcardCertificate       bool
	OverrideWildcardDomains      string `validate:"omitempty,excludesall=/ "`
	AcceptAllInsecureHostname    bool
	DNSChallengeConfig           map[string]string `json:"DNSChallengeConfig,omitempty"`
	UseForwardedFor              bool
	AllowSearchEngine            bool
	PublishMDNS                  bool
}

type HTTPErrorResult

type HTTPErrorResult struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Code    string `json:"code"`
}

type HomepageConfig

type HomepageConfig struct {
	Background string
	Widgets    []string
	Expanded   bool
}

type LoggingLevel

type LoggingLevel string

type MarketConfig

type MarketConfig struct {
	Sources []MarketSource
}

type MarketSource

type MarketSource struct {
	Name string
	Url  string
}

type MyUser

type MyUser struct {
	Email        string
	Registration *registration.Resource
	// contains filtered or unexported fields
}

You'll need a user or account type that implements acme.User

func (*MyUser) GetEmail

func (u *MyUser) GetEmail() string

func (*MyUser) GetPrivateKey

func (u *MyUser) GetPrivateKey() crypto.PrivateKey

func (MyUser) GetRegistration

func (u MyUser) GetRegistration() *registration.Resource

type NebulaConfig added in v0.10.0

type NebulaConfig struct {
	PKI struct {
		CA        string   `yaml:"ca"`
		Cert      string   `yaml:"cert"`
		Key       string   `yaml:"key"`
		Blocklist []string `yaml:"blocklist"`
	} `yaml:"pki"`

	StaticHostMap map[string][]string `yaml:"static_host_map"`

	Lighthouse struct {
		AMLighthouse bool     `yaml:"am_lighthouse"`
		Interval     int      `yaml:"interval"`
		Hosts        []string `yaml:"hosts"`
	} `yaml:"lighthouse"`

	Listen struct {
		Host string `yaml:"host"`
		Port int    `yaml:"port"`
	} `yaml:"listen"`

	Punchy struct {
		Punch   bool `yaml:"punch"`
		Respond bool `yaml:"respond"`
	} `yaml:"punchy"`

	Relay struct {
		AMRelay   bool     `yaml:"am_relay"`
		UseRelays bool     `yaml:"use_relays"`
		Relays    []string `yaml:"relays"`
	} `yaml:"relay"`

	TUN struct {
		Disabled           bool     `yaml:"disabled"`
		Dev                string   `yaml:"dev"`
		DropLocalBroadcast bool     `yaml:"drop_local_broadcast"`
		DropMulticast      bool     `yaml:"drop_multicast"`
		TxQueue            int      `yaml:"tx_queue"`
		MTU                int      `yaml:"mtu"`
		Routes             []string `yaml:"routes"`
		UnsafeRoutes       []string `yaml:"unsafe_routes"`
	} `yaml:"tun"`

	Logging struct {
		Level  string `yaml:"level"`
		Format string `yaml:"format"`
	} `yaml:"logging"`

	Firewall struct {
		OutboundAction string                `yaml:"outbound_action"`
		InboundAction  string                `yaml:"inbound_action"`
		Conntrack      NebulaConntrackConfig `yaml:"conntrack"`
		Outbound       []NebulaFirewallRule  `yaml:"outbound"`
		Inbound        []NebulaFirewallRule  `yaml:"inbound"`
	} `yaml:"firewall"`
}

type NebulaConntrackConfig added in v0.10.0

type NebulaConntrackConfig struct {
	TCPTimeout     string `yaml:"tcp_timeout"`
	UDPTimeout     string `yaml:"udp_timeout"`
	DefaultTimeout string `yaml:"default_timeout"`
}

type NebulaFirewallRule added in v0.10.0

type NebulaFirewallRule struct {
	Port   string   `yaml:"port"`
	Proto  string   `yaml:"proto"`
	Host   string   `yaml:"host"`
	Groups []string `yaml:"groups,omitempty"omitempty"`
}

type NetworkStatus

type NetworkStatus struct {
	BytesSent uint64
	BytesRecv uint64
}

func GetNetworkUsage

func GetNetworkUsage() NetworkStatus

type Notification added in v0.12.0

type Notification struct {
	ID        primitive.ObjectID `bson:"_id,omitempty"`
	Title     string
	Message   string
	Vars      string
	Icon      string
	Link      string
	Date      time.Time
	Level     string
	Read      bool
	Recipient string
	Actions   []NotificationActions
}

type NotificationActions added in v0.12.0

type NotificationActions struct {
	Text string
	Link string
}

type OpenIDClient

type OpenIDClient struct {
	ID       string `json:"id"`
	Secret   string `json:"secret"`
	Redirect string `json:"redirect"`
}

type ProxyConfig

type ProxyConfig struct {
	Routes []ProxyRouteConfig
}

type ProxyMode

type ProxyMode string

type ProxyRouteConfig

type ProxyRouteConfig struct {
	Disabled                  bool                    `yaml:"disabled"`
	Name                      string                  `yaml:"name" validate:"required"`
	Description               string                  `yaml:"description,omitempty"`
	UseHost                   bool                    `yaml:"use_host"`
	Host                      string                  `yaml:"host,omitempty"`
	UsePathPrefix             bool                    `yaml:"use_path_prefix"`
	PathPrefix                string                  `yaml:"path_prefix,omitempty"`
	Timeout                   time.Duration           `yaml:"timeout"`
	ThrottlePerMinute         int                     `yaml:"throttle_per_minute"`
	CORSOrigin                string                  `yaml:"cors_origin,omitempty"`
	StripPathPrefix           bool                    `yaml:"strip_path_prefix"`
	MaxBandwith               int64                   `yaml:"max_bandwidth"`
	AuthEnabled               bool                    `yaml:"auth_enabled"`
	AdminOnly                 bool                    `yaml:"admin_only"`
	Target                    string                  `yaml:"target" validate:"required"`
	SmartShield               SmartShieldPolicy       `yaml:"smart_shield"`
	Mode                      ProxyMode               `yaml:"mode"`
	BlockCommonBots           bool                    `yaml:"block_common_bots"`
	BlockAPIAbuse             bool                    `yaml:"block_api_abuse"`
	AcceptInsecureHTTPSTarget bool                    `yaml:"accept_insecure_https_target"`
	HideFromDashboard         bool                    `yaml:"hide_from_dashboard"`
	DisableHeaderHardening    bool                    `yaml:"disable_header_hardening"`
	SpoofHostname             bool                    `yaml:"spoof_hostname"`
	AddionalFilters           []AddionalFiltersConfig `yaml:"additional_filters,omitempty"`
	RestrictToConstellation   bool                    `yaml:"restrict_to_constellation"`
	OverwriteHostHeader       string                  `yaml:"overwrite_host_header,omitempty"`
	WhitelistInboundIPs       []string                `yaml:"whitelist_inbound_ips,omitempty"`
	Icon                      string                  `yaml:"icon,omitempty"`
	TunnelVia                 string                  `yaml:"tunnel_via,omitempty"`
	TunneledHost              string                  `yaml:"tunneled_host,omitempty"`
}

type Role

type Role int

type SmartShieldPolicy

type SmartShieldPolicy struct {
	Enabled               bool    `yaml:"enabled"`
	PolicyStrictness      int     `yaml:"policy_strictness"`
	PerUserTimeBudget     float64 `yaml:"per_user_time_budget"`
	PerUserRequestLimit   int     `yaml:"per_user_request_limit"`
	PerUserByteLimit      int64   `yaml:"per_user_byte_limit"`
	PerUserSimultaneous   int     `yaml:"per_user_simultaneous"`
	MaxGlobalSimultaneous int     `yaml:"max_global_simultaneous"`
	PrivilegedGroups      int     `yaml:"privileged_groups"`
}

type SnapRAIDConfig added in v0.15.0

type SnapRAIDConfig struct {
	Name         string
	Enabled      bool
	Data         map[string]string
	Parity       []string
	SyncCrontab  string
	ScrubCrontab string
	CheckOnFix   bool
}

type StorageConfig added in v0.15.0

type StorageConfig struct {
	SnapRAIDs []SnapRAIDConfig
}

type ThemeConfig

type ThemeConfig struct {
	PrimaryColor   string
	SecondaryColor string
}

type User

type User struct {
	ID                    primitive.ObjectID `json:"-" bson:"_id,omitempty"`
	Nickname              string             `validate:"required" json:"nickname" bson:"Nickname"`
	Password              string             `validate:"required" json:"-" bson:"Password"`
	RegisterKey           string             `json:"registerKey" bson:"RegisterKey"`
	RegisterKeyExp        time.Time          `json:"registerKeyExp" bson:"RegisterKeyExp"`
	Role                  Role               `validate:"required" json:"role" bson:"Role"`
	PasswordCycle         int                `json:"-" bson:"PasswordCycle"`
	Link                  string             `json:"link" bson:"-"`
	Email                 string             `validate:"email" json:"email" bson:"Email"`
	RegisteredAt          time.Time          `json:"registeredAt" bson:"RegisteredAt"`
	LastPasswordChangedAt time.Time          `json:"lastPasswordChangedAt" bson:"LastPasswordChangedAt"`
	CreatedAt             time.Time          `json:"createdAt" bson:"CreatedAt"`
	LastLogin             time.Time          `json:"lastLogin" bson:"LastLogin"`
	MFAKey                string             `json:"-" bson:"MFAKey"`
	Was2FAVerified        bool               `json:"-" bson:"Was2FAVerified"`
	MFAState              int                `json:"-" bson:"-"`
}

func ListAllUsers added in v0.12.0

func ListAllUsers(role string) []User

Jump to

Keyboard shortcuts

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