|
66 | 66 | #define PASSWORD "([^@]*)" |
67 | 67 | #define IP "((([0-9]{1,3})\\.){3}[0-9]{1,3})" |
68 | 68 | #define IPMASK "(" IP "(/" DIGIT "+)?)" |
| 69 | +#define IPV6SCOPE "((%[^ \t\\/]{1,16})?)" |
69 | 70 | #define IPV6 "(" \ |
70 | | - "(([0-9a-f:]{2,39}))|" \ |
71 | | - "(([0-9a-f:]{0,29}:" IP "))" \ |
| 71 | + "([0-9a-f:]{2,39})" IPV6SCOPE "|" \ |
| 72 | + "([0-9a-f:]{0,29}:" IP ")" IPV6SCOPE \ |
72 | 73 | ")" |
73 | 74 |
|
74 | 75 | #define IPV6MASK "(" IPV6 "(/" DIGIT "+)?)" |
|
80 | 81 | * number. Given the usual structure of the configuration file, sixteen |
81 | 82 | * substring matches should be plenty. |
82 | 83 | */ |
83 | | -#define RE_MAX_MATCHES 24 |
| 84 | +#define RE_MAX_MATCHES 33 |
84 | 85 |
|
85 | 86 | #define CP_WARN(FMT, ...) \ |
86 | 87 | log_message (LOG_WARNING, "line %lu: " FMT, lineno, __VA_ARGS__) |
@@ -249,7 +250,7 @@ struct { |
249 | 250 | "(" "(none)" WS STR ")|" \ |
250 | 251 | "(" "(http|socks4|socks5)" WS \ |
251 | 252 | "(" USERNAME /*username*/ ":" PASSWORD /*password*/ "@" ")?" |
252 | | - "(" IP "|" ALNUM ")" |
| 253 | + "(" IP "|" "\\[(" IPV6 ")\\]" "|" ALNUM ")" |
253 | 254 | ":" INT "(" WS STR ")?" ")", handle_upstream), |
254 | 255 | #endif |
255 | 256 | /* loglevel */ |
@@ -1114,10 +1115,13 @@ static HANDLE_FUNC (handle_upstream) |
1114 | 1115 | pass = get_string_arg (line, &match[mi]); |
1115 | 1116 | mi++; |
1116 | 1117 |
|
1117 | | - ip = get_string_arg (line, &match[mi]); |
| 1118 | + if (match[mi+4].rm_so != -1) /* IPv6 address in square brackets */ |
| 1119 | + ip = get_string_arg (line, &match[mi+4]); |
| 1120 | + else |
| 1121 | + ip = get_string_arg (line, &match[mi]); |
1118 | 1122 | if (!ip) |
1119 | 1123 | return -1; |
1120 | | - mi += 5; |
| 1124 | + mi += 16; |
1121 | 1125 |
|
1122 | 1126 | port = (int) get_long_arg (line, &match[mi]); |
1123 | 1127 | mi += 3; |
|
0 commit comments