/* This file is part of Metaproxy.
- Copyright (C) 2005-2012 Index Data
+ Copyright (C) Index Data
Metaproxy 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
#include <yaz/log.h>
#include <yaz/otherinfo.h>
#include <yaz/diagbib1.h>
+#include <yaz/oid_db.h>
#include <yazpp/socket-manager.h>
#include <yazpp/pdu-assoc.h>
int m_timeout_sec;
int m_max_sockets;
bool m_force_close;
+ bool m_client_ip;
std::string m_default_target;
std::string m_force_target;
boost::mutex m_mutex;
m_p->m_timeout_sec = 30;
m_p->m_max_sockets = 0;
m_p->m_force_close = false;
+ m_p->m_client_ip = false;
}
yf::Z3950Client::~Z3950Client() {
return 0;
}
boost::xtime xt;
- xtime_get(&xt, boost::TIME_UTC);
+ xtime_get(&xt,
+#if BOOST_VERSION >= 105000
+ boost::TIME_UTC_
+#else
+ boost::TIME_UTC
+#endif
+ );
xt.sec += 15;
if (!m_cond_session_ready.timed_wait(lock, xt))
if (gdu->u.z3950->which == Z_APDU_close)
c->m_has_closed = true;
+ Z_APDU *apdu = gdu->u.z3950;
+
// prepare connect
c->m_time_elapsed = 0;
c->m_waiting = true;
{
return;
}
-
+ mp::odr odr;
+ if (m_client_ip)
+ {
+ std::string peer_name2 = package.origin().get_address();
+ if (apdu->which == Z_APDU_initRequest && peer_name2.length())
+ {
+ Z_OtherInformation **oi = &apdu->u.initRequest->otherInfo;
+ char *peer_name1 =
+ yaz_oi_get_string_oid(oi, yaz_oid_userinfo_client_ip, 1, 1);
+ std::string pcomb;
+ if (peer_name1)
+ {
+ pcomb.append(peer_name1);
+ pcomb.append(", ");
+ }
+ pcomb.append(peer_name2);
+ yaz_oi_set_string_oid(&apdu->u.initRequest->otherInfo,
+ odr, yaz_oid_userinfo_client_ip,
+ 1, pcomb.c_str());
+ }
+ }
// prepare response
c->m_time_elapsed = 0;
c->m_waiting = true;
{
m_p->m_force_close = mp::xml::get_bool(ptr, 0);
}
+ else if (!strcmp((const char *) ptr->name, "client_ip"))
+ {
+ m_p->m_client_ip = mp::xml::get_bool(ptr, 0);
+ }
else
{
throw mp::filter::FilterException("Bad element "