* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: yaz-pdu-assoc.h,v 1.5 1999-04-20 10:30:05 adam Exp $
+ * $Id: yaz-pdu-assoc.h,v 1.6 1999-11-10 10:02:34 adam Exp $
*/
#include <comstack.h>
int m_idleTime;
public:
/// Create object using specified socketObservable
- Yaz_PDU_Assoc(IYazSocketObservable *socketObservable, COMSTACK cs);
+ Yaz_PDU_Assoc(IYazSocketObservable *socketObservable, COMSTACK cs = 0);
/// Close socket and destroy object.
virtual ~Yaz_PDU_Assoc();
/// Clone the object
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: yaz-proxy.h,v 1.7 1999-04-28 13:31:17 adam Exp $
+ * $Id: yaz-proxy.h,v 1.8 1999-11-10 10:02:34 adam Exp $
*/
#include <yaz-z-assoc.h>
IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable);
void failNotify();
void timeoutNotify();
+ void proxyTarget(const char *target);
private:
char *get_cookie(Z_OtherInformation **otherInfo);
char *get_proxy(Z_OtherInformation **otherInfo);
Yaz_Proxy *m_parent;
int m_seqno;
int m_keepalive;
+ char *m_proxyTarget;
};
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: yaz-client.cpp,v $
- * Revision 1.7 1999-04-21 12:09:01 adam
+ * Revision 1.8 1999-11-10 10:02:34 adam
+ * Work on proxy.
+ *
+ * Revision 1.7 1999/04/21 12:09:01 adam
* Many improvements. Modified to proxy server to work with "sessions"
* based on cookies.
*
int main(int argc, char **argv)
{
Yaz_SocketManager mySocketManager;
- Yaz_PDU_Assoc *some = new Yaz_PDU_Assoc(&mySocketManager, 0);
+ Yaz_PDU_Assoc *some = new Yaz_PDU_Assoc(&mySocketManager);
MyClient z(some, &mySocketManager);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: yaz-proxy-main.cpp,v $
- * Revision 1.5 1999-04-21 12:09:01 adam
+ * Revision 1.6 1999-11-10 10:02:34 adam
+ * Work on proxy.
+ *
+ * Revision 1.5 1999/04/21 12:09:01 adam
* Many improvements. Modified to proxy server to work with "sessions"
* based on cookies.
*
*/
#include <log.h>
+#include <options.h>
#include <yaz-socket-manager.h>
#include <yaz-pdu-assoc.h>
#include <yaz-proxy.h>
+void usage(char *prog)
+{
+ fprintf (stderr, "%s: [-v log] [-t target] @:port\n", prog);
+ exit (1);
+}
+
+
+int args(Yaz_Proxy *proxy, int argc, char **argv)
+{
+ char *addr = 0;
+ char *arg;
+ char *prog = argv[0];
+ int ret;
+
+ while ((ret = options("p:v:q", argv, argc, &arg)) != -2)
+ {
+ switch (ret)
+ {
+ case 0:
+ if (addr)
+ {
+ usage(prog);
+ return 1;
+ }
+ addr = arg;
+ break;
+ case 't':
+ proxy->proxyTarget(arg);
+ break;
+ case 'v':
+ log_init_level (log_mask_str(arg));
+ break;
+ default:
+ usage(prog);
+ return 1;
+ }
+ }
+ if (addr)
+ {
+ proxy->server(addr);
+ }
+ return 0;
+}
+
+
int main(int argc, char **argv)
{
Yaz_SocketManager mySocketManager;
- Yaz_Proxy proxy(new Yaz_PDU_Assoc(&mySocketManager, 0));
+ Yaz_Proxy proxy(new Yaz_PDU_Assoc(&mySocketManager));
- proxy.server(argc < 2 ? "@:9000" : argv[1]);
+ args(&proxy, argc, argv);
while (mySocketManager.processEvent() > 0)
;
return 0;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: yaz-proxy.cpp,v $
- * Revision 1.9 1999-09-13 12:53:44 adam
+ * Revision 1.10 1999-11-10 10:02:34 adam
+ * Work on proxy.
+ *
+ * Revision 1.9 1999/09/13 12:53:44 adam
* Proxy removes OtherInfo Proxy Address and Session ID. Other
* Otherinfo remains untouched.
*
m_clientPool = 0;
m_seqno = 1;
m_keepalive = 1;
+ m_proxyTarget = 0;
}
Yaz_Proxy::~Yaz_Proxy()
{
+ xfree (m_proxyTarget);
+}
+
+
+void Yaz_Proxy::proxyTarget(const char *target)
+{
+ xfree (m_proxyTarget);
+ m_proxyTarget = 0;
+ if (target)
+ m_proxyTarget = (char *) xstrdup (target);
}
IYaz_PDU_Observer *Yaz_Proxy::clone(IYaz_PDU_Observable
}
if (!m_client)
{
+ const char *proxy_host = 0;
+ if (apdu->which == Z_APDU_initRequest)
+ {
+ logf (LOG_LOG, "got InitRequest");
+
+ char *proxy_host = get_proxy(&apdu->u.initRequest->otherInfo);
+ if (!proxy_host)
+ proxy_host = m_proxyTarget;
+ if (!proxy_host)
+ return 0;
+ }
logf (LOG_LOG, "Yaz_Proxy::get_client creating new");
c = new Yaz_ProxyClient(m_PDU_Observable->clone());
c->m_next = parent->m_clientPool;
{
logf (LOG_LOG, "got InitRequest");
- char *proxy_host = get_proxy(&apdu->u.initRequest->otherInfo);
- if (proxy_host)
- c->client(proxy_host);
- else
- c->client("localhost:9999");
+ c->client(proxy_host);
}
c->timeout(600);
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: yaz-z-assoc.cpp,v $
- * Revision 1.4 1999-09-13 12:53:44 adam
+ * Revision 1.5 1999-11-10 10:02:34 adam
+ * Work on proxy.
+ *
+ * Revision 1.4 1999/09/13 12:53:44 adam
* Proxy removes OtherInfo Proxy Address and Session ID. Other
* Otherinfo remains untouched.
*
#include <log.h>
#include <yaz-z-assoc.h>
+#include <otherinfo.h>
int Yaz_Z_Assoc::yaz_init_func()
{