Ir al contenido
Guides 3 min de lectura 815 vistas

Uso de Proxy en Delphi/Pascal

Configuración de proxy en Delphi y Free Pascal: Indy, Synapse, WinINet y trabajando con proxies HTTP/SOCKS5.

Uso de Proxy en Delphi/Pascal

Proxies en Delphi/Pascal

Delphi y Free Pascal siguen siendo populares para desarrollar aplicaciones de Windows. El trabajo con proxies se realiza a través de las librerías Indy (estándar de Delphi), Synapse y la API de WinINet.

Indy (Internet Direct)

Indy es la librería integrada de Delphi para programación de red.

Proxy HTTP

uses IdHTTP, IdSSLOpenSSL;

procedure FetchViaProxy;
var
  HTTP: TIdHTTP;
  SSL: TIdSSLIOHandlerSocketOpenSSL;
begin
  HTTP := TIdHTTP.Create(nil);
  SSL := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
  try
    HTTP.IOHandler := SSL;

    // Configuración del proxy
    HTTP.ProxyParams.ProxyServer := 'proxy_ip';
    HTTP.ProxyParams.ProxyPort := 8080;
    HTTP.ProxyParams.ProxyUsername := 'username';
    HTTP.ProxyParams.ProxyPassword := 'password';
    HTTP.ProxyParams.BasicAuthentication := True;

    WriteLn(HTTP.Get('https://httpbin.org/ip'));
  finally
    SSL.Free;
    HTTP.Free;
  end;
end;

Proxy SOCKS5 a través de Indy

uses IdHTTP, IdSocks, IdSSLOpenSSL;

procedure FetchViaSocks5;
var
  HTTP: TIdHTTP;
  SSL: TIdSSLIOHandlerSocketOpenSSL;
  Socks: TIdSocksInfo;
begin
  HTTP := TIdHTTP.Create(nil);
  SSL := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
  Socks := TIdSocksInfo.Create(nil);
  try
    // Configuración de SOCKS5
    Socks.Host := 'proxy_ip';
    Socks.Port := 1080;
    Socks.Version := svSocks5;
    Socks.Username := 'username';
    Socks.Password := 'password';
    Socks.Authentication := saUsernamePassword;

    SSL.TransparentProxy := Socks;
    HTTP.IOHandler := SSL;

    WriteLn(HTTP.Get('https://httpbin.org/ip'));
  finally
    Socks.Free;
    SSL.Free;
    HTTP.Free;
  end;
end;

SOCKS4

Socks.Version := svSocks4;
// SOCKS4 no soporta autenticación
Socks.Authentication := saNoAuthentication;

Synapse

Synapse es una librería de red alternativa para Free Pascal y Delphi.

Instalación

Descarga desde synapse.ararat.cz y añade a tu proyecto.

Proxy HTTP

uses httpsend;

procedure FetchViaSynapseProxy;
var
  HTTP: THTTPSend;
begin
  HTTP := THTTPSend.Create;
  try
    HTTP.ProxyHost := 'proxy_ip';
    HTTP.ProxyPort := '8080';
    HTTP.ProxyUser := 'username';
    HTTP.ProxyPass := 'password';

    if HTTP.HTTPMethod('GET', 'https://httpbin.org/ip') then
      WriteLn(HTTP.Document.DataString)
    else
      WriteLn('Error: ', HTTP.ResultCode);
  finally
    HTTP.Free;
  end;
end;

SOCKS a través de Synapse

uses blcksock;

procedure FetchViaSynapseSocks;
var
  Sock: TTCPBlockSocket;
begin
  Sock := TTCPBlockSocket.Create;
  try
    Sock.SocksIP := 'proxy_ip';
    Sock.SocksPort := '1080';
    Sock.SocksUsername := 'username';
    Sock.SocksPassword := 'password';
    Sock.SocksType := ST_Socks5;

    Sock.Connect('httpbin.org', '80');
    if Sock.LastError = 0 then begin
      Sock.SendString('GET /ip HTTP/1.1' + #13#10 +
                      'Host: httpbin.org' + #13#10 +
                      #13#10);
      WriteLn(Sock.RecvString(10000));
    end;
  finally
    Sock.Free;
  end;
end;

WinINet API (Windows)

Uso de la API de sistema de Windows:

uses WinInet;

procedure FetchViaWinINet;
var
  hInternet, hConnect: HINTERNET;
  Buffer: array[0..4095] of Char;
  BytesRead: DWORD;
begin
  // Abrir con proxy
  hInternet := InternetOpen(
    'MyApp',
    INTERNET_OPEN_TYPE_PROXY,
    PChar('http://proxy_ip:8080'),
    nil,
    0
  );

  if hInternet <> nil then begin
    // Establecer autenticación de proxy
    InternetSetOption(hInternet, INTERNET_OPTION_PROXY_USERNAME,
      PChar('username'), Length('username'));
    InternetSetOption(hInternet, INTERNET_OPTION_PROXY_PASSWORD,
      PChar('password'), Length('password'));

    hConnect := InternetOpenUrl(hInternet,
      'https://httpbin.org/ip', nil, 0,
      INTERNET_FLAG_RELOAD, 0);

    if hConnect <> nil then begin
      InternetReadFile(hConnect, @Buffer, SizeOf(Buffer), BytesRead);
      WriteLn(Copy(Buffer, 1, BytesRead));
      InternetCloseHandle(hConnect);
    end;

    InternetCloseHandle(hInternet);
  end;
end;

Uso de Proxies del Sistema

hInternet := InternetOpen(
  'MyApp',
  INTERNET_OPEN_TYPE_PRECONFIG,  // usar configuración del sistema
  nil,
  nil,
  0
);

Rotación de Proxies

type
  TProxyInfo = record
    Host: string;
    Port: Integer;
    Username: string;
    Password: string;
  end;

var
  Proxies: array of TProxyInfo;
  ProxyIndex: Integer = 0;

function GetNextProxy: TProxyInfo;
begin
  Result := Proxies[ProxyIndex mod Length(Proxies)];
  Inc(ProxyIndex);
end;

procedure FetchWithRotation(const URL: string);
var
  HTTP: TIdHTTP;
  Proxy: TProxyInfo;
begin
  Proxy := GetNextProxy;
  HTTP := TIdHTTP.Create(nil);
  try
    HTTP.ProxyParams.ProxyServer := Proxy.Host;
    HTTP.ProxyParams.ProxyPort := Proxy.Port;
    HTTP.ProxyParams.ProxyUsername := Proxy.Username;
    HTTP.ProxyParams.ProxyPassword := Proxy.Password;

    try
      WriteLn(HTTP.Get(URL));
    except
      on E: Exception do
        WriteLn('Error con el proxy ', Proxy.Host, ': ', E.Message);
    end;
  finally
    HTTP.Free;
  end;
end;

Consejos

  1. Indy es la elección estándar para Delphi, viene con el IDE.
  2. Synapse es para Free Pascal y proyectos multiplataforma.
  3. WinINet es solo para aplicaciones de Windows, usando la pila del sistema.
  4. Para SOCKS, usa Indy TIdSocksInfo o Synapse SocksType.
  5. DLL de OpenSSL — no olvides colocar libeay32.dll y ssleay32.dll junto a tu ejecutable para HTTPS.

Conclusión

Delphi/Pascal proporcionan herramientas maduras para trabajar con proxies. Indy es la solución más completa, soportando HTTP, SOCKS4, SOCKS5 y autenticación. Para tareas sencillas en Windows, la API de WinINet es una opción rápida sin dependencias externas.

Actualizado: 06.03.2026
Volver a la categoría

Leer también

Guides 2 min

Proxy para Nike SNKRS: Consigue lanzamientos limitados y múltiples entradas con GProxy

Usa proxies residenciales o móviles para Nike SNKRS para participar en sorteos con múltiples cuentas, superar los límites de IP y hacer cop de drops limitados sin baneos. Qué tipo elegir y cómo configurarlo.

Guides 2 min

Cómo configurar un proxy en iPhone (Wi-Fi y SOCKS5)

Configura un proxy en iPhone mediante los ajustes nativos de Wi-Fi (HTTP/HTTPS) o una aplicación de proxy como Shadowrocket para SOCKS5 y cobertura celular. Configuración paso a paso en iOS y las limitaciones que debes conocer.

Guides 3 min

Proxy para Tinder: Cuentas Múltiples y Evitar Bloqueos

Usa proxies móviles o residenciales para Tinder para gestionar múltiples perfiles y evitar shadowbans de IP. Por qué el móvil gana, cómo configurarlo y por qué un proxy por sí solo no cambiará tu ciudad.

Guides 2 min

Proxy para StockX: Monitoree precios y gestione cuentas

Usa proxies residenciales, ISP o móviles para StockX para monitorear precios, manejar múltiples cuentas y hacer cop de drops sin baneos. Aquí tienes qué tipo elegir y cómo configurarlo.

Guides 3 min

Proxy para la API de OpenAI: acceso, límites de velocidad y configuración

Enrute la OpenAI API a través de un proxy residencial o ISP para acceder a regiones compatibles, esquivar límites de tasa 429 e aislar cuentas. Qué proxy usar más ejemplos de configuración en Python.

Guides 1 min

Aquí tienes las traducciones:

Configurando Proxy en Cypress para Pruebas E2E

Pruebe nuestros proxies

20,000+ proxies en 100+ países del mundo

support_agent
GProxy Support
Usually replies within minutes
Hi there!
Send us a message and we'll reply as soon as possible.