mirror of
https://github.com/rofl0r/proxychains-ng.git
synced 2025-09-06 17:06:58 +00:00
replace problematic hostentdb with hostsreader
the hostentdb introduced between 4.2 and 4.3
(via af5c6f0c6a
)
had several issues:
- it caused breakage on FreeBSD and was commented out there
- prevented usage of the hostdb when proxy_dns was turned off
(issue #42)
- required dynamic memory allocation which was accessed from several
threads
- wouldnt reflect changes to the hosts file made during program run
the only sensible solution is to remove the hostentdb and replace it
with a home-grown hosts parser (we can't use gethostent() since
that would mess up the gethostent()-state from different threads).
the new parser used here is deliberately held simple and only meant
to provide the user with means to reference hardcoded ipv4 addresses
via his hosts file.
fixes #42
This commit is contained in:
@ -719,11 +719,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
return -1;
|
||||
}
|
||||
|
||||
#include "hostentdb.h"
|
||||
struct hostent_list hl;
|
||||
|
||||
void core_initialize(void) {
|
||||
hdb_init(&hl);
|
||||
}
|
||||
|
||||
void core_unload(void) {
|
||||
@ -734,6 +730,7 @@ static void gethostbyname_data_setstring(struct gethostbyname_data* data, char*
|
||||
data->hostent_space.h_name = data->addr_name;
|
||||
}
|
||||
|
||||
extern ip_type hostsreader_get_numeric_ip_for_name(const char* name);
|
||||
struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data* data) {
|
||||
PFUNC();
|
||||
char buff[256];
|
||||
@ -758,10 +755,8 @@ struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data*
|
||||
goto retname;
|
||||
}
|
||||
|
||||
memset(buff, 0, sizeof(buff));
|
||||
|
||||
// this iterates over the "known hosts" db, usually /etc/hosts
|
||||
ip_type hdb_res = hdb_get(&hl, (char*) name);
|
||||
ip_type hdb_res = hostsreader_get_numeric_ip_for_name(name);
|
||||
if(hdb_res.as_int != ip_type_invalid.as_int) {
|
||||
data->resolved_addr = hdb_res.as_int;
|
||||
goto retname;
|
||||
|
Reference in New Issue
Block a user