/* -*- c++ -*- */ /* $Id: Config.h,v 1.1 1999/02/22 02:40:46 mahara Exp $ */ #ifndef __config_h_ #define __config_h_ #include #ifndef NO_SSL #include #include #include #include #endif /* !NO_SSL */ #include "common.h" #include "acl.h" #include "portinfo.h" #include "log.h" #include "Socket.h" class Config { public: int log_level; int read_timeout; int max_connection; int deny_wait; int spare_servers; int do_fork; char access_log[FILENAMELEN]; char error_log[FILENAMELEN]; PortinfoList accept_port; PortinfoList connect_port; ACLList acl; char CA_cert_file[FILENAMELEN]; char CA_cert_path[FILENAMELEN]; char client_cert_file[FILENAMELEN]; int service_type; /* ----------------------------------------------------------------- */ Config *parent, *next; /* ----------------------------------------------------------------- */ Logger *alogp; /* pointer to access log object */ Logger *elogp; /* pointer to error log object */ int f_open_access_log; /* 1 : alogp was created by this object */ int f_open_error_log; /* 1 : elogp was created by this object */ SOCKADDR_IN sa_accept, sa_connect; SOCKET soc_accept; #ifndef NO_SSL SSL_CTX *ctx_accept; SSL_CTX *ctx_connect; X509 *CA_X509; RSA *CA_RSA; #endif /* NO_SSL */ Portinfo *connectp; char servicename[80]; /* ----------------------------------------------------------------- */ Config(char *name = 0); ~Config(); void debug(); void setNext(Config *obj); int init(); int readFile(char *filename); int canStart() { return (accept_port.isEnable() && connect_port.isEnable()) ? 1 : 0; } int start(); int _accept(int flag = FALSE); void stop(); int makeCert(char *name, time_t days, int bits); protected: int parse(FILE *fp); int createAcceptSocket(); int createConnectSocket(); void closeClientSocket(int csoc, SOCKADDR_IN *sap); void closeServerSocket(int ssoc, SOCKADDR_IN *sap); int openAccessLog(); int openErrorLog(); void listen(); #ifndef NO_SSL SSL *acceptSSL(SOCKET csoc); SSL *connectSSL(SOCKET ssoc); void PUTSSLERR(); #endif /* !NO_SSL */ int relay(Socket *c, Socket *s); int initAccept(); int initConnect(Portinfo *cp); int createSpareServer(); }; #ifndef NO_SSL int initSSL(); #endif /* NO_SSL */ #endif /* __config_h__ */