package com.hereonline.heritrix.http5977;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class Router {
private static final String USERNAME_PASSWORD = "admin:wangxiong";
private String oldIpStr = null;
public static void main(String[] args) {
new Router();
}
public Router() {
// this.oldIpStr = JsIpUtils.getIpInInternet();
this.disconnect();
// System.out.println(this.oldIpStr + " -> " +
// JsIpUtils.getIpInInternet());
}
private void disconnect() {
String urlStr = "http://192.168.0.1/Status/st_devic.xgi?set/runtime/wan/inf:1/Disconnect=1";
this.runCgi(urlStr, USERNAME_PASSWORD);
}
private void runCgi(String urlStr, String authorizationStr) {
URL xUrl = null;
HttpURLConnection xHuc = null;
try {
xUrl = new URL(urlStr);
if (xUrl != null) {
xHuc = (HttpURLConnection) xUrl.openConnection();
if (xHuc != null) {
// cookies / login
if (!"".equals(authorizationStr)) {
xHuc.setRequestProperty("Authorization", "Basic "
+ Base64.encodeBytes(USERNAME_PASSWORD
.getBytes()));
}
// entity
xHuc.setRequestProperty("Content-Length", "0");
xHuc.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
// connect
xHuc.connect();
// get response
String aa = xHuc.getResponseMessage();
System.out.println(aa);
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// long endTimeLng = System.currentTimeMillis() + 10000;
// while (JsIpUtils.getIpInInternet().equals(this.oldIpStr)
// && JsTimeUtils.sleepIfNotTimeout(1000, endTimeLng));
// disconnect
if (xHuc != null) {
xHuc.disconnect();
}
}
}
}
分享到:
相关推荐
宽带路由器 D-Link DI-604_DI-704P.pdf
DI-604+路由器设置 请查看。 DI-604+路由器设置 DI-604+路由器设置
很详细的中文说明!几乎就是傻瓜式的 ,就具体怎么设置的。看了就知道了
D-Link无线路由器DI-514.pdf
D-Link推出宽带路由器DI-714P+.pdf
D-Link推出ADSL无线远程路由器DSL-604+.pdf
无线路由器DI-724UP+A:D-Link.pdf
D-Link推出DI-604+宽带路由器.pdf
D-link DI-604专为家庭和小型办公室设计,提供强大的Internet和局域网资源共享功能。其具备高速、安全、简单、灵活、兼容性好等多种优势,同时产品设置简单,对于非专业技术人员也可以很容易的安装配置,亲和友好的...
D-Link DI-7100G A1 企业路由器/行为管理 升级固件 ,版本号:Build-DI051026-120808.bin
华硕路由器RT-N16N18N66AC66梅林固件搭建PHP环境终版.pdf
最新DI-624+A固件适合很多种有DI-624+A掉线的路由器
cisco路由器配置-桥接dlsw+与桌面协议
H3C AR 28 系列模块化路由器 AR28-CMW340-R0311P26.zip
DI-4500 路由器硬件安装手册DI-4500 路由器硬件安装手册DI-4500 路由器硬件安装手册
D-Link,DI-7000,路由器vpn怎么设置.doc
路由器dd-wrt功能介绍及设置教程路由器dd-wrt功能介绍及设置教程路由器dd-wrt功能介绍及设置教程
工业级3G路由器--南京德托pdf,工业级3G路由器--南京德托
D-Link推出无线路由器新品DI-624+A.pdf