More local string management.
This commit is contained in:
@ -10,6 +10,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "../dlib/dlib.h"
|
#include "../dlib/dlib.h"
|
||||||
#include "msg.hh"
|
#include "msg.hh"
|
||||||
@ -17,8 +18,8 @@
|
|||||||
#include "domain.hh"
|
#include "domain.hh"
|
||||||
|
|
||||||
struct Rule {
|
struct Rule {
|
||||||
char *origin;
|
std::string origin;
|
||||||
char *destination;
|
std::string destination;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector< Rule > exceptions;
|
std::vector< Rule > exceptions;
|
||||||
@ -64,10 +65,8 @@ 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 {
|
||||||
exceptions.emplace_back();
|
exceptions.emplace_back( tok1, tok2 );
|
||||||
exceptions.back().origin = dStrdup(tok1);
|
_MSG("Domain: Exception from %s to %s.\n", tok1.c_str(), tok2.c_str());
|
||||||
exceptions.back().destination = dStrdup(tok2);
|
|
||||||
_MSG("Domain: Exception from %s to %s.\n", tok1, tok2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,12 +76,6 @@ void a_Domain_parse(FILE *fp)
|
|||||||
|
|
||||||
void a_Domain_freeall(void)
|
void a_Domain_freeall(void)
|
||||||
{
|
{
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < exceptions.size(); i++) {
|
|
||||||
dFree(exceptions[i].origin);
|
|
||||||
dFree(exceptions[i].destination);
|
|
||||||
}
|
|
||||||
exceptions.clear();
|
exceptions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,11 +131,11 @@ 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 < exceptions.size(); i++) {
|
for (i = 0; i < exceptions.size(); i++) {
|
||||||
if (Domain_match(source_host, exceptions[i].origin) &&
|
if (Domain_match(source_host, exceptions[i].origin.c_str()) &&
|
||||||
Domain_match(dest_host, exceptions[i].destination)) {
|
Domain_match(dest_host, exceptions[i].destination.c_str())) {
|
||||||
ret = default_deny;
|
ret = default_deny;
|
||||||
_MSG("Domain: Matched rule from %s to %s.\n", exceptions[i].origin,
|
_MSG("Domain: Matched rule from %s to %s.\n", exceptions[i].origin.c_str(),
|
||||||
exceptions[i].destination);
|
exceptions[i].destination.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user