tntconfig.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Tommi Maekitalo
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * As a special exception, you may use this file as part of a free
10  * software library without restriction. Specifically, if other files
11  * instantiate templates or use macros or inline functions from this
12  * file, or you compile this file and link it with other files to
13  * produce an executable, this file does not by itself cause the
14  * resulting executable to be covered by the GNU General Public
15  * License. This exception does not however invalidate any other
16  * reasons why the executable file might be covered by the GNU Library
17  * General Public License.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27  */
28 
29 
30 #ifndef TNT_TNTCONFIG_H
31 #define TNT_TNTCONFIG_H
32 
33 #include <string>
34 #include <vector>
35 #include <map>
36 #include <tnt/http.h>
38 #include <cxxtools/timespan.h>
39 #include <cxxtools/log.h>
40 
41 namespace tnt
42 {
43  static const int SSL_ALL = 0;
44  static const int SSL_NO = 1;
45  static const int SSL_YES = 2;
46 
100  struct TntConfig
101  {
103  struct Mapping
104  {
105  std::string target;
106  std::string url;
107  std::string vhost;
108  std::string method;
109  std::string pathinfo;
110  unsigned httpreturn;
111  int ssl;
112 
113  typedef std::map<std::string, std::string> ArgsType;
114 
116 
118  : httpreturn(HTTP_OK)
119  { }
120  };
121 
123  struct Listener
124  {
125  std::string ip;
126  unsigned short port;
127  };
128 
130  struct SslListener : public Listener
131  {
132  std::string certificate;
133  std::string key;
134  };
135 
136  typedef std::vector<Mapping> MappingsType;
137  typedef std::vector<Listener> ListenersType;
138  typedef std::vector<SslListener> SslListenersType;
139  typedef std::vector<std::string> CompPathType;
140  typedef std::map<std::string, std::string> EnvironmentType;
141 
147 
153 
159 
168  unsigned maxRequestSize;
169 
179 
187  std::string user;
188 
196  std::string group;
197 
205  std::string dir;
206 
217  std::string chrootdir;
218 
228  std::string pidfile;
229 
236  bool daemon;
237 
242  unsigned minThreads;
243 
248  unsigned maxThreads;
249 
258 
266  unsigned queueSize;
267 
276 
285 
297 
307 
317 
322  unsigned keepAliveMax;
323 
329 
338  unsigned listenBacklog;
339 
347  unsigned listenRetry;
348 
349  // TODO: Where do the 10% come from? Was this an old behaviour replaced
350  // by minCompressSize or is this an additional (unconfigurable) check?
360 
367  unsigned minCompressSize;
368 
375  std::string mimeDb;
376 
385  unsigned maxUrlMapCache;
386 
394  std::string defaultContentType;
395 
404  std::string accessLog;
405 
415  std::string errorLog;
416 
425 
436 
440 
448 
456  std::string documentRoot;
457 
467  std::string server;
468 
478 
486  std::vector<std::string> includes;
487 
492  std::string sslCipherList;
493 
504  std::string sslProtocols;
505 
507  TntConfig();
508 
510  bool hasValue(const std::string& key) const
511  { return config.findMember(key) != 0; }
512 
518  static TntConfig& it();
519  };
520 
522  void operator>>= (const cxxtools::SerializationInfo& si, TntConfig::Mapping& mapping);
524  void operator>>= (const cxxtools::SerializationInfo& si, TntConfig::Listener& listener);
526  void operator>>= (const cxxtools::SerializationInfo& si, TntConfig::SslListener& ssllistener);
528  void operator>>= (const cxxtools::SerializationInfo& si, TntConfig& config);
529 }
530 
531 #endif // TNT_TNTCONFIG_H
532