Skip to content

Commit 8135869

Browse files
committed
Send proxy version in logs
1 parent 4d6d25e commit 8135869

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Diff for: Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ SRC=src/mod_redirectionio.c \
33
src/json.c \
44
src/redirectionio_protocol.c
55

6+
PROXY_VERSION ?= libapache2-mod-redirectionio:dev
7+
68
all: src/mod_redirectionio.la
79

810
src/mod_redirectionio.la: $(SRC) src/mod_redirectionio.h src/json.h src/redirectionio_protocol.h
9-
apxs -Wc,"-std=c99 " -Wl,"" -lm -Wc,-Wall -Wc,-g -c $(SRC)
11+
apxs -Wc,"-std=c99 -DPROXY_VERSION=$(PROXY_VERSION) " -Wl,"" -lm -Wc,-Wall -Wc,-g -c $(SRC)
1012

1113
.PHONY: install
1214
install: src/mod_redirectionio.la

Diff for: src/mod_redirectionio.h

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
#define UNIX 0
1818
#define TCP 1
1919

20+
#ifndef PROXY_VERSION
21+
#define PROXY_VERSION libapache2-mod-redirectionio:dev
22+
#endif
23+
24+
#define STRINGIZE(x) #x
25+
#define PROXY_VERSION_STR(x) STRINGIZE(x)
26+
2027
#define RIO_TIMEOUT 100000 // Timeout in microseconds
2128
#define RIO_RECONNECT_INTERVAL 0
2229
#define RIO_MIN_CONNECTIONS 1

Diff for: src/redirectionio_protocol.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static char errbuf[1024];
1111
const char COMMAND_MATCH_NAME[] = "MATCH_WITH_RESPONSE";
1212
const char COMMAND_MATCH_QUERY[] = "{ \"project_id\": \"%s\", \"request_uri\": \"%s\", \"host\": \"%s\" }";
1313
const char COMMAND_LOG_NAME[] = "LOG";
14-
const char COMMAND_LOG_QUERY[] = "{ \"project_id\": \"%s\", \"request_uri\": \"%s\", \"host\": \"%s\", \"rule_id\": \"%s\", \"target\": \"%s\", \"status_code\": %d, \"user_agent\": \"%s\", \"referer\": \"%s\", \"method\": \"%s\" }";
14+
const char COMMAND_LOG_QUERY[] = "{ \"project_id\": \"%s\", \"request_uri\": \"%s\", \"host\": \"%s\", \"rule_id\": \"%s\", \"target\": \"%s\", \"status_code\": %d, \"user_agent\": \"%s\", \"referer\": \"%s\", \"method\": \"%s\", \"proxy\": \"%s\" }";
1515
const char COMMAND_FILTER_HEADER_NAME[] = "FILTER_HEADER";
1616
const char COMMAND_FILTER_BODY_NAME[] = "FILTER_BODY";
1717

@@ -130,7 +130,8 @@ apr_status_t redirectionio_protocol_log(redirectionio_connection *conn, redirect
130130
+ strlen(user_agent)
131131
+ strlen(referer)
132132
+ strlen(r->method)
133-
- 18 // 9 * 2 (%x) characters replaced with values
133+
+ strlen(PROXY_VERSION_STR(PROXY_VERSION))
134+
- 20 // 10 * 2 (%x) characters replaced with values
134135
;
135136

136137
dst = (char *) apr_palloc(r->pool, wlen);
@@ -146,7 +147,8 @@ apr_status_t redirectionio_protocol_log(redirectionio_connection *conn, redirect
146147
r->status,
147148
user_agent,
148149
referer,
149-
r->method
150+
r->method,
151+
PROXY_VERSION_STR(PROXY_VERSION)
150152
);
151153

152154
clen = sizeof(COMMAND_LOG_NAME);

0 commit comments

Comments
 (0)