2012-06-04 10:48:31 -04:00
|
|
|
/*
|
|
|
|
* Spdylay - SPDY Library
|
|
|
|
*
|
|
|
|
* Copyright (c) 2012 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
#ifndef SHRPX_CONFIG_H
|
|
|
|
#define SHRPX_CONFIG_H
|
|
|
|
|
2012-06-04 14:11:43 -04:00
|
|
|
#include "shrpx.h"
|
|
|
|
|
2012-06-04 10:48:31 -04:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
|
|
namespace shrpx {
|
|
|
|
|
2012-08-01 11:06:41 -04:00
|
|
|
extern const char SHRPX_OPT_PRIVATE_KEY_FILE[];
|
|
|
|
extern const char SHRPX_OPT_CERTIFICATE_FILE[];
|
|
|
|
|
|
|
|
extern const char SHRPX_OPT_BACKEND[];
|
|
|
|
extern const char SHRPX_OPT_FRONTEND[];
|
|
|
|
extern const char SHRPX_OPT_WORKERS[];
|
|
|
|
extern const char SHRPX_OPT_SPDY_MAX_CONCURRENT_STREAMS[];
|
|
|
|
extern const char SHRPX_OPT_LOG_LEVEL[];
|
|
|
|
extern const char SHRPX_OPT_DAEMON[];
|
|
|
|
extern const char SHRPX_OPT_SPDY_PROXY[];
|
|
|
|
extern const char SHRPX_OPT_ADD_X_FORWARDED_FOR[];
|
|
|
|
extern const char SHRPX_OPT_FRONTEND_SPDY_READ_TIMEOUT[];
|
|
|
|
extern const char SHRPX_OPT_FRONTEND_READ_TIMEOUT[];
|
|
|
|
extern const char SHRPX_OPT_FRONTEND_WRITE_TIMEOUT[];
|
|
|
|
extern const char SHRPX_OPT_BACKEND_READ_TIMEOUT[];
|
|
|
|
extern const char SHRPX_OPT_BACKEND_WRITE_TIMEOUT[];
|
|
|
|
extern const char SHRPX_OPT_ACCESSLOG[];
|
|
|
|
extern const char SHRPX_OPT_BACKEND_KEEP_ALIVE_TIMEOUT[];
|
|
|
|
extern const char SHRPX_OPT_FRONTEND_SPDY_WINDOW_BITS[];
|
|
|
|
extern const char SHRPX_OPT_PID_FILE[];
|
|
|
|
extern const char SHRPX_OPT_USER[];
|
2012-08-01 12:20:18 -04:00
|
|
|
extern const char SHRPX_OPT_SYSLOG[];
|
|
|
|
extern const char SHRPX_OPT_SYSLOG_FACILITY[];
|
2012-08-01 12:28:59 -04:00
|
|
|
extern const char SHRPX_OPT_BACKLOG[];
|
2012-08-01 11:06:41 -04:00
|
|
|
|
2012-06-04 10:48:31 -04:00
|
|
|
union sockaddr_union {
|
|
|
|
sockaddr sa;
|
|
|
|
sockaddr_storage storage;
|
|
|
|
sockaddr_in6 in6;
|
|
|
|
sockaddr_in in;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Config {
|
|
|
|
bool verbose;
|
|
|
|
bool daemon;
|
2012-08-01 11:06:41 -04:00
|
|
|
char *host;
|
2012-06-04 10:48:31 -04:00
|
|
|
uint16_t port;
|
2012-08-01 11:06:41 -04:00
|
|
|
char *private_key_file;
|
|
|
|
char *cert_file;
|
2012-06-04 10:48:31 -04:00
|
|
|
bool verify_client;
|
|
|
|
const char *server_name;
|
2012-08-01 11:06:41 -04:00
|
|
|
char *downstream_host;
|
2012-06-04 10:48:31 -04:00
|
|
|
uint16_t downstream_port;
|
2012-08-01 11:06:41 -04:00
|
|
|
char *downstream_hostport;
|
2012-06-04 10:48:31 -04:00
|
|
|
sockaddr_union downstream_addr;
|
|
|
|
size_t downstream_addrlen;
|
2012-07-17 11:13:11 -04:00
|
|
|
timeval spdy_upstream_read_timeout;
|
2012-06-04 10:48:31 -04:00
|
|
|
timeval upstream_read_timeout;
|
|
|
|
timeval upstream_write_timeout;
|
|
|
|
timeval downstream_read_timeout;
|
|
|
|
timeval downstream_write_timeout;
|
2012-06-12 10:02:01 -04:00
|
|
|
timeval downstream_idle_read_timeout;
|
2012-06-05 12:26:04 -04:00
|
|
|
size_t num_worker;
|
2012-06-06 10:58:19 -04:00
|
|
|
size_t spdy_max_concurrent_streams;
|
2012-07-11 03:20:16 -04:00
|
|
|
bool spdy_proxy;
|
2012-07-12 10:39:11 -04:00
|
|
|
bool add_x_forwarded_for;
|
2012-07-17 12:08:05 -04:00
|
|
|
bool accesslog;
|
2012-07-26 10:18:37 -04:00
|
|
|
size_t spdy_upstream_window_bits;
|
2012-08-01 11:06:41 -04:00
|
|
|
char *pid_file;
|
2012-07-31 12:51:16 -04:00
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
2012-08-01 11:06:41 -04:00
|
|
|
char *conf_path;
|
2012-08-01 12:20:18 -04:00
|
|
|
bool syslog;
|
|
|
|
int syslog_facility;
|
|
|
|
// This member finally decides syslog is used or not
|
|
|
|
bool use_syslog;
|
2012-08-01 12:28:59 -04:00
|
|
|
int backlog;
|
2012-06-04 10:48:31 -04:00
|
|
|
Config();
|
|
|
|
};
|
|
|
|
|
|
|
|
const Config* get_config();
|
|
|
|
Config* mod_config();
|
|
|
|
void create_config();
|
|
|
|
|
2012-08-01 11:06:41 -04:00
|
|
|
// Parses option name |opt| and value |optarg|. The results are
|
|
|
|
// stored into statically allocated Config object. This function
|
|
|
|
// returns 0 if it succeeds, or -1.
|
|
|
|
int parse_config(const char *opt, const char *optarg);
|
|
|
|
|
|
|
|
// Loads configurations from |filename| and stores them in statically
|
|
|
|
// allocated Config object. This function returns 0 if it succeeds, or
|
|
|
|
// -1.
|
|
|
|
int load_config(const char *filename);
|
|
|
|
|
|
|
|
// Copies NULL-terminated string |val| to |*destp|. If |*destp| is not
|
|
|
|
// NULL, it is freed before copying.
|
|
|
|
void set_config_str(char **destp, const char *val);
|
|
|
|
|
2012-08-01 12:20:18 -04:00
|
|
|
// Returns string for syslog |facility|.
|
|
|
|
const char* str_syslog_facility(int facility);
|
|
|
|
|
|
|
|
// Returns integer value of syslog |facility| string.
|
|
|
|
int int_syslog_facility(const char *strfacility);
|
|
|
|
|
2012-06-04 10:48:31 -04:00
|
|
|
} // namespace shrpx
|
|
|
|
|
|
|
|
#endif // SHRPX_CONFIG_H
|