在flutter方面开发过程中,有一个痛点,那就是没有办法进行抓包,如何解决呢,我初步的想法是原生获取到所代理的ip和端口,给fluter传递过去,然后flutter在请求相关的处理中,把ip和端口设置进去。
CFDictionaryRef proxySettings = CFNetworkCopySystemProxySettings();
NSDictionary *dictProxy = (__bridge_transfer id)proxySettings;
NSLog(@"%@",dictProxy);
//是否开启了http代理
if ([[dictProxy objectForKey:@"HTTPEnable"] boolValue]) {
NSString *proxyAddress = [dictProxy objectForKey:@"HTTPProxy"]; //代理地址
NSInteger proxyPort = [[dictProxy objectForKey:@"HTTPPort"] integerValue]; //代理端口号
NSLog(@"%@:%ld",proxyAddress,proxyPort);
}