fix: working HTTP and SOCKS5 proxies; save only working servers
- SOCKS5 had been fed to HttpClient.findProxy, which supports only HTTP
proxies ("Invalid proxy configuration"), and socks5h was treated as an
HTTP proxy ("Invalid request method"). HTTP/HTTPS proxies stay on
findProxy; socks5/socks5h tunnel through socks5_proxy, which resolves
names at the proxy; user:pass in the proxy URL is passed along.
- Saving moved to the successful path: a failed attempt stays in the form
with a short reason, and the server list keeps no duplicates.
- package net.blumia.openchamber.flutter (namespace, applicationId,
MainActivity, iOS bundle id), version 0.3.1 (code 301).
- show the proxy in the instance and server lists; clearer connect errors.
- tool/proxy_probe.dart checks direct, socks5, socks5h and HTTP proxies
(requests and SSE) against a live server.
This commit is contained in:
1 parent
782ac2bd4d
commit
55dac37baf
12 files changed
+227
-46
No files matched your search
@@ -92,7 +92,17 @@ class _ServersScreenState extends State<ServersScreen> {
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
child: ListTile(
|
||||
title: Text(c.label, style: const TextStyle(fontWeight: FontWeight.w600)),
|
||||
subtitle: Text(c.url, maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(c.url, maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
if (c.proxy.isNotEmpty)
|
||||
Text('经由 ${c.proxy}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 12, color: theme.hintColor)),
|
||||
],
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -146,6 +156,8 @@ class _ServersScreenState extends State<ServersScreen> {
|
||||
}
|
||||
|
||||
void _startEdit(Connection? c) {
|
||||
widget.app.error = null;
|
||||
widget.app.clearLastError();
|
||||
setState(() {
|
||||
_editing = true;
|
||||
_editNew = c == null;
|
||||
@@ -166,7 +178,11 @@ class _ServersScreenState extends State<ServersScreen> {
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => setState(() => _editing = false),
|
||||
onPressed: () {
|
||||
widget.app.error = null;
|
||||
widget.app.clearLastError();
|
||||
setState(() => _editing = false);
|
||||
},
|
||||
),
|
||||
title: Text(_editNew ? '添加服务器' : '连接 ${_edit!.label}'),
|
||||
),
|
||||
@@ -257,19 +273,8 @@ class _ServersScreenState extends State<ServersScreen> {
|
||||
insecure: _insecure,
|
||||
fingerprint: _fingerprint,
|
||||
);
|
||||
if (_editNew) {
|
||||
await widget.app.saveConnection(c);
|
||||
} else {
|
||||
final list = [...widget.app.connections];
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (list[i].id == c.id) {
|
||||
list[i] = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
widget.app.connections = list;
|
||||
await widget.app.storage.saveConnections(list);
|
||||
}
|
||||
// Only a connection that works is saved (AppState saves it on success),
|
||||
// so failed attempts do not pile up in the server list.
|
||||
await widget.app.connect(c, password: _password);
|
||||
if (mounted) {
|
||||
if (widget.app.client != null) {
|
||||
|
||||
@@ -304,7 +304,7 @@ class _SessionsScreenState extends State<SessionsScreen> {
|
||||
for (final c in app.connections) ...[
|
||||
ListTile(
|
||||
title: Text(c.label),
|
||||
subtitle: Text(c.url),
|
||||
subtitle: Text(c.proxy.isEmpty ? c.url : '${c.url}\n经由 ${c.proxy}'),
|
||||
trailing: app.conn?.id == c.id
|
||||
? Text('已连接', style: TextStyle(color: Theme.of(context).colorScheme.primary))
|
||||
: null,
|
||||
|
||||
Reference in new issue
Block a user