View Single Post
  #1  
Old 21.05.2011, 17:23
JoeH
Guest
 
Posts: n/a
Cool Guide: How to modify JDownloader's user-agent string

I recently found myself needing to change JDownloader’s user-agent string, as I am oftentimes behind a ZScaler filter, which doesn’t work well with JDownloader using the default user-agent string (if you are interested in knowing why, cf. this thread).

If you search around on the forum here, you will see that every once in a while this feature request has come up for one reason or another. Regardless of what the reason is, if you need to modify JDownloader’s user-agent, this guide is for you. If JDownloader is working just fine, or you don’t know what a user-agent string is, feel free to move on – it’s something you don’t need to worry about.

What we are going to do is install a local proxy and send JDownloader’s requests through the local proxy to the Internet. The local proxy will modify the user-agent string before sending out the requests. Thanks to Jiaz for the idea.

I am using Squid proxy in this tutorial, and running it on Windows. This tutorial is for Windows, but if you need to run it on Linux or some other operating system, just head over to **External links are only visible to Support Staff****External links are only visible to Support Staff** (that's h-t-t-p://wiki.squid-cache.org/SquidFaq/BinaryPackages for you non-supporters out there!) and download the version you need. The instructions below should be easy to adapt to other operating systems.

1. For Windows, download Squid from **External links are only visible to Support Staff****External links are only visible to Support Staff** (for non-supporters: h-t-t-p://squid.acmeconsulting.it/download/squid-2.7.STABLE8-bin.zip). This is the latest stable Windows release.
2. Unzip to c:\squid. It is highly recommended you use this directory. If you are going to use a different directory, you will need to modify all the configuration files to point to that directory, as well as the instructions below to adjust to that fact.
3. In the c:\squid\etc directory copy and rename the following files:
Code:
squid.conf.default ==> squid.conf
mime.conf.default ==> mime.conf
cachemgr.conf.default ==> cachemgr.conf
4. Open up an MS-DOS command prompt (as administrator) to c:\squid\sbin and run the following commands:
Code:
squid -i –f "c:/squid/etc/squid.conf" –n “Squid”
squid -z -f "c:/squid/etc/squid.conf"
squid -O servicecommandline –n “Squid”
5. Open c:\squid\etc\squid.conf in a text editor. Delete everything in the file (make sure you have the backup copy in case you need to reference it) and past in the following:

Code:
#These first lines identify "access control lists". 
#We are going to identify some IPs (all and localhost) we will later allow or block
acl all src all
acl localhost src 127.0.0.1/255.255.255.255

#Now we will identify ports we want to later allow or block
acl SSL_ports port 443
acl Safe_ports port 80		# http
acl Safe_ports port 21		# ftp
acl Safe_ports port 443		# https
acl Safe_ports port 70		# gopher
acl Safe_ports port 210		# wais
acl Safe_ports port 1025-65535	# unregistered ports
acl Safe_ports port 280		# http-mgmt
acl Safe_ports port 488		# gss-http
acl Safe_ports port 591		# filemaker
acl Safe_ports port 777		# multiling http
acl CONNECT method CONNECT

#We block unsafe ports
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports

#We allow access to the localhost, but block everyone else
http_access allow localhost
http_access deny all

#In this case we don't need icp access (access to the Squid cache), so we'll block that for everyone
icp_access deny all

#Allow htcp access to localhost, block everyone else
htcp_access allow localhost
htcp_access deny all

#Indicate the port you want the proxy (127.0.0.1) to listen on. By default Sqid uses 3128
#In JDownloader you will then set your proxy to 127.0.0.1 and your port to whatever port you indicate here
http_port 3128

#These next lines are necessary if you are going to use a proxy. 
#The first line indicates the proxy, the second tells Squid to forward everything it receives to the proxy
#Replace “YOUR_PROXY_IP_ADDRESS” with your proxy number.
#Replace “YOUR_PROXY_PORT_NUMBER” with your proxy port number
#If you aren't going to use a proxy you must delete or put a # before these lines
cache_peer YOUR_PROXY_IP_ADDRESS parent YOUR_PROXY_PORT_NUMBER 0 no-query no-digest
never_direct allow all

#Some default Squid configuration lines. Not sure what they all do, but they are recommended and don't seem to hurt
hierarchy_stoplist cgi-bin ?
cache_dir ufs c:/squid/var/cache 100 16 256
access_log c:/squid/var/logs/access.log squid
refresh_pattern ^ftp:		1440	20%	10080
refresh_pattern ^gopher:	1440	0%	1440
refresh_pattern -i (/cgi-bin/|\?) 0	0%	0
refresh_pattern .		0	20%	4320
acl shoutcast rep_header X-HTTP09-First-Line ^ICY.[0-9]
upgrade_http0.9 deny shoutcast
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache

#Here's where the magic happens. 
#Squid denies all user-agents and then replaces them with another user agent, in this case "JDownloader"
#If you want to use a different user-agent, just replace "JDownloader" with whatever agent you want to use
header_access User-Agent deny all
header_replace User-Agent JDownloader
6. In your new squid.conf file change the proxy number and port number as needed. If you don’t use a proxy, you must delete the two lines in the proxy section, or put a # infront of them so that Squid ignores them. You may also want to edit the default port that Squid listens on. The default is 3128, but you may want to use 8080 or some other port.
7. Notice the last two lines of the squid.conf file. Those are the lines that modify the user-agent string. They are currently set to use the user-agent string "JDownloader". If you want to use a different user-agent, change the text “JDownloader” to whatever user-agent you want to use. Save and close the file.
8. Open up “Services” and start the Squid service, or restart it if it is already running.
9. In the JDownloader options, configure JDownloader to use the proxy 127.0.0.1 and the port number 3128 (or whatever port number you chose). This option can be found in "Settings" - "Download and Connections" - "Internet and Network".

That’s it! Now Squid will intercept all the traffic that comes from JDownloader and modify the user-agent to whatever you tell it to, then send the traffic out to the Internet.

So far I have tested it with the update function, DLC files, FileServe and RapidShare and everything has worked perfectly. In theory it could cause problems with some plugins, however, so I would only recommend using it if you need to.

Enjoy!

Last edited by JoeH; 21.05.2011 at 19:57. Reason: Modify external links so they will be visible to all
Reply With Quote