39 #ifdef FIX8_HAVE_OPENSSL
40 #include <Poco/Net/Context.h>
57 using item = tuple<f8String, group_types, bool>;
58 static const item items[]
60 { item(
"session", g_sessions,
true) }, { item(
"log", g_loggers,
false) },
61 { item(
"server_group", g_server_group,
false) }, { item(
"client_group", g_client_group,
false) },
62 { item(
"ssl_context", g_ssl_context,
false) }, { item(
"schedule", g_schedules,
false) },
63 { item(
"login", g_logins,
false) }, { item(
"persist", g_persisters,
false) }
66 for (
auto &pp : items)
67 if (!load_map(
"fix8/" + get<0>(pp), _groups[get<1>(pp)], get<2>(pp)) && get<2>(pp))
68 throw ConfigurationError(
"could not locate server session in configuration", get<0>(pp));
70 return static_cast<int>(_groups[g_sessions].size());
77 return from_or_default(from,
"role", role)
85 Poco::Net::SocketAddress to;
87 if (from_or_default(from,
"ip", ip) && from_or_default(from,
"port", port))
88 to = Poco::Net::SocketAddress(ip, port);
96 Poco::Net::IPAddress to;
98 if (from_or_default(from,
"ip", ip))
99 to = Poco::Net::IPAddress(ip);
109 if (from_or_default(from,
"server_group", name) && (which =
find_group(g_server_group, name)))
112 if (which->
find(
"server_group/server", slist))
114 const Poco::Net::SocketAddress empty_addr;
115 for(
const auto *pp : slist)
118 Poco::Net::SocketAddress addr(get_address(pp));
119 if (pp->GetAttr(
"name", name) && addr != empty_addr && pp->FindAttr(
"active",
true))
121 pp->FindAttr(
"reset_sequence_numbers",
false)));
124 return target.size();
133 Tickval start(get_time_field(which,
"start_time",
true));
136 const int utc_offset(which->
FindAttr(
"utc_offset_mins", 0));
137 const unsigned duration(which->
FindAttr(
"duration", 0));
138 Tickval end(get_time_field(which,
"end_time",
true));
140 if (end.is_errorval())
148 throw ConfigurationError(
"Schedule end time cannot be equal to or before session start time");
151 const int start_day(which->
GetAttr(
"start_day", daytmp) ?
decode_dow(daytmp) : -1);
152 const int end_day(which->
GetAttr(
"end_day", daytmp) ?
decode_dow(daytmp) : start_day < 0 ? -1 : start_day);
153 return {start, end,
Tickval(static_cast<Tickval::ticks>(duration)), utc_offset, start_day, end_day};
164 if (from_or_default(from,
"schedule", name) && (which =
find_group(g_schedules, name)))
166 Schedule sch(create_schedule(which));
167 f8String reject_text(
"Business messages are not accepted now.");
168 which->
GetAttr(
"reject_text", reject_text);
169 const int reject_code(which->
FindAttr(
"reject_code", 0));
181 return from_or_default(from,
"login", name) && (which =
find_group(g_logins, name))
182 ? create_schedule(which) :
Schedule();
190 if (from_or_default(from,
"persist", name) && (which =
find_group(g_persisters, name)) && which->
GetAttr(
"type", type))
195 string dir(
"./"), db(
"persist_db");
201 else if (which->
FindAttr(
"use_session_id",
false))
202 db += (
'.' + get_sender_comp_id(from)() +
'.' + get_target_comp_id(from)());
204 #if defined FIX8_HAVE_LIBMEMCACHED
205 if (type ==
"memcached")
208 if (which->
GetAttr(
"config_string", config_str))
210 unique_ptr<MemcachedPersister> result(
new MemcachedPersister);
211 if (result->initialise(config_str, db, flag))
212 return result.release();
215 throw ConfigurationError(
"memcached: config_string attribute must be given when using memcached");
219 #if defined FIX8_HAVE_LIBHIREDIS
223 if (which->
GetAttr(
"host", host_str))
225 unique_ptr<HiredisPersister> result(
new HiredisPersister);
226 if (result->initialise(host_str, which->
FindAttr(
"port", 6379),
228 return result.release();
235 #if defined FIX8_HAVE_BDB
238 unique_ptr<BDBPersister> result(
new BDBPersister);
239 if (result->initialise(dir, db, flag))
240 return result.release();
247 if (result->initialise(dir, db, flag))
248 return result.release();
259 if (from_or_default(from, ltype == session_log ?
"session_log" :
"protocol_log", name))
267 if (which->
GetAttr(
"type", type)
268 && ((type %
"session" && ltype == session_log) || (type %
"protocol" && ltype == protocol_log)))
270 string logname(
"logname_not_set.log"), levstr, delim(
" ");
273 if (which->
GetAttr(
"delimiter", delim) && delim.size() > 2)
276 which->
GetAttr(
"levels", levstr);
284 if (logname[0] ==
'|')
286 #ifndef FIX8_HAVE_POPEN
289 return new PipeLogger(logname, flags, levels, delim, positions);
293 if (_ipexp.SearchString(match, logname, 3) == 3)
296 _ipexp.SubExpr(match, logname, ip, 0, 1);
297 _ipexp.SubExpr(match, logname, port, 0, 2);
298 return new BCLogger(ip, stoul(port), flags, levels, delim, positions);
301 get_logname(which, logname, sid);
303 return new XmlFileLogger(logname, flags, levels, delim, positions, get_logfile_rotation(which));
304 return new FileLogger(logname, flags, levels, delim, positions, get_logfile_rotation(which));
318 if (from_or_default(from,
"target_comp_id", name) && (which =
find_group(g_client_group, name)))
321 if (which->
find(
"client_group/client", slist))
324 for(
const auto *pp : slist)
327 const Poco::Net::IPAddress addr(get_ip(pp));
328 if (pp->GetAttr(
"name", name) && pp->GetAttr(
"target_comp_id", tci) && pp->FindAttr(
"active",
true))
329 if (!clients.insert({tci, Client(name, addr)}).second)
343 else if (from && from->
FindAttr(
"use_session_id",
false))
344 to += (
'.' + get_sender_comp_id(from)() +
'.' + get_target_comp_id(from)());
356 if (from && from->
GetAttr(tag, flags_str))
358 istringstream istr(flags_str);
359 for(
char extr[32]; !istr.get(extr,
sizeof(extr),
'|').fail(); istr.ignore(1))
362 const int evalue(flags.set(names,
trim(result),
true,
true));
363 if (positions && evalue >= 0)
364 positions->push_back(evalue);
374 for (
const auto *pp : _allsessions)
376 target.push_back(pp);
377 return static_cast<unsigned>(target.size());
383 static const vector<f8String> process_strings {
"threaded",
"pipelined",
"coroutine" };
385 return from_or_default(from,
"process_model", pm)
390 #ifdef FIX8_HAVE_OPENSSL
396 if (from_or_default(from,
"ssl_context", name) && (which =
find_group(g_ssl_context, name)))
398 static std::string empty, cipher(
"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"), relaxed(
"relaxed");
405 name = which->
FindAttrRef(
"verification_mode", relaxed);
408 else if (name ==
"relaxed")
410 else if (name ==
"strict")
412 else if (name ==
"once")
const MessageSpec * find_group(const CommonGroupMap &globmap, int &vers, unsigned tp, uint32_t key)
T FindAttr(const std::string &what, const T defValue) const
f8_thread delegated async logging class
std::string _certificate_file
static const int StdFlags
F8API std::string & get_logname(const XmlElement *from, std::string &to, const SessionID *sid=nullptr) const
POSIX regex wrapper class.
int _verification_mode
are used (see loadDefaultCAs).
std::string trim(const std::string &source, const std::string &ws=" \t")
T & FindAttrRef(const std::string &what, T &target) const
std::string _cipher_list
"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"
Base (ABC) Persister class.
Class to hold server settings for failoverable sessions.
bool _load_default_cas
false
F8API Schedule create_schedule(const XmlElement *from) const
F8API Poco::Net::SocketAddress get_address(const XmlElement *from) const
static const std::vector< std::string > _bit_names
string representation of logflags
const sender_comp_id & get_senderCompID() const
Role
Roles: acceptor, initiator or unknown.
Quickfix style sessionid.
std::unordered_map< f8String, Client > Clients
ProcessModel
Supported session process models.
F8API Persister * create_persister(const XmlElement *from, const SessionID *sid=nullptr, bool flag=false) const
F8API size_t get_addresses(const XmlElement *from, std::vector< Server > &target) const
std::vector< int > LogPositions
A simple xml parser with Xpath style lookup.
An bad or missing configuration parameter.
F8API unsigned get_all_sessions(std::vector< const XmlElement * > &target, const Connection::Role role=Connection::cn_unknown) const
static const std::vector< std::string > _level_names
string representation of levels
F8API int decode_dow(const std::string &from)
F8API Connection::Role get_role(const XmlElement *from) const
std::set< const XmlElement *, EntityOrderComp > XmlSet
std::string _private_key_file
T enum_str_get(const std::vector< std::string > &sset, const std::string &what, const T def, bool ignorecase=false)
const target_comp_id & get_targetCompID() const
F8API bool GetAttr(const std::string &what, std::string &target) const
Memory based message persister.
F8API Session_Schedule * create_session_schedule(const XmlElement *from) const
F8API Poco::Net::IPAddress get_ip(const XmlElement *from) const
static const ticks minute
T get_logflags(const std::string &tag, const std::vector< std::string > &names, const XmlElement *from, Logger::LogPositions *positions=nullptr) const
A class to contain regex matches using RegExp.
F8API Schedule create_login_schedule(const XmlElement *from) const
F8API Clients create_clients(const XmlElement *from) const
bool HasAttr(const std::string &what) const
Class to hold SSL context for failoverable sessions.
F8API Logger * create_logger(const XmlElement *from, const Logtype ltype, const SessionID *sid=nullptr) const
F8API ProcessModel get_process_model(const XmlElement *from) const
F8API const XmlElement * find(const std::string &what, const std::string *atag=nullptr, const std::string *aval=nullptr, const char delim='/') const