From: divverent Date: Sat, 19 Dec 2009 19:04:20 +0000 (+0000) Subject: useful stuff for server admins: curl command now allows the host name to be X-Git-Tag: xonotic-v0.1.0preview~1057 X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=cddbfb714e686d4818d3bf4631871d6fa6639eb0 useful stuff for server admins: curl command now allows the host name to be left out, like this: http:///~nexuiz/files/ http://:8080/~nexuiz/files/ allows setting up the HTTP server for map downloads on the same machine as the DP server on a dynamic IP without using dyndns. Client needs to support this. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9590 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/libcurl.c b/libcurl.c index 141086ae..df2db7f9 100644 --- a/libcurl.c +++ b/libcurl.c @@ -695,10 +695,31 @@ static qboolean Curl_Begin(const char *URL, const char *name, qboolean ispak, qb else { char fn[MAX_OSPATH]; + char urlbuf[1024]; const char *p, *q; size_t length; downloadinfo *di; + // if URL is protocol:///* or protocol://:port/*, insert the IP of the current server + p = strchr(URL, ':'); + if(p) + { + if(!strncmp(p, ":///", 4) || !strncmp(p, "://:", 4)) + { + char addressstring[128]; + *addressstring = 0; + InfoString_GetValue(cls.userinfo, "*ip", addressstring, sizeof(addressstring)); + q = strchr(addressstring, ':'); + if(!q) + q = addressstring + strlen(addressstring); + if(*addressstring) + { + dpsnprintf(urlbuf, sizeof(urlbuf), "%.*s://%.*s%s", (int) (p - URL), URL, (int) (q - addressstring), addressstring, URL + (p - URL) + 3); + URL = urlbuf; + } + } + } + // Note: This extraction of the file name portion is NOT entirely correct. // // It does the following: