diff --git a/parser/lexer.go b/parser/lexer.go index ab37800..52912e4 100644 --- a/parser/lexer.go +++ b/parser/lexer.go @@ -8,6 +8,7 @@ import ( "os" "regexp" "strconv" + "strings" "text/scanner" "unicode" @@ -278,6 +279,15 @@ func (l *Lexer) run() { token = IP_CIDR } + // IPADDR_RANGE(XXX.YYY.ZZZ.WWW-VVV) + if ss := strings.Split(s, "-"); len(ss) == 2 { + if net.ParseIP(ss[0]) != nil { + if ok, _ := regexp.MatchString(`^[\d]{1,3}$`, ss[1]); ok { + token = IPADDR_RANGE + } + } + } + if ok, _ := regexp.MatchString("[[:xdigit:]]{32}", s); ok { token = HEX32 } diff --git a/parser/parser.go.y b/parser/parser.go.y index 12b2f57..96689af 100644 --- a/parser/parser.go.y +++ b/parser/parser.go.y @@ -8,7 +8,7 @@ package parser }; %token NUMBER -%token ID STRING EMAIL IPADDR IP_CIDR HEX32 PATHSTR +%token ID STRING EMAIL IPADDR IP_CIDR IPADDR_RANGE HEX32 PATHSTR %token LB RB %token GLOBALDEFS %token NOTIFICATION_EMAIL NOTIFICATION_EMAIL_FROM SMTP_SERVER SMTP_CONNECT_TIMEOUT ROUTER_ID LVS_ID @@ -150,7 +150,7 @@ virtual_server_group_statements: virtual_server_group_statement virtual_server_g virtual_server_group_statement: { } | IPADDR NUMBER { } -| IP_CIDR NUMBER { } +| IPADDR_RANGE NUMBER { } | FWMARK NUMBER { } virtual_server_block: VIRTUAL_SERVER iporfw LB virtual_server_statements RB