|
|
@@ -56,5 +56,49 @@ namespace molilian.api.Controllers
|
|
|
}
|
|
|
|
|
|
|
|
|
+ [HttpGet]
|
|
|
+ public async Task<ActionResult> ChangePublicIpByName(string nodeName)
|
|
|
+ {
|
|
|
+
|
|
|
+ var proxy_node = new DBContext.Table("proxy_nodes").Get<dynamic>("name=@nodeName", new { nodeName });
|
|
|
+ if (proxy_node == null) return new APIResult(new { success = false, msg = "没有匹配的 proxy_nodes 记录" });
|
|
|
+
|
|
|
+ int aliyun_id = proxy_node.aliyun_id;
|
|
|
+ string proxy_server = proxy_node.server;
|
|
|
+
|
|
|
+ var account = new DBContext.Table("aliyun_pool").Get<AliyunPoolDTO>(aliyun_id);
|
|
|
+ if (account == null) return new APIResult(new { success = false, msg = "没有匹配的 aliyun_pool 记录" });
|
|
|
+
|
|
|
+
|
|
|
+ var uri = new Uri(proxy_server);
|
|
|
+ string privateIp = uri.Host;
|
|
|
+ AliyunCore core = new AliyunCore(account);
|
|
|
+ var success = core.ChangePublicIp(privateIp);
|
|
|
+ return new APIResult(new { success = "ok" });
|
|
|
+ }
|
|
|
+
|
|
|
+ [HttpGet]
|
|
|
+ public async Task<ActionResult> ChangePublicIp(int id)
|
|
|
+ {
|
|
|
+ id = id >= 20000 ? id - 20000 : id;
|
|
|
+
|
|
|
+ var proxy_node = new DBContext.Table("proxy_nodes").Get<dynamic>(id);
|
|
|
+ if (proxy_node == null) return new APIResult(new { success = false, msg = "没有匹配的 proxy_nodes 记录" });
|
|
|
+
|
|
|
+ int aliyun_id = proxy_node.aliyun_id;
|
|
|
+ string proxy_server = proxy_node.server;
|
|
|
+
|
|
|
+ var account = new DBContext.Table("aliyun_pool").Get<AliyunPoolDTO>(aliyun_id);
|
|
|
+ if (account == null) return new APIResult(new { success = false, msg = "没有匹配的 aliyun_pool 记录" });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ var uri = new Uri(proxy_server);
|
|
|
+ string privateIp = uri.Host;
|
|
|
+ AliyunCore core = new AliyunCore(account);
|
|
|
+ var success = core.ChangePublicIp(privateIp);
|
|
|
+ return new APIResult(new { success = "ok" });
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|