Commit 89e25559 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Added more debugging

parent de4cdc07
......@@ -136,17 +136,20 @@ sub protocol_parse {
sub protocol_response
{
my ($server,$resp,$data) = @_;
my $log = defined($server->{'config'}{'logging'}{'protocols'});
# Check protocol responses...
if ($resp == PROTO_PASS) {
$response = "200";
$response_data = $data;
$server->log(LOG_DEBUG,"[PROTOCOL/Bizanga] Received PROTO_PASS with response '$response':'$response_data'") if ($log);
return CBP_CONTINUE;
} elsif ($resp == PROTO_OK) {
$response = "200";
$response_data = $data;
$server->log(LOG_DEBUG,"[PROTOCOL/Bizanga] Received PROTO_OK with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_REJECT) {
......@@ -157,6 +160,7 @@ sub protocol_response
$response = "403";
$response_data = $data;
}
$server->log(LOG_DEBUG,"[PROTOCOL/Bizanga] Received PROTO_REJECT with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_DEFER) {
......@@ -167,6 +171,7 @@ sub protocol_response
$response = "401";
$response_data = $data;
}
$server->log(LOG_DEBUG,"[PROTOCOL/Bizanga] Received PROTO_DEFER with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_HOLD) {
......@@ -192,16 +197,19 @@ sub protocol_response
} elsif ($resp == PROTO_ERROR) {
$response = "503";
$response_data = defined($data) ? $data : "Unknown error";
$server->log(LOG_DEBUG,"[PROTOCOL/Bizanga] Received PROTO_ERROR with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_DB_ERROR) {
$response = "504";
$response_data = defined($data) ? $data : "Database error";
$server->log(LOG_DEBUG,"[PROTOCOL/Bizanga] Received PROTO_DB_ERROR with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_DATA_ERROR) {
$response = "502";
$response_data = defined($data) ? $data : "Database record error";
$server->log(LOG_DEBUG,"[PROTOCOL/Bizanga] Received PROTO_DATA_ERROR with response '$response':'$response_data'") if ($log);
return CBP_STOP;
# Fallthrough
......
......@@ -120,17 +120,20 @@ sub protocol_parse {
sub protocol_response
{
my ($server,$resp,$data) = @_;
my $log = defined($server->{'config'}{'logging'}{'protocols'});
# Check protocol responses...
if ($resp == PROTO_PASS) {
$response = "DUNNO";
$response_data = $data;
$server->log(LOG_DEBUG,"[PROTOCOL/Postfix] Received PROTO_PASS with response '$response':'$response_data'") if ($log);
return CBP_CONTINUE;
} elsif ($resp == PROTO_OK) {
$response = "OK";
$response_data = $data;
$server->log(LOG_DEBUG,"[PROTOCOL/Postfix] Received PROTO_OK with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_REJECT) {
......@@ -141,6 +144,7 @@ sub protocol_response
$response = "REJECT";
$response_data = $data;
}
$server->log(LOG_DEBUG,"[PROTOCOL/Postfix] Received PROTO_REJECT with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_DEFER) {
......@@ -151,46 +155,55 @@ sub protocol_response
$response = "DEFER";
$response_data = $data;
}
$server->log(LOG_DEBUG,"[PROTOCOL/Postfix] Received PROTO_DEFER with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_HOLD) {
$response = "HOLD";
$response_data = $data;
$server->log(LOG_DEBUG,"[PROTOCOL/Postfix] Received PROTO_HOLD with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_REDIRECT) {
$response = "REDIRECT";
$response_data = $data;
$server->log(LOG_DEBUG,"[PROTOCOL/Postfix] Received PROTO_REDIRECT with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_DISCARD) {
$response = "DISCARD";
$response_data = $data;
$server->log(LOG_DEBUG,"[PROTOCOL/Postfix] Received PROTO_DISCARD with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_FILTER) {
$response = "FILTER";
$response_data = $data;
$server->log(LOG_DEBUG,"[PROTOCOL/Postfix] Received PROTO_FILTER with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_PREPEND) {
$response = "PREPEND";
$response_data = $data;
$server->log(LOG_DEBUG,"[PROTOCOL/Postfix] Received PROTO_PREPEND with response '$response':'$response_data'") if ($log);
return CBP_CONTINUE;
} elsif ($resp == PROTO_ERROR) {
$response = "DEFER";
$response_data = $data;
$server->log(LOG_DEBUG,"[PROTOCOL/Postfix] Received PROTO_ERROR with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_DB_ERROR) {
$response = "DEFER";
$response_data = $data;
$server->log(LOG_DEBUG,"[PROTOCOL/Postfix] Received PROTO_DB_ERROR with response '$response':'$response_data'") if ($log);
return CBP_STOP;
} elsif ($resp == PROTO_DATA_ERROR) {
$response = "DEFER";
$response_data = $data;
$server->log(LOG_DEBUG,"[PROTOCOL/Postfix] Received PROTO_DATA_ERROR with response '$response':'$response_data'") if ($log);
return CBP_STOP;
# Fallthrough
......
......@@ -548,12 +548,15 @@ sub process_request {
last;
} elsif ($res == CBP_SKIP) {
$self->log(LOG_DEBUG,"[CBPOLICYD] Module '".$module->{'name'}."' returned CBP_SKIP") if ($log);
next;
} elsif ($res == CBP_CONTINUE) {
$self->log(LOG_DEBUG,"[CBPOLICYD] Module '".$module->{'name'}."' returned CBP_CONTINUE") if ($log);
next;
} elsif ($res == CBP_STOP) {
$self->log(LOG_DEBUG,"[CBPOLICYD] Module '".$module->{'name'}."' returned CBP_STOP") if ($log);
last;
} elsif ($res == CBP_ERROR) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment