Skip to content

Commit

Permalink
Well that was a bad idea.
Browse files Browse the repository at this point in the history
  • Loading branch information
abedra committed Dec 9, 2018
1 parent 8be2f15 commit 73f2051
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 3 additions & 7 deletions ngx_http_repsheet_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
#include "ngx_http_repsheet_xff.h"
#include "ngx_http_repsheet_lookup.h"

void set_reason_header(ngx_http_request_t *r, ngx_str_t *reason) {
void set_repsheet_header(ngx_http_request_t *r) {
ngx_table_elt_t *h;
h = ngx_list_push(&r->headers_in.headers);
h->hash = 1;
ngx_str_set(&h->key, "X-Repsheet");
h->value.data = reason->data;
h->value.len = reason->len;
ngx_str_set(&h->value, "true");
}

ngx_int_t lookup_ip(ngx_http_request_t *r, repsheet_main_conf_t *main_conf, repsheet_loc_conf_t *loc_conf)
Expand Down Expand Up @@ -42,10 +41,7 @@ ngx_int_t lookup_ip(ngx_http_request_t *r, repsheet_main_conf_t *main_conf, reps

if (is_ip_marked(lookup_result)) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "[Repsheet] - IP %s was found on repsheet. Reason: %s", address, reason);
ngx_str_t value;
ngx_memcpy(value.data, reason, ngx_strlen(reason));
value.len = ngx_strlen(reason);
set_reason_header(r, &value);
set_repsheet_header(r);
}

if (lookup_result == WHITELISTED) {
Expand Down
4 changes: 2 additions & 2 deletions sample_application/app.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'sinatra'

get '/app' do
if request.env['HTTP_X_REPSHEET']
"Actor is marked. Reason: #{request.env['HTTP_X_REPSHEET']}"
if request.env['HTTP_X_REPSHEET'] == "true"
"Actor is marked"
else
"Actor is not on the Repsheet"
end
Expand Down

0 comments on commit 73f2051

Please sign in to comment.