Android檢測代理

一、框架

System.getProperties().remove("http.proxyHost");
System.getProperties().remove("http.proxyPort");
System.getProperties().remove("https.proxyHost");
System.getProperties().remove("https.proxyPort");
沒錯,這就是移除全部代理,但問題是若是移除所有,那其餘的功能就必會受一些影響,沒辦法,只能
本身去看SDK,果真,Android是提供單個接口訪問不帶代理的,不廢話,上代碼ui

   URL url = new URL(urlStr);
   urlConnection = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY);url

嗯,很實在,而後又去看了一下OKhttp框架是否提供相似的操做,·······果真不愧是好框架:代理

OkHttpClient client = new OkHttpClient().newBuilder().proxy(Proxy.NO_PROXY).build();接口

 

二、rem

#pragma mark 禁止抓包方法get

-(void)getProxyStatus {it

NSDictionary *proxySettings = (__bridge NSDictionary *)(CFNetworkCopySystemProxySettings());io

NSArray *proxies = (__bridge NSArray *)(CFNetworkCopyProxiesForURL((__bridge CFURLRef _Nonnull)([NSURL URLWithString:@"https://www.baidu.com/"]), (__bridge CFDictionaryRef _Nonnull)(proxySettings)));cli

NSDictionary *settings = proxies[0];

if (![[settings objectForKey:(NSString *)kCFProxyTypeKey] isEqualToString:@"kCFProxyTypeNone"]){

//檢測到抓包

}

}

相關文章
相關標籤/搜索