Xamarin iOS IPv6 crashes Apple Store

We are creating an iOS application dedicated to the Client-Server App. We are using a SQL and WCF web service connection in an iOS application with Xamarin.

SQL connection code:

    String ips = "10.0.0.1" ; //Example.
  SqlConnection con =   new SqlConnection(@"Data Source=" + ips + "; initial Catalog="x";user id =y;password = z;");

Apple decided to use only ipv6 on iOS9, so they published an IPv6 compatibility document - IPv6 Documentation

Xamarin posted a blog post about this too - Creating Your iOS IPv6 Ready Applications

I read all of these documents, but I was not able to get rid of this problem with "Store Rejection".

I want to show you my last attemp: (ipv4 to ipv6)

string input = "10.0.0.1";
            string ips = "";
            IPAddress address;
            if (IPAddress.TryParse(deviceIP, out address))
            {
                switch (address.AddressFamily)
                {
                    case System.Net.Sockets.AddressFamily.InterNetwork:
                        // we have IPv4
                        ips = input;
                        break;
                    case System.Net.Sockets.AddressFamily.InterNetworkV6:
                        // we have IPv6
                        IPAddress ip = IPAddress.Parse(input).MapToIPv6();
                        ips = "[" + ip.ToString() + "]";
                        break;
                    default:
                        //
                        break;
                }
            }

I used the function MapToIPv6()as described in the Xamarin blog post, but again my application was rejected by Apple.

IPv4 (Apple ). Apple ipv4 ipv6, .

, .

: Visual Studio 2015 Xamarin Windows 10 + Mac OS X El-Capitan

: IPv4.

+2
3

, , , IPv4-IPv6 . IPv4 , , IPv6- IPv6, .

:

string input = "10.0.0.0";
string ips = "";
IPAddress address;
if (IPAddress.TryParse(input, out address))
{
    switch (address.AddressFamily)
    {
        case System.Net.Sockets.AddressFamily.InterNetwork:
            // we have IPv4, map it to IPv6
            IPAddress ip = IPAddress.Parse(input).MapToIPv6();
            ips = ip.ToString();
            break;
        case System.Net.Sockets.AddressFamily.InterNetworkV6:
            // we have IPv6, leave it as is
            ips = input;
            break;
    }
}

, Reference Source. , AddressFamily InterNetworkV6, MapToIPv6 IPAddress , .

public IPAddress MapToIPv6()
{
    if (AddressFamily == AddressFamily.InterNetworkV6)
    {
        return this;
    }

    // ...
}
+3

IP- IP: 10.0.0.0 , db.test.com, Apple.

string input = "db.test.com";
IPAddress[] ads = Dns.GetHostAddresses (input);
string ips = ads[0];
+1

Is it allowed? You do not have to worry about the AddressFamily device, just care about the remote ip AddressFamily. IPAddress ip = IPAddress.Parse(input); Socket s = new Socket (ip.AddressFamily, SocketType.Stream, ProtocolType.Tcp); I used it and it works.

0
source

Source: https://habr.com/ru/post/1652213/


All Articles