Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/rofl0r/proxychains-ng.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrofl0r <rofl0r@users.noreply.github.com>2020-09-23 19:00:16 +0300
committerrofl0r <rofl0r@users.noreply.github.com>2020-09-23 19:00:16 +0300
commit1e00b9ac1ee473b13c01010b32fc40dca8f0fb9b (patch)
treed7373c59b8808947a33b3077c8f77e2368315e58
parent1221c5e93a0e88e8a4c75927d359cb0689cf9d95 (diff)
get rid of ip_type.c
-rw-r--r--Makefile2
-rw-r--r--src/allocator_thread.c8
-rw-r--r--src/core.c6
-rw-r--r--src/hostsreader.c2
-rw-r--r--src/ip_type.c5
-rw-r--r--src/ip_type.h8
-rw-r--r--src/libproxychains.c2
7 files changed, 15 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 2dd9e9c..31ba8db 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ SRCS = $(sort $(wildcard src/*.c))
OBJS = $(SRCS:.c=.o)
LOBJS = src/nameinfo.o src/version.o \
src/core.o src/common.o src/libproxychains.o \
- src/allocator_thread.o src/ip_type.o \
+ src/allocator_thread.o \
src/hostsreader.o src/hash.o src/debug.o
GENH = src/version.h
diff --git a/src/allocator_thread.c b/src/allocator_thread.c
index ad0321f..66cf7f6 100644
--- a/src/allocator_thread.c
+++ b/src/allocator_thread.c
@@ -67,7 +67,7 @@ ip_type4 make_internal_ip(uint32_t index) {
ip_type4 ret;
index++; // so we can start at .0.0.1
if(index > 0xFFFFFF)
- return ip_type_invalid.addr.v4;
+ return IPT4_INVALID;
ret.octet[0] = remote_dns_subnet & 0xFF;
ret.octet[1] = (index & 0xFF0000) >> 16;
ret.octet[2] = (index & 0xFF00) >> 8;
@@ -105,7 +105,7 @@ static ip_type4 ip_from_internal_list(char* name, size_t len) {
}
res = make_internal_ip(internal_ips->counter);
- if(res.as_int == ip_type_invalid.addr.v4.as_int)
+ if(res.as_int == IPT4_INVALID.as_int)
goto err_plus_unlock;
string_hash_tuple tmp = { 0 };
@@ -134,7 +134,7 @@ static ip_type4 ip_from_internal_list(char* name, size_t len) {
err_plus_unlock:
PDEBUG("return err\n");
- return ip_type_invalid.addr.v4;
+ return IPT4_INVALID;
}
/* stuff for communication with the allocator thread */
@@ -276,7 +276,7 @@ ip_type4 at_get_ip_for_host(char* host, size_t len) {
getmessage(ATD_CLIENT, &msg)) readbuf = msg.m.ip;
else {
inv:
- readbuf = ip_type_invalid.addr.v4;
+ readbuf = IPT4_INVALID;
}
assert(msg.h.msgtype == ATM_GETIP);
MUTEX_UNLOCK(internal_ips_lock);
diff --git a/src/core.c b/src/core.c
index 9dfba49..53e52d9 100644
--- a/src/core.c
+++ b/src/core.c
@@ -854,19 +854,19 @@ struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data*
if(!strcmp(buff, name)) {
data->resolved_addr = inet_addr(buff);
if(data->resolved_addr == (in_addr_t) (-1))
- data->resolved_addr = (in_addr_t) (ip_type_localhost.addr.v4.as_int);
+ data->resolved_addr = (in_addr_t) (IPT4_LOCALHOST.as_int);
goto retname;
}
// this iterates over the "known hosts" db, usually /etc/hosts
ip_type4 hdb_res = hostsreader_get_numeric_ip_for_name(name);
- if(hdb_res.as_int != ip_type_invalid.addr.v4.as_int) {
+ if(hdb_res.as_int != IPT4_INVALID.as_int) {
data->resolved_addr = hdb_res.as_int;
goto retname;
}
data->resolved_addr = at_get_ip_for_host((char*) name, strlen(name)).as_int;
- if(data->resolved_addr == (in_addr_t) ip_type_invalid.addr.v4.as_int) return NULL;
+ if(data->resolved_addr == (in_addr_t) IPT4_INVALID.as_int) return NULL;
retname:
diff --git a/src/hostsreader.c b/src/hostsreader.c
index b2b0b07..86aeb3c 100644
--- a/src/hostsreader.c
+++ b/src/hostsreader.c
@@ -82,7 +82,7 @@ ip_type4 hostsreader_get_numeric_ip_for_name(const char* name) {
ip_type4 res;
memcpy(res.octet, &c.s_addr, 4);
return res;
- } else return ip_type_invalid.addr.v4;
+ } else return IPT4_INVALID;
}
#ifdef HOSTSREADER_TEST
diff --git a/src/ip_type.c b/src/ip_type.c
deleted file mode 100644
index cbe4815..000000000
--- a/src/ip_type.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "ip_type.h"
-
-const ip_type ip_type_invalid = { .addr.v4.as_int = -1 };
-const ip_type ip_type_localhost = { .addr.v4.octet = {127, 0, 0, 1} };
-
diff --git a/src/ip_type.h b/src/ip_type.h
index 064153e..c09400b 100644
--- a/src/ip_type.h
+++ b/src/ip_type.h
@@ -16,8 +16,10 @@ typedef struct {
char is_v6;
} ip_type;
-extern const ip_type ip_type_invalid;
-extern const ip_type ip_type_localhost;
+#define IPT4_INT(X) (ip_type4){.as_int = (X)}
+#define IPT4_INVALID IPT4_INT(-1)
+
+#define IPT4_BYTES(A,B,C,D) (ip_type4){.octet = {(A), (B), (C), (D)} }
+#define IPT4_LOCALHOST IPT4_BYTES(127,0,0,1)
-//RcB: DEP "ip_type.c"
#endif
diff --git a/src/libproxychains.c b/src/libproxychains.c
index 8cdfbce..ca10cda 100644
--- a/src/libproxychains.c
+++ b/src/libproxychains.c
@@ -345,7 +345,7 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
ip_type4 internal_ip = at_get_ip_for_host(host, strlen(host));
pd[count].ip.is_v6 = 0;
host_ip->addr.v4 = internal_ip;
- if(internal_ip.as_int == ip_type_invalid.addr.v4.as_int)
+ if(internal_ip.as_int == IPT4_INVALID.as_int)
goto inv_host;
} else {
inv_host: