From 6b97c4c2d7a3f1e8812d99bbdd7db87e062a3abd Mon Sep 17 00:00:00 2001
From: Peng-YM <1048217874pengym@gmail.com>
Date: Fri, 4 Sep 2020 21:15:26 +0800
Subject: [PATCH] Bug fixed
---
backend/.idea/workspace.xml | 91 ++++++++++++++++----------------
backend/sub-store.js | 10 ++++
web/src/components/ProxyList.vue | 18 ++++---
3 files changed, 67 insertions(+), 52 deletions(-)
diff --git a/backend/.idea/workspace.xml b/backend/.idea/workspace.xml
index 777abab..158c22f 100644
--- a/backend/.idea/workspace.xml
+++ b/backend/.idea/workspace.xml
@@ -21,6 +21,7 @@
+
@@ -105,7 +106,7 @@
-
+
@@ -125,7 +126,7 @@
-
+
@@ -137,8 +138,8 @@
-
-
+
+
@@ -150,8 +151,8 @@
-
-
+
+
@@ -163,8 +164,8 @@
-
-
+
+
@@ -176,9 +177,9 @@
-
-
-
+
+
+
@@ -189,9 +190,9 @@
-
-
-
+
+
+
@@ -202,9 +203,9 @@
-
-
-
+
+
+
@@ -215,9 +216,9 @@
-
-
-
+
+
+
@@ -228,9 +229,9 @@
-
-
-
+
+
+
@@ -241,9 +242,9 @@
-
-
-
+
+
+
@@ -254,9 +255,9 @@
-
-
-
+
+
+
@@ -267,9 +268,9 @@
-
-
-
+
+
+
@@ -280,9 +281,9 @@
-
-
-
+
+
+
@@ -293,9 +294,9 @@
-
-
-
+
+
+
@@ -306,9 +307,9 @@
-
-
-
+
+
+
@@ -319,9 +320,9 @@
-
-
-
+
+
+
@@ -332,7 +333,7 @@
-
+
diff --git a/backend/sub-store.js b/backend/sub-store.js
index b32e743..958c32f 100644
--- a/backend/sub-store.js
+++ b/backend/sub-store.js
@@ -51,11 +51,15 @@ $.info("Initializing Express...");
$app.get("/download/collection/:name", downloadCollection);
$app.get("/download/:name", downloadSub);
+// IP_API
+$app.get("/api/IP_API/:server", IP_API);
+
// subscriptions
$app.route("/api/sub/:name").get(getSub).patch(updateSub).delete(deleteSub);
$app.route("/api/sub").get(getAllSubs).post(newSub).delete(deleteAllSubs);
+
// refresh
$app.post("/api/refresh", refreshResource);
@@ -79,6 +83,12 @@ $app.all("/", async (req, res) => {
$.info("Express initialized");
$app.start();
+async function IP_API(req, res) {
+ const server = decodeURIComponent(req.params.server);
+ const result = await $.http.get(`http://ip-api.com/json/${server}?lang=zh-CN`).then(resp => JSON.parse(resp.body));
+ res.json(result);
+}
+
/**************************** API -- Subscriptions ***************************************/
// refresh resource
async function refreshResource(req, res) {
diff --git a/web/src/components/ProxyList.vue b/web/src/components/ProxyList.vue
index 0c4a218..d1b8818 100644
--- a/web/src/components/ProxyList.vue
+++ b/web/src/components/ProxyList.vue
@@ -37,9 +37,11 @@
- {{info.title}}
+ {{info.isp}}
- {{info.subtitle}}
+ {{info.region}}
+
+ {{info.ip}}
@@ -60,8 +62,9 @@ export default {
dialog: false,
info: {
name: "",
- title: "",
- subtitle: "",
+ isp: "",
+ region: "",
+ ip: ""
}
}
},
@@ -83,10 +86,11 @@ export default {
async showInfo(idx) {
const {server, name} = this.proxies[idx];
- const res = await axios.get(`http://ip-api.com/json/${server}?lang=zh-CN`).then(resp => resp.data);
+ const res = await axios.get(`/IP_API/${encodeURIComponent(server)}`).then(resp => resp.data);
this.info.name = name;
- this.info.title = `地区:${flags.get(res.countryCode)} ${res.regionName} ${res.city}`;
- this.info.subtitle = `IP:${res.query}`
+ this.info.isp = `ISP:${res.org}`;
+ this.info.region = `地区:${flags.get(res.countryCode)} ${res.regionName} ${res.city}`;
+ this.info.ip = `IP:${res.query}`
this.dialog = true
},
},