Hallo Martin,
ich habe mal den Code zur Proxy-Nutzung dahin gehend erweitert, dass er
nun auch mit Proxies funktioniert, die eine Anmeldung mit Benutzername
und Passwort verlangen. Der veränderte Code prüft dafür, ob die
Umgebungsvariable GWEN_PROXY_CREDENTIALS gesetzt ist und entnimmt daraus
ggfs. die benötigten Anmeldedaten. Ich habe die Änderungen hier lokal
kurz erfolgreich getestet.
Außerdem habe ich mal das README.txt um die Dokumentation der
Umgebungsvariablen GWEN_PROXY und GWEN_PROXY_CREDENTIALS erweitert.
Der Patch steht unter der gleichen Lizenz wie Gwenhywfar: Aktuell die
LGPL Version 2.1. Auf Anfrage lizensiere ich ihn an einzelne Leute evtl.
auch unter einer anderen Lizenz.
Ich würde mich freuen, wenn der Patch ins SVN aufgenommen wird.
Schöne Grüße
Micha
Index: src/iolayer/io_socket.c
===================================================================
--- src/iolayer/io_socket.c (Revision 1580)
+++ src/iolayer/io_socket.c (Arbeitskopie)
@@ -52,13 +52,24 @@
GWEN_INETADDRESS *in;
char taddr[64];
char wrk[1024];
+ char proxy_creds[1024];
+ const char *proxy_cred_env = getenv("GWEN_PROXY_CREDENTIALS");
if (GWEN_Socket_GetSocketType(sp)!=GWEN_SocketTypeTCP)
return GWEN_Socket_Connect(sp, addr);
tport=GWEN_InetAddr_GetPort(addr);
GWEN_InetAddr_GetAddress(addr, taddr, sizeof(taddr));
- snprintf(wrk, sizeof(wrk)-1, "CONNECT %s:%d\n", taddr, tport);
+ proxy_creds[0]=0;
+ if (proxy_cred_env != 0) {
+ // use credentials to authenticate at the proxy
+ GWEN_BUFFER *proxy_creds_b64 = GWEN_Buffer_new(0, 128, 0, 0);
+ GWEN_Base64_Encode(proxy_cred_env, strlen(proxy_cred_env), proxy_creds_b64, 128);
+ snprintf(proxy_creds, sizeof(proxy_creds)-1, "Proxy-Authorization: Basic %s\r\n",
+ GWEN_Buffer_GetStart(proxy_creds_b64));
+ GWEN_Buffer_free(proxy_creds_b64);
+ }
+ snprintf(wrk, sizeof(wrk)-1, "CONNECT %s:%d HTTP/1.1\r\n%s\r\n", taddr, tport, proxy_creds);
wrk[sizeof(wrk)-1]=0;
len=strlen(wrk);
@@ -167,14 +178,18 @@
if (strncmp(wrk, "HTTP/1.0 200", 12)==0 ||
strncmp(wrk, "HTTP/1.1 200", 12)==0)
ok=1;
- else
+ else {
+ DBG_ERROR(GWEN_LOGDOMAIN, "Proxy rejected connection: %s", wrk);
return GWEN_ERROR_IO;
+ }
}
idx=0;
}
- else if (++idx==sizeof(wrk))
+ else if (++idx==sizeof(wrk)) {
+ DBG_ERROR(GWEN_LOGDOMAIN, "Confusing answer from proxy: %s", wrk);
return GWEN_ERROR_IO;
+ }
}
}
Index: README
===================================================================
--- README (Revision 1580)
+++ README (Arbeitskopie)
@@ -115,7 +115,27 @@
connection to /tmp/written.bin".
+"GWEN_PROXY"
+------------
+If this environment variable exists the I/O layer uses a proxy for
+TCP connections. You must set this variable in format HOSTNAME:PORT. For
+example, given your proxy server is "proxy.firewall.com" and is listening at
+TCP port 3128, you need to set this environment variable to the value
+"proxy.firewall.com:3128".
+
+
+"GWEN_PROXY_CREDENTIALS"
+------------------------
+
+If the proxy specified by the environment variable GWEN_PROXY requires
+authentication, you can provide your authentication credentials by setting this
+variable in format USERNAME:PASSWORD. For example, given the proxy requires you
+to authenticate with user name "Aladdin" and password "open sesame", you need to
+set this environment variable to the value "Aladdin:open sesame".
+
+
+
Registry Keys
=============
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Aqbanking-devel mailing list
Aqbanking-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/aqbanking-devel