]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
useful stuff for server admins: curl command now allows the host name to be
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 Dec 2009 19:04:20 +0000 (19:04 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 Dec 2009 19:04:20 +0000 (19:04 +0000)
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

libcurl.c

index 141086ae0bef4da54297b179f01f92034610a7f3..df2db7f9eb9cc42feafde31a380bc7aebadd28e1 100644 (file)
--- 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: