2011-02-25 09:40:11 +00:00
|
|
|
/***************************************************************************
|
|
|
|
core.h - description
|
|
|
|
-------------------
|
|
|
|
begin : Tue May 14 2002
|
|
|
|
copyright : netcreature (C) 2002
|
|
|
|
email : netcreature@users.sourceforge.net
|
2012-07-07 22:16:00 +00:00
|
|
|
***************************************************************************
|
|
|
|
***************************************************************************
|
2011-02-25 09:40:11 +00:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************/
|
2012-07-07 22:16:00 +00:00
|
|
|
|
2012-11-07 15:49:14 +00:00
|
|
|
#include <unistd.h>
|
2012-07-07 22:16:00 +00:00
|
|
|
#include <stdint.h>
|
2012-08-05 23:26:34 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netdb.h>
|
2012-07-07 22:16:00 +00:00
|
|
|
|
2011-02-25 09:40:11 +00:00
|
|
|
#ifndef __CORE_HEADER
|
|
|
|
#define __CORE_HEADER
|
|
|
|
#define BUFF_SIZE 8*1024 // used to read responses from proxies.
|
2012-04-23 23:48:17 +00:00
|
|
|
#define MAX_LOCALNET 64
|
2011-09-10 20:32:27 +00:00
|
|
|
|
2012-11-07 19:11:14 +00:00
|
|
|
#include "ip_type.h"
|
2011-11-06 13:12:50 +00:00
|
|
|
|
2011-02-25 09:40:11 +00:00
|
|
|
/*error codes*/
|
2011-11-06 13:12:50 +00:00
|
|
|
typedef enum {
|
|
|
|
SUCCESS=0,
|
|
|
|
MEMORY_FAIL, // malloc failed
|
|
|
|
SOCKET_ERROR, // look errno for more
|
|
|
|
CHAIN_DOWN, // no proxy in chain responds to tcp
|
|
|
|
CHAIN_EMPTY, // if proxy_count = 0
|
|
|
|
BLOCKED // target's port blocked on last proxy in the chain
|
2011-02-25 09:40:11 +00:00
|
|
|
} ERR_CODE;
|
|
|
|
|
2011-11-06 13:12:50 +00:00
|
|
|
typedef enum {
|
|
|
|
HTTP_TYPE,
|
|
|
|
SOCKS4_TYPE,
|
|
|
|
SOCKS5_TYPE
|
|
|
|
} proxy_type;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
DYNAMIC_TYPE,
|
|
|
|
STRICT_TYPE,
|
|
|
|
RANDOM_TYPE}
|
|
|
|
chain_type;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
PLAY_STATE,
|
|
|
|
DOWN_STATE,
|
|
|
|
BLOCKED_STATE,
|
|
|
|
BUSY_STATE
|
|
|
|
} proxy_state;
|
2011-02-25 09:40:11 +00:00
|
|
|
|
2011-11-06 13:12:50 +00:00
|
|
|
typedef enum {
|
|
|
|
RANDOMLY,
|
|
|
|
FIFOLY
|
|
|
|
} select_type;
|
|
|
|
|
|
|
|
typedef struct {
|
2011-02-25 15:16:58 +00:00
|
|
|
struct in_addr in_addr, netmask;
|
2011-03-22 14:04:52 +00:00
|
|
|
unsigned short port;
|
2011-02-25 15:16:58 +00:00
|
|
|
} localaddr_arg;
|
|
|
|
|
2011-09-03 23:45:16 +00:00
|
|
|
typedef struct {
|
2011-11-06 13:12:50 +00:00
|
|
|
ip_type ip;
|
2011-09-03 23:45:16 +00:00
|
|
|
unsigned short port;
|
|
|
|
proxy_type pt;
|
|
|
|
proxy_state ps;
|
|
|
|
char user[256];
|
|
|
|
char pass[256];
|
2011-02-25 09:40:11 +00:00
|
|
|
} proxy_data;
|
|
|
|
|
2012-04-23 18:26:13 +00:00
|
|
|
int connect_proxy_chain (int sock, ip_type target_ip, unsigned short target_port,
|
|
|
|
proxy_data * pd, unsigned int proxy_count, chain_type ct,
|
|
|
|
unsigned int max_chain );
|
2011-02-25 09:40:11 +00:00
|
|
|
|
2012-07-14 15:59:06 +00:00
|
|
|
void proxychains_write_log(char *str, ...);
|
2011-02-25 09:40:11 +00:00
|
|
|
|
2013-01-21 00:54:45 +00:00
|
|
|
typedef int (*close_t)(int);
|
2011-02-25 09:40:11 +00:00
|
|
|
typedef int (*connect_t)(int, const struct sockaddr *, socklen_t);
|
|
|
|
typedef struct hostent* (*gethostbyname_t)(const char *);
|
2012-07-07 22:16:00 +00:00
|
|
|
typedef int (*freeaddrinfo_t)(struct addrinfo *);
|
|
|
|
typedef struct hostent *(*gethostbyaddr_t) (const void *, socklen_t, int);
|
2011-02-25 09:40:11 +00:00
|
|
|
|
2012-07-07 22:16:00 +00:00
|
|
|
typedef int (*getaddrinfo_t)(const char *, const char *, const struct addrinfo *,
|
|
|
|
struct addrinfo **);
|
2011-02-25 09:40:11 +00:00
|
|
|
|
2012-07-07 22:16:00 +00:00
|
|
|
typedef int (*getnameinfo_t) (const struct sockaddr *, socklen_t, char *,
|
|
|
|
socklen_t, char *, socklen_t, int);
|
2011-02-25 09:40:11 +00:00
|
|
|
|
|
|
|
|
2012-07-07 22:16:00 +00:00
|
|
|
extern connect_t true_connect;
|
|
|
|
extern gethostbyname_t true_gethostbyname;
|
|
|
|
extern getaddrinfo_t true_getaddrinfo;
|
|
|
|
extern freeaddrinfo_t true_freeaddrinfo;
|
|
|
|
extern getnameinfo_t true_getnameinfo;
|
|
|
|
extern gethostbyaddr_t true_gethostbyaddr;
|
2011-02-25 09:40:11 +00:00
|
|
|
|
2012-07-15 23:05:28 +00:00
|
|
|
struct gethostbyname_data {
|
|
|
|
struct hostent hostent_space;
|
|
|
|
in_addr_t resolved_addr;
|
|
|
|
char *resolved_addr_p[2];
|
|
|
|
char addr_name[1024 * 8];
|
|
|
|
};
|
2012-04-23 18:26:13 +00:00
|
|
|
|
2012-07-15 23:05:28 +00:00
|
|
|
struct hostent* proxy_gethostbyname(const char *name, struct gethostbyname_data *data);
|
2011-02-25 09:40:11 +00:00
|
|
|
|
2012-07-07 22:16:00 +00:00
|
|
|
int proxy_getaddrinfo(const char *node, const char *service,
|
|
|
|
const struct addrinfo *hints, struct addrinfo **res);
|
2012-07-15 23:05:28 +00:00
|
|
|
void proxy_freeaddrinfo(struct addrinfo *res);
|
2011-02-25 09:40:11 +00:00
|
|
|
|
2012-11-07 20:28:09 +00:00
|
|
|
void core_initialize(void);
|
|
|
|
void core_unload(void);
|
|
|
|
|
2012-11-07 15:49:14 +00:00
|
|
|
#include "debug.h"
|
2011-02-25 09:40:11 +00:00
|
|
|
|
2012-01-27 16:55:37 +00:00
|
|
|
#endif
|
2012-11-04 04:01:38 +00:00
|
|
|
|
|
|
|
//RcB: DEP "core.c"
|
|
|
|
//RcB: DEP "libproxychains.c"
|
2012-12-25 17:01:11 +00:00
|
|
|
//RcB: LINK "-Wl,--no-as-needed -ldl -lpthread"
|
|
|
|
|