mirror of
https://github.com/omar-polo/gmid.git
synced 2024-09-28 05:21:48 +02:00
add `log on/off' to enable/disable logs per-location
This commit is contained in:
parent
fd9a486925
commit
793835cb26
@ -1,3 +1,7 @@
|
|||||||
|
2021-02-22 Omar Polo <op@omarpolo.com>
|
||||||
|
|
||||||
|
* log.c (log_request): add `log on/off' to enable/disable logs per-server or per-location
|
||||||
|
|
||||||
2021-02-09 Omar Polo <op@omarpolo.com>
|
2021-02-09 Omar Polo <op@omarpolo.com>
|
||||||
|
|
||||||
* parse.y (locopt): add `require client ca' rule to require client certs signed by a specified CA
|
* parse.y (locopt): add `require client ca' rule to require client certs signed by a specified CA
|
||||||
|
2
gmid.h
2
gmid.h
@ -66,6 +66,7 @@ struct location {
|
|||||||
const char *block_fmt;
|
const char *block_fmt;
|
||||||
int strip;
|
int strip;
|
||||||
X509_STORE *reqca;
|
X509_STORE *reqca;
|
||||||
|
int disable_log;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vhost {
|
struct vhost {
|
||||||
@ -234,6 +235,7 @@ int vhost_auto_index(struct vhost*, const char*);
|
|||||||
int vhost_block_return(struct vhost*, const char*, int*, const char**);
|
int vhost_block_return(struct vhost*, const char*, int*, const char**);
|
||||||
int vhost_strip(struct vhost*, const char*);
|
int vhost_strip(struct vhost*, const char*);
|
||||||
X509_STORE *vhost_require_ca(struct vhost*, const char*);
|
X509_STORE *vhost_require_ca(struct vhost*, const char*);
|
||||||
|
int vhost_disable_log(struct vhost*, const char*);
|
||||||
void mark_nonblock(int);
|
void mark_nonblock(int);
|
||||||
void loop(struct tls*, int, int);
|
void loop(struct tls*, int, int);
|
||||||
|
|
||||||
|
1
lex.l
1
lex.l
@ -65,6 +65,7 @@ ipv6 return TIPV6;
|
|||||||
key return TKEY;
|
key return TKEY;
|
||||||
lang return TLANG;
|
lang return TLANG;
|
||||||
location return TLOCATION;
|
location return TLOCATION;
|
||||||
|
log return TLOG;
|
||||||
mime return TMIME;
|
mime return TMIME;
|
||||||
port return TPORT;
|
port return TPORT;
|
||||||
prefork return TPREFORK;
|
prefork return TPREFORK;
|
||||||
|
3
log.c
3
log.c
@ -188,6 +188,9 @@ log_request(struct client *c, char *meta, size_t l)
|
|||||||
size_t len;
|
size_t len;
|
||||||
int ec;
|
int ec;
|
||||||
|
|
||||||
|
if (vhost_disable_log(c->host, c->iri.path))
|
||||||
|
return;
|
||||||
|
|
||||||
len = sizeof(c->addr);
|
len = sizeof(c->addr);
|
||||||
ec = getnameinfo((struct sockaddr*)&c->addr, len,
|
ec = getnameinfo((struct sockaddr*)&c->addr, len,
|
||||||
hbuf, sizeof(hbuf),
|
hbuf, sizeof(hbuf),
|
||||||
|
3
parse.y
3
parse.y
@ -58,7 +58,7 @@ void advance_loc(void);
|
|||||||
|
|
||||||
%token TIPV6 TPORT TPROTOCOLS TMIME TDEFAULT TTYPE
|
%token TIPV6 TPORT TPROTOCOLS TMIME TDEFAULT TTYPE
|
||||||
%token TCHROOT TUSER TSERVER TPREFORK
|
%token TCHROOT TUSER TSERVER TPREFORK
|
||||||
%token TLOCATION TCERT TKEY TROOT TCGI TLANG TINDEX TAUTO
|
%token TLOCATION TCERT TKEY TROOT TCGI TLANG TLOG TINDEX TAUTO
|
||||||
%token TSTRIP TBLOCK TRETURN TENTRYPOINT TREQUIRE TCLIENT TCA
|
%token TSTRIP TBLOCK TRETURN TENTRYPOINT TREQUIRE TCLIENT TCA
|
||||||
%token TERR
|
%token TERR
|
||||||
|
|
||||||
@ -190,6 +190,7 @@ locopt : TAUTO TINDEX TBOOL { loc->auto_index = $3 ? 1 : -1; }
|
|||||||
yyerror("`lang' specified more than once");
|
yyerror("`lang' specified more than once");
|
||||||
loc->lang = $2;
|
loc->lang = $2;
|
||||||
}
|
}
|
||||||
|
| TLOG TBOOL { loc->disable_log = !$2; }
|
||||||
| TREQUIRE TCLIENT TCA TSTRING {
|
| TREQUIRE TCLIENT TCA TSTRING {
|
||||||
if (loc->reqca != NULL)
|
if (loc->reqca != NULL)
|
||||||
yyerror("`require client ca' specified more than once");
|
yyerror("`require client ca' specified more than once");
|
||||||
|
16
server.c
16
server.c
@ -224,6 +224,22 @@ vhost_require_ca(struct vhost *v, const char *path)
|
|||||||
return v->locations[0].reqca;
|
return v->locations[0].reqca;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
vhost_disable_log(struct vhost *v, const char *path)
|
||||||
|
{
|
||||||
|
struct location *loc;
|
||||||
|
|
||||||
|
if (v == NULL || path == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for (loc = &v->locations[1]; loc->match != NULL; ++loc) {
|
||||||
|
if (loc->disable_log && matches(loc->match, path))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return v->locations[0].disable_log;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
check_path(struct client *c, const char *path, int *fd)
|
check_path(struct client *c, const char *path, int *fd)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user