/*
 * ProFTPD - mod_proxy
 * Copyright (c) 2012-2020 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 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.7"

/* 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

/* 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

#ifndef PROXY_DEFAULT_RETRY_COUNT
# define PROXY_DEFAULT_RETRY_COUNT		5 
#endif

#endif /* MOD_PROXY_H */
