Como veo que nadie tiene una respuesta les paso algo mas de info a ver si se aclara lo que necesito.
El tema es que tengo una función como la que pongo y que fue tomada de otro foro.
Código Delphi
[-]
function AuthenticateProxy(aURL: PChar; const aUserName, aPassword: String): Boolean;
var
poiInternetOpen: HINTERNET;
poiInternetConnect: HINTERNET;
poiInternetRequest: HINTERNET;
recUrlComponents: URL_COMPONENTS;
dwdStatus: DWORD;
dwdStatusSize: DWORD;
i: DWORD;
begin
Result := False;
dwdStatusSize := SizeOf(dwdStatus);
ZeroMemory(@recUrlComponents, SizeOf(URL_COMPONENTS));
recUrlComponents.dwStructSize := SizeOf(URL_COMPONENTS);
recUrlComponents.dwHostNameLength := INTERNET_MAX_HOST_NAME_LENGTH;
InternetCrackUrl(aURL, Length(aURL) + 1, 0, recUrlComponents);
poiInternetOpen := InternetOpen('agent', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
poiInternetConnect := InternetConnect(poiInternetOpen, recUrlComponents.lpszHostName, INTERNET_INVALID_PORT_NUMBER,
nil, nil, INTERNET_SERVICE_HTTP, 0, 0);
poiInternetRequest := HttpOpenRequest(poiInternetConnect, 'GET', recUrlComponents.lpszHostName, nil, nil, nil, INTERNET_FLAG_KEEP_CONNECTION, 0);
for i := 0 to 1 do
begin
HttpSendRequest(poiInternetRequest, nil, 0, nil, 0);
HttpQueryInfo(poiInternetRequest, HTTP_QUERY_FLAG_NUMBER or HTTP_QUERY_STATUS_CODE, @dwdStatus, dwdStatusSize, PCardinal(0)^);
if (dwdStatus = HTTP_STATUS_PROXY_AUTH_REQ) or (dwdStatus = HTTP_STATUS_DENIED) then
begin
InternetSetOption(poiInternetRequest, INTERNET_OPTION_PROXY_USERNAME, PChar(aUserName), Length(aUserName) + 1);
InternetSetOption(poiInternetRequest, INTERNET_OPTION_PROXY_PASSWORD, PChar(aPassWord), Length(aPassWord) + 1);
end;
end;
InternetCloseHandle(poiInternetOpen);
InternetCloseHandle(poiInternetConnect);
InternetCloseHandle(poiInternetRequest);
Result := (dwdStatus <> HTTP_STATUS_PROXY_AUTH_REQ) and (dwdStatus <> HTTP_STATUS_DENIED);
end;
Esto lo que hace es autenticar una URL pasando por el proxy. Con esto también podríamos decir que sabemos si se tiene conexión a internet si es que no se puede llegar a la URL.
El caso es que no se como hacer lo mismo pero para direcciones que están en servidores con IPv6. Todo esto por lo expuesto en mi primer mensajes.
Lo único que se me ocurrió es cuando la función toma la URL que se le agregue los corchetes y validar por IPv6, si todo sale bien es que hay internet contra el servidor ese, en caso de error validar por IPv4. Pero mi pregunta es la siguiente, ¿esta función funciona con IPv6?
¿Los navegadores cuando uno ingresa la URL y la tienen que mostrar primero agregan los corchetes para ver si existe en un servidor IPv6 para luego según el resultado salir a buscar en un servidor de IPv4?
Saludos,
El Rayo