Created
June 20, 2025 09:51
-
-
Save odysseus0/714aea1a35043bcbd90468c8195fd2e9 to your computer and use it in GitHub Desktop.
Test TikAPI IPv6 issue - Raw investigation script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """ | |
| Demonstrate how unusual TikAPI's IPv6 behavior is compared to other services. | |
| """ | |
| import asyncio | |
| import socket | |
| import ssl | |
| import time | |
| async def test_service(name, host, port=443): | |
| """Test both IPv4 and IPv6 for a service.""" | |
| print(f"\n{'='*60}") | |
| print(f"Testing: {name} ({host}:{port})") | |
| print('='*60) | |
| results = {} | |
| for ip_version in [6, 4]: | |
| family = socket.AF_INET if ip_version == 4 else socket.AF_INET6 | |
| try: | |
| # Get address | |
| addr_info = socket.getaddrinfo(host, port, family=family, proto=socket.IPPROTO_TCP) | |
| if not addr_info: | |
| results[f'ipv{ip_version}'] = "No address" | |
| print(f"IPv{ip_version}: No address found") | |
| continue | |
| addr = addr_info[0][4] | |
| print(f"\nIPv{ip_version}: {addr[0]}") | |
| # TCP test | |
| sock = socket.socket(family, socket.SOCK_STREAM) | |
| sock.settimeout(5) | |
| try: | |
| sock.connect(addr) | |
| print(f" ✅ TCP: Connected") | |
| # TLS test | |
| context = ssl.create_default_context() | |
| try: | |
| ssock = context.wrap_socket(sock, server_hostname=host) | |
| print(f" ✅ TLS: Handshake successful") | |
| results[f'ipv{ip_version}'] = "Full success" | |
| ssock.close() | |
| except Exception as e: | |
| print(f" ❌ TLS: {type(e).__name__}: {str(e)[:50]}") | |
| results[f'ipv{ip_version}'] = "TCP works, TLS fails" | |
| sock.close() | |
| except Exception as e: | |
| print(f" ❌ TCP: {type(e).__name__}: {str(e)[:50]}") | |
| results[f'ipv{ip_version}'] = "TCP fails" | |
| except Exception as e: | |
| results[f'ipv{ip_version}'] = f"Error: {type(e).__name__}" | |
| print(f"IPv{ip_version}: Error - {type(e).__name__}") | |
| return results | |
| async def main(): | |
| """Test various services to show how unusual TikAPI's behavior is.""" | |
| print("Comparing IPv6 behavior across different services") | |
| print("=" * 70) | |
| print("\nNormal behavior patterns:") | |
| print("1. Both IPv4 and IPv6 work completely (best)") | |
| print("2. Only IPv4 works, no IPv6 address (acceptable)") | |
| print("3. IPv6 address exists but TCP connection fails (acceptable)") | |
| print("4. IPv6 TCP works but TLS fails (BROKEN - TikAPI's issue)") | |
| # Test various services | |
| services = [ | |
| ("TikAPI", "api.tikapi.io"), | |
| ("Google", "www.google.com"), | |
| ("Cloudflare", "cloudflare.com"), | |
| ("GitHub", "api.github.com"), | |
| ("OpenAI", "api.openai.com"), | |
| ] | |
| all_results = {} | |
| for name, host in services: | |
| all_results[name] = await test_service(name, host) | |
| # Summary | |
| print("\n" + "="*70) | |
| print("SUMMARY") | |
| print("="*70) | |
| print(f"{'Service':<15} {'IPv6 Status':<25} {'IPv4 Status':<25}") | |
| print("-"*70) | |
| for name, results in all_results.items(): | |
| ipv6 = results.get('ipv6', 'Unknown') | |
| ipv4 = results.get('ipv4', 'Unknown') | |
| # Highlight the broken pattern | |
| if ipv6 == "TCP works, TLS fails": | |
| ipv6 = f"⚠️ {ipv6} (BROKEN!)" | |
| print(f"{name:<15} {ipv6:<25} {ipv4:<25}") | |
| print("\n" + "="*70) | |
| print("ANALYSIS") | |
| print("="*70) | |
| print("\nTikAPI's IPv6 configuration is BROKEN because:") | |
| print("1. They publish AAAA (IPv6) records in DNS") | |
| print("2. They accept TCP connections on port 443") | |
| print("3. But they immediately reset connections during TLS handshake") | |
| print("\nThis defeats:") | |
| print("- Happy Eyeballs (only works at TCP level)") | |
| print("- Standard retry mechanisms (TCP succeeded, so no retry)") | |
| print("- Developer expectations (if TCP works, TLS should work)") | |
| print("\nProper solutions TikAPI should implement:") | |
| print("1. Fix their IPv6 TLS configuration") | |
| print("2. OR: Remove AAAA records from DNS") | |
| print("3. OR: Reject IPv6 TCP connections (fail fast)") | |
| print("\nYour workaround (forcing IPv4) is the correct approach until they fix this!") | |
| if __name__ == "__main__": | |
| asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment