An ersatz vector is now replaced.
This commit is contained in:
@ -9,19 +9,19 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "../dlib/dlib.h"
|
#include "../dlib/dlib.h"
|
||||||
#include "msg.hh"
|
#include "msg.hh"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "domain.hh"
|
#include "domain.hh"
|
||||||
|
|
||||||
typedef struct {
|
struct Rule {
|
||||||
char *origin;
|
char *origin;
|
||||||
char *destination;
|
char *destination;
|
||||||
} Rule;
|
};
|
||||||
|
|
||||||
static Rule *exceptions = NULL;
|
std::vector< Rule > exceptions;
|
||||||
static int num_exceptions = 0;
|
|
||||||
static int num_exceptions_max = 1;
|
|
||||||
|
|
||||||
static bool_t default_deny = FALSE;
|
static bool_t default_deny = FALSE;
|
||||||
|
|
||||||
@ -64,10 +64,9 @@ void a_Domain_parse(FILE *fp)
|
|||||||
MSG("Domain: Default action \"%s\" not recognised.\n", tok2);
|
MSG("Domain: Default action \"%s\" not recognised.\n", tok2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
a_List_add(exceptions, num_exceptions, num_exceptions_max, Rule);
|
exceptions.emplace_back();
|
||||||
exceptions[num_exceptions].origin = dStrdup(tok1);
|
exceptions.back().origin = dStrdup(tok1);
|
||||||
exceptions[num_exceptions].destination = dStrdup(tok2);
|
exceptions.back().destination = dStrdup(tok2);
|
||||||
num_exceptions++;
|
|
||||||
_MSG("Domain: Exception from %s to %s.\n", tok1, tok2);
|
_MSG("Domain: Exception from %s to %s.\n", tok1, tok2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,11 +79,11 @@ void a_Domain_freeall(void)
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (i = 0; i < num_exceptions; i++) {
|
for (i = 0; i < exceptions.size(); i++) {
|
||||||
dFree(exceptions[i].origin);
|
dFree(exceptions[i].origin);
|
||||||
dFree(exceptions[i].destination);
|
dFree(exceptions[i].destination);
|
||||||
}
|
}
|
||||||
dFree(exceptions);
|
exceptions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,7 +118,7 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest)
|
|||||||
bool_t ret;
|
bool_t ret;
|
||||||
const char *source_host, *dest_host;
|
const char *source_host, *dest_host;
|
||||||
|
|
||||||
if (default_deny == FALSE && num_exceptions == 0)
|
if (default_deny == FALSE && exceptions.size() == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
source_host = URL_HOST(source);
|
source_host = URL_HOST(source);
|
||||||
@ -138,7 +137,7 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest)
|
|||||||
|
|
||||||
ret = default_deny ? FALSE : TRUE;
|
ret = default_deny ? FALSE : TRUE;
|
||||||
|
|
||||||
for (i = 0; i < num_exceptions; i++) {
|
for (i = 0; i < exceptions.size(); i++) {
|
||||||
if (Domain_match(source_host, exceptions[i].origin) &&
|
if (Domain_match(source_host, exceptions[i].origin) &&
|
||||||
Domain_match(dest_host, exceptions[i].destination)) {
|
Domain_match(dest_host, exceptions[i].destination)) {
|
||||||
ret = default_deny;
|
ret = default_deny;
|
||||||
|
|||||||
Reference in New Issue
Block a user