From 8dececb4891f2d93822cbce3a247e60034932cd6 Mon Sep 17 00:00:00 2001 From: libo Date: Mon, 25 May 2020 19:20:01 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Web/api/api.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Src/Web/api/api.py b/Src/Web/api/api.py index f5bec51..c2a42f7 100644 --- a/Src/Web/api/api.py +++ b/Src/Web/api/api.py @@ -82,13 +82,33 @@ def get(self): log.debug("receive params: {}".format(options)) item = proxy_manager.getSampleUsefulProxy(**options) - if item: - del item["_id"] result["data"] = item return result +class deleteProxy(Resource): + def __init__(self, **kwargs): + super(Proxy, self).__init__(**kwargs) + + parser = reqparse.RequestParser() + parser.add_argument('id', type=str, choices=[1], location='args') + self.args = parser.parse_args() + def get(self): + result = { + "data": {} + } + + options = { + "id": self.args.get('id'), + } + log.debug("receive params: {}".format(options)) + + item = proxy_manager.deleteRawProxy(**options) + + result["data"] = item + + return result class Proxies(Resource): def __init__(self, **kwargs): @@ -140,4 +160,6 @@ def init_app(app): api = Api(app) api.add_resource(Proxies, '/api/v1/proxies/') api.add_resource(Proxy, '/api/v1/proxy/') + api.add_resource(deleteProxy, '/api/v1/proxy/delete') + api.add_resource(ApiList, '/api/v1/') From 01bf80a06f826bb43083bfbde40d19eba6e52dba Mon Sep 17 00:00:00 2001 From: libo Date: Mon, 25 May 2020 19:28:06 +0800 Subject: [PATCH 02/10] debug --- Src/Web/api/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Src/Web/api/api.py b/Src/Web/api/api.py index c2a42f7..9d2f0a4 100644 --- a/Src/Web/api/api.py +++ b/Src/Web/api/api.py @@ -82,7 +82,8 @@ def get(self): log.debug("receive params: {}".format(options)) item = proxy_manager.getSampleUsefulProxy(**options) - + if item: + del item["_id"] result["data"] = item return result From 75334e22b15c182a8d1c030aa1703e5df7b5abd6 Mon Sep 17 00:00:00 2001 From: libo Date: Mon, 25 May 2020 19:34:57 +0800 Subject: [PATCH 03/10] update --- Src/Web/api/api.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Src/Web/api/api.py b/Src/Web/api/api.py index 9d2f0a4..5f865f9 100644 --- a/Src/Web/api/api.py +++ b/Src/Web/api/api.py @@ -89,10 +89,11 @@ def get(self): return result class deleteProxy(Resource): def __init__(self, **kwargs): - super(Proxy, self).__init__(**kwargs) + super(deleteProxy, self).__init__(**kwargs) parser = reqparse.RequestParser() - parser.add_argument('id', type=str, choices=[1], location='args') + parser.add_argument('host', type=str, choices=[1], location='args') + parser.add_argument('port', type=str, choices=[1], location='args') self.args = parser.parse_args() def get(self): @@ -101,11 +102,12 @@ def get(self): } options = { - "id": self.args.get('id'), + "host": self.args.get('host'), + "port": self.args.get('port'), } log.debug("receive params: {}".format(options)) - item = proxy_manager.deleteRawProxy(**options) + item = proxy_manager.deleteUsefulProxy(**options) result["data"] = item From 048da12e7c92ff997f0c0157806b3d97ce2f8a1f Mon Sep 17 00:00:00 2001 From: libo Date: Mon, 25 May 2020 19:43:10 +0800 Subject: [PATCH 04/10] update --- Src/Web/api/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Web/api/api.py b/Src/Web/api/api.py index 5f865f9..bbb7dcd 100644 --- a/Src/Web/api/api.py +++ b/Src/Web/api/api.py @@ -107,7 +107,7 @@ def get(self): } log.debug("receive params: {}".format(options)) - item = proxy_manager.deleteUsefulProxy(**options) + item = proxy_manager.deleteUsefulProxy(options) result["data"] = item From 58f21461ec581fba00c3c577d0d588e29ccf609d Mon Sep 17 00:00:00 2001 From: libo Date: Tue, 26 May 2020 14:28:51 +0800 Subject: [PATCH 05/10] remove chonic --- Src/Web/api/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/Web/api/api.py b/Src/Web/api/api.py index bbb7dcd..38defd1 100644 --- a/Src/Web/api/api.py +++ b/Src/Web/api/api.py @@ -92,8 +92,8 @@ def __init__(self, **kwargs): super(deleteProxy, self).__init__(**kwargs) parser = reqparse.RequestParser() - parser.add_argument('host', type=str, choices=[1], location='args') - parser.add_argument('port', type=str, choices=[1], location='args') + parser.add_argument('host', type=str, location='args') + parser.add_argument('port', type=str, location='args') self.args = parser.parse_args() def get(self): From 93d04d78caadcff85d8ed94b3c4cc6d12b44e95c Mon Sep 17 00:00:00 2001 From: libo Date: Tue, 26 May 2020 14:49:39 +0800 Subject: [PATCH 06/10] add log --- Src/Manager/ProxyManager.py | 1 + Src/Web/api/api.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Src/Manager/ProxyManager.py b/Src/Manager/ProxyManager.py index 5a73c96..8f3882d 100644 --- a/Src/Manager/ProxyManager.py +++ b/Src/Manager/ProxyManager.py @@ -107,6 +107,7 @@ def getQualityUsefulProxy(self, **kwargs): return result def deleteRawProxy(self, proxy): + log.info(proxy) self.raw_proxy.deleteRawProxy(proxy) def saveRawProxy(self, proxy): diff --git a/Src/Web/api/api.py b/Src/Web/api/api.py index 38defd1..a48b201 100644 --- a/Src/Web/api/api.py +++ b/Src/Web/api/api.py @@ -105,10 +105,10 @@ def get(self): "host": self.args.get('host'), "port": self.args.get('port'), } - log.debug("receive params: {}".format(options)) + log.info("receive params: {}".format(options)) item = proxy_manager.deleteUsefulProxy(options) - + log.info("delete {}".format(item)) result["data"] = item return result From e34ef4ce85e21903f9cb065b3cf81a0ac5fa351f Mon Sep 17 00:00:00 2001 From: libo Date: Tue, 26 May 2020 15:36:42 +0800 Subject: [PATCH 07/10] update delete --- Src/Web/api/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Web/api/api.py b/Src/Web/api/api.py index a48b201..58a8843 100644 --- a/Src/Web/api/api.py +++ b/Src/Web/api/api.py @@ -107,7 +107,7 @@ def get(self): } log.info("receive params: {}".format(options)) - item = proxy_manager.deleteUsefulProxy(options) + item = proxy_manager.deleteUsefulProxy(self.args.get('host').':'.self.args.get('port')) log.info("delete {}".format(item)) result["data"] = item From 1f55f1eb3e5e4b9a0c7648a8290f909d32a1e560 Mon Sep 17 00:00:00 2001 From: libo Date: Tue, 26 May 2020 15:48:12 +0800 Subject: [PATCH 08/10] add proxy --- Src/Web/api/api.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Src/Web/api/api.py b/Src/Web/api/api.py index 58a8843..2aa8880 100644 --- a/Src/Web/api/api.py +++ b/Src/Web/api/api.py @@ -92,8 +92,7 @@ def __init__(self, **kwargs): super(deleteProxy, self).__init__(**kwargs) parser = reqparse.RequestParser() - parser.add_argument('host', type=str, location='args') - parser.add_argument('port', type=str, location='args') + parser.add_argument('proxy', type=str, location='args') self.args = parser.parse_args() def get(self): @@ -102,12 +101,11 @@ def get(self): } options = { - "host": self.args.get('host'), - "port": self.args.get('port'), + "proxy": self.args.get('proxy'), } log.info("receive params: {}".format(options)) - item = proxy_manager.deleteUsefulProxy(self.args.get('host').':'.self.args.get('port')) + item = proxy_manager.deleteUsefulProxy(self.args.get('proxy')) log.info("delete {}".format(item)) result["data"] = item From d804f593735bdaaff2fd0b9b012921db328e2f44 Mon Sep 17 00:00:00 2001 From: libo Date: Tue, 26 May 2020 20:39:08 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9DockerFile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Docker/Dockerfile | 2 +- requirements.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 8d3fe31..0d74819 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -5,7 +5,7 @@ COPY . . ENV DEBIAN_FRONTEND noninteractive ENV TZ Asia/Shanghai -RUN pip install -r requirements.txt +RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple EXPOSE 35050 EXPOSE 36050 diff --git a/requirements.txt b/requirements.txt index 8a04b6f..eedf907 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,3 +12,4 @@ pymongo==3.7.2 flask-mongoengine==0.8.2 Flask-Admin==1.5.3 Flask-Security==3.0.0 +email-validator==1.1.1 \ No newline at end of file From a6af1580b20ea7ed3ab0fed6cc64de4fca1c5b4e Mon Sep 17 00:00:00 2001 From: libo Date: Wed, 27 May 2020 19:52:13 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=AA=E9=99=A4?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Manager/ProxyManager.py | 3 +++ Src/Web/api/api.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Src/Manager/ProxyManager.py b/Src/Manager/ProxyManager.py index 8f3882d..068ab11 100644 --- a/Src/Manager/ProxyManager.py +++ b/Src/Manager/ProxyManager.py @@ -160,6 +160,9 @@ def updateUsefulProxy(self, item, info): if item.get("https") == PROXY_HTTPS["UNKNOWN"]: data["$set"]["https"] = info["https"] + if item.get("quality"): + data["$set"]["quality"] = -1 + if len(data["$set"]) > 0: self.useful_proxy.updateUsefulProxy(item["proxy"], data) diff --git a/Src/Web/api/api.py b/Src/Web/api/api.py index 2aa8880..91b9e52 100644 --- a/Src/Web/api/api.py +++ b/Src/Web/api/api.py @@ -102,10 +102,11 @@ def get(self): options = { "proxy": self.args.get('proxy'), + "quality":-1 } log.info("receive params: {}".format(options)) - - item = proxy_manager.deleteUsefulProxy(self.args.get('proxy')) + info={} + item = proxy_manager.updateUsefulProxy(options, info) log.info("delete {}".format(item)) result["data"] = item