[BACK]Return to client.h CVS log [TXT][DIR] Up to [local] / acopm / lib / proxy

File: [local] / acopm / lib / proxy / client.h (download)

Revision 1.1.1.1 (vendor branch), Sat May 8 15:42:18 2021 UTC (3 years, 2 months ago) by bountyht
Branch: alphachat, MAIN
CVS Tags: start, HEAD
Changes since 1.1: +0 -0 lines

Initial import

/*
 * Copyright (C) 2017 Aaron M. D. Jones <aaronmdjones@gmail.com>
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following
 * conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE ARE DISCLAIMED.
 *
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef INC_LIBACOPM_PROXY_CLIENT_H
#define INC_LIBACOPM_PROXY_CLIENT_H

#include "acopm-common.h"

#include <time.h> /* time_t */

#include <event2/event.h> /* struct event_base */

#define ACOPM_PROXY_CONNECT_TIMEOUT_MIN 3U
#define ACOPM_PROXY_CONNECT_TIMEOUT_MAX 60U
#define ACOPM_PROXY_DATA_TIMEOUT_MIN    3U
#define ACOPM_PROXY_DATA_TIMEOUT_MAX    60U

#define ACOPM_PROXY_RECVBUF_SZ_MIN      256U
#define ACOPM_PROXY_RECVBUF_SZ_MAX      262144U
#define ACOPM_PROXY_SENDBUF_SZ_MIN      128U
#define ACOPM_PROXY_SENDBUF_SZ_MAX      4096U

#define ACOPM_PROXY_USER_DEF            "acopm"
#define ACOPM_PROXY_USER_MAX            15

enum acopm_proxy_type
{
	ACOPM_PROXY_TYPE_NONE           = 0,
	ACOPM_PROXY_TYPE_PORT           = 1,
	ACOPM_PROXY_TYPE_SOCKS4         = 2,
	ACOPM_PROXY_TYPE_SOCKS5         = 3,
	ACOPM_PROXY_TYPE_HTTP_CONNECT   = 4,

#ifdef BUILD_WITH_MBEDTLS
	ACOPM_PROXY_TYPE_HTTPS_CONNECT  = 5,
#endif

} acopm_attr_packed;

struct acopm_proxy_client;

struct acopm_proxy_client *acopm_proxy_new(struct event_base *) acopm_attr_malloc;
void acopm_proxy_set_recvbuf_sz(struct acopm_proxy_client *, size_t);
void acopm_proxy_set_sendbuf_sz(struct acopm_proxy_client *, size_t);
void acopm_proxy_set_connect_timeout(struct acopm_proxy_client *, time_t);
void acopm_proxy_set_data_timeout(struct acopm_proxy_client *, time_t);
void acopm_proxy_set_username(struct acopm_proxy_client *, const char *);
void acopm_proxy_free(struct acopm_proxy_client *);
const char *acopm_proxy_type_str(enum acopm_proxy_type);

#endif /* !INC_LIBACOPM_PROXY_CLIENT_H */