1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-21 06:59:01 +00:00

Removed per-node information structures as well as data encoding/decoding

interface.

These were unused and I think won't be required by any proxy type (HTTP and
SOCKS).
This commit is contained in:
henri
2013-04-22 19:32:04 +00:00
parent 173adc678b
commit 152490e630
3 changed files with 6 additions and 77 deletions

View File

@@ -156,44 +156,17 @@ int nsp_set_proxychain(nsock_pool nspool, nsock_proxychain chain) {
struct proxy_chain_context *proxy_chain_context_new(nsock_pool nspool) {
mspool *nsp = (mspool *)nspool;
struct proxy_chain_context *ctx;
gh_list_elem *elt;
ctx = (struct proxy_chain_context *)safe_malloc(sizeof(struct proxy_chain_context));
ctx->px_chain = nsp->px_chain;
ctx->px_state = PROXY_STATE_INITIAL;
ctx->px_current = GH_LIST_FIRST_ELEM(&nsp->px_chain->nodes);
gh_list_init(&ctx->px_info);
for (elt = GH_LIST_FIRST_ELEM(&nsp->px_chain->nodes); elt != NULL; elt = GH_LIST_ELEM_NEXT(elt)) {
struct proxy_node *px = (struct proxy_node *)GH_LIST_ELEM_DATA(elt);
void *pinfo = NULL;
px->ops->info_new(&pinfo);
gh_list_append(&ctx->px_info, pinfo);
}
return ctx;
}
void proxy_chain_context_delete(struct proxy_chain_context *ctx) {
if (ctx) {
gh_list_elem *pxe;
assert(GH_LIST_COUNT(&ctx->px_chain->nodes) == GH_LIST_COUNT(&ctx->px_info));
for (pxe = GH_LIST_FIRST_ELEM(&ctx->px_chain->nodes); pxe != NULL; pxe = GH_LIST_ELEM_NEXT(pxe)) {
struct proxy_node *pxn;
void *px_info;
pxn = (struct proxy_node *)GH_LIST_ELEM_DATA(pxe);
px_info = gh_list_pop(&ctx->px_info);
pxn->ops->info_delete(px_info);
}
gh_list_free(&ctx->px_info);
if (ctx)
free(ctx);
}
}
static char *mkstr(const char *start, const char *end) {

View File

@@ -118,15 +118,14 @@ struct proxy_chain {
struct proxy_chain_context {
const struct proxy_chain *px_chain;
/* Those fields are used to store current state during the tunnel
* establishment phase. */
/* Nodes iterator in px_chain->nodes */
gh_list_elem *px_current;
/* Current node connection state. */
enum nsock_proxy_state px_state;
/* Each proxy in the chain maintains a data structure. This can contains r/w
* buffers for instance. */
gh_list px_info;
/* Those fields are used to store information about the final target
* to reach. */
struct sockaddr_storage target_ss;
size_t target_sslen;
unsigned short target_port;
@@ -136,17 +135,9 @@ struct proxy_chain_context {
struct proxy_op {
const char *prefix;
enum nsock_proxy_type type;
int (*node_new)(struct proxy_node **node, const struct uri *uri);
void (*node_delete)(struct proxy_node *node);
int (*info_new)(void **info);
void (*info_delete)(void *info);
void (*handler)(nsock_pool nspool, nsock_event nsevent, void *udata);
char *(*encode)(const char *src, size_t len, size_t *dlen);
char *(*decode)(const char *src, size_t len, size_t *dlen);
};

View File

@@ -69,11 +69,7 @@ struct http_proxy_info {
/* ---- PROTOTYPES ---- */
static int proxy_http_node_new(struct proxy_node **node, const struct uri *uri);
static void proxy_http_node_delete(struct proxy_node *node);
static int proxy_http_info_new(void **info);
static void proxy_http_info_delete(void *info);
static void proxy_http_handler(nsock_pool nspool, nsock_event nsevent, void *udata);
static char *proxy_http_encode(const char *src, size_t len, size_t *dlen);
static char *proxy_http_decode(const char *src, size_t len, size_t *dlen);
/* ---- PROXY DEFINITION ---- */
@@ -82,11 +78,7 @@ const struct proxy_op proxy_http_ops = {
.type = PROXY_TYPE_HTTP,
.node_new = proxy_http_node_new,
.node_delete = proxy_http_node_delete,
.info_new = proxy_http_info_new,
.info_delete = proxy_http_info_delete,
.handler = proxy_http_handler,
.encode = proxy_http_encode,
.decode = proxy_http_decode
};
@@ -118,22 +110,6 @@ void proxy_http_node_delete(struct proxy_node *node) {
free(node);
}
int proxy_http_info_new(void **info) {
struct http_proxy_info *pxi;
pxi = (struct http_proxy_info *)safe_zalloc(sizeof(struct http_proxy_info));
pxi->dummy = NULL; // TODO
*info = pxi;
return 1;
}
void proxy_http_info_delete(void *info) {
if (info)
free(info);
}
void proxy_http_handler(nsock_pool nspool, nsock_event nsevent, void *udata) {
mspool *nsp = (mspool *)nspool;
msevent *nse = (msevent *)nsevent;
@@ -180,7 +156,6 @@ void proxy_http_handler(nsock_pool nspool, nsock_event nsevent, void *udata) {
} else {
nse->iod->px_ctx->px_current = nse->iod->px_ctx->px_current->next;
nse->iod->px_ctx->px_state = PROXY_STATE_INITIAL;
nsock_proxy_ev_dispatch(nsp, nse, udata);
}
}
@@ -195,13 +170,3 @@ void proxy_http_handler(nsock_pool nspool, nsock_event nsevent, void *udata) {
}
}
char *proxy_http_encode(const char *src, size_t len, size_t *dlen) {
// TODO
return NULL;
}
char *proxy_http_decode(const char *src, size_t len, size_t *dlen) {
// TODO
return NULL;
}