xsltproc docbook docbook-xml docbook-xsl inkscape
libxslt1-dev libgnutls-dev libreadline5-dev libicu-dev
libboost-dev libboost-thread-dev libboost-test-dev
- libboost-regex-dev
+ libboost-regex-dev libboost-system-dev
And if you want to make a Debian package: dpkg-dev fakeroot debhelper
(Then run "dpkg-buildpackage -rfakeroot" in this directory.)
USEMARCON_INIT
## YAZPP checks
-YAZPP_INIT([threads],[1.4.0])
+YAZPP_INIT([threads],[1.4.1])
if test -z "$YAZPPLIB"; then
AC_MSG_ERROR([YAZ++ development libraries missing])
fi
)
YAZ_DOC
-ID_BOOST([thread test regex],[1.33])
+ID_BOOST([system thread test regex],[1.33])
if test -z "${BOOST_THREAD_LIB}"; then
AC_MSG_ERROR([Boost thread development libraries required])
fi
Standards-Version: 3.6.2
Maintainer: Adam Dickmeiss <adam@indexdata.dk>
Priority: extra
-Build-Depends: debhelper (>= 4),
+Build-Depends: debhelper (>= 5),
libyaz4-dev (>= 4.2.50),
- libyazpp5-dev (>= 1.4.0),
+ libyazpp5-dev (>= 1.4.1),
libxslt1-dev,
libboost-dev,
+ libboost-system-dev,
libboost-thread-dev,
libboost-test-dev,
libboost-regex-dev
.
This package includes the Metaproxy libraries.
+Package: libmetaproxy4-dbg
+Section: debug
+Architecture: any
+Depends: libmetaproxy4 (= ${binary:Version}), ${misc:Depends}
+Description: debugging symbols for libmetaproxy4
+ This is a universal router, proxy and encapsulated metasearcher
+ for information retrieval protocols. It accepts, processes, interprets
+ and redirects requests from IR clients using standard protocols such as
+ the binary ANSI/NISO Z39.50 and the information search and retrieval web
+ service SRU as well as functioning as a limited HTTP server.
+ .
+ This package contains the debugging symbols for libmetaproxy4.
+
Package: libmetaproxy4-dev
Section: libdevel
Architecture: any
# dh_installinfo
dh_installman
dh_link
- dh_strip
+ dh_strip --dbg-package=libmetaproxy4-dbg
dh_compress
dh_fixperms
# dh_perl
<command>metaproxy</command>
<arg choice="opt"><option>--help</option></arg>
<arg choice="opt"><option>--version</option></arg>
+ <arg choice="opt"><option>-v <replaceable>loglevel</replaceable></option></arg>
<arg choice="opt"><option>--config <replaceable>config</replaceable></option></arg>
<arg choice="opt"><option>-D</option></arg>
<arg choice="opt"><option>-l <replaceable>logfile</replaceable></option></arg>
</varlistentry>
<varlistentry>
+ <term>-v <replaceable>loglevel</replaceable></term>
+ <listitem><para>
+ Specify YAZ log level (all, debug, log)
+ </para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term>--config <replaceable>config</replaceable></term>
<listitem><para>
Specify the configuration.
$(srcdir)/config-zoom.xml \
$(srcdir)/retrieval-info.xml
-config = example.simple-auth example.target-auth pqf2pqf.xsl explain.xml
+config = example.simple-auth example.target-auth pqf2pqf.xsl explain.xml \
+ ztest.pem
rng = $(srcdir)/../xml/schema/metaproxy.rng
--- /dev/null
+<?xml version="1.0"?>
+<metaproxy xmlns="http://indexdata.com/metaproxy" version="1.0">
+ <start route="start"/>
+ <!-- sample config which illustrates the use of http_file filter.. -->
+ <filters>
+ <filter id="frontend" type="frontend_net">
+ <threads>20</threads>
+ <port>@:9000</port>
+ <message>FN</message>
+ <stat-req>/fn_stat</stat-req>
+ </filter>
+ </filters>
+ <routes>
+ <route id="start">
+ <filter refid="frontend"/>
+ <filter type="http_file">
+ <mimetypes>/etc/mime.types</mimetypes>
+ <area>
+ <documentroot>.</documentroot>
+ <prefix>/etc</prefix>
+ </area>
+ </filter>
+ <filter type="log"><category access="false" line="true" apdu="true" /></filter>
+<!--
+ <filter type="http_rewrite1">
+ <replace content-type="text/html" pattern="YAZ" replacement="yaz"/>
+ </filter>
+-->
+ <filter type="http_client">
+<!--
+ <proxy>localhost:9999</proxy>
+-->
+ </filter>
+ <filter type="bounce"/>
+ </route>
+ </routes>
+</metaproxy>
+
<filter type="log">
<message>log</message>
</filter>
+ <filter type="sd_remove"/>
<filter type="present_chunk">
<chunk>2</chunk>
</filter>
<filter type="frontend_net">
<threads>10</threads>
<port>@:9000</port>
+ <port cert_fname="ztest.pem">ssl:@:9001</port>
</filter>
<filter type="log">
<message>M</message>
<prefix>/etc</prefix>
</area>
</filter>
+ <filter type="http_rewrite1">
+ <replace content-type="text/html" pattern="YAZ" replacement="yaz"/>
+ </filter>
<filter type="http_client">
- <proxy>localhost:9999</proxy>
+ <default-host>http://localhost:9999</default-host>
</filter>
<filter type="bounce"/>
</route>
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIDNzCCAqCgAwIBAgIJAJm06bCx5AKQMA0GCSqGSIb3DQEBBQUAMHExCzAJBgNV
+BAYTAkRLMRMwEQYDVQQHEwpDb3BlbmhhZ2VuMRcwFQYDVQQKEw5JbmRleCBEYXRh
+IEFwUzESMBAGA1UEAxMJbG9jYWxob3N0MSAwHgYJKoZIhvcNAQkBFhFhZGFtQGlu
+ZGV4ZGF0YS5kazAeFw0xMjExMTQxNzQ3MDNaFw0yMjExMTIxNzQ3MDNaMHExCzAJ
+BgNVBAYTAkRLMRMwEQYDVQQHEwpDb3BlbmhhZ2VuMRcwFQYDVQQKEw5JbmRleCBE
+YXRhIEFwUzESMBAGA1UEAxMJbG9jYWxob3N0MSAwHgYJKoZIhvcNAQkBFhFhZGFt
+QGluZGV4ZGF0YS5kazCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAuPTZwVaB
+u5OEjNOFaGCiCiIUJTsa9YZ0CO18bzcC8+2ENjnYpoSqzzYpnXwBtN71S7Wim+H+
+D9XMpvi9Y+qtwe49RHUL9B+J+mV+zB9OR8yJibkXEAOrkVNCegrOAIze4gvMm4ek
+FTXsicQNdanQeQMC9uyIEn8EiJHdgWjSaQMCAwEAAaOB1jCB0zAdBgNVHQ4EFgQU
+uLY9vUCqQxYVstTwjhjALoC04g8wgaMGA1UdIwSBmzCBmIAUuLY9vUCqQxYVstTw
+jhjALoC04g+hdaRzMHExCzAJBgNVBAYTAkRLMRMwEQYDVQQHEwpDb3BlbmhhZ2Vu
+MRcwFQYDVQQKEw5JbmRleCBEYXRhIEFwUzESMBAGA1UEAxMJbG9jYWxob3N0MSAw
+HgYJKoZIhvcNAQkBFhFhZGFtQGluZGV4ZGF0YS5ka4IJAJm06bCx5AKQMAwGA1Ud
+EwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAWHZogB1vW9B32c786yBb1yckWueV
+CNebkXBhPBECJ5uE91ZEIc2L++KISS9yy4Za4ctvDJihgxOotGo0JCfkPLlpA5lR
+n1WR4hgk6YdeoySEtozjRcBwQtfQxBSvUG03XosDAETUGT94rM6cEftvKdJKiKfh
+1SxxGV7fviahCg8=
+-----END CERTIFICATE-----
+-----BEGIN RSA PRIVATE KEY-----
+MIICXAIBAAKBgQC49NnBVoG7k4SM04VoYKIKIhQlOxr1hnQI7XxvNwLz7YQ2Odim
+hKrPNimdfAG03vVLtaKb4f4P1cym+L1j6q3B7j1EdQv0H4n6ZX7MH05HzImJuRcQ
+A6uRU0J6Cs4AjN7iC8ybh6QVNeyJxA11qdB5AwL27IgSfwSIkd2BaNJpAwIDAQAB
+AoGAZmHzoFh4nBL+zs3QDYVgbWeL60galksFNGPx+8Zh9hFGnJXM3fCWdPmwc6LP
+dwXslypGhy/EaZOaI9uRSxv/bmb82LWgizEyHmKGzsaOwhDiehYq0lTteTI5yA7s
+1ViLBk2iEfCwbMyVJjQ/oyqDyqGFr/TVfqNbGV1amManXtECQQDrpRBmW/ZAgiVt
+P7UGrOhE8c4bcioMBHmb2tSoajh13UyTmh/igR3IqsTWPurBDm0XTKxj8Hb9qxr9
+QqYsv5FVAkEAyO7jlJImiIV08E5vrOSpIfk7/9Zup+ZyMtF3D0jk22dDhf9PuCUA
+nxrwLRd4R1aQ8V6GTKg8jz0VZdV7Wshw9wJAKItCAxqXiAncfquTbg6Z+CLSn45J
+BcBPXC2OoVuFU2I8JrlB+yrUAQ7Ax0wUABuHUZbzok5hasvh3Ol2xgQ/8QJBAK/e
+eA+IRHXl6c6TuKdplKgJz/xDoaMPzxCvyjf0o2tuXOmh6BLTQFICcAnnqv01xbOd
++oqKDkeJPXteeZOiMU0CQFYD+XIaTkBd+9aCien4gsKX8fNsKB+H2UVZQDoG7Vah
+G++Axlf9EXtan01wU3cFrfrukotwA7oEetx8Eh3kmBA=
+-----END RSA PRIVATE KEY-----
-CONFIG=../../yazpp/yazpp-config
+CONFIG=../metaproxy-config
SO=metaproxy_filter_myfilter.so
all: $(SO)
$(SO): filter_myfilter.cpp
- $(CXX) -shared `$(CONFIG) --cflags` -fPIC -I ../src $< -o $(SO) ../src/.libs/libmetaproxy.so -ldl
+ echo $(LIBS)
+ $(CXX) -shared `$(CONFIG) --cflags` -fPIC -I ../src $< \
+ -o $(SO) `$(CONFIG) --libs`
clean:
rm -f *.so
class Filter_myfilter: public mp::filter::Base {
public:
void process(mp::Package & package) const;
- void configure(const xmlNode *ptr, bool test_only);
+ void configure(const xmlNode *ptr, bool test_only, const char *path);
};
}
}
}
}
-void mp::filter::Filter_myfilter::configure(const xmlNode *ptr, bool test_only)
+void mp::filter::Filter_myfilter::configure(const xmlNode *ptr, bool test_only, const char *path)
{
- yaz_log(YLOG_LOG, "myfilter::configure");
+ yaz_log(YLOG_LOG, "myfilter::configure called with test_only %d and %s", test_only, path);
for (ptr = ptr->children; ptr; ptr = ptr->next)
{
if (ptr->type != XML_ELEMENT_NODE)
-Subproject commit c40c0aca772c390de538192e144b79af3831f0d7
+Subproject commit 06ec18fbfaad00e4aaf915a2704c4b04c6f2924d
src_root=@abs_top_srcdir@
build_root=@abs_top_builddir@
-libs="@YAZPPLIB@ @LIBS@"
+libs="@BOOST_LIB@ @BOOST_SYSTEM_LIB@ @BOOST_REGEX_LIB@ @BOOST_THREAD_LIB@ @YAZPPLIB@ @LIBS@"
lalibs="@YAZPPLALIB@ @LIBS@"
VERSION=@VERSION@
Source: metaproxy-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Prefix: %{_prefix} /etc/metaproxy
-BuildRequires: pkgconfig, libyaz4-devel >= 4.2.50, libyazpp5-devel >= 1.4.0
+BuildRequires: pkgconfig, libyaz4-devel >= 4.2.50, libyazpp5-devel >= 1.4.1
BuildRequires: libxslt-devel, boost-devel
Conflicts: cf-engine <= 2.12.5
Packager: Adam Dickmeiss <adam@indexdata.dk>
AM_CPPFLAGS = -I$(top_srcdir)/include $(USEMARCONINC)
-AM_LDFLAGS =
-
bin_SCRIPTS = metaproxy-config
-# Rules for the library..
-
-lib_LTLIBRARIES = libmetaproxy.la
-libmetaproxy_la_LDFLAGS = -version-info 4:0:0 -export-dynamic
-
-libmetaproxy_la_SOURCES = \
- factory_filter.cpp factory_filter.hpp \
- factory_static.cpp factory_static.hpp \
- filter.cpp \
+filter_src = \
filter_auth_simple.cpp filter_auth_simple.hpp \
filter_backend_test.cpp filter_backend_test.hpp \
filter_bounce.cpp filter_bounce.hpp \
filter_cgi.cpp filter_cgi.hpp \
filter_cql_to_rpn.cpp filter_cql_to_rpn.hpp \
- filter_frontend_net.cpp filter_frontend_net.hpp \
filter_http_client.cpp filter_http_client.hpp \
filter_http_file.cpp filter_http_file.hpp \
+ filter_http_rewrite1.cpp filter_http_rewrite1.hpp \
filter_limit.cpp filter_limit.hpp \
filter_load_balance.cpp filter_load_balance.hpp \
filter_log.cpp filter_log.hpp \
filter_z3950_client.cpp filter_z3950_client.hpp \
filter_zeerex_explain.cpp filter_zeerex_explain.hpp \
filter_zoom.cpp filter_zoom.hpp \
+ filter_frontend_net.cpp filter_frontend_net.hpp \
+ filter_sd_remove.cpp filter_sd_remove.hpp
+
+lib_LTLIBRARIES = libmetaproxy.la
+libmetaproxy_la_LDFLAGS = -version-info 4:0:0 -export-dynamic
+
+libmetaproxy_la_SOURCES = \
+ factory_filter.cpp factory_filter.hpp \
+ factory_static.cpp factory_static.hpp \
+ filter.cpp \
gduutil.cpp gduutil.hpp \
origin.cpp \
package.cpp \
util.cpp \
xmlutil.cpp
-
-libmetaproxy_la_LIBADD = $(YAZPPLALIB) $(BOOST_LIB) $(BOOST_THREAD_LIB) \
+libmetaproxy_la_LIBADD = $(YAZPPLALIB) \
+ $(BOOST_LIB) $(BOOST_SYSTEM_LIB) $(BOOST_THREAD_LIB) \
$(BOOST_REGEX_LIB)
-# Rules for lib
-
-LDADD = libmetaproxy.la $(YAZPPLALIB) $(BOOST_LIB) $(BOOST_THREAD_LIB) \
+metaproxy_LDADD = libmetaproxy.la $(YAZPPLALIB) \
+ $(BOOST_LIB) $(BOOST_SYSTEM_LIB) $(BOOST_THREAD_LIB) \
$(BOOST_REGEX_LIB) $(USEMARCONLALIB)
+LDADD = $(metaproxy_LDADD) $(BOOST_TEST_LIB)
+AM_LDFLAGS = -export-dynamic
+
bin_PROGRAMS = metaproxy
-noinst_PROGRAMS = ex_filter_frontend_net ex_router_flexml tstdl
+noinst_PROGRAMS = tstdl
-ex_filter_frontend_net_SOURCES = ex_filter_frontend_net.cpp
-ex_router_flexml_SOURCES = ex_router_flexml.cpp
tstdl_SOURCES = tstdl.cpp
-metaproxy_SOURCES = metaproxy_prog.cpp
+metaproxy_SOURCES = metaproxy_prog.cpp $(filter_src)
# Rules for dl programs
pkglib_LTLIBRARIES = metaproxy_filter_dl.la
test_session2_SOURCES=test_session2.cpp
test_boost_threads_SOURCES=test_boost_threads.cpp
test_thread_pool_observer_SOURCES = test_thread_pool_observer.cpp
-test_filter_auth_simple_SOURCES = test_filter_auth_simple.cpp
+test_filter_auth_simple_SOURCES = test_filter_auth_simple.cpp $(filter_src)
test_filter_factory_SOURCES = test_filter_factory.cpp
-test_filter_frontend_net_SOURCES = test_filter_frontend_net.cpp
-test_filter_log_SOURCES = test_filter_log.cpp
-test_filter_multi_SOURCES = test_filter_multi.cpp
-test_filter_query_rewrite_SOURCES = test_filter_query_rewrite.cpp
-test_filter_z3950_client_SOURCES = test_filter_z3950_client.cpp
-test_filter_backend_test_SOURCES = test_filter_backend_test.cpp
-test_filter_bounce_SOURCES = test_filter_bounce.cpp
-test_filter_record_transform_SOURCES = test_filter_record_transform.cpp
-test_filter_sru_to_z3950_SOURCES = test_filter_sru_to_z3950.cpp
-test_filter_virt_db_SOURCES = test_filter_virt_db.cpp
+test_filter_frontend_net_SOURCES = test_filter_frontend_net.cpp $(filter_src)
+test_filter_log_SOURCES = test_filter_log.cpp $(filter_src)
+test_filter_multi_SOURCES = test_filter_multi.cpp $(filter_src)
+test_filter_query_rewrite_SOURCES = test_filter_query_rewrite.cpp $(filter_src)
+test_filter_z3950_client_SOURCES = test_filter_z3950_client.cpp $(filter_src)
+test_filter_backend_test_SOURCES = test_filter_backend_test.cpp $(filter_src)
+test_filter_bounce_SOURCES = test_filter_bounce.cpp $(filter_src)
+test_filter_record_transform_SOURCES = test_filter_record_transform.cpp \
+ $(filter_src)
+test_filter_sru_to_z3950_SOURCES = test_filter_sru_to_z3950.cpp $(filter_src)
+test_filter_virt_db_SOURCES = test_filter_virt_db.cpp $(filter_src)
test_ses_map_SOURCES = test_ses_map.cpp
-test_router_flexml_SOURCES = test_router_flexml.cpp
+test_router_flexml_SOURCES = test_router_flexml.cpp $(filter_src)
test_xmlutil_SOURCES = test_xmlutil.cpp
-TESTLDADD = $(LDADD) $(BOOST_TEST_LIB)
-
-test_package1_LDADD = $(TESTLDADD)
-test_pipe_LDADD = $(TESTLDADD)
-test_filter1_LDADD = $(TESTLDADD)
-test_filter2_LDADD = $(TESTLDADD)
-test_session1_LDADD = $(TESTLDADD)
-test_session2_LDADD = $(TESTLDADD)
-test_boost_threads_LDADD = $(TESTLDADD)
-test_filter_auth_simple_LDADD = $(TESTLDADD)
-test_filter_factory_LDADD = $(TESTLDADD)
-test_filter_frontend_net_LDADD = $(TESTLDADD)
-test_filter_log_LDADD = $(TESTLDADD)
-test_filter_multi_LDADD = $(TESTLDADD)
-test_filter_query_rewrite_LDADD = $(TESTLDADD)
-test_filter_z3950_client_LDADD = $(TESTLDADD)
-test_filter_backend_test_LDADD = $(TESTLDADD)
-test_filter_bounce_LDADD = $(TESTLDADD)
-test_filter_record_transform_LDADD = $(TESTLDADD)
-test_filter_sru_to_z3950_LDADD = $(TESTLDADD)
-test_filter_virt_db_LDADD = $(TESTLDADD)
-test_router_flexml_LDADD = $(TESTLDADD)
-test_ses_map_LDADD = $(TESTLDADD)
-test_thread_pool_observer_LDADD = $(TESTLDADD)
-test_xmlutil_LDADD = $(TESTLDADD)
+# doxygen target
+dox:
+ (cd $(top_srcdir) ; make dox)
+showdox:
+ (cd $(top_srcdir) ; make showdox)
{
return true;
}
-
- std::string full_path = path + "/metaproxy_filter_" + fi + ".so";
- void *dl_handle = dlopen(full_path.c_str(), RTLD_GLOBAL|RTLD_NOW);
- if (!dl_handle)
- {
- const char *dl = dlerror();
- std::cout << "dlopen " << full_path << " failed. dlerror=" << dl <<
- std::endl;
- return false;
- }
-
std::string full_name = "metaproxy_1_filter_" + fi;
+ void *dl_handle = dlopen(0, RTLD_GLOBAL|RTLD_NOW);
void *dlsym_ptr = dlsym(dl_handle, full_name.c_str());
+
+ if (!dlsym_ptr)
+ {
+ std::string full_path = path + "/metaproxy_filter_" + fi + ".so";
+ dl_handle = dlopen(full_path.c_str(), RTLD_GLOBAL|RTLD_NOW);
+ if (!dl_handle)
+ {
+ const char *dl = dlerror();
+ std::cout << "dlopen " << full_path << " failed. dlerror=" << dl <<
+ std::endl;
+ return false;
+ }
+ dlsym_ptr = dlsym(dl_handle, full_name.c_str());
+ }
if (!dlsym_ptr)
{
std::cout << "dlsym " << full_name << " failed\n";
#include "filter_frontend_net.hpp"
#include "filter_http_client.hpp"
#include "filter_http_file.hpp"
+#include "filter_http_rewrite1.hpp"
#include "filter_limit.hpp"
#include "filter_load_balance.hpp"
#include "filter_log.hpp"
#include "filter_present_chunk.hpp"
#include "filter_query_rewrite.hpp"
#include "filter_record_transform.hpp"
+#include "filter_sd_remove.hpp"
#include "filter_session_shared.hpp"
#include "filter_sort.hpp"
#include "filter_sru_to_z3950.hpp"
mp::FactoryStatic::FactoryStatic()
{
+#ifdef HAVE_DLFCN_H
struct metaproxy_1_filter_struct *buildins[] = {
&metaproxy_1_filter_auth_simple,
&metaproxy_1_filter_backend_test,
&metaproxy_1_filter_frontend_net,
&metaproxy_1_filter_http_client,
&metaproxy_1_filter_http_file,
+ &metaproxy_1_filter_http_rewrite1,
&metaproxy_1_filter_limit,
&metaproxy_1_filter_load_balance,
&metaproxy_1_filter_log,
&metaproxy_1_filter_present_chunk,
&metaproxy_1_filter_query_rewrite,
&metaproxy_1_filter_record_transform,
+ &metaproxy_1_filter_sd_remove,
&metaproxy_1_filter_session_shared,
&metaproxy_1_filter_sort,
&metaproxy_1_filter_sru_to_z3950,
for (i = 0; buildins[i]; i++)
add_creator(buildins[i]->type, buildins[i]->creator);
+// WIN32
+#endif
}
friend class FrontendNet;
std::string port;
std::string route;
+ std::string cert_fname;
int max_recv_bytes;
};
class FrontendNet::Rep {
{
Port port;
- const char *names[4] = {"route", "max_recv_bytes", "port", 0};
- std::string values[3];
+ const char *names[5] = {"route", "max_recv_bytes", "port",
+ "cert_fname", 0};
+ std::string values[4];
mp::xml::parse_attr(ptr, names, values);
port.route = values[0];
port.port = values[2];
else
port.port = mp::xml::get_text(ptr);
+ port.cert_fname = values[3];
ports.push_back(port);
}
else if (!strcmp((const char *) ptr->name, "threads"))
// create a PDU assoc object (one per yf::FrontendNet::ZAssocServer)
yazpp_1::PDU_Assoc *as = new yazpp_1::PDU_Assoc(&m_p->mySocketManager);
+ if (m_p->m_ports[i].cert_fname.length())
+ as->set_cert_fname(m_p->m_ports[i].cert_fname.c_str());
// create ZAssoc with PDU Assoc
m_p->az[i] = new yf::FrontendNet::ZAssocServer(
as, m_p->m_ports[i].route, m_p.get());
friend class HTTPClient;
void proxy(mp::Package &package);
std::string proxy_host;
+ std::string default_host;
};
}
}
Z_GDU *res_gdu = 0;
mp::odr o;
yaz_url_t yaz_url = yaz_url_create();
+ std::string uri;
if (proxy_host.length())
yaz_url_set_proxy(yaz_url, proxy_host.c_str());
- Z_HTTP_Response *http_response =
- yaz_url_exec(yaz_url, hreq->path, hreq->method,
+
+ if (hreq->path[0] == '/')
+ {
+ if (default_host.length())
+ uri = default_host + hreq->path;
+ }
+ else
+ uri = hreq->path;
+ Z_HTTP_Response *http_response = 0;
+ if (uri.length())
+ http_response =
+ yaz_url_exec(yaz_url, uri.c_str(), hreq->method,
hreq->headers, hreq->content_buf,
hreq->content_len);
if (http_response)
{
m_p->proxy_host = mp::xml::get_text(ptr);
}
+ else if (!strcmp((const char *) ptr->name, "default-host"))
+ {
+ m_p->default_host = mp::xml::get_text(ptr);
+ if (m_p->default_host.find("://") == std::string::npos)
+ {
+ throw mp::filter::FilterException
+ ("default-host is missing method (such as http://)"
+ " in http_client filter");
+ }
+ }
else
{
throw mp::filter::FilterException
("Bad element "
+ std::string((const char *) ptr->name)
- + " in virt_db filter");
+ + " in http_client filter");
}
}
}
--- /dev/null
+/* This file is part of Metaproxy.
+ Copyright (C) 2005-2013 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
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "config.hpp"
+#include <metaproxy/filter.hpp>
+#include <metaproxy/package.hpp>
+#include <metaproxy/util.hpp>
+#include "filter_http_rewrite1.hpp"
+
+#include <yaz/zgdu.h>
+#include <yaz/log.h>
+
+#include <boost/thread/mutex.hpp>
+#include <boost/regex.hpp>
+
+#include <list>
+#include <map>
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+namespace mp = metaproxy_1;
+namespace yf = mp::filter;
+
+namespace metaproxy_1 {
+ namespace filter {
+ class HttpRewrite1::Rule {
+ public:
+ std::string content_type;
+ std::string pattern;
+ std::string replacement;
+ std::string mode;
+ };
+ class HttpRewrite1::Rep {
+ friend class HttpRewrite1;
+ void rewrite_response(mp::odr &o, Z_HTTP_Response *hres);
+ std::list<Rule> rules;
+ };
+ }
+}
+
+yf::HttpRewrite1::HttpRewrite1() : m_p(new Rep)
+{
+}
+
+yf::HttpRewrite1::~HttpRewrite1()
+{
+}
+
+void yf::HttpRewrite1::Rep::rewrite_response(mp::odr &o, Z_HTTP_Response *hres)
+{
+ const char *ctype = z_HTTP_header_lookup(hres->headers, "Content-Type");
+ if (ctype && hres->content_buf)
+ {
+ std::string text(hres->content_buf, hres->content_len);
+ std::list<Rule>::const_iterator it;
+ int number_of_replaces = 0;
+ for (it = rules.begin(); it != rules.end(); it++)
+ {
+ if (strcmp(ctype, it->content_type.c_str()) == 0)
+ {
+ boost::regex::flag_type b_mode = boost::regex::perl;
+ if (it->mode.find_first_of('i') != std::string::npos)
+ b_mode |= boost::regex::icase;
+ boost::regex e(it->pattern, b_mode);
+ boost::match_flag_type match_mode = boost::format_first_only;
+ if (it->mode.find_first_of('g') != std::string::npos)
+ match_mode = boost::format_all;
+ text = regex_replace(text, e, it->replacement, match_mode);
+ number_of_replaces++;
+ }
+ }
+ if (number_of_replaces > 0)
+ {
+ hres->content_buf = odr_strdup(o, text.c_str());
+ hres->content_len = strlen(hres->content_buf);
+ }
+ }
+}
+
+void yf::HttpRewrite1::process(mp::Package &package) const
+{
+ Z_GDU *gdu_req = package.request().get();
+ if (gdu_req && gdu_req->which == Z_GDU_HTTP_Request)
+ {
+ Z_HTTP_Request *hreq = gdu_req->u.HTTP_Request;
+
+ assert(hreq); // not changing request (such as POST content)
+ package.move();
+
+ Z_GDU *gdu_res = package.response().get();
+ Z_HTTP_Response *hres = gdu_res->u.HTTP_Response;
+ if (hres)
+ {
+ mp::odr o;
+ m_p->rewrite_response(o, hres);
+ package.response() = gdu_res;
+ }
+ }
+ else
+ package.move();
+}
+
+void mp::filter::HttpRewrite1::configure(const xmlNode * ptr, bool test_only,
+ const char *path)
+{
+ for (ptr = ptr->children; ptr; ptr = ptr->next)
+ {
+ if (ptr->type != XML_ELEMENT_NODE)
+ continue;
+ else if (!strcmp((const char *) ptr->name, "replace"))
+ {
+ HttpRewrite1::Rule rule;
+
+ const struct _xmlAttr *attr;
+ for (attr = ptr->properties; attr; attr = attr->next)
+ {
+ if (!strcmp((const char *) attr->name, "pattern"))
+ rule.pattern = mp::xml::get_text(attr->children);
+ else if (!strcmp((const char *) attr->name, "replacement"))
+ rule.replacement = mp::xml::get_text(attr->children);
+ else if (!strcmp((const char *) attr->name, "mode"))
+ rule.mode = mp::xml::get_text(attr->children);
+ else if (!strcmp((const char *) attr->name, "content-type"))
+ rule.content_type = mp::xml::get_text(attr->children);
+ else
+ throw mp::filter::FilterException
+ ("Bad attribute "
+ + std::string((const char *) attr->name)
+ + " in replace section of http_rewrite1");
+ }
+ if (rule.pattern.length() > 0)
+ m_p->rules.push_back(rule);
+ }
+ else
+ {
+ throw mp::filter::FilterException
+ ("Bad element "
+ + std::string((const char *) ptr->name)
+ + " in http_rewrite1 filter");
+ }
+ }
+}
+
+static mp::filter::Base* filter_creator()
+{
+ return new mp::filter::HttpRewrite1;
+}
+
+extern "C" {
+ struct metaproxy_1_filter_struct metaproxy_1_filter_http_rewrite1 = {
+ 0,
+ "http_rewrite1",
+ filter_creator
+ };
+}
+
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of Metaproxy.
+ Copyright (C) 2005-2013 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
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef FILTER_HTTP_REWRITE1_HPP
+#define FILTER_HTTP_REWRITE1_HPP
+
+#include <boost/scoped_ptr.hpp>
+
+#include <metaproxy/filter.hpp>
+
+namespace metaproxy_1 {
+ namespace filter {
+ class HttpRewrite1 : public Base {
+ class Rep;
+ class Rule;
+ boost::scoped_ptr<Rep> m_p;
+ public:
+ HttpRewrite1();
+ ~HttpRewrite1();
+ void process(metaproxy_1::Package & package) const;
+ void configure(const xmlNode * ptr, bool test_only,
+ const char *path);
+ };
+ }
+}
+
+extern "C" {
+ extern struct metaproxy_1_filter_struct metaproxy_1_filter_http_rewrite1;
+}
+
+#endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of Metaproxy.
+ Copyright (C) 2005-2013 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
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "config.hpp"
+#include "filter_sd_remove.hpp"
+#include <metaproxy/package.hpp>
+#include <metaproxy/util.hpp>
+#include <yaz/zgdu.h>
+#include <metaproxy/filter.hpp>
+#include <yaz/querytowrbuf.h>
+
+namespace metaproxy_1 {
+ namespace filter {
+ class SD_Remove : public Base {
+ public:
+ SD_Remove();
+ ~SD_Remove();
+ void process(metaproxy_1::Package & package) const;
+ void configure(const xmlNode * ptr, bool test_only,
+ const char *path);
+ };
+ }
+}
+
+namespace mp = metaproxy_1;
+namespace yf = mp::filter;
+
+yf::SD_Remove::SD_Remove()
+{
+}
+
+yf::SD_Remove::~SD_Remove()
+{
+}
+
+void yf::SD_Remove::configure(const xmlNode *xmlnode, bool test_only,
+ const char *path)
+{
+ if (xmlnode)
+ {
+ xmlNode *ptr;
+ for (ptr = xmlnode->children; ptr; ptr = ptr->next)
+ {
+ if (ptr->type == XML_ELEMENT_NODE)
+ throw mp::filter::FilterException("Bad element "
+ + std::string((const char *)
+ ptr->name));
+ }
+ }
+}
+
+void yf::SD_Remove::process(mp::Package &package) const
+{
+ package.move();
+
+ Z_GDU *gdu_res = package.response().get();
+ if (gdu_res && gdu_res->which == Z_GDU_Z3950)
+ {
+ Z_NamePlusRecordList *records = 0;
+ Z_APDU *apdu = gdu_res->u.z3950;
+ if (apdu->which == Z_APDU_presentResponse)
+ {
+ Z_PresentResponse * pr_res = apdu->u.presentResponse;
+ if (pr_res->numberOfRecordsReturned
+ && *(pr_res->numberOfRecordsReturned) > 0
+ && pr_res->records
+ && pr_res->records->which == Z_Records_DBOSD)
+ {
+ records = pr_res->records->u.databaseOrSurDiagnostics;
+ }
+ }
+ if (apdu->which == Z_APDU_searchResponse)
+ {
+ Z_SearchResponse *sr_res = apdu->u.searchResponse;
+ if (
+ sr_res->numberOfRecordsReturned
+ && *(sr_res->numberOfRecordsReturned) > 0
+ && sr_res->records
+ && sr_res->records->which == Z_Records_DBOSD)
+ {
+ records = sr_res->records->u.databaseOrSurDiagnostics;
+ }
+ }
+ if (records)
+ {
+ mp::odr odr_en(ODR_ENCODE);
+ int i;
+ for (i = 0; i < records->num_records; i++)
+ {
+ Z_NamePlusRecord *npr = records->records[i];
+ if (npr->which == Z_NamePlusRecord_surrogateDiagnostic)
+ {
+ WRBUF w = wrbuf_alloc();
+ wrbuf_diags(w, 1, &npr->u.surrogateDiagnostic);
+ npr->which = Z_NamePlusRecord_databaseRecord;
+ npr->u.databaseRecord = z_ext_record_sutrs(odr_en,
+ wrbuf_buf(w),
+ wrbuf_len(w));
+ wrbuf_destroy(w);
+ }
+ }
+ package.response() = gdu_res;
+ }
+ }
+}
+
+
+static mp::filter::Base* filter_creator()
+{
+ return new mp::filter::SD_Remove;
+}
+
+extern "C" {
+ struct metaproxy_1_filter_struct metaproxy_1_filter_sd_remove = {
+ 0,
+ "sd_remove",
+ filter_creator
+ };
+}
+
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of Metaproxy.
+ Copyright (C) 2005-2013 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
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef FILTER_SD_REMOVE_HPP
+#define FILTER_SD_REMOVE_HPP
+
+extern "C" {
+ extern struct metaproxy_1_filter_struct metaproxy_1_filter_sd_remove;
+}
+
+#endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
set_log_prefix();
- while ((ret = options("c{config}:Dh{help}l:m:p:tu:V{version}w:X",
+ while ((ret = options("c{config}:Dh{help}l:m:p:tu:v:V{version}w:X",
argv, argc, &arg)) != -2)
{
switch (ret)
std::cerr << "metaproxy\n"
" -h|--help help\n"
" -V|--version version\n"
+ " -v level\n"
" -c|--config f config filename\n"
" -D daemon and keepalive operation\n"
" -l f log file f\n"
case 'u':
uid = arg;
break;
+ case 'v':
+ yaz_log_init_level(yaz_log_mask_str(arg));
+ break;
case 'V':
std::cout << VERSION;
#ifdef VERSION_SHA1
$(OBJDIR)\filter_bounce.obj \
$(OBJDIR)\filter_cql_to_rpn.obj \
$(OBJDIR)\filter_frontend_net.obj \
+ $(OBJDIR)\filter_http_client.obj \
$(OBJDIR)\filter_http_file.obj \
+ $(OBJDIR)\filter_http_rewrite1.obj \
$(OBJDIR)\filter_limit.obj \
$(OBJDIR)\filter_load_balance.obj \
$(OBJDIR)\filter_log.obj \
$(OBJDIR)\filter_multi.obj \
$(OBJDIR)\filter_query_rewrite.obj \
$(OBJDIR)\filter_record_transform.obj \
+ $(OBJDIR)\filter_sd_remove.obj \
$(OBJDIR)\filter_session_shared.obj \
$(OBJDIR)\filter_sort.obj \
$(OBJDIR)\filter_sru_to_z3950.obj \
filter_multi.rnc \
filter_query_rewrite.rnc \
filter_record_transform.rnc \
+filter_sd_remove.rnc \
filter_session_shared.rnc \
filter_sort.rnc \
filter_sru_z3950.rnc \
element mp:port {
attribute route { xsd:NCName }?,
attribute max_recv_bytes { xsd:integer }?,
- xsd:string
+ attribute port { xsd:integer }?,
+ attribute cert_fname { xsd:string }?,
+ xsd:string
}+,
element mp:timeout { xsd:integer }?,
element mp:connect-max { xsd:integer }?,
attribute type { "http_client" },
attribute id { xsd:NCName }?,
attribute name { xsd:NCName }?,
+ element mp:default-host { xsd:string }?,
element mp:proxy { xsd:string }?
element mp:area {
element mp:documentroot { xsd:string },
element mp:prefix { xsd:string }
- }
+ }*
--- /dev/null
+# Metaproxy XML config file schema
+
+namespace mp = "http://indexdata.com/metaproxy"
+
+filter_http_rewrite1 =
+ attribute type { "http_rewrite1" },
+ attribute id { xsd:NCName }?,
+ attribute name { xsd:NCName }?,
+ element mp:replace {
+ attribute pattern { xsd:string },
+ attribute replacement { xsd:string }?,
+ attribute mode { xsd:string }?,
+ attribute content-type { xsd:string }?
+ }*
+
--- /dev/null
+# Metaproxy XML config file schema
+
+namespace mp = "http://indexdata.com/metaproxy"
+
+filter_sd_remove =
+ attribute type { "sd_remove" },
+ attribute id { xsd:NCName }?,
+ attribute name { xsd:NCName }?
+
include "filter_frontend_net.rnc"
include "filter_http_client.rnc"
include "filter_http_file.rnc"
+include "filter_http_rewrite1.rnc"
include "filter_limit.rnc"
include "filter_load_balance.rnc"
include "filter_log.rnc"
include "filter_present_chunk.rnc"
include "filter_query_rewrite.rnc"
include "filter_record_transform.rnc"
+include "filter_sd_remove.rnc"
include "filter_session_shared.rnc"
include "filter_sort.rnc"
include "filter_sru_z3950.rnc"
| filter_frontend_net
| filter_http_client
| filter_http_file
+ | filter_http_rewrite1
| filter_limit
| filter_load_balance
| filter_log
| filter_present_chunk
| filter_query_rewrite
| filter_record_transform
+ | filter_sd_remove
| filter_session_shared
| filter_sort
| filter_sru_z3950