mirror of
https://github.com/honmashironeko/ProxyCat.git
synced 2025-05-06 18:51:33 +00:00
Update 2.0.1
This commit is contained in:
parent
6a63ec0f0d
commit
b3230edd5f
4
app.py
4
app.py
@ -173,7 +173,7 @@ def save_config():
|
||||
config_parser.write(f)
|
||||
|
||||
server.config = load_config('config/config.ini')
|
||||
server._update_config_values(server.config)
|
||||
server._init_config_values(server.config)
|
||||
|
||||
return jsonify({
|
||||
'status': 'success',
|
||||
@ -638,4 +638,4 @@ if __name__ == '__main__':
|
||||
proxy_thread = threading.Thread(target=run_proxy_server, daemon=True)
|
||||
proxy_thread.start()
|
||||
|
||||
app.run(host='0.0.0.0', port=web_port)
|
||||
app.run(host='0.0.0.0', port=web_port)
|
@ -10,6 +10,7 @@ proxy_username =
|
||||
proxy_password =
|
||||
proxy_file = ip.txt
|
||||
check_proxies = True
|
||||
test_url =
|
||||
language = cn
|
||||
whitelist_file = whitelist.txt
|
||||
blacklist_file = blacklist.txt
|
||||
|
@ -517,7 +517,9 @@ def parse_proxy(proxy):
|
||||
except Exception:
|
||||
return None, None, None, None
|
||||
|
||||
async def check_http_proxy(proxy, test_url='https://www.baidu.com'):
|
||||
async def check_http_proxy(proxy, test_url=None):
|
||||
if test_url is None:
|
||||
test_url = 'https://www.baidu.com'
|
||||
protocol, auth, host, port = parse_proxy(proxy)
|
||||
proxies = {}
|
||||
if auth:
|
||||
@ -541,10 +543,10 @@ async def check_http_proxy(proxy, test_url='https://www.baidu.com'):
|
||||
except:
|
||||
return False
|
||||
|
||||
async def check_https_proxy(proxy, test_url='https://www.baidu.com'):
|
||||
async def check_https_proxy(proxy, test_url=None):
|
||||
return await check_http_proxy(proxy, test_url)
|
||||
|
||||
async def check_socks_proxy(proxy, test_url='www.baidu.com'):
|
||||
async def check_socks_proxy(proxy, test_url=None):
|
||||
protocol, auth, host, port = parse_proxy(proxy)
|
||||
if not all([host, port]):
|
||||
return False
|
||||
|
@ -49,6 +49,7 @@ class AsyncProxyServer:
|
||||
self.blacklist_file = os.path.join('config', os.path.basename(config.get('blacklist_file', 'blacklist.txt')))
|
||||
self.ip_auth_priority = config.get('ip_auth_priority', 'whitelist')
|
||||
|
||||
self.test_url = config.get('test_url', 'https://www.baidu.com')
|
||||
self.whitelist = load_ip_list(self.whitelist_file)
|
||||
self.blacklist = load_ip_list(self.blacklist_file)
|
||||
|
||||
@ -121,7 +122,7 @@ class AsyncProxyServer:
|
||||
|
||||
async def _check_proxies(self):
|
||||
from modules.modules import check_proxies
|
||||
valid_proxies = await check_proxies(self.proxies)
|
||||
valid_proxies = await check_proxies(self.proxies, test_url=self.test_url)
|
||||
if valid_proxies:
|
||||
self.proxies = valid_proxies
|
||||
self.proxy_cycle = cycle(valid_proxies)
|
||||
|
@ -1826,23 +1826,38 @@
|
||||
// 合并所有代理列表
|
||||
const allProxies = [...httpProxies, ...httpsProxies, ...socks5Proxies, ...fullProxies];
|
||||
|
||||
// 发送到服务器
|
||||
// 获取测试URL
|
||||
const testUrl = document.getElementById('test-target-url').value.trim();
|
||||
|
||||
// 首先更新配置
|
||||
$.ajax({
|
||||
url: appendToken('/api/proxies'),
|
||||
url: appendToken('/api/config'),
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ proxies: allProxies }),
|
||||
success: function(response) {
|
||||
if (response.status === 'success') {
|
||||
showNotification(translations[currentLanguage].proxy_save_success, 'success');
|
||||
// 重新加载代理列表以确保显示正确
|
||||
loadProxies();
|
||||
} else {
|
||||
showNotification(translations[currentLanguage].proxy_save_failed.format(response.message), 'error');
|
||||
}
|
||||
data: JSON.stringify({ test_url: testUrl }),
|
||||
success: function(configResponse) {
|
||||
// 然后保存代理列表
|
||||
$.ajax({
|
||||
url: appendToken('/api/proxies'),
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ proxies: allProxies }),
|
||||
success: function(response) {
|
||||
if (response.status === 'success' && configResponse.status === 'success') {
|
||||
showNotification(translations[currentLanguage].proxy_save_success, 'success');
|
||||
// 重新加载代理列表以确保显示正确
|
||||
loadProxies();
|
||||
} else {
|
||||
showNotification(translations[currentLanguage].proxy_save_failed.format(response.message), 'error');
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
showNotification(translations[currentLanguage].proxy_save_failed.format(xhr.responseText), 'error');
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(xhr) {
|
||||
showNotification(translations[currentLanguage].proxy_save_failed.format(xhr.responseText), 'error');
|
||||
showNotification(translations[currentLanguage].config_save_failed.format(xhr.responseText), 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -2693,7 +2708,11 @@
|
||||
function showMessage(key, ...args) {
|
||||
const message = translations[currentLanguage][key];
|
||||
if (args.length > 0) {
|
||||
showNotification(message.format(...args), key.includes('success') ? 'success' : 'error');
|
||||
try {
|
||||
showNotification(message.replace('{}', args.join(', ')), key.includes('success') ? 'success' : 'error');
|
||||
} catch (e) {
|
||||
showNotification(message, key.includes('success') ? 'success' : 'error');
|
||||
}
|
||||
} else {
|
||||
showNotification(message, key.includes('success') ? 'success' : 'error');
|
||||
}
|
||||
@ -3138,4 +3157,4 @@
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user