6 const char *proxy_type_strmap
[] = {
12 const char *chain_type_strmap
[] = {
19 const char *proxy_state_strmap
[] = {
26 /* isnumericipv4() taken from libulz */
27 int pc_isnumericipv4(const char* ipstring
) {
28 size_t x
= 0, n
= 0, d
= 0;
34 if(!n
|| wasdot
) return 0;
38 case '0': case '1': case '2': case '3': case '4':
39 case '5': case '6': case '7': case '8': case '9':
49 if(d
== 3 && n
>= 4 && n
<= 12) return 1;
53 // stolen from libulz (C) rofl0r
54 void pc_stringfromipv4(unsigned char *ip_buf_4_bytes
, char *outbuf_16_bytes
) {
56 char *o
= outbuf_16_bytes
;
58 for(p
= ip_buf_4_bytes
; p
< ip_buf_4_bytes
+ 4; p
++) {
68 *(o
++) = (n
/ 10) + '0';
77 static int check_path(char *path
) {
80 return access(path
, R_OK
) != -1;
83 char *get_config_path(char* default_path
, char* pbuf
, size_t bufsize
) {
85 // top priority: user defined path
86 char *path
= default_path
;
90 // priority 1: env var PROXYCHAINS_CONF_FILE
91 path
= getenv(PROXYCHAINS_CONF_FILE_ENV_VAR
);
95 // priority 2; proxychains conf in actual dir
96 path
= getcwd(buf
, sizeof(buf
));
97 snprintf(pbuf
, bufsize
, "%s/%s", path
, PROXYCHAINS_CONF_FILE
);
102 // priority 3; $HOME/.proxychains/proxychains.conf
103 path
= getenv("HOME");
104 snprintf(pbuf
, bufsize
, "%s/.proxychains/%s", path
, PROXYCHAINS_CONF_FILE
);
109 // priority 3b: ~/config/settings/proxychains.conf (for haiku)
110 path
= getenv("HOME");
111 snprintf(pbuf
, bufsize
, "%s/config/settings/%s", path
, PROXYCHAINS_CONF_FILE
);
116 // priority 4: $SYSCONFDIR/proxychains.conf
117 path
= SYSCONFDIR
"/" PROXYCHAINS_CONF_FILE
;
121 // priority 5: /etc/proxychains.conf
122 path
= "/etc/" PROXYCHAINS_CONF_FILE
;
126 perror("couldnt find configuration file");