Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
5 changes: 3 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Wed Sep 25 17:08:44 IST 2024
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
zipStoreBase=GRADLE_USER_HOME
6 changes: 3 additions & 3 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 23 08:50:38 CEST 2017
#Wed Sep 25 17:08:39 IST 2024
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
zipStoreBase=GRADLE_USER_HOME
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
platform :ios, '11.0'
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_system_proxy/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_system_proxy: 96eb97e3857a1d1bc533a6f7387a1f0dcb63d782

PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d
PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048

COCOAPODS: 1.11.3
COCOAPODS: 1.15.2
8 changes: 4 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -342,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -420,7 +420,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -469,7 +469,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
20 changes: 10 additions & 10 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:io';
import 'dart:async';
import 'package:dio/adapter.dart';
import 'package:flutter/material.dart';
import 'package:dio/dio.dart';
Expand Down Expand Up @@ -35,13 +34,10 @@ class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
String _res = "Response";
void _incrementCounter() {
setState(() {
_counter++;
});
fetchLocalHost().then((value) {
print(value);
setState(() {
_res = value.toString();
_counter++;
_res = value;
});
});
}
Expand All @@ -61,11 +57,11 @@ class _MyHomePageState extends State<MyHomePage> {
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
style: Theme.of(context).textTheme.headlineMedium,
),
Text(
'$_counter:$_res',
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
)
],
),
Expand All @@ -80,17 +76,21 @@ class _MyHomePageState extends State<MyHomePage> {
}

Future<String> fetchLocalHost() async {
try {
var dio = new Dio();
var url = 'http://ip-api.com/json';
var proxy = await FlutterSystemProxy.findProxyFromEnvironment(url);
print(proxy);
(dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
(HttpClient client) {
client.findProxy = (uri) {
return proxy;
};
return null;
};
var response = await dio.get(url);
print(response.toString());
return response.toString();
} catch (e) {
print(e);
return "Error";
}
}
58 changes: 41 additions & 17 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.0"
version: "0.1.4"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -90,38 +90,62 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.2"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
matcher:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16"
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.15.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.9.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -171,10 +195,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.2"
typed_data:
dependency: transitive
description:
Expand All @@ -191,14 +215,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
web:
vm_service:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "0.3.0"
version: "14.2.5"
sdks:
dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=1.20.0"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
65 changes: 29 additions & 36 deletions ios/Classes/SwiftFlutterSystemProxyPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,23 @@ public class SwiftFlutterSystemProxyPlugin: NSObject, FlutterPlugin {
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "getDeviceProxy":
do {
let args = call.arguments as! NSDictionary
let url = args.value(forKey:"url") as! String
var dict:[String:Any] = [:]
var dict:[String:Any]? = [:]
if(SwiftFlutterSystemProxyPlugin.proxyCache[url] != nil){
let res = SwiftFlutterSystemProxyPlugin.proxyCache[url]
if(res != nil){
dict = res as! [String:Any]
dict = res
}
}
else
{
let res = try SwiftFlutterSystemProxyPlugin.resolve(url: url)
let res = SwiftFlutterSystemProxyPlugin.resolve(url: url)
if(res != nil){
dict = res as! [String:Any]
dict = res
}
}
result(dict)
} catch let error {
print("Unexpected Proxy Error: \(error).")
result(error)
}
break
default:
result(FlutterMethodNotImplemented)
Expand Down Expand Up @@ -88,34 +83,32 @@ public class SwiftFlutterSystemProxyPlugin: NSObject, FlutterPlugin {
}

static func handlePacUrl(pacUrl: String, url: String){
var _pacUrl = CFURLCreateWithString(kCFAllocatorDefault, pacUrl as CFString?,nil)
var targetUrl = CFURLCreateWithString(kCFAllocatorDefault, url as CFString?, nil)
let _pacUrl = CFURLCreateWithString(kCFAllocatorDefault, pacUrl as CFString?,nil)
let targetUrl = CFURLCreateWithString(kCFAllocatorDefault, url as CFString?, nil)
var info = url;
if(pacUrl != nil && targetUrl != nil){
var context:CFStreamClientContext = CFStreamClientContext.init(version: 0, info: &info, retain: nil, release: nil, copyDescription: nil)
let runLoopSource = CFNetworkExecuteProxyAutoConfigurationURL(_pacUrl!,targetUrl!, { client, proxies, error in
let _proxies = proxies as? [[CFString: Any]] ?? [];
if(_proxies != nil){
if(_proxies.count > 0){
let proxy = _proxies.first{$0[kCFProxyTypeKey] as! CFString == kCFProxyTypeHTTP || $0[kCFProxyTypeKey] as! CFString == kCFProxyTypeHTTPS}
if(proxy != nil){
let host = proxy?[kCFProxyHostNameKey] ?? nil
let port = proxy?[kCFProxyPortNumberKey] ?? nil
var dict:[String: Any] = [:]
dict["host"] = host
dict["port"] = port
let url = client.assumingMemoryBound(to: String.self).pointee
SwiftFlutterSystemProxyPlugin.proxyCache[url] = dict
}
}
}
CFRunLoopStop(CFRunLoopGetCurrent());
}, &context).takeUnretainedValue()
let runLoop = CFRunLoopGetCurrent();
CFRunLoopAddSource(runLoop, runLoopSource, CFRunLoopMode.defaultMode);
CFRunLoopRun();
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), runLoopSource, CFRunLoopMode.defaultMode);
}
withUnsafeMutablePointer(to: &info, { infoPointer in
var context:CFStreamClientContext = CFStreamClientContext.init(version: 0, info: infoPointer, retain: nil, release: nil, copyDescription: nil)
let runLoopSource = CFNetworkExecuteProxyAutoConfigurationURL(_pacUrl!,targetUrl!, { client, proxies, error in
let _proxies = proxies as? [[CFString: Any]] ?? [];
if(_proxies.count > 0){
let proxy = _proxies.first{$0[kCFProxyTypeKey] as! CFString == kCFProxyTypeHTTP || $0[kCFProxyTypeKey] as! CFString == kCFProxyTypeHTTPS}
if(proxy != nil){
let host = proxy?[kCFProxyHostNameKey] ?? nil
let port = proxy?[kCFProxyPortNumberKey] ?? nil
var dict:[String: Any] = [:]
dict["host"] = host
dict["port"] = port
let url = client.assumingMemoryBound(to: String.self).pointee
SwiftFlutterSystemProxyPlugin.proxyCache[url] = dict
}
}
CFRunLoopStop(CFRunLoopGetCurrent());
}, &context);
let runLoop = CFRunLoopGetCurrent();
CFRunLoopAddSource(runLoop, runLoopSource, CFRunLoopMode.defaultMode);
CFRunLoopRun();
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), runLoopSource, CFRunLoopMode.defaultMode);
})
}

}
Expand Down
8 changes: 0 additions & 8 deletions pac/test.pac

This file was deleted.

Loading