extends RefCounted class_name GurtProtocol const DNS_SERVER_IP: String = "135.125.163.131" const DNS_SERVER_PORT: int = 4878 static func is_gurt_domain(url: String) -> bool: if url.begins_with("gurt://"): return true if not url.contains("://"): # Extract just the domain part (before any path) var domain = url.split("/")[0] var parts = domain.split(".") return parts.size() == 2 return false static func is_direct_address(domain: String) -> bool: # Check if it's already an IP address or localhost if domain.contains(":"): var parts = domain.split(":") domain = parts[0] return domain == "localhost" or domain == "127.0.0.1" or is_ip_address(domain) static func is_ip_address(address: String) -> bool: var parts = address.split(".") if parts.size() != 4: return false for part in parts: if not part.is_valid_int(): return false var num = part.to_int() if num < 0 or num > 255: return false return true static func resolve_gurt_domain(domain: String) -> String: if is_direct_address(domain): if domain == "localhost": return "127.0.0.1" return domain return domain static func get_error_type(error_message: String) -> Dictionary: if "DNS server is not responding" in error_message or "Domain not found" in error_message: return {"code": "ERR_NAME_NOT_RESOLVED", "title": "This site can't be reached", "icon": "? :("} elif "timeout" in error_message.to_lower() or "timed out" in error_message.to_lower(): return {"code": "ERR_CONNECTION_TIMED_OUT", "title": "This site can't be reached", "icon": "...?"} elif "Failed to fetch" in error_message or "No response" in error_message: return {"code": "ERR_CONNECTION_REFUSED", "title": "This site can't be reached", "icon": ">:("} elif "Invalid domain format" in error_message: return {"code": "ERR_INVALID_URL", "title": "This page isn't working", "icon": ":|"} else: return {"code": "ERR_UNKNOWN", "title": "Something went wrong", "icon": ">_<"} static func create_error_page(error_message: String) -> PackedByteArray: var error_info = get_error_type(error_message) return ("""
""" + error_info.icon + """
""" + error_message + """