From: Marc Cromme Date: Wed, 6 Jun 2007 11:49:48 +0000 (+0000) Subject: removed Z39.50 Proxy functionality from parameters global overrides and moved into... X-Git-Tag: PAZPAR2.1.0.0~67 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=dc9f59ce5f4bedc6cd1cc68e0309b74d241f434d;p=pazpar2-moved-to-github.git removed Z39.50 Proxy functionality from parameters global overrides and moved into the session settings. Added new setting 'pz:zproxy' for the same. --- diff --git a/src/client.c b/src/client.c index fe1d950..bb1fd0c 100644 --- a/src/client.c +++ b/src/client.c @@ -1,4 +1,4 @@ -/* $Id: client.c,v 1.6 2007-06-02 04:32:28 quinn Exp $ +/* $Id: client.c,v 1.7 2007-06-06 11:49:48 marc Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -455,6 +455,27 @@ static void init_authentication(struct client *cl, Z_InitRequest *req) } } +static void init_zproxy(struct client *cl, Z_InitRequest *req) +{ + struct session_database *sdb = client_get_database(cl); + char *ztarget = sdb->database->url; + //char *ztarget = sdb->url; + char *zproxy = session_setting_oneval(sdb, PZ_ZPROXY); + + if (*zproxy) +#if YAZ_VERSIONL >= 0x020163 + yaz_oi_set_string_oid(&req->otherInfo, + global_parameters.odr_out, + yaz_oid_userinfo_proxy, + 1, ztarget); +#else + yaz_oi_set_string_oidval(&req->otherInfo, + global_parameters.odr_out, VAL_PROXY, + 1, ztarget); +#endif +} + + static void client_init_request(struct client *cl) { Z_APDU *a = zget_APDU(global_parameters.odr_out, Z_APDU_initRequest); @@ -472,23 +493,9 @@ static void client_init_request(struct client *cl) ODR_MASK_SET(a->u.initRequest->protocolVersion, Z_ProtocolVersion_3); init_authentication(cl, a->u.initRequest); + init_zproxy(cl, a->u.initRequest); + - /* add virtual host if tunneling through Z39.50 proxy */ - - if (0 < strlen(global_parameters.zproxy_override) - && 0 < strlen(client_get_database(cl)->database->url)) - { -#if YAZ_VERSIONL >= 0x020163 - yaz_oi_set_string_oid(&a->u.initRequest->otherInfo, - global_parameters.odr_out, - yaz_oid_userinfo_proxy, - 1, client_get_database(cl)->database->url); -#else - yaz_oi_set_string_oidval(&a->u.initRequest->otherInfo, - global_parameters.odr_out, VAL_PROXY, - 1, client_get_database(cl->database)->url); -#endif - } if (send_apdu(cl, a) >= 0) client_set_state(cl, Client_Initializing); diff --git a/src/config.c b/src/config.c index e6f733d..8214030 100644 --- a/src/config.c +++ b/src/config.c @@ -1,4 +1,4 @@ -/* $Id: config.c,v 1.34 2007-05-23 11:19:31 marc Exp $ +/* $Id: config.c,v 1.35 2007-06-06 11:49:48 marc Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -19,7 +19,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: config.c,v 1.34 2007-05-23 11:19:31 marc Exp $ */ +/* $Id: config.c,v 1.35 2007-06-06 11:49:48 marc Exp $ */ #include @@ -405,8 +405,8 @@ static struct conf_server *parse_server(xmlNode *node) server->proxy_host = 0; server->proxy_port = 0; server->myurl = 0; - server->zproxy_host = 0; - server->zproxy_port = 0; + //server->zproxy_host = 0; + //server->zproxy_port = 0; server->service = 0; server->next = 0; server->settings = 0; @@ -453,22 +453,22 @@ static struct conf_server *parse_server(xmlNode *node) xmlFree(host); xmlFree(myurl); } - else if (!strcmp((const char *) n->name, "zproxy")) - { - xmlChar *port = 0; - xmlChar *host = 0; - - port = xmlGetProp(n, (xmlChar *) "port"); - host = xmlGetProp(n, (xmlChar *) "host"); - - if (port) - server->zproxy_port = atoi((const char *) port); - if (host) - server->zproxy_host = nmem_strdup(nmem, (const char *) host); - - xmlFree(port); - xmlFree(host); - } +/* else if (!strcmp((const char *) n->name, "zproxy")) */ +/* { */ +/* xmlChar *port = 0; */ +/* xmlChar *host = 0; */ + +/* port = xmlGetProp(n, (xmlChar *) "port"); */ +/* host = xmlGetProp(n, (xmlChar *) "host"); */ + +/* if (port) */ +/* server->zproxy_port = atoi((const char *) port); */ +/* if (host) */ +/* server->zproxy_host = nmem_strdup(nmem, (const char *) host); */ + +/* xmlFree(port); */ +/* xmlFree(host); */ +/* } */ else if (!strcmp((const char *) n->name, "settings")) { if (server->settings) diff --git a/src/config.h b/src/config.h index d643a4f..90a08c3 100644 --- a/src/config.h +++ b/src/config.h @@ -1,4 +1,4 @@ -/* $Id: config.h,v 1.23 2007-05-23 11:19:31 marc Exp $ +/* $Id: config.h,v 1.24 2007-06-06 11:49:48 marc Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -148,8 +148,8 @@ struct conf_server char *proxy_host; int proxy_port; char *myurl; - char *zproxy_host; - int zproxy_port; + //char *zproxy_host; + //int zproxy_port; char *settings; #ifdef HAVE_ICU diff --git a/src/connection.c b/src/connection.c index 2a12785..c53b64f 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1,4 +1,4 @@ -/* $Id: connection.c,v 1.3 2007-06-02 04:32:28 quinn Exp $ +/* $Id: connection.c,v 1.4 2007-06-06 11:49:48 marc Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -319,6 +319,9 @@ int connection_connect(struct connection *con) void *addr; int res; + struct session_database *sdb = client_get_database(con->client); + char *zproxy = session_setting_oneval(sdb, PZ_ZPROXY); + assert(host->ipport); assert(con); @@ -328,7 +331,7 @@ int connection_connect(struct connection *con) return -1; } - if (0 == strlen(global_parameters.zproxy_override)){ + if (!zproxy || 0 == strlen(zproxy)){ /* no Z39.50 proxy needed - direct connect */ yaz_log(YLOG_DEBUG, "Connection create %s", connection_get_url(con)); @@ -342,13 +345,13 @@ int connection_connect(struct connection *con) } else { /* Z39.50 proxy connect */ yaz_log(YLOG_DEBUG, "Connection create %s proxy %s", - connection_get_url(con), global_parameters.zproxy_override); + connection_get_url(con), zproxy); - if (!(addr = cs_straddr(link, global_parameters.zproxy_override))) + if (!(addr = cs_straddr(link, zproxy))) { yaz_log(YLOG_WARN|YLOG_ERRNO, - "Lookup of IP address %s failed", - global_parameters.zproxy_override); + "Lookup of ZProxy IP address %s failed", + zproxy); return -1; } } diff --git a/src/logic.c b/src/logic.c index ea6e66f..9776239 100644 --- a/src/logic.c +++ b/src/logic.c @@ -1,4 +1,4 @@ -/* $Id: logic.c,v 1.35 2007-06-02 04:32:28 quinn Exp $ +/* $Id: logic.c,v 1.36 2007-06-06 11:49:48 marc Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -79,8 +79,8 @@ struct parameters global_parameters = { "", "", - "", - "", + /* "", */ + "", 0, 0, /* dump_records */ 0, /* debug_mode */ @@ -856,38 +856,38 @@ void start_proxy(void) http_set_proxyaddr(hp, ser->myurl ? ser->myurl : ""); } -void start_zproxy(void) -{ - struct conf_server *ser = global_parameters.server; - - if (*global_parameters.zproxy_override){ - yaz_log(YLOG_LOG, "Z39.50 proxy %s", - global_parameters.zproxy_override); - return; - } - - else if (ser->zproxy_host || ser->zproxy_port) - { - char hp[128] = ""; - - strcpy(hp, ser->zproxy_host ? ser->zproxy_host : ""); - if (ser->zproxy_port) - { - if (*hp) - strcat(hp, ":"); - else - strcat(hp, "@:"); - - sprintf(hp + strlen(hp), "%d", ser->zproxy_port); - } - strcpy(global_parameters.zproxy_override, hp); - yaz_log(YLOG_LOG, "Z39.50 proxy %s", - global_parameters.zproxy_override); - - } - else - return; -} +/* void start_zproxy(void) */ +/* { */ +/* struct conf_server *ser = global_parameters.server; */ + +/* if (*global_parameters.zproxy_override){ */ +/* yaz_log(YLOG_LOG, "Z39.50 proxy %s", */ +/* global_parameters.zproxy_override); */ +/* return; */ +/* } */ + +/* else if (ser->zproxy_host || ser->zproxy_port) */ +/* { */ +/* char hp[128] = ""; */ + +/* strcpy(hp, ser->zproxy_host ? ser->zproxy_host : ""); */ +/* if (ser->zproxy_port) */ +/* { */ +/* if (*hp) */ +/* strcat(hp, ":"); */ +/* else */ +/* strcat(hp, "@:"); */ + +/* sprintf(hp + strlen(hp), "%d", ser->zproxy_port); */ +/* } */ +/* strcpy(global_parameters.zproxy_override, hp); */ +/* yaz_log(YLOG_LOG, "Z39.50 proxy %s", */ +/* global_parameters.zproxy_override); */ + +/* } */ +/* else */ +/* return; */ +/* } */ // Master list of connections we're handling events to static IOCHAN channel_list = 0; diff --git a/src/parameters.h b/src/parameters.h index 4b4ea71..c4db163 100644 --- a/src/parameters.h +++ b/src/parameters.h @@ -1,4 +1,4 @@ -/* $Id: parameters.h,v 1.2 2007-05-23 21:58:28 adam Exp $ +/* $Id: parameters.h,v 1.3 2007-06-06 11:49:48 marc Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -28,7 +28,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA struct parameters { char proxy_override[128]; char listener_override[128]; - char zproxy_override[128]; + //char zproxy_override[128]; char settings_path_override[128]; struct conf_server *server; int dump_records; diff --git a/src/pazpar2.c b/src/pazpar2.c index 117464c..e19a98a 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -1,4 +1,4 @@ -/* $Id: pazpar2.c,v 1.85 2007-05-23 21:58:28 adam Exp $ +/* $Id: pazpar2.c,v 1.86 2007-06-06 11:49:48 marc Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -41,7 +41,8 @@ int main(int argc, char **argv) yaz_log_init_prefix("pazpar2"); - while ((ret = options("f:h:p:z:t:l:dX", argv, argc, &arg)) != -2) + //while ((ret = options("f:h:p:z:t:l:dX", argv, argc, &arg)) != -2) + while ((ret = options("f:h:p:t:l:dX", argv, argc, &arg)) != -2) { switch (ret) { @@ -55,9 +56,9 @@ int main(int argc, char **argv) case 'p': strcpy(global_parameters.proxy_override, arg); break; - case 'z': - strcpy(global_parameters.zproxy_override, arg); - break; +/* case 'z': */ +/* strcpy(global_parameters.zproxy_override, arg); */ +/* break; */ case 't': strcpy(global_parameters.settings_path_override, arg); break; @@ -94,7 +95,7 @@ int main(int argc, char **argv) start_http_listener(); start_proxy(); - start_zproxy(); + //start_zproxy(); init_settings(); if (*global_parameters.settings_path_override) diff --git a/src/pazpar2.h b/src/pazpar2.h index 5ba1584..c74b5fe 100644 --- a/src/pazpar2.h +++ b/src/pazpar2.h @@ -1,4 +1,4 @@ -/* $Id: pazpar2.h,v 1.36 2007-05-10 11:46:09 adam Exp $ +/* $Id: pazpar2.h,v 1.37 2007-06-06 11:49:48 marc Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -161,7 +161,7 @@ char *session_setting_oneval(struct session_database *db, int offset); void start_http_listener(void); void start_proxy(void); -void start_zproxy(void); +//void start_zproxy(void); void pazpar2_add_channel(IOCHAN c); void pazpar2_event_loop(void); diff --git a/src/settings.c b/src/settings.c index f602843..8cc5e6c 100644 --- a/src/settings.c +++ b/src/settings.c @@ -1,4 +1,4 @@ -/* $Id: settings.c,v 1.22 2007-05-18 19:52:52 quinn Exp $ +/* $Id: settings.c,v 1.23 2007-06-06 11:49:48 marc Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -59,6 +59,7 @@ static char *hard_settings[] = { "pz:name", "pz:queryencoding", "pz:ip", + "pz:zproxy", 0 }; diff --git a/src/settings.h b/src/settings.h index abc784b..17b2f17 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,4 +1,4 @@ -/* $Id: settings.h,v 1.17 2007-05-16 17:16:21 quinn Exp $ +/* $Id: settings.h,v 1.18 2007-06-06 11:49:48 marc Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -35,6 +35,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #define PZ_NAME 10 #define PZ_QUERYENCODING 11 #define PZ_IP 12 +#define PZ_ZPROXY 13 struct setting