Comments (29)
https://developer.apple.com/documentation/networkextension/neproxysettings
from nekit.
感谢您的回复,这个我试过,但好像不起作用,是否需要在PacketTunnelProvide里面做别的处理?
以下是我的代码。运行起来后,IP并不是https代理服务器的IP.
PacketTunnelProvider.m
- (void)startTunnelWithOptions:(NSDictionary *)options completionHandler:(void (^)(NSError *))completionHandler {
NEIPv4Settings *ipv4Settings = [[NEIPv4Settings alloc] initWithAddresses:@[@"192.0.2.1"] subnetMasks:@[@"255.255.255.0"]];
NSArray *dnsServers = @[@"8.8.8.8"];
ipv4Settings.includedRoutes = @[[NEIPv4Route defaultRoute]];
NEPacketTunnelNetworkSettings *settings = [[NEPacketTunnelNetworkSettings alloc] initWithTunnelRemoteAddress:@"192.0.2.2"];
settings.IPv4Settings = ipv4Settings;
settings.MTU = @(1500);
NEProxySettings* proxySettings = [[NEProxySettings alloc] init];
NSInteger proxyServerPort = 443;
NSString *proxyServerName = @"xxxx.xxxx.xxxx";
proxySettings.HTTPSEnabled = YES;
proxySettings.HTTPSServer = [[NEProxyServer alloc] initWithAddress:proxyServerName port:proxyServerPort];
proxySettings.autoProxyConfigurationEnabled = NO;
proxySettings.excludeSimpleHostnames = YES;
settings.proxySettings = proxySettings;
NEDNSSettings *dnsSettings = [[NEDNSSettings alloc] initWithServers:dnsServers];
settings.DNSSettings = dnsSettings;
[self setTunnelNetworkSettings:settings completionHandler:^(NSError * _Nullable error) {
if (error) {
if (completionHandler) {
completionHandler(error);
}
}else{
if (completionHandler) {
completionHandler(nil);
}
}
}];
}
from nekit.
from nekit.
明白了,您的源码demo里面有这个转换处理吗?感激不尽
from nekit.
我想的就是填入一个https代理服务器的地址,连接后,网络请求通过代理发出,IP地址也会变成代理服务器的IP地址
from nekit.
from nekit.
from nekit.
用了PAC之后是不是可以不需要用NEKit的HttpsAdapter呢,只需要用我原来的代码,也就是NEProxySettings就可以了达到我的目标吗?
from nekit.
from nekit.
再次感谢大佬,我试试
from nekit.
您好,按照您的建议试了一下,连接上之后还是无网络,我的代理服务器肯定是正常的,因为PC浏览器可以正常使用代理。以下是代码片段。感觉我就差最后一步了。。
NEPacketTunnelNetworkSettings *settings = [[NEPacketTunnelNetworkSettings alloc] initWithTunnelRemoteAddress:@"192.0.2.2"];
settings.IPv4Settings = ipv4Settings;
settings.MTU = @(1500);
NEProxySettings* proxySettings = [[NEProxySettings alloc] init];
NSInteger proxyServerPort = 443;
NSString *proxyServerName = @"example.myproxy.com";
proxySettings.HTTPSEnabled = YES;
proxySettings.HTTPSServer = [[NEProxyServer alloc] initWithAddress:proxyServerName port:proxyServerPort];
proxySettings.autoProxyConfigurationEnabled = YES;
proxySettings.proxyAutoConfigurationURL = [NSURL URLWithString:@"https://example.mypac.com/pac.txt"];
//proxySettings.excludeSimpleHostnames = YES;
settings.proxySettings = proxySettings;
其中https://example.mypac.com/pac.txt的内容如下,格式应该也没问题。
function FindProxyForURL(url, host) {
return "HTTPS example.myproxy.com:443"
}
from nekit.
from nekit.
您好,去掉httpsserver相关后,就只剩以下这几行代码了,好像还是有问题
NEProxySettings* proxySettings = [[NEProxySettings alloc] init];
proxySettings.autoProxyConfigurationEnabled = YES;
proxySettings.HTTPSEnabled = YES;
proxySettings.proxyAutoConfigurationURL = [NSURL
URLWithString:@"https://example.mypac.com/pac.txt"];
settings.proxySettings = proxySettings;
from nekit.
from nekit.
您好,去掉HTTPSEnabled之后,就只剩与PAC相关的代码了。似乎还是没有网络。有没有可能是其他的比如ipv4setting等设置问题?
NEProxySettings* proxySettings = [[NEProxySettings alloc] init];
proxySettings.autoProxyConfigurationEnabled = YES;
proxySettings.proxyAutoConfigurationURL = [NSURL
URLWithString:@"https://example.mypac.com/pac.txt"];
settings.proxySettings = proxySettings;
from nekit.
from nekit.
您好,defaultRoute去掉后,网络正常,但是IP是本机IP,不是代理服务器的IP
from nekit.
from nekit.
您好,matchDomains也去掉了。现在整体代码如下:
- (void)startTunnelWithOptions:(NSDictionary *)options completionHandler:(void (^)(NSError *))completionHandler
{
NEIPv4Settings *ipv4Settings = [[NEIPv4Settings alloc] initWithAddresses:@[@"192.0.2.1"] subnetMasks:@[@"255.255.255.0"]];
NSArray *dnsServers = @[@"8.8.8.8"];
NEPacketTunnelNetworkSettings *settings = [[NEPacketTunnelNetworkSettings alloc] initWithTunnelRemoteAddress:@"192.0.2.2"];
settings.IPv4Settings = ipv4Settings;
settings.MTU = @(1500);
NEProxySettings* proxySettings = [[NEProxySettings alloc] init];
proxySettings.autoProxyConfigurationEnabled = YES;
proxySettings.proxyAutoConfigurationURL = [NSURL
URLWithString:@"https://example.mypac.com/pac.txt"];
settings.proxySettings = proxySettings;
NEDNSSettings *dnsSettings = [[NEDNSSettings alloc] initWithServers:dnsServers];
settings.DNSSettings = dnsSettings;
[self setTunnelNetworkSettings:settings completionHandler:^(NSError * _Nullable error) {
if (error) {
if (completionHandler) {
completionHandler(error);
}
}else{
if (completionHandler) {
completionHandler(nil);
}
}
}];
}
from nekit.
from nekit.
所以还是需要借助您这个httpAdapter吗?
from nekit.
你之前有写过matchDomains吗?
加上了这一行么?
https://github.com/zhuhaow/Specht/blob/cfd35278f05eef0cbf20f1e53a477947f38388dd/SpechtTunnelPacketProvider/PacketTunnelProvider.swift#L56
from nekit.
您好,之前没有写matchDomains这个参数,刚才加上了设置proxySettings.matchDomains = [""]
,与刚才一样的现象,有网络但IP是本机IP
from nekit.
你怎么测的ip
from nekit.
就是在safari里面打开测IP网站,比如百度搜索IP.
from nekit.
pac服务器访问日志有记录么
from nekit.
您好,我现在没权限访问pac服务器,但我直接把js脚本写到ios代理里了。但是这样也是不行的。 :(
proxySettings.proxyAutoConfigurationJavaScript = @"function FindProxyForURL(url, host) { return \"HTTPS example.myproxy.com:443\"}";
from nekit.
from nekit.
好的,不好意思打扰您这么久,网上这方面的资料确实太少了。我再自己研究一下,非常感谢!
from nekit.
Related Issues (20)
- 使用NEKit能否完全使用tcp/udp的方式去代理呢? HOT 2
- 关于dns转发的疑问 HOT 15
- nekit vpn打开之后 微信,qq 这种基于socket做的通信类app都无法访问
- 请问支持V2ray vmess协议吗? HOT 3
- 我设置全局走代理,ios12正常,ios13偶尔不走代理
- 编译报错(Module 'NEKit' was created for incompatible target x86_64-apple-macos10.11:) HOT 2
- support SSR? HOT 1
- mayday mayday telegram连接的问题 HOT 2
- is there any plan to support AES256GCM?
- xcode11.2.1 telegram socks5代理连接失败 HOT 3
- Question HOT 2
- How to support aes-256-gcm? HOT 2
- xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH HOT 1
- 新手问一下怎么打包带CHACHA20POLY1305的项目 HOT 1
- 你好,我试用NEkit 软件在后台经常遇到Crashed HOT 11
- 这个框架能链接V2ray吗
- Fails when `Building scheme "iOS Framework" in CocoaAsyncSocket.xcodeproj` HOT 5
- 升级到最新的NEKit ,iOS和MacOS上连接正常的SS都是先连接成功然后过几秒就断开 HOT 6
- 连接几次后,打开网络或者请求VPN就会断开,请问什么原因 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nekit.