在 OSX 上使用 WPAD 检索 PAC 脚本
如何在 OSX 上使用 WPAD 检索 PAC 脚本?获取“http://wpad/wpad.dat”的内容是否足以希望 DNS 已为此约定预先配置“wpad”?
有没有更“正式”的方法来做到这一点?
How do I retrieve the PAC script using WPAD on OSX? is it enough to fetch the contents of "http://wpad/wpad.dat" in hopes that the DNS has "wpad" pre-configured for this convention?
is there a more "formal" method of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是如何获取给定 URL 的 PAC 代理:
为了简单起见,此代码充满了漏洞(您应该释放通过 Copy 和 Create 函数获得的所有内容)并且不处理任何潜在的错误。
Here is how to get PAC proxies for a given URL:
For the sake of simplicity, this code is full of leaks (you should release everything you got through Copy and Create functions) and does not handle any potential error.
请参阅 WPAD 草案有关合规性的第 8 节。按照您的建议仅使用 DNS 将使您“最低限度合规”。
为了完全合规,您应该在使用 DNS 之前检查主机是否已从 DHCP 接收到 WPAD 配置。您应该能够使用系统配置框架来查看主机是否从 DHCP 服务器接收到选项 252 参数。
编辑:实际上,您可以直接从 系统配置框架。您似乎对
kSCPropNetProxiesProxyAutoConfigEnable
感兴趣,如果将其设置为1
,则 WPAD URL 应位于kSCPropNetProxiesProxyAutoConfigURLString
中。See section 8 of the WPAD draft on compliance. Using only DNS as you suggest would make you "minimally compliant".
To be fully compliant, you should check to see if the host has received WPAD configuration from DHCP prior to using DNS. You should be able to use the System Configuration framework to see if the host received an option 252 parameter from the DHCP server.
EDIT: Actually, you can get the WPAD URL directly from the system configuration framework. Looks like you'd be interested in
kSCPropNetProxiesProxyAutoConfigEnable
, and if that's set to1
, the WPAD URL should be inkSCPropNetProxiesProxyAutoConfigURLString
.