mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-05-09 00:34:17 +08:00
mobile favorite title color & android proxy default port
This commit is contained in:
@@ -98,9 +98,9 @@ class ConnectionManager private constructor() : CloseableConnection {
|
||||
connection.channel = channel
|
||||
|
||||
var socketAddress: SocketAddress? = null
|
||||
if (DEFAULT_PORTS.contains(port)) {
|
||||
socketAddress = proxyAddress
|
||||
}
|
||||
// if (DEFAULT_PORTS.contains(port)) {
|
||||
// socketAddress = proxyAddress
|
||||
// }
|
||||
|
||||
connection.isInitConnect = socketAddress != null
|
||||
|
||||
|
||||
@@ -55,9 +55,15 @@ class HostAndPort {
|
||||
String? scheme;
|
||||
//域名格式 直接解析
|
||||
if (schemes.any((scheme) => url.startsWith(scheme))) {
|
||||
//httpScheme
|
||||
scheme = schemes.firstWhere((element) => url.startsWith(element),orElse: () => httpScheme);
|
||||
domain = url.substring(scheme.length).split("/")[0];
|
||||
try {
|
||||
Uri uri = Uri.parse(url);
|
||||
return HostAndPort('${uri.scheme}://', uri.host, uri.port);
|
||||
} catch (e) {
|
||||
//httpScheme
|
||||
scheme = schemes.firstWhere((element) => url.startsWith(element), orElse: () => httpScheme);
|
||||
domain = url.substring(scheme.length).split("/")[0];
|
||||
}
|
||||
|
||||
//说明支持ipv6
|
||||
if (domain.startsWith('[') && domain.endsWith(']')) {
|
||||
return HostAndPort(scheme, domain, scheme == httpScheme ? 80 : 443);
|
||||
|
||||
@@ -152,7 +152,9 @@ class HttpRequest extends HttpMessage {
|
||||
HttpRequest copy({String? uri}) {
|
||||
var request = HttpRequest(method, uri ?? this.uri, protocolVersion: protocolVersion);
|
||||
request.headers.addAll(headers);
|
||||
request.hostAndPort = uri == null ? hostAndPort : HostAndPort.of(uri);
|
||||
if (uri != null && !uri.startsWith('/')) {
|
||||
request.hostAndPort = HostAndPort.of(uri);
|
||||
}
|
||||
request.body = body;
|
||||
return request;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import 'package:network_proxy/ui/content/panel.dart';
|
||||
import 'package:network_proxy/ui/mobile/request/repeat.dart';
|
||||
import 'package:network_proxy/ui/mobile/request/request_editor.dart';
|
||||
import 'package:network_proxy/utils/curl.dart';
|
||||
import 'package:network_proxy/utils/lang.dart';
|
||||
import 'package:network_proxy/utils/python.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
@@ -94,7 +95,24 @@ class _FavoriteItemState extends State<_FavoriteItem> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var response = request.response;
|
||||
var title = '${request.method.name} ${request.requestUrl}';
|
||||
Widget? title = widget.favorite.name?.isNotEmpty == true
|
||||
? Text(widget.favorite.name!,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: TextStyle(fontSize: 14, color: Colors.blueAccent.shade200))
|
||||
: Text.rich(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
TextSpan(children: [
|
||||
TextSpan(text: '${request.method.name} ', style: const TextStyle(fontSize: 14, color: Colors.teal)),
|
||||
TextSpan(
|
||||
text: '${request.remoteDomain()}${request.path()}'.fixAutoLines(),
|
||||
style: TextStyle(fontSize: 14, color: Colors.blueAccent.shade200)),
|
||||
TextSpan(
|
||||
text: '?${request.requestUri?.query}',
|
||||
style: TextStyle(fontSize: 14, color: Colors.pinkAccent.shade200)),
|
||||
]));
|
||||
|
||||
var time = formatDate(request.requestTime, [mm, '-', d, ' ', HH, ':', nn, ':', ss]);
|
||||
String subtitle =
|
||||
'$time - [${response?.status.code ?? ''}] ${response?.contentType.name.toUpperCase() ?? ''} ${response?.costTime() ?? ''} ';
|
||||
@@ -102,7 +120,7 @@ class _FavoriteItemState extends State<_FavoriteItem> {
|
||||
onLongPress: menu,
|
||||
minLeadingWidth: 25,
|
||||
leading: getIcon(response),
|
||||
title: Text(widget.favorite.name ?? title, overflow: TextOverflow.ellipsis, maxLines: 2),
|
||||
title: title,
|
||||
subtitle: Text.rich(
|
||||
maxLines: 1,
|
||||
TextSpan(children: [
|
||||
|
||||
@@ -67,9 +67,9 @@ class RequestRowState extends State<RequestRow> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String path = widget.displayDomain ? '${request.remoteDomain()}${request.path()}' : request.path();
|
||||
String url = widget.displayDomain ? request.requestUrl : request.path();
|
||||
|
||||
var title = Strings.autoLineString('${request.method.name} $path');
|
||||
var title = Strings.autoLineString('${request.method.name} $url');
|
||||
|
||||
var time = formatDate(request.requestTime, [HH, ':', nn, ':', ss]);
|
||||
var contentType = response?.contentType.name.toUpperCase() ?? '';
|
||||
@@ -77,7 +77,7 @@ class RequestRowState extends State<RequestRow> {
|
||||
|
||||
var subTitle = '$time - [${response?.status.code ?? ''}] $contentType $packagesSize ${response?.costTime() ?? ''}';
|
||||
|
||||
var highlightColor = KeywordHighlight.getHighlightColor(path);
|
||||
var highlightColor = KeywordHighlight.getHighlightColor(url);
|
||||
|
||||
return ListTile(
|
||||
visualDensity: const VisualDensity(vertical: -4),
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import 'dart:io';
|
||||
|
||||
main() async {
|
||||
print(Uri.parse("https://www.v2ex.com").scheme);
|
||||
// await socketTest();
|
||||
await webTest();
|
||||
}
|
||||
|
||||
webTest() async {
|
||||
|
||||
var httpClient = HttpClient();
|
||||
httpClient.findProxy = (uri) => "PROXY 127.0.0.1:7890";
|
||||
// httpClient.badCertificateCallback = (X509Certificate cert, String host, int port) => true;
|
||||
|
||||
Reference in New Issue
Block a user