Documentation
¶
Index ¶
- Constants
- Variables
- func Access(access int) string
- func ByteCountIEC(b uint64) string
- func CheckInternalError(err error, w *http.ResponseWriter) bool
- func Check_email(email string) error
- func Check_password(password string) error
- func Check_security(security *[]models.Account_security) error
- func Check_username(username string) error
- func DropJWT(w http.ResponseWriter, claimsId string)
- func Format(n int) string
- func GetPublicIP() string
- func GetUser() string
- func Intel_Init(whitelist []string) error
- func IssueJWT(acct *models.Account, w http.ResponseWriter)
- func LoadTails()
- func RandString(n int, source string) string
- func RefreshJWT(claims *Claims, w http.ResponseWriter)
- func Setup_logging()
- func Sifplurral(input int) string
- type Claims
- type EnvVar
- type GDLEMonitorConf
- type GDLEMonitorConfig_Dynamic
- type IP_Result
- type Persistance
- func (per *Persistance) HeartBeat()
- func (per *Persistance) Intel_Cleanup()
- func (per *Persistance) JWTKeys_Cleanup()
- func (per *Persistance) JWTState_Add(claims *Claims)
- func (per *Persistance) JWTState_Cleanup()
- func (per *Persistance) JWTState_Del(Id string)
- func (per *Persistance) New() *Persistance
- func (per *Persistance) Pull_ip(ip string) *IP_Result
- func (per *Persistance) Read() bool
- func (per *Persistance) UserLimiter_Cleanup()
- func (per *Persistance) UserrateLimiter_Get(ip string) *Userlimiter
- func (per *Persistance) Write()
- type TLSCert
- type Userlimiter
Constants ¶
const HTTPCookieBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#$%&'()*+-./:<>?@[]^_`{|}~"
const HexBytes = "0123456789abcdef"
const JWT_key_change_interval int64 = 1800 // seconds
JWT Key - these are server-wide keys, used to digitally sign and validate tokens. Internally
const JWT_state_lifetime int64 = 1800 // seconds
const JWTkeyBytes = " !#$%&()*+,-./0123456789:;<=>?&ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}"
const SQLpasswordBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
const URLBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_~!$&'()*+,;=:@"
Variables ¶
var ( IP_whitelist []*net.IPNet Intel_httpClient http.Client = http.Client{Timeout: 10 * time.Second} )
var ( InfoLog *log.Logger ErrorLog *log.Logger DebugLog *log.Logger EWInfo *eWInfo EWError *eWError EWDebug *eWDebug )
var Elog debug.Log
var ISDebug bool = false
var WD string
Functions ¶
func ByteCountIEC ¶
func CheckInternalError ¶
func CheckInternalError(err error, w *http.ResponseWriter) bool
if err != nil, writes http 500 with err.Error(), return true if no error, return false
func Check_email ¶
func Check_password ¶
func Check_security ¶
func Check_security(security *[]models.Account_security) error
func Check_username ¶
func DropJWT ¶
func DropJWT(w http.ResponseWriter, claimsId string)
func GetPublicIP ¶
func GetPublicIP() string
////////////////////////////////////////////////////////////// returns public ip address. on error, it returns 0.0.0.0
func Intel_Init ¶
Should be called before GetResult, to parse the default whitelist, and validate contact email
func RandString ¶
func RefreshJWT ¶
func RefreshJWT(claims *Claims, w http.ResponseWriter)
func Setup_logging ¶
func Setup_logging()
func Sifplurral ¶
Types ¶
type Claims ¶
type Claims struct {
models.Claim
jwt.StandardClaims
}
func GetJWTClaims ¶
func GetJWTClaims(w http.ResponseWriter, r *http.Request) *Claims
func VerifyAccess ¶
////////////////////////////////////////////////////////////// verify access level returns authenticated claims struct, if access level is >= reqLevel. returns nil if access level < reqLevel returns nil if client has no claims if reqLevel >= 0, sends HTTP 401
type GDLEMonitorConf ¶
type GDLEMonitorConf struct {
Gdle struct {
Config string `json:"config"`
Logs []string `json:"logs"`
} `json:"gdle"`
Heartbeat int `json:"heartbeat"`
BindIP string `json:"bind_ip"`
DomainName string `json:"domain_name"`
DomainContact string `json:"domain_contact"`
ENV map[string]string `json:"env"`
SpamAddress string `json:"spam_address"`
Whitelist []string `json:"whitelist"`
API struct {
Port int `json:"port"`
RedirectNonsecurePort bool `json:"redirect_nonsecure_port"`
AccountLimitEmail int `json:"account_limit_email"`
AccountLimitIP int `json:"account_limit_ip"`
AccountSQMax int `json:"account_sq_max"`
AccountSQMin int `json:"account_sq_min"`
AccountRequireEmail bool `json:"require_email"`
AccountLimitProxy bool `json:"account_limit_proxy"`
LoginLimitProxy bool `json:"login_limit_proxy"`
} `json:"api"`
}
type GDLEMonitorConfig_Dynamic ¶
type GDLEMonitorConfig_Dynamic struct {
Origin string `json:"origin"` // set in service.go@gdlemonitormain(), used in templating, API ref, javascript
ACServerName string `json:"title"` // set in service.go@readServerConfig(), used in templating, API ref, javascript
ACServer string `json:"ac_server"` // set in service.go@readServerConfig()(), used in templating, API ref, javascript
PublicIP string `json:"public_ip"` // set in service.go@gdlemonitormain(), used in templating, API ref, javascript, domain, tls certs
}
type IP_Result ¶
type IP_Result struct {
LastChecked time.Time `json:"last_checked"`
ContinentCode string `json:"continentCode"`
CountryCode string `json:"countryCode"`
Region string `json:"region"`
City string `json:"city"`
Lat float64 `json:"lat"`
Lon float64 `json:"lon"`
Offset int `json:"offset"`
Reverse string `json:"reverse"`
Mobile bool `json:"mobile"`
Proxy bool `json:"proxy"`
Hosting bool `json:"hosting"`
}
type Persistance ¶
type Persistance struct {
C GDLEMonitorConf `json:"config"`
Cd GDLEMonitorConfig_Dynamic `json:"conf"`
GDLEcfg map[string]interface{} `json:"gdle"`
GDLEcfg_ts time.Time `json:"gdle_ts"`
Dirty bool `json:"-"`
JWTKeys map[string]string `json:"jwt_keys"`
JWTKeys_m sync.Mutex `json:"-"`
JWTState map[string]*Claims `json:"jwt_state"`
JWTState_m sync.Mutex `json:"-"`
IP map[string]*IP_Result `json:"ip"`
IP_m sync.Mutex `json:"-"`
UserLimiter map[string]*Userlimiter `json:"-"`
UserLimiter_m sync.Mutex `json:"-"`
GlobalLimiter *ratelimit.Bucket `json:"-"`
TLS map[string]*TLSCert `json:"tls"`
TLS_m sync.Mutex `json:"-"`
}
var P *Persistance
////////////////////////////////////////////////////////////// Persistance Cache in-memory database, with periodic marshals to json mostly to persist state for development; most can be nulled in production. //////////////////////////////////////////////////////////////
func (*Persistance) HeartBeat ¶
func (per *Persistance) HeartBeat()
split up the various types into their own cleanup routines.
func (*Persistance) Intel_Cleanup ¶
func (per *Persistance) Intel_Cleanup()
func (*Persistance) JWTKeys_Cleanup ¶
func (per *Persistance) JWTKeys_Cleanup()
func (*Persistance) JWTState_Add ¶
func (per *Persistance) JWTState_Add(claims *Claims)
func (*Persistance) JWTState_Cleanup ¶
func (per *Persistance) JWTState_Cleanup()
func (*Persistance) JWTState_Del ¶
func (per *Persistance) JWTState_Del(Id string)
func (*Persistance) New ¶
func (per *Persistance) New() *Persistance
func (*Persistance) Pull_ip ¶
func (per *Persistance) Pull_ip(ip string) *IP_Result
Internal getResult
func (*Persistance) Read ¶
func (per *Persistance) Read() bool
func (*Persistance) UserLimiter_Cleanup ¶
func (per *Persistance) UserLimiter_Cleanup()
func (*Persistance) UserrateLimiter_Get ¶
func (per *Persistance) UserrateLimiter_Get(ip string) *Userlimiter
func (*Persistance) Write ¶
func (per *Persistance) Write()
type TLSCert ¶
type TLSCert struct {
Subject string `json:"subject"`
Provider string `json:"provider"`
Domain []string `json:"domain"`
IP []net.IP `json:"ip"`
CRT []byte `json:"crt"`
KEY []byte `json:"key"`
Serial int64 `json:"serial"`
Iss time.Time `json:"iss"`
Exp time.Time `json:"exp"`
Tls *tls.Certificate `json:"-"`
}