View Single Post
  #22  
Old 04.03.2011, 08:57
buggsy buggsy is offline
BugMeNot Account
 
Join Date: Mar 2009
Location: everywhere/nowhere
Posts: 1,111
Default Reconnect for Thomson TG585 v7, Softwareversion: 8.6.9.0

I wrote an application to reconnect with this router using mono/C#. Here is the code if you want to compile it yourself:
Spoiler:
Code:
using System;
using System.Net;
using System.Text.RegularExpressions;

namespace reconnect
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string address = null;
			
			Regex reg = new Regex (@"**External links are only visible to Support Staff**);
			
			if (reg.IsMatch (args[0])) {
				address = args[0];
			} 
			else {
				address = "**External links are only visible to Support Staff** + args[0];
			}
			
			Router router = new Router (address);
			router.Terminate ();
			router.Reconnect ();
		}

		public class Router
		{
			private string address;
			private string data;
			private string reply;
			private WebClient client = new WebClient ();
			private Regex reg;
			private Match match;

			public Router (string address)
			{
				this.address = address;
				this.data = this.client.DownloadString (address);
			}

			public void Terminate ()
			{
				this.reg = new Regex (@"<input type=\'hidden\' name=\'2\' value=\'(\d+)\'>");
				this.match = reg.Match (data);
				
				string num = match.Groups[1].Value;
				
				string terminate = "0=13&1=INTERNET&2=" + num + "&5=2";
				this.client.Headers.Add ("Content-Type", "application/x-www-form-urlencoded");
				this.reply = client.UploadString (address, terminate);
			}

			public void Reconnect ()
			{
				this.match = reg.Match (reply);
				string num = match.Groups[1].Value;
				
				string reconnect = "0=12&1=INTERNET&2=" + num + "&5=2";
				this.client.Headers.Add ("Content-Type", "application/x-www-form-urlencoded");
				this.reply = client.UploadString (address, reconnect);
			}
		}
	}
}


If you want an already compiled file you can get it from:
**External links are only visible to Support Staff****External links are only visible to Support Staff**

To use it from commandline:
Code:
For Linux: mono reconnect.exe <ROUTER_IP>
For Windows: reconnect.exe <ROUTER_IP>
//Please replace <ROUTER_IP> with the IP address of the Thomson router (e.g. 10.0.0.138)
The router needs rather long to reconnect, so I had to set the timeout in jdownloader to 120 sec for reconnection.

Last edited by buggsy; 04.03.2011 at 09:06. Reason: Added info for timout settings
Reply With Quote