mirror of
https://github.com/rofl0r/proxychains-ng
synced 2025-01-24 02:02:53 +08:00
af5c6f0c6a
the central dns resolver function proxy_gethostbyname() used to iterate over the gethostent() db (/etc/hosts) on each dns request. since this is not threadsafe, we synchronized access to it previously using mutexes. the parsing of this file is slow, and blocking all threads to do it even moreso. since gethostent_r() is only available on a few platforms, i decided to read the hostent db once and then use a quick in-memory lookup on further usage. + some further refactoring.
24 lines
364 B
C
24 lines
364 B
C
#ifndef HOSTENTDB_H
|
|
#define HOSTENTDB_H
|
|
|
|
#include "ip_type.h"
|
|
#include <unistd.h>
|
|
|
|
struct hostent_entry {
|
|
uint32_t hash;
|
|
ip_type ip;
|
|
char* str;
|
|
};
|
|
|
|
struct hostent_list {
|
|
size_t count;
|
|
size_t capa;
|
|
struct hostent_entry *entries;
|
|
};
|
|
|
|
void hdb_init(struct hostent_list *hl);
|
|
ip_type hdb_get(struct hostent_list *hl, char* host);
|
|
|
|
//RcB: DEP "hostendb.c"
|
|
#endif
|