aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2004-10-18 15:51:43 +0000
committerDavid Shaw <[email protected]>2004-10-18 15:51:43 +0000
commit83d391431710bcc91b1a118e0b21faa8ef7bb656 (patch)
tree72aeed32dac061075a1fe324e8a6dbbbb69c60f6
parentMore fixups to help Debian's install-info. (diff)
downloadgnupg-83d391431710bcc91b1a118e0b21faa8ef7bb656.tar.gz
gnupg-83d391431710bcc91b1a118e0b21faa8ef7bb656.zip
* http.c (connect_server, send_request): Use the URI scheme as the SRV tag
rather than hard-coding _hkp.
Diffstat (limited to '')
-rw-r--r--util/ChangeLog5
-rw-r--r--util/http.c38
2 files changed, 27 insertions, 16 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index 5a20a817f..9d42f3a39 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,8 @@
+2004-10-18 David Shaw <[email protected]>
+
+ * http.c (connect_server, send_request): Use the URI scheme as the
+ SRV tag rather than hard-coding _hkp.
+
2004-10-16 David Shaw <[email protected]>
* http.c (connect_server): [_WIN32] actually fill in the sin_addr
diff --git a/util/http.c b/util/http.c
index e1c3c25ef..8d5679181 100644
--- a/util/http.c
+++ b/util/http.c
@@ -72,7 +72,8 @@ static int send_request( HTTP_HD hd, const char *proxy );
static byte *build_rel_path( PARSED_URI uri );
static int parse_response( HTTP_HD hd );
-static int connect_server(const char *server, ushort port, unsigned int flags);
+static int connect_server( const char *server, ushort port, unsigned int flags,
+ const char *srvtag );
static int write_server( int sock, const char *data, size_t length );
#ifdef _WIN32
@@ -309,13 +310,12 @@ do_parse_uri( PARSED_URI uri, int only_local_part )
*p2++ = 0;
strlwr( p );
uri->scheme = p;
- uri->port = 80;
- if( !strcmp( uri->scheme, "http" ) )
- ;
- else if( !strcmp( uri->scheme, "x-hkp" ) ) /* same as HTTP */
- uri->port = 11371;
+ if(strcmp(uri->scheme,"http")==0)
+ uri->port = 80;
+ else if(strcmp(uri->scheme,"hkp")==0)
+ uri->port = 11371;
else
- return G10ERR_INVALID_URI; /* Unsupported scheme */
+ return G10ERR_INVALID_URI; /* Unsupported scheme */
p = p2;
@@ -525,7 +525,7 @@ send_request( HTTP_HD hd, const char *proxy )
return G10ERR_NETWORK;
}
hd->sock = connect_server( *uri->host? uri->host : "localhost",
- uri->port? uri->port : 80, 0 );
+ uri->port? uri->port : 80, 0, NULL );
if(uri->auth)
{
char *x=make_radix64_string(uri->auth,strlen(uri->auth));
@@ -538,7 +538,7 @@ send_request( HTTP_HD hd, const char *proxy )
}
else
{
- hd->sock = connect_server( server, port, hd->flags );
+ hd->sock = connect_server( server, port, hd->flags, hd->uri->scheme );
if(hd->uri->auth)
{
char *x=make_radix64_string(hd->uri->auth,strlen(hd->uri->auth));
@@ -755,7 +755,8 @@ start_server()
static int
-connect_server( const char *server, ushort port, unsigned int flags )
+connect_server( const char *server, ushort port, unsigned int flags,
+ const char *srvtag )
{
int sock=-1,srv,srvcount=0,connected=0,hostfound=0;
struct srventry *srvlist=NULL;
@@ -794,14 +795,19 @@ connect_server( const char *server, ushort port, unsigned int flags )
#ifdef USE_DNS_SRV
/* Do the SRV thing */
- if(flags&HTTP_FLAG_TRY_SRV)
+ if(flags&HTTP_FLAG_TRY_SRV && srvtag)
{
/* We're using SRV, so append the tags */
- char srvname[MAXDNAME];
- strcpy(srvname,"_hkp._tcp.");
- strncat(srvname,server,MAXDNAME-11);
- srvname[MAXDNAME-1]='\0';
- srvcount=getsrv(srvname,&srvlist);
+ if(1+strlen(srvtag)+6+strlen(server)+1<=MAXDNAME)
+ {
+ char srvname[MAXDNAME];
+
+ strcpy(srvname,"_");
+ strcat(srvname,srvtag);
+ strcat(srvname,"._tcp.");
+ strcat(srvname,server);
+ srvcount=getsrv(srvname,&srvlist);
+ }
}
#endif