Documentation
¶
Overview ¶
Package parserconfig provides canonical configuration types for HAProxy parsing.
This package defines StructuredConfig - the single source of truth for parsed HAProxy configurations. Both CE and EE parsers return this type.
Index ¶
Constants ¶
const ( FilterTypeWAF = "waf" FilterTypeBotMgmt = "botmgmt" )
EE filter type constants.
const ( ActionWAFEvaluate = "waf-evaluate" ActionBotMgmtEvaluate = "botmgmt-evaluate" )
EE http-request action type constants.
const ( DirectiveMaxmindLoad = "maxmind-load" DirectiveMaxmindCacheSize = "maxmind-cache-size" DirectiveWAFLoad = "waf-load" )
EE global directive type constants.
const ( KeywordProfile = "profile" KeywordLearning = "learning" KeywordIf = "if" KeywordUnless = "unless" )
Common keyword constants.
Variables ¶
This section is empty.
Functions ¶
func BuildGroupIndex ¶
BuildGroupIndex builds a pointer index from a slice of groups. Returns nil if the input slice is nil.
Types ¶
type EEBackendData ¶
type EEBackendData struct {
Filters []*EEFilter
HTTPRequests []*EEHTTPRequestAction
}
EEBackendData holds EE-specific directives parsed from a backend section.
type EEFilter ¶
type EEFilter struct {
// Type is the filter type: "waf" or "botmgmt"
Type string
// Name is the filter instance name (for WAF filters)
Name string
// Profile is the profile reference (for botmgmt filters)
Profile string
// RulesFile is the path to rules file (for WAF filters)
RulesFile string
// Learning enables learning mode for WAF filters
Learning bool
// LogEnabled enables logging for the filter
LogEnabled bool
// Comment is the inline comment
Comment string
}
EEFilter represents an Enterprise Edition filter directive.
type EEFrontendData ¶
type EEFrontendData struct {
Filters []*EEFilter
HTTPRequests []*EEHTTPRequestAction
}
EEFrontendData holds EE-specific directives parsed from a frontend section.
type EEGlobalData ¶
type EEGlobalData struct {
Directives []*EEGlobalDirective
}
EEGlobalData holds EE-specific directives parsed from the global section.
type EEGlobalDirective ¶
type EEGlobalDirective struct {
// Type is the directive type: "maxmind-load", "maxmind-cache-size", etc.
Type string
// Parts contains the directive arguments
Parts []string
// Comment is the inline comment
Comment string
}
EEGlobalDirective represents an Enterprise Edition global directive.
type EEHTTPRequestAction ¶
type EEHTTPRequestAction struct {
// Type is the action type: "waf-evaluate" or "botmgmt-evaluate"
Type string
// Profile is the profile name for the action
Profile string
// Cond is the condition type: "if" or "unless"
Cond string
// CondTest is the ACL condition expression
CondTest string
// Comment is the inline comment
Comment string
}
EEHTTPRequestAction represents an Enterprise Edition http-request action.
type StructuredConfig ¶
type StructuredConfig struct {
Global *models.Global
Defaults []*models.Defaults
Frontends []*models.Frontend
Backends []*models.Backend
Peers []*models.PeerSection
Resolvers []*models.Resolver
Mailers []*models.MailersSection
Caches []*models.Cache
Rings []*models.Ring
HTTPErrors []*models.HTTPErrorsSection
Userlists []*models.Userlist
Programs []*models.Program
LogForwards []*models.LogForward
FCGIApps []*models.FCGIApp
CrtStores []*models.CrtStore
// Observability sections (v3.1+ features)
LogProfiles []*models.LogProfile // log-profile sections
Traces *models.Traces // traces section (singleton)
// Certificate automation (v3.2+ features)
AcmeProviders []*models.AcmeProvider // acme sections for Let's Encrypt/ACME automation
UDPLBs []*v32ee.UdpLbBase // udp-lb sections
WAFGlobal *v32ee.WafGlobal // waf-global section (singleton)
WAFProfiles []*v32ee.WafProfile // waf-profile sections
BotMgmtProfiles []*v32ee.BotmgmtProfile // botmgmt-profile sections
Captchas []*v32ee.Captcha // captcha sections
// EEFrontends maps frontend name to EE-specific directive data.
// Contains filter waf/botmgmt, http-request waf-evaluate/botmgmt-evaluate, etc.
EEFrontends map[string]*EEFrontendData
// EEBackends maps backend name to EE-specific directive data.
EEBackends map[string]*EEBackendData
// EEGlobal holds EE-specific directives from the global section.
// Contains maxmind-load, maxmind-cache-size, etc.
EEGlobal *EEGlobalData
// ServerIndex maps backend name -> server name -> server pointer
ServerIndex map[string]map[string]*models.Server
// ServerTemplateIndex maps backend name -> template prefix -> server template pointer
ServerTemplateIndex map[string]map[string]*models.ServerTemplate
// BindIndex maps frontend name -> bind name -> bind pointer
BindIndex map[string]map[string]*models.Bind
// PeerEntryIndex maps peer section name -> peer entry name -> peer entry pointer
PeerEntryIndex map[string]map[string]*models.PeerEntry
// NameserverIndex maps resolver name -> nameserver name -> nameserver pointer
NameserverIndex map[string]map[string]*models.Nameserver
// MailerEntryIndex maps mailers section name -> mailer entry name -> mailer entry pointer
MailerEntryIndex map[string]map[string]*models.MailerEntry
// UserIndex maps userlist name -> username -> user pointer
UserIndex map[string]map[string]*models.User
// GroupIndex maps userlist name -> group name -> group pointer
GroupIndex map[string]map[string]*models.Group
}
StructuredConfig holds all parsed configuration sections.
This is the canonical configuration type used by both CE and EE parsers. CE parser populates standard fields, leaving EE fields nil. EE parser populates all fields including enterprise-specific ones.
Usage:
// CE parsing ceParser, _ := parser.New() config, _ := ceParser.ParseFromString(configStr) // config.WAFProfiles is nil, config.EEFrontends is nil // EE parsing eeParser := enterprise.NewParser() config, _ := eeParser.ParseFromString(configStr) // config.WAFProfiles and config.EEFrontends are populated