Skip to content

Commit

Permalink
Enable to parse IPADDR_RANGE
Browse files Browse the repository at this point in the history
  • Loading branch information
yuuki committed Jan 25, 2016
1 parent 4fd79d0 commit 0a307e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions parser/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"regexp"
"strconv"
"strings"
"text/scanner"
"unicode"

Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions parser/parser.go.y
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package parser
};

%token <integer> NUMBER
%token <symbol> ID STRING EMAIL IPADDR IP_CIDR HEX32 PATHSTR
%token <symbol> 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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0a307e9

Please sign in to comment.