diff options
-rw-r--r-- | contrib/example.conf | 4 | ||||
-rw-r--r-- | src/cfg_parser.rl | 25 |
2 files changed, 16 insertions, 13 deletions
diff --git a/contrib/example.conf b/contrib/example.conf index 647fd44..161090e 100644 --- a/contrib/example.conf +++ b/contrib/example.conf @@ -2,10 +2,10 @@ listen * 8000 { remote: www.google.at 80; remote-resolv: ipv6; - source: 2a02:3e0:2002:1:215:58ff:fe31:2ce7; + source: 2a02:3e0:2002:1:218:deff:fe03:ed; }; -listen 2a02:3e0:2002:1:215:58ff:fe31:2ce7 xmpp-server +listen 2a02:3e0:2002:1:218:deff:fe03:ed xmpp-server { remote: www.google.at www; remote-resolv: ipv4; diff --git a/src/cfg_parser.rl b/src/cfg_parser.rl index 76fcf08..07027f7 100644 --- a/src/cfg_parser.rl +++ b/src/cfg_parser.rl @@ -110,6 +110,14 @@ static int owrt_string(char** dest, char* start, char* end) ret = listeners_add(listener, lst.la_, lst.lrt_, lst.lp_, lst.ra_, lst.rrt_, lst.rp_, lst.sa_); clear_listener_struct(&lst); } + action logerror { + if(fpc == eof) + log_printf(ERROR, "config file syntax error: unexpected end of file"); + else + log_printf(ERROR, "config file syntax error at line %d", cur_line); + + fgoto *cfg_parser_error; + } newline = '\n' @{cur_line++;}; ws = [ \t]; @@ -145,7 +153,7 @@ static int owrt_string(char** dest, char* start, char* end) listen_head = 'listen' ws+ local_addr ws+ local_port; listen_body = '{' ( ign+ | resolv | remote | remote_resolv | source )* '};' @add_listener; - main := ( listen_head ign* listen_body | ign+ )*; + main := ( listen_head ign* listen_body | ign+ )* $!logerror; }%% @@ -159,22 +167,17 @@ int parse_listener(char* p, char* pe, listeners_t* listener) char* cpy_start = NULL; struct listener lst; init_listener_struct(&lst); - + char* eof = pe; %% write exec; - + if(cs == cfg_parser_error) { - log_printf(ERROR, "config file syntax error at line %d", cur_line); listeners_revert(listener); ret = 1; - } else if(cs != cfg_parser_first_final) { - // we only have one file so if we aren't there something is wrong - log_printf(ERROR, "config file syntax error: unexpected end of file"); - listeners_revert(listener); - ret = 1; - } else + } + else ret = listeners_update(listener); - + clear_listener_struct(&lst); return ret; |