SRCDS Steam group


sv_downloadurl multi server hack
#1
i had a large trouble with my server, because i had two smallish servers that i could use (each was the free webspace given to me and a friend by our isps) but the files i wanted to serve for the server were too numerous for a single sv_downloadurl. Srcds, to my knowledge, has no way of allowing more than one file server and thus i had run into a bit of a sticking point.

However i devised this little PHP script for myself, which i have now commented up and made usable (i hope) for anyone with a little knowledge about PHP (or computers).

everything you need to know is explained in the code, so here it is:

Code:
<?php
/*
################################################################################​#
-gµssy sv_downloadurl multi server hack script
-version 1.0a
-this is not a hack in the bad sense, its a hack in that it makes srcds do things it doesnt normally want to.
-this is really only a proof of concept ATM.  That said i've given it a quick test run and it seemed to work okay
-if you don't have experience with sv_downloadurl, dont even ATTEMPT to get this to run, familiarse yourself with srcds first.
-in order to use this, place this file in the directory below your files (or even in your base file directory, it shouldnt matter) and call it whatever you want.
-next point your sv_downloadurl variable in your server.cfg to <path><filename>.php?dl=
-that last bit is vitally important
-this essentially works, for those interested in PHP jediness, by accepting the file that srcdsis looking for as a GET argument, and then forwarding the page, via headers, to the file in questions.  this allows files to be defined for different servers so that you arent stuck with a single sv_downloadurl location  
-READ ALL NOTES, they are useful and contain some important information
-send any feedback (ie IF IT DONT WORK) via the srcds forums, or at angus dot moore at internode dot on dot net
*/


####################################
/* SERVER DEFINITIONS. SHOULD BE IN THE SAME FORMAT AS SV_DOWNLOADURL WOULD BE*/
####################################
//you can have  as many different servers as you like


//this must be the default server.  Any file on this server does not need its own file definition.
    $location[1]="http://www.example.com/hl2mp";
//other server numbers.
    $location[2]="http://www.example2.net/files";
    $location[3]="http://www.example3.net/wtfeva";    


####################################
/* FILE DEFINITIONS.  ANY FILE THAT IS NOT ON THE DEFAULT SERVER MUST BE DEFINED HERE AS TO WHICH SERVER IT IS ON */
####################################
//these files must be in the form that srcds will search for them, ie /maps/map_name.bsp.bz2 orthe like  
//VERY IMPORTANT - you MUST use bz2 for these files, as srcds will search for these first, and im pretty sure this script will break if you dont use bz2.
//that said im sure you could set it up to not use bz2, but why wouldnt you want to use bz2.  its quicker.

//this is in the form $files["<file name and path>"]=<server number>
$files["/maps/aim_arena_b7.bsp.bz2"]=2;
$files["/sounds/quake/headshot.mp3.bz2"]=3;
//etc. you get the idea


###################################
//actual code - dont alter this unless you know what your doing
###################################
if($_GET['dl']) {
    if(!isset($files[$_GET['dl']])) {
        //defualt it to the main server
        header("Location: " . $location[1] . $_GET['dl']);
    } else {
        //send it the new place
        header("Location: " . $location[$files[$_GET['dl']]] . $_GET['dl']);
    }
    
} else {

//feel free to alter the below code to whatever.  this is just what i use if someone gets there by accident.
    echo "<html>
<head>
<title>gµssy sv_downloadurl hack</title>
</head>
<body>
This is our file server.  You shouldn't probably be here. Try <A href=\"http://www.mysite.com\">here</a> instead.<br><br>
Have a nice day!
</body>
</html>";
}
?>

and remember, though my title says hack, its not a hack in the bad way
Reply
#2
Looks promising I'll check it out some time!

ps: never thought it would be THAT easy... lol!
pss: for the people that still think hacking is bad: hacking = modifying stuff, can be done in good way and bad.
Join the Source Dedicated Server Support Group on Steam Community!
Source Dedicated Server (SRCDS)
Free to join, Live support! (When available)

http://forums.srcds.com/viewtopic/5114
Reply
#3
lol, it really is so easy in execution, but just not something that immediately came to me. I originally thought of trying to set the server to see .bz2 files as ones that could be read by php, and then redirect each individual file - buts thats just a bad idea really.

i felt it was necessary to add the hack in a good way - didnt want people getting the wrong idea, hacking has a bad name these days
Reply
#4
Cant seem to get this to work....

I followed your directions to the point, but no luck.


Is this what IM supposed to put in my server.cfg?

Code:
sv_downloadurl "c:\srcds\downloads.php?dl="
Reply
#5
Can someone give instructions on how to put it on the server?

Like I copy and save it in a text file under a name with an extension of?...

How can you tell if this works? How fast the download is?
Earn Points, get Free Rewards with your Amazon Points!
Points2Shop

Reply
#6
The download is as fast as normal if you want i can make one on a per folder basis and include extensive documentation
~ trewq
Reply
#7
That would be great if can.Cool
Earn Points, get Free Rewards with your Amazon Points!
Points2Shop

Reply
#8
Bah. This is extremely nice but mostly useless hack. Cool stuff, but useless for 99.99% server admins. Everybody with server will have enough space somewhere else for the files. This kind of hack could have been useful about five years ago when everybody weren't giving out gigabytes of free web space everywhere.

This PHP system makes it possible to use multiple HTTP web servers in sv_downloadurl. The PHP script distributes file requests to pre-defined servers. For example file de_seasideresort.bsp.bz2 could be hosted at http://www.freewebhosting.com/freeaccount/files/cssmaps/ and de_nightfever.bsp.bz2 could be at http://www.geocity.com/area51/mygeoaccount/mapfiles/. Then the PHP script itself could be on some very limited 10 MB size webhosting which your ISP gives you. Then you set up "sv_downloadurl" to point to this PHP file hosted on your ISP's webhosting. None of the map files fit on the 10 MB space, but the PHP script ingeniously redirects all map downloads to corresponding servers.

@ Ghost Assassin, eipeks
You don't need this. You just need to set up sv_downloadurl correctly. Read another tutorial how to setup sv_downloadurl correctly. This "sv_downloadurl multi server hack" is not what you are looking for.

PS. Everybody without enough web space for your map files raise your hand.
Reply
#9
If you dont have enough space just talk to me and we can work something out
~ trewq
Reply
#10
Hrm.

Well, i just though it would be cool to try this cuz I get 10 web accounts with my ISP which are 20 MB each. 1 isnt enough for a few maps....

The nice thing about my ISP is that fastdownloads are FAST. Ive tried freewebhosting, and a buncha my buddies webhosts, but even compressed, the downloads are so slow.

I just need some web space that is FAST and cheap enough.
Reply
#11
css Wrote:@ Ghost Assassin, eipeks
You don't need this. You just need to set up sv_downloadurl correctly. Read another tutorial how to setup sv_downloadurl correctly. This "sv_downloadurl multi server hack" is not what you are looking for.

PS. Everybody without enough web space for your map files raise your hand.

I do know how to set up sv_downloadurl. I just need more space and something that is fast. If I can make it work, it would be very useful to me. I just cant figure out where to put the my Download.php with all that code in it.
Reply
#12
eipeks Wrote:Well, i just though it would be cool to try this cuz I get 10 web accounts with my ISP which are 20 MB each.

20MB? What 3rd world country are we speaking of?

eipeks Wrote:I just cant figure out where to put the my Download.php with all that code in it.

Put the PHP file on any of your 20 MB web spaces. Set sv_downloadurl to the script as said in the instructions. Then configure in the script those 10 web hosts where you have files.

The location of the PHP script is irrelevant. It can be on any webhost that can run the PHP file. None of the map files (or other downloads) have to be on the same host.
Reply
#13
css: An ISP gives webspace but they don't give a lot. It isn't a Web Hosting company. Mine (Canada, Rogers Internet) gave 20MB afaik.

BTW, this is just a simple PHP Script that just redirects the user to the proper location where the file resides.

What would be nice is load balancing :p Get a bunch of free hosts from different locations, and make sure every user that downloads from you will download quick. Good for custom maps servers for TF2 where each map is like 20-50mb.
Reply
#14
You can use this website.

http://www.diino.com/

Just make an account. It gives you free 2 GB space. Download their program...and connect to upload your files. You need to make the folder public for sv_downloadurl to work.
Earn Points, get Free Rewards with your Amazon Points!
Points2Shop

Reply
#15
m0- Wrote:What would be nice is load balancing :p Get a bunch of free hosts from different locations, and make sure every user that downloads from you will download quick.

Nah... Load balancing (more like bandwidth/traffic balancing) in this scenario is useless. Everybody plays on low-ping servers, which means the best place to download is the server itself. If the server itself is not an option, then it's all the same where the download comes. I get 500kbps downloads even from USA, so it's not a problem.

Anyways, this is nice proof-of-concept plugin. Mostly useless, but everybody knows it's possible now Smile
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)