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-10-28 13:39:27 +0300
committerrofl0r <rofl0r@users.noreply.github.com>2020-10-28 13:39:27 +0300
commit452830283c081ac9a677a3e823d28575295626d9 (patch)
treed7f8905936984f7e7898c7964a2047b23af1cd0a
parent486f8200ad9ab5c0726f021912cff09a6a21261c (diff)
move isnumericipv4() to common.c
-rw-r--r--src/common.c27
-rw-r--r--src/common.h1
-rw-r--r--src/hostsreader.c31
3 files changed, 30 insertions, 29 deletions
diff --git a/src/common.c b/src/common.c
index 2af642e..1da1c45 100644
--- a/src/common.c
+++ b/src/common.c
@@ -23,6 +23,33 @@ const char *proxy_state_strmap[] = {
"busy",
};
+/* isnumericipv4() taken from libulz */
+int pc_isnumericipv4(const char* ipstring) {
+ size_t x = 0, n = 0, d = 0;
+ int wasdot = 0;
+ while(1) {
+ switch(ipstring[x]) {
+ case 0: goto done;
+ case '.':
+ if(!n || wasdot) return 0;
+ d++;
+ wasdot = 1;
+ break;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ n++;
+ wasdot = 0;
+ break;
+ default:
+ return 0;
+ }
+ x++;
+ }
+ done:
+ if(d == 3 && n >= 4 && n <= 12) return 1;
+ return 0;
+}
+
// stolen from libulz (C) rofl0r
void pc_stringfromipv4(unsigned char *ip_buf_4_bytes, char *outbuf_16_bytes) {
unsigned char *p;
diff --git a/src/common.h b/src/common.h
index 5335bd1..91468bc 100644
--- a/src/common.h
+++ b/src/common.h
@@ -17,6 +17,7 @@ extern const char *proxy_state_strmap[];
char *get_config_path(char* default_path, char* pbuf, size_t bufsize);
void pc_stringfromipv4(unsigned char *ip_buf_4_bytes, char *outbuf_16_bytes);
+int pc_isnumericipv4(const char* ipstring);
//RcB: DEP "common.c"
#endif
diff --git a/src/hostsreader.c b/src/hostsreader.c
index 86aeb3c..42e5323 100644
--- a/src/hostsreader.c
+++ b/src/hostsreader.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <ctype.h>
#include <string.h>
+#include "common.h"
/*
simple reader for /etc/hosts
@@ -24,7 +25,6 @@ void hostsreader_close(struct hostsreader *ctx) {
fclose(ctx->f);
}
-static int isnumericipv4(const char* ipstring);
int hostsreader_get(struct hostsreader *ctx, char* buf, size_t bufsize) {
while(1) {
if(!fgets(buf, bufsize, ctx->f)) return 0;
@@ -51,7 +51,7 @@ int hostsreader_get(struct hostsreader *ctx, char* buf, size_t bufsize) {
}
if(!l || !*p) continue;
*p = 0;
- if(isnumericipv4(ctx->ip)) return 1;
+ if(pc_isnumericipv4(ctx->ip)) return 1;
}
}
@@ -94,30 +94,3 @@ int main(int a, char**b) {
printf("%s\n", ret ? ret : "null");
}
#endif
-
-/* isnumericipv4() taken from libulz */
-static int isnumericipv4(const char* ipstring) {
- size_t x = 0, n = 0, d = 0;
- int wasdot = 0;
- while(1) {
- switch(ipstring[x]) {
- case 0: goto done;
- case '.':
- if(!n || wasdot) return 0;
- d++;
- wasdot = 1;
- break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- n++;
- wasdot = 0;
- break;
- default:
- return 0;
- }
- x++;
- }
- done:
- if(d == 3 && n >= 4 && n <= 12) return 1;
- return 0;
-}