/*
 * ProFTPD - mod_proxy
 * Copyright (c) 2012-2023 TJ Saunders
 *
 * 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.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
 *
 * As a special exemption, TJ Saunders and other respective copyright holders
 * give permission to link this program with OpenSSL, and distribute the
 * resulting executable, without including the source code for OpenSSL in the
 * source distribution.
 */

#ifndef MOD_PROXY_H
#define MOD_PROXY_H

#include "conf.h"
#include "privs.h"

#include <signal.h>

#if HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif

/* Define if you have the <zlib.h> header.  */
#undef HAVE_ZLIB_H

/* Define if you have OpenSSL with crippled AES support. */
#undef HAVE_AES_CRIPPLED_OPENSSL

/* Define if you have OpenSSL with EVP_aes_128_ctr support. */
#undef HAVE_EVP_AES_128_CTR_OPENSSL

/* Define if you have OpenSSL with EVP_aes_192_ctr support. */
#undef HAVE_EVP_AES_192_CTR_OPENSSL

/* Define if you have OpenSSL with EVP_aes_256_ctr support. */
#undef HAVE_EVP_AES_256_CTR_OPENSSL

/* Define if you have OpenSSL with EVP_aes_256_gcm support. */
#undef HAVE_EVP_AES_256_GCM_OPENSSL

/* Define if you have OpenSSL with OSSL_PROVIDER_load support. */
#undef HAVE_OSSL_PROVIDER_LOAD_OPENSSL

/* Define if you have OpenSSL with SHA256 support. */
#undef HAVE_SHA256_OPENSSL

/* Define if you have OpenSSL with SHA512 support. */
#undef HAVE_SHA512_OPENSSL

/* Define if you have OpenSSL with X448 support. */
#undef HAVE_X448_OPENSSL

/* Define if you have the sqlite3.h header.  */
#undef HAVE_SQLITE3_H
#if !defined(HAVE_SQLITE3_H)
# error "SQLite library/headers required"
#endif

/* Define if you have the random(3) function.  */
#undef HAVE_RANDOM

/* Define if you have the sqlite3_stmt_readonly() function.  */
#undef HAVE_SQLITE3_STMT_READONLY

/* Define if you have the sqlite3_trace() function.  */
#undef HAVE_SQLITE3_TRACE

/* Define if you have the sqlite3_trace_v2() function.  */
#undef HAVE_SQLITE3_TRACE_V2

/* Define if you have the srandom(3) function.  */
#undef HAVE_SRANDOM

/* Define if you have the strnstr(3) function.  */
#undef HAVE_STRNSTR

#define MOD_PROXY_VERSION	"mod_proxy/0.9.3"

/* Make sure the version of proftpd is as necessary. */
#if PROFTPD_VERSION_NUMBER < 0x0001030706
# error "ProFTPD 1.3.7a or later required"
#endif

/* mod_proxy option flags */
#define PROXY_OPT_USE_PROXY_PROTOCOL_V1		0x0001
#define PROXY_OPT_SHOW_FEATURES			0x0002
#define PROXY_OPT_USE_REVERSE_PROXY_AUTH	0x0004
#define PROXY_OPT_USE_DIRECT_DATA_TRANSFERS	0x0008
#define PROXY_OPT_IGNORE_CONFIG_PERMS		0x0010
#define PROXY_OPT_USE_PROXY_PROTOCOL_V2		0x0020
#define PROXY_OPT_USE_PROXY_PROTOCOL_V2_TLVS	0x0040

/* mod_proxy datastores */
#define PROXY_DATASTORE_SQLITE			1
#define PROXY_DATASTORE_REDIS			2

/* Miscellaneous */
extern int proxy_logfd;
extern module proxy_module;
extern pool *proxy_pool;
extern unsigned long proxy_opts;
extern unsigned int proxy_sess_state;
extern int proxy_datastore;
extern void *proxy_datastore_data;
extern size_t proxy_datastore_datasz;

/* mod_proxy session state flags */
#define PROXY_SESS_STATE_PROXY_AUTHENTICATED	0x0001
#define PROXY_SESS_STATE_CONNECTED		0x0002
#define PROXY_SESS_STATE_BACKEND_AUTHENTICATED	0x0004
#define PROXY_SESS_STATE_BACKEND_HAS_CTRL_TLS	0x0008
#define PROXY_SESS_STATE_BACKEND_HAS_DATA_TLS	0x0010

#define PROXY_SESS_STATE_SSH_HAVE_KEX		0x0020
#define PROXY_SESS_STATE_SSH_HAVE_SERVICE	0x0040
#define PROXY_SESS_STATE_SSH_HAVE_AUTH		0x0080
#define PROXY_SESS_STATE_SSH_REKEYING		0x0100
#define PROXY_SESS_STATE_SSH_HAVE_EXT_INFO	0x0200

#ifndef PROXY_DEFAULT_RETRY_COUNT
# define PROXY_DEFAULT_RETRY_COUNT		5 
#endif

/* mod_proxy SSH roles */
#define PROXY_SSH_ROLE_SERVER			1
#define PROXY_SSH_ROLE_CLIENT			2

#endif /* MOD_PROXY_H */
