From daff55ae48e617f257274d8c760e800fb25f88d1 Mon Sep 17 00:00:00 2001 From: Dorae <86833913+Toperlock@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:00:20 +0800 Subject: [PATCH 1/2] Update tool.py --- tool.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tool.py b/tool.py index ccc160003..792467a61 100644 --- a/tool.py +++ b/tool.py @@ -1,5 +1,8 @@ import urllib.parse,base64,requests,paramiko,random,string,re,chardet -from paramiko import SSHClient +import warnings +from cryptography.utils import CryptographyDeprecationWarning +with warnings.catch_warnings(action="ignore", category=CryptographyDeprecationWarning): + from paramiko import SSHClient from scp import SCPClient def get_encoding(file): From 375cdbfd9fade6047f5b5fef0e8259442942db3d Mon Sep 17 00:00:00 2001 From: Toperlock <861705708@qq.com> Date: Thu, 8 Aug 2024 17:35:57 +0800 Subject: [PATCH 2/2] silence `paramiko` warnings --- README.md | 2 +- api/app.py | 5 ++--- instructions/README.md | 2 +- main.py | 2 +- parsers/http.py | 2 +- parsers/https.py | 4 ++-- parsers/hysteria.py | 2 +- parsers/hysteria2.py | 2 +- parsers/socks.py | 4 ++-- parsers/ss.py | 2 +- parsers/ssr.py | 2 +- parsers/trojan.py | 2 +- parsers/tuic.py | 4 ++-- parsers/vless.py | 2 +- parsers/vmess.py | 4 ++-- parsers/wg.py | 2 +- tool.py | 6 +++--- 17 files changed, 24 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 09837ab2f..183921c8e 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ https://xxxxxxx.vercel.app/config/https://xxxxxxsubscribe?token=123456&file=2 python main.py ``` -或者你可以直接带template_index参数选定模板,0表示第一个模板 +或者你可以直接带template_index参数选定模板,0表示第一个模板(no flask不支持此参数) ``` python main.py --template_index=0 diff --git a/api/app.py b/api/app.py index b95b3541f..86d1c0931 100644 --- a/api/app.py +++ b/api/app.py @@ -1,10 +1,9 @@ -from flask import Flask, render_template, request, redirect, url_for, flash, send_file, jsonify, Response -from urllib.parse import quote, urlparse, parse_qs, unquote +from flask import Flask, render_template, request, redirect, url_for, flash, jsonify, Response +from urllib.parse import quote, urlparse, unquote import json import os import sys import subprocess -import argparse # 添加 argparse 模块 import tempfile import shutil import tempfile # 导入 tempfile 模块 diff --git a/instructions/README.md b/instructions/README.md index 7f00b95ab..7593beab2 100644 --- a/instructions/README.md +++ b/instructions/README.md @@ -165,7 +165,7 @@ pip install -r requirements.txt python main.py ``` -or you can directly select the template with the `template_index`, `0` means the first template +or you can directly select the template with the `template_index`, `0` means the first template(no flask doesn't support) ``` python main.py --template_index=0 diff --git a/main.py b/main.py index 7abd97cf9..a9206109c 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,4 @@ -import json, os, tool, time, requests, sys, urllib, importlib, argparse, yaml, ruamel.yaml +import json, os, tool, time, requests, sys, importlib, argparse, yaml, ruamel.yaml import re from datetime import datetime from urllib.parse import urlparse diff --git a/parsers/http.py b/parsers/http.py index 692087c56..a5a5ae46b 100644 --- a/parsers/http.py +++ b/parsers/http.py @@ -1,4 +1,4 @@ -import tool,json,re,urllib,sys +import tool,re from urllib.parse import urlparse, parse_qs, unquote def parse(data): info = data[:] diff --git a/parsers/https.py b/parsers/https.py index e2b27abef..6c116c419 100644 --- a/parsers/https.py +++ b/parsers/https.py @@ -1,5 +1,5 @@ -import tool,json,re,urllib,sys -from urllib.parse import urlparse, parse_qs, unquote +import tool,re +from urllib.parse import urlparse,unquote def parse(data): info = data[:] server_info = urlparse(info) diff --git a/parsers/hysteria.py b/parsers/hysteria.py index 203b95f51..100605e9c 100644 --- a/parsers/hysteria.py +++ b/parsers/hysteria.py @@ -1,4 +1,4 @@ -import tool,json,re,urllib,sys +import tool,re from urllib.parse import urlparse, parse_qs, unquote def parse(data): diff --git a/parsers/hysteria2.py b/parsers/hysteria2.py index 44a192a0a..016c44cd1 100644 --- a/parsers/hysteria2.py +++ b/parsers/hysteria2.py @@ -1,4 +1,4 @@ -import tool,json,re,urllib,sys +import tool,re from urllib.parse import urlparse, parse_qs, unquote def parse(data): diff --git a/parsers/socks.py b/parsers/socks.py index 5980d2503..8a654ffc7 100644 --- a/parsers/socks.py +++ b/parsers/socks.py @@ -1,5 +1,5 @@ -import tool,json,re,urllib,sys -from urllib.parse import urlparse, parse_qs, unquote +import tool,re +from urllib.parse import urlparse,unquote def parse(data): info = data[:] server_info = urlparse(info) diff --git a/parsers/ss.py b/parsers/ss.py index 2632857f0..fab672a0b 100644 --- a/parsers/ss.py +++ b/parsers/ss.py @@ -1,4 +1,4 @@ -import tool,json,re,urllib,sys +import tool,json,re,urllib from urllib.parse import parse_qs def parse(data): param = data[5:] diff --git a/parsers/ssr.py b/parsers/ssr.py index f7f46df6b..d1ed84cd5 100644 --- a/parsers/ssr.py +++ b/parsers/ssr.py @@ -1,4 +1,4 @@ -import tool,json,re,urllib,sys +import tool def parse(data): info = data[6:] if not info or info.isspace(): diff --git a/parsers/trojan.py b/parsers/trojan.py index 2039823da..e798b84c0 100644 --- a/parsers/trojan.py +++ b/parsers/trojan.py @@ -1,4 +1,4 @@ -import tool,json,re,urllib,sys +import tool,re from urllib.parse import urlparse, parse_qs, unquote def parse(data): info = data[:] diff --git a/parsers/tuic.py b/parsers/tuic.py index a8e77815f..e2e6c0c3d 100644 --- a/parsers/tuic.py +++ b/parsers/tuic.py @@ -1,5 +1,5 @@ -import tool,json,re,urllib,sys -from urllib.parse import urlparse, parse_qs, unquote +import tool,re +from urllib.parse import urlparse, parse_qs def parse(data): info = data[:] server_info = urlparse(info) diff --git a/parsers/vless.py b/parsers/vless.py index 7df2b559d..d69e7411d 100644 --- a/parsers/vless.py +++ b/parsers/vless.py @@ -1,4 +1,4 @@ -import tool,json,re,urllib,sys +import tool,re from urllib.parse import urlparse, parse_qs, unquote def parse(data): info = data[:] diff --git a/parsers/vmess.py b/parsers/vmess.py index 9c00d9439..68258d283 100644 --- a/parsers/vmess.py +++ b/parsers/vmess.py @@ -1,5 +1,5 @@ -import tool,json,re,urllib,sys -from urllib.parse import urlparse, parse_qs, unquote +import tool,json,re +from urllib.parse import urlparse, parse_qs def parse(data): info = data[8:] if not info or info.isspace(): diff --git a/parsers/wg.py b/parsers/wg.py index bdb777230..26ec5461f 100644 --- a/parsers/wg.py +++ b/parsers/wg.py @@ -1,4 +1,4 @@ -import tool,json,re,urllib,sys +import tool,re from urllib.parse import urlparse, parse_qs, unquote def parse(data): info = data[:] diff --git a/tool.py b/tool.py index 792467a61..bb4106dfa 100644 --- a/tool.py +++ b/tool.py @@ -1,8 +1,8 @@ -import urllib.parse,base64,requests,paramiko,random,string,re,chardet +import base64,requests,random,string,re,chardet import warnings from cryptography.utils import CryptographyDeprecationWarning with warnings.catch_warnings(action="ignore", category=CryptographyDeprecationWarning): - from paramiko import SSHClient + import paramiko from scp import SCPClient def get_encoding(file): @@ -314,7 +314,7 @@ def __init__(self,server:dict) -> None: if k in server.keys(): self.server[k] = server[k] def connect(self): - ssh = SSHClient() + ssh = paramiko.SSHClient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(hostname=self.server['ip'],port=22, username=self.server['user'], password=self.server['password'])