优化获取小米路由器后台token
This commit is contained in:
parent
8e98929622
commit
b5076323d7
@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class QQBotApplication {
|
||||
public static final String version="QQBot v.1.2.7";
|
||||
public static final String version="QQBot v.1.2.7.1";
|
||||
public static void main(String[] args) {
|
||||
System.out.println("version = " + version);
|
||||
SpringApplication.run(QQBotApplication.class, args);
|
||||
|
@ -106,6 +106,8 @@ public class MiRouter extends Model {
|
||||
}
|
||||
}
|
||||
RedisTools.set(redis_key, devs.toJSONString());
|
||||
}else {
|
||||
XiaoMiRouter.setNotToken();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,16 @@ import java.util.Date;
|
||||
|
||||
public class XiaoMiRouter {
|
||||
private final static String key = "a2ffa5c9be07488bbb04a3a47d3c5f6a";
|
||||
private static String token = null;
|
||||
|
||||
public static void setNotToken() {
|
||||
token = null;
|
||||
}
|
||||
|
||||
public static String getToken() {
|
||||
if (token != null) {
|
||||
return token;
|
||||
}
|
||||
String nonce = nonceCreat();
|
||||
String oldPwd = DigestUtils.sha1Hex(nonce + DigestUtils.sha1Hex("34864394" + key));
|
||||
JSONObject json = new JSONObject();
|
||||
@ -21,7 +29,8 @@ public class XiaoMiRouter {
|
||||
json.put("nonce", nonce);
|
||||
json = JSONObject.parseObject(HttpTools.http_post("http://192.168.31.1/cgi-bin/luci/api/xqsystem/login", HttpTools.toUrlParams(json).getBytes(StandardCharsets.UTF_8), 1, null));
|
||||
if (json.getInteger("code") == 0) {
|
||||
return json.getString("token");
|
||||
token = json.getString("token");
|
||||
return token;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user