Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Happy Eyeballs #4

Open
gusarov opened this issue Feb 10, 2020 · 1 comment
Open

Happy Eyeballs #4

gusarov opened this issue Feb 10, 2020 · 1 comment

Comments

@gusarov
Copy link
Owner

gusarov commented Feb 10, 2020

Implement Happy Eyeballs to fallback from IPv6 if it is not supported by the next party.
IETF promotes that IPv6 should be the preference when choosing among 2 addresses. But the next party (your ISP) might not support it. So:

  1. on a IPv6 enabled machine you can receive AAAA dns entry for www.google.com but if you continue with IPv6 over SOCKS it might fail on a proxy server side if proxy's ISP is not supporting IPv6.
  2. if you are connecting private machine it might have local IPv4 which is unreachable by proxy, while reachable by IPv6.
    To facilitate this, there should be Happy Eyeballs or similar implementation: Happy Eyeballs attempts to establish connection with both algorithms simultaneously. If IPv6 succeeded, it proceeds with IPv6 otherwise falls back to IPv4.

For the PROXY server in the middle this have one more option: proceed with Domain Name instead. This one also should be considered for better connectivity

@gusarov
Copy link
Owner Author

gusarov commented Feb 17, 2020

This is mostly for Socks5ClientStream

			var targetIsIp = IPAddress.TryParse(targetHost, out var ip);
			if (!targetIsIp) // if targetHost is IP - just use IP
			{
				var dns = Dns.GetHostAddresses(targetHost);
				var ipv4 = dns.FirstOrDefault(x => x.AddressFamily == AddressFamily.InterNetwork);
				var ipv6 = dns.FirstOrDefault(x => x.AddressFamily == AddressFamily.InterNetworkV6);

				ip = ipv4 ?? ipv6; // have to take ipv4 first because ipv6 is not working most of the times and HappyEyeballs is not possible via socks due to single connection
			}

For ShadowSocks it is even harder, because protocol does not acknowledge proper connection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant