Build a free Domain Name website in ADSL

Source: Internet
Author: User

If you use ADSL to access the Internet, you can create a free website at home, but the speed is not flattering.

In fact, it is to get the Internet IP address and then update the free Domain Name Information of mycool.net. In this way, when your ADSL Network is disconnected, the new IP address can be promptly updated to your free Domain Name System.

You need to apply for a free Domain Name On www.mycool.net, modify the user name and password in the code, and then run OK.

Import java. Io. bufferedreader;
Import java. Io. ioexception;
Import java. Io. inputstreamreader;
Import java. Io. outputstreamwriter;
Import java.net. malformedurlexception;
Import java.net. url;
Import java.net. urlconnection;
Import java. Text. messageformat;


Public final class Main ...{
Private Static string oldip = "";

Public static void main (string [] ARGs )...{
While (true )...{
String IP = getwanip ();
If (! Oldip. Equals (IP ))...{
Updatedomaininfo ("yourname", "oldpass", "newpass", "yourmail.domain.com", ip );
Oldip = IP;
}

Try ...{
Thread. Sleep (1000*60 );
} Catch (interruptedexception e )...{
E. printstacktrace ();
}
}
}

Private Static string getwanip ()...{
Bufferedreader in = NULL;
Try ...{
URL url = new URL ("http://vip.cn99.com/ret.php ");

In = new bufferedreader (New inputstreamreader (URL. openstream ()));
String STR = in. Readline ();
Return STR;
} Catch (malformedurlexception e )...{
} Catch (ioexception e )...{
} Finally ...{
If (in! = NULL)
Try ...{
In. Close ();
} Catch (ioexception e )...{}
}
Return NULL;
}

Private Static void updatedomaininfo (string user, string pass, string newpass, string email, string IP )...{
Try ...{
String data = "Action = modifybio & username = {0} & Password = {1} & Email = {2} & newpassword = {3} & url = http % 3A % 2f % 2f {4} & dirtype = No & submit = % C8 % B7 % B6 % A8 % D0 % de % B8 % c4 ";
Data = messageformat. Format (data, new string []... {user, pass, email, newpass, IP });
URL url = new URL ("http://mycool.net/cgi-bin/modi.cgi ");
Urlconnection conn = URL. openconnection ();
Conn. setdooutput (true );
Outputstreamwriter wR = new outputstreamwriter (conn. getoutputstream ());
Wr. Write (data );
Wr. Flush ();

Bufferedreader RD = new bufferedreader (New inputstreamreader (conn. getinputstream ()));
String line;
While (line = RD. Readline ())! = NULL )...{

}
Wr. Close ();
Rd. Close ();
System. Out. println ("Update domain to:" + IP );
} Catch (exception e )...{
E. printstacktrace ();
}

}
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.