iOS - Support ipv4 only API

偶尔善良 提交于 2019-12-12 23:30:31

问题


For a university project we're developing a small App which we'd like to get reviewed so we can use it with external testers on the App store.

It got declined however, stating that it couldn't work on ipv6 only networks. The main problem: Our backend server is only accessible via ipv4 (since our university IT doesn't want to allow ipv6 yet) and thus there isn't any ipv6 DNS entry that could be looked up. I understand the concept of the DNS64/NAT64 workflow as explained on https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW1 . However, the main DNS of our university isn't configured to work this way yet..

Is there any way to work around that (using swift)? I think we could be able to somehow detect if the network is ipv6 or ipv4 and then reroute the traffic via a ipv6 tunnel such as sixxs.org?


回答1:


It has nothing to do with your backend server and/or school DNS server. Those being IPv4-only will work fine. It's your app that needs to do the right thing to connect to them.

You don't need to detect whether you are on an IPv6-only network or use any IPv6 tunnels. Higher-level iOS networking APIs already transparently work with DNS64/NAT64 without any changes. If you use low-level socket APIs you just need to call a system API to do a lookup (and you can do this regardless of whether you are on an IPv6-only network or not) before you connect.



来源:https://stackoverflow.com/questions/40213601/ios-support-ipv4-only-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!