aboutsummaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2022-01-01 17:08:39 +0000
committerOmar Polo <op@omarpolo.com>2022-01-01 17:08:39 +0000
commit7bdcc91ec70ddde092ac5d7b4f75d54915e7b221 (patch)
tree94066bd47c57b6610ae184e0e6c9b6a32cc440ad /parse.y
parentbd5f79542cf6491ed9e30bca926286e3b9e2600c (diff)
simplify the proxying code
it doesn't make any sense to keep the proxying info per-location: proxying only one per-vhost. It can't work differently, it doesn't make sense anyway.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y91
1 files changed, 48 insertions, 43 deletions
diff --git a/parse.y b/parse.y
index 154e3a5..db1ebb6 100644
--- a/parse.y
+++ b/parse.y
@@ -278,9 +278,57 @@ servopt : ALIAS string {
| PARAM string '=' string {
add_param($2, $4, 0);
}
+ | proxy
| locopt
;
+proxy : PROXY proxy_opt
+ | PROXY '{' optnl proxy_opts '}'
+ ;
+
+proxy_opts : /* empty */
+ | proxy_opts proxy_opt optnl
+ ;
+
+proxy_opt : CERT string {
+ struct proxy *p = &host->proxy;
+
+ only_once(p->cert, "proxy cert");
+ ensure_absolute_path($2);
+ p->cert = tls_load_file($2, &p->certlen, NULL);
+ if (p->cert == NULL)
+ yyerror("can't load cert %s", $2);
+ }
+ | KEY string {
+ struct proxy *p = &host->proxy;
+
+ only_once(p->key, "proxy key");
+ ensure_absolute_path($2);
+ p->key = tls_load_file($2, &p->keylen, NULL);
+ if (p->key == NULL)
+ yyerror("can't load key %s", $2);
+ }
+ | RELAY_TO string {
+ char *at;
+ const char *errstr;
+ struct proxy *p = &host->proxy;
+
+ only_once(p->host, "proxy relay-to");
+ p->host = $2;
+
+ if ((at = strchr($2, ':')) != NULL) {
+ *at++ = '\0';
+ p->port = at;
+ } else
+ p->port = "1965";
+
+ strtonum(p->port, 1, UINT16_MAX, &errstr);
+ if (errstr != NULL)
+ yyerror("proxy port is %s: %s", errstr,
+ p->port);
+ }
+ ;
+
locations : /* empty */
| locations location optnl
;
@@ -330,7 +378,6 @@ locopt : AUTO INDEX bool { loc->auto_index = $3 ? 1 : -1; }
loc->lang = $2;
}
| LOG bool { loc->disable_log = !$2; }
- | proxy
| REQUIRE CLIENT CA string {
only_once(loc->reqca, "require client ca");
ensure_absolute_path($4);
@@ -345,48 +392,6 @@ locopt : AUTO INDEX bool { loc->auto_index = $3 ? 1 : -1; }
| STRIP NUM { loc->strip = check_strip_no($2); }
;
-proxy : PROXY proxy_opt
- | PROXY '{' optnl proxy_opts '}'
- ;
-
-proxy_opts : /* empty */
- | proxy_opts proxy_opt optnl
- ;
-
-proxy_opt : CERT string {
- only_once(loc->proxy_cert, "proxy cert");
- ensure_absolute_path($2);
- loc->proxy_cert = tls_load_file($2, &loc->proxy_cert_len, NULL);
- if (loc->proxy_cert == NULL)
- yyerror("can't load cert %s", $2);
- }
- | KEY string {
- only_once(loc->proxy_key, "proxy key");
- ensure_absolute_path($2);
- loc->proxy_key = tls_load_file($2, &loc->proxy_key_len, NULL);
- if (loc->proxy_key == NULL)
- yyerror("can't load key %s", $2);
- }
- | RELAY_TO string {
- char *at;
- const char *errstr;
-
- only_once(loc->proxy_host, "proxy relay-to");
- loc->proxy_host = $2;
-
- if ((at = strchr($2, ':')) != NULL) {
- *at++ = '\0';
- loc->proxy_port = at;
- } else
- loc->proxy_port = "1965";
-
- strtonum(loc->proxy_port, 1, UINT16_MAX, &errstr);
- if (errstr != NULL)
- yyerror("proxy port is %s: %s", errstr,
- loc->proxy_port);
- }
- ;
-
fastcgi : SPAWN string {
only_oncei(loc->fcgi, "fastcgi");
loc->fcgi = fastcgi_conf(NULL, NULL, $2);