diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-11-21 14:12:05 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-11-21 14:12:05 +0000 |
commit | b55935b72e33d89ef3252cc43a95ee4a1ef6e67c (patch) | |
tree | c474f5e7d39f992abb5c51fc891077d40e7ccb5d | |
parent | be5ab7bfe39ae355eec8a4dac9d734f6a8650924 (diff) |
rename the "url" filter action to "query" to use the correct term.
please update your hoststated.conf configurations. also add more
examples to the manpage.
alright pyr@
-rw-r--r-- | usr.sbin/hoststated/hoststated.conf.5 | 22 | ||||
-rw-r--r-- | usr.sbin/hoststated/hoststated.h | 6 | ||||
-rw-r--r-- | usr.sbin/hoststated/parse.y | 12 | ||||
-rw-r--r-- | usr.sbin/hoststated/relay.c | 16 | ||||
-rw-r--r-- | usr.sbin/relayd/parse.y | 12 | ||||
-rw-r--r-- | usr.sbin/relayd/relay.c | 16 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.conf.5 | 22 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 6 |
8 files changed, 72 insertions, 40 deletions
diff --git a/usr.sbin/hoststated/hoststated.conf.5 b/usr.sbin/hoststated/hoststated.conf.5 index 8ebf4f306e5..66e260a8cb2 100644 --- a/usr.sbin/hoststated/hoststated.conf.5 +++ b/usr.sbin/hoststated/hoststated.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: hoststated.conf.5,v 1.59 2007/11/21 13:04:42 reyk Exp $ +.\" $OpenBSD: hoststated.conf.5,v 1.60 2007/11/21 14:12:04 reyk Exp $ .\" .\" Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> .\" Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -547,12 +547,26 @@ Look up the entity as a value in the URL path when using the protocol. This type is only available with the direction .Ic request . -.It Ic url -Look up the entity as a GET variable in the URL when using the +The +.Ar key +will match the path of the requested URL without the hostname +and query and the value will match the complete query, +for example: +.Bd -literal -offset indent +request path filter "*" from "/index.html" +request path filter "foo=bar*" from "/cgi-bin/t.cgi" +.Ed +.It Ic query +Look up the entity as a query variable in the URL when using the .Ic http protocol. This type is only available with the direction -.Ic request . +.Ic request , +for example: +.Bd -literal -offset indent +# Will match /cgi-bin/example.pl?foo=bar&ok=yes +request query expect "bar" from "foo" +.Ed .El .Pp The following actions are available: diff --git a/usr.sbin/hoststated/hoststated.h b/usr.sbin/hoststated/hoststated.h index 9f092475756..6b1a5d3a63c 100644 --- a/usr.sbin/hoststated/hoststated.h +++ b/usr.sbin/hoststated/hoststated.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hoststated.h,v 1.77 2007/11/21 13:04:42 reyk Exp $ */ +/* $OpenBSD: hoststated.h,v 1.78 2007/11/21 14:12:04 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -434,7 +434,7 @@ enum nodeaction { enum nodetype { NODE_TYPE_HEADER = 0, - NODE_TYPE_URL = 1, + NODE_TYPE_QUERY = 1, NODE_TYPE_COOKIE = 2, NODE_TYPE_PATH = 3 }; @@ -442,7 +442,7 @@ enum nodetype { #define PNFLAG_MACRO 0x01 #define PNFLAG_MARK 0x02 #define PNFLAG_LOG 0x04 -#define PNFLAG_LOOKUP_URL 0x08 +#define PNFLAG_LOOKUP_QUERY 0x08 #define PNFLAG_LOOKUP_COOKIE 0x10 enum noderesult { diff --git a/usr.sbin/hoststated/parse.y b/usr.sbin/hoststated/parse.y index e5ddea110a2..fda997e730e 100644 --- a/usr.sbin/hoststated/parse.y +++ b/usr.sbin/hoststated/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.88 2007/11/21 13:04:42 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.89 2007/11/21 14:12:04 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -121,7 +121,7 @@ typedef struct { %token SEND EXPECT NOTHING SSL LOADBALANCE ROUNDROBIN CIPHERS COOKIE %token RELAY LISTEN ON FORWARD TO NAT LOOKUP PREFORK NO MARK MARKED %token PROTO SESSION CACHE APPEND CHANGE REMOVE FROM FILTER HASH HEADER -%token LOG UPDATES ALL DEMOTE NODELAY SACK SOCKET BUFFER URL RETRY IP +%token LOG UPDATES ALL DEMOTE NODELAY SACK SOCKET BUFFER QUERYSTR RETRY IP %token ERROR %token <v.string> STRING %token <v.number> NUMBER @@ -747,8 +747,8 @@ protoptsl : SSL sslflags RB_INSERT(proto_tree, tree, pn); } switch (node.type) { - case NODE_TYPE_URL: - pn->flags |= PNFLAG_LOOKUP_URL; + case NODE_TYPE_QUERY: + pn->flags |= PNFLAG_LOOKUP_QUERY; break; case NODE_TYPE_COOKIE: pn->flags |= PNFLAG_LOOKUP_COOKIE; @@ -927,7 +927,7 @@ marked : /* empty */ nodetype : HEADER { node.type = NODE_TYPE_HEADER; } - | URL { node.type = NODE_TYPE_URL; } + | QUERYSTR { node.type = NODE_TYPE_QUERY; } | COOKIE { node.type = NODE_TYPE_COOKIE; } @@ -1297,6 +1297,7 @@ lookup(char *s) { "port", PORT }, { "prefork", PREFORK }, { "protocol", PROTO }, + { "query", QUERYSTR }, { "real", REAL }, { "relay", RELAY }, { "remove", REMOVE }, @@ -1320,7 +1321,6 @@ lookup(char *s) { "timeout", TIMEOUT }, { "to", TO }, { "updates", UPDATES }, - { "url", URL }, { "virtual", VIRTUAL } }; const struct keywords *p; diff --git a/usr.sbin/hoststated/relay.c b/usr.sbin/hoststated/relay.c index 4553adb4a3a..2c581edda84 100644 --- a/usr.sbin/hoststated/relay.c +++ b/usr.sbin/hoststated/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.61 2007/11/21 11:06:21 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.62 2007/11/21 14:12:04 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -281,14 +281,17 @@ relay_shutdown(void) void relay_nodedebug(const char *name, struct protonode *pn) { + if (pn->action == NODE_ACTION_NONE) + return; + fprintf(stderr, "\t\t"); fprintf(stderr, "%s ", name); switch (pn->type) { case NODE_TYPE_HEADER: break; - case NODE_TYPE_URL: - fprintf(stderr, "url "); + case NODE_TYPE_QUERY: + fprintf(stderr, "query "); break; case NODE_TYPE_COOKIE: fprintf(stderr, "cookie "); @@ -326,7 +329,6 @@ relay_nodedebug(const char *name, struct protonode *pn) fprintf(stderr, "log \"%s\"", pn->key); break; case NODE_ACTION_NONE: - fprintf(stderr, "none \"%s\"", pn->key); break; } fprintf(stderr, "\n"); @@ -1296,7 +1298,7 @@ relay_read_http(struct bufferevent *bev, void *arg) cre->method = HTTP_METHOD_CONNECT; /* - * Decode the URL + * Decode the path and query */ cre->path = strdup(pk.value); if (cre->path == NULL) { @@ -1374,7 +1376,7 @@ relay_read_http(struct bufferevent *bev, void *arg) if (cre->dir == RELAY_DIR_RESPONSE) goto handle; - if (pn->flags & PNFLAG_LOOKUP_URL) { + if (pn->flags & PNFLAG_LOOKUP_QUERY) { if (cre->path == NULL || cre->args == NULL || strlen(cre->args) < 2 || (val = strdup(cre->args)) == NULL) @@ -1382,7 +1384,7 @@ relay_read_http(struct bufferevent *bev, void *arg) ptr = val; while (ptr != NULL && strlen(ptr)) { pkv.key = ptr; - pkv.type = NODE_TYPE_URL; + pkv.type = NODE_TYPE_QUERY; if ((ptr = strchr(ptr, '&')) != NULL) *ptr++ = '\0'; if ((pkv.value = diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y index e5ddea110a2..fda997e730e 100644 --- a/usr.sbin/relayd/parse.y +++ b/usr.sbin/relayd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.88 2007/11/21 13:04:42 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.89 2007/11/21 14:12:04 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -121,7 +121,7 @@ typedef struct { %token SEND EXPECT NOTHING SSL LOADBALANCE ROUNDROBIN CIPHERS COOKIE %token RELAY LISTEN ON FORWARD TO NAT LOOKUP PREFORK NO MARK MARKED %token PROTO SESSION CACHE APPEND CHANGE REMOVE FROM FILTER HASH HEADER -%token LOG UPDATES ALL DEMOTE NODELAY SACK SOCKET BUFFER URL RETRY IP +%token LOG UPDATES ALL DEMOTE NODELAY SACK SOCKET BUFFER QUERYSTR RETRY IP %token ERROR %token <v.string> STRING %token <v.number> NUMBER @@ -747,8 +747,8 @@ protoptsl : SSL sslflags RB_INSERT(proto_tree, tree, pn); } switch (node.type) { - case NODE_TYPE_URL: - pn->flags |= PNFLAG_LOOKUP_URL; + case NODE_TYPE_QUERY: + pn->flags |= PNFLAG_LOOKUP_QUERY; break; case NODE_TYPE_COOKIE: pn->flags |= PNFLAG_LOOKUP_COOKIE; @@ -927,7 +927,7 @@ marked : /* empty */ nodetype : HEADER { node.type = NODE_TYPE_HEADER; } - | URL { node.type = NODE_TYPE_URL; } + | QUERYSTR { node.type = NODE_TYPE_QUERY; } | COOKIE { node.type = NODE_TYPE_COOKIE; } @@ -1297,6 +1297,7 @@ lookup(char *s) { "port", PORT }, { "prefork", PREFORK }, { "protocol", PROTO }, + { "query", QUERYSTR }, { "real", REAL }, { "relay", RELAY }, { "remove", REMOVE }, @@ -1320,7 +1321,6 @@ lookup(char *s) { "timeout", TIMEOUT }, { "to", TO }, { "updates", UPDATES }, - { "url", URL }, { "virtual", VIRTUAL } }; const struct keywords *p; diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index 4553adb4a3a..2c581edda84 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.61 2007/11/21 11:06:21 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.62 2007/11/21 14:12:04 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -281,14 +281,17 @@ relay_shutdown(void) void relay_nodedebug(const char *name, struct protonode *pn) { + if (pn->action == NODE_ACTION_NONE) + return; + fprintf(stderr, "\t\t"); fprintf(stderr, "%s ", name); switch (pn->type) { case NODE_TYPE_HEADER: break; - case NODE_TYPE_URL: - fprintf(stderr, "url "); + case NODE_TYPE_QUERY: + fprintf(stderr, "query "); break; case NODE_TYPE_COOKIE: fprintf(stderr, "cookie "); @@ -326,7 +329,6 @@ relay_nodedebug(const char *name, struct protonode *pn) fprintf(stderr, "log \"%s\"", pn->key); break; case NODE_ACTION_NONE: - fprintf(stderr, "none \"%s\"", pn->key); break; } fprintf(stderr, "\n"); @@ -1296,7 +1298,7 @@ relay_read_http(struct bufferevent *bev, void *arg) cre->method = HTTP_METHOD_CONNECT; /* - * Decode the URL + * Decode the path and query */ cre->path = strdup(pk.value); if (cre->path == NULL) { @@ -1374,7 +1376,7 @@ relay_read_http(struct bufferevent *bev, void *arg) if (cre->dir == RELAY_DIR_RESPONSE) goto handle; - if (pn->flags & PNFLAG_LOOKUP_URL) { + if (pn->flags & PNFLAG_LOOKUP_QUERY) { if (cre->path == NULL || cre->args == NULL || strlen(cre->args) < 2 || (val = strdup(cre->args)) == NULL) @@ -1382,7 +1384,7 @@ relay_read_http(struct bufferevent *bev, void *arg) ptr = val; while (ptr != NULL && strlen(ptr)) { pkv.key = ptr; - pkv.type = NODE_TYPE_URL; + pkv.type = NODE_TYPE_QUERY; if ((ptr = strchr(ptr, '&')) != NULL) *ptr++ = '\0'; if ((pkv.value = diff --git a/usr.sbin/relayd/relayd.conf.5 b/usr.sbin/relayd/relayd.conf.5 index 77506e1d3da..cc0ddf0ec62 100644 --- a/usr.sbin/relayd/relayd.conf.5 +++ b/usr.sbin/relayd/relayd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: relayd.conf.5,v 1.59 2007/11/21 13:04:42 reyk Exp $ +.\" $OpenBSD: relayd.conf.5,v 1.60 2007/11/21 14:12:04 reyk Exp $ .\" .\" Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> .\" Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -547,12 +547,26 @@ Look up the entity as a value in the URL path when using the protocol. This type is only available with the direction .Ic request . -.It Ic url -Look up the entity as a GET variable in the URL when using the +The +.Ar key +will match the path of the requested URL without the hostname +and query and the value will match the complete query, +for example: +.Bd -literal -offset indent +request path filter "*" from "/index.html" +request path filter "foo=bar*" from "/cgi-bin/t.cgi" +.Ed +.It Ic query +Look up the entity as a query variable in the URL when using the .Ic http protocol. This type is only available with the direction -.Ic request . +.Ic request , +for example: +.Bd -literal -offset indent +# Will match /cgi-bin/example.pl?foo=bar&ok=yes +request query expect "bar" from "foo" +.Ed .El .Pp The following actions are available: diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index 16f8c3ec955..929df02e2cf 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.77 2007/11/21 13:04:42 reyk Exp $ */ +/* $OpenBSD: relayd.h,v 1.78 2007/11/21 14:12:04 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -434,7 +434,7 @@ enum nodeaction { enum nodetype { NODE_TYPE_HEADER = 0, - NODE_TYPE_URL = 1, + NODE_TYPE_QUERY = 1, NODE_TYPE_COOKIE = 2, NODE_TYPE_PATH = 3 }; @@ -442,7 +442,7 @@ enum nodetype { #define PNFLAG_MACRO 0x01 #define PNFLAG_MARK 0x02 #define PNFLAG_LOG 0x04 -#define PNFLAG_LOOKUP_URL 0x08 +#define PNFLAG_LOOKUP_QUERY 0x08 #define PNFLAG_LOOKUP_COOKIE 0x10 enum noderesult { |