SOCKS5批量检测工具,多线程的,速度很快。

  • Post author:
  • Post category:其他


SOCKS5批量检测工具,

多线程的,

速度很快。

可以批量检测SOCKS5是否可达,

并在软件上显示,

或者保存在文本文件里。

原理,

采用多线程来检测,

使用临界处理。



点这里下载



在这里插入图片描述

部分核心代码如下:

function IsIPAddress(ss: string): Boolean;
var
  s, s1: string;
  ii, p: integer;
begin
  s1 := ss;
  result := false;
  for ii := 1 to 3 do
  begin
    p := pos('.', s1);
    if p = 0 then
      exit;
    s := Copy(s1, 1, p - 1);
    s1 := copy(s1, p + 1, Length(s1));
    p := StrToIntDef(s, -1);
    if (p <= 0) or (p >= 255) then
      exit;
  end;
  p := StrToIntDef(s1, -1);
  if (p <= 0) or (p >= 255) then
    exit;
  result := true;
end;

function IsReadible(s: TSocket; dwTimeout: DWORD): Boolean;
var
  timeout: TTimeVal;
  fds: TFDSet;
  nStatus: Integer;
begin
  timeout.tv_sec := dwTimeout div 1000;
  timeout.tv_usec := (dwTimeout mod 1000) * 1000;
  FD_ZERO(fds);
  FD_SET(s, fds);
  nStatus := select(0, @fds, nil, nil, @timeout);
  if (nStatus = SOCKET_ERROR) then
  begin
    Result := False;
    Exit;
  end;
  Result := not (nStatus = 0);
end;

function IsWritable(s: TSocket; dwTimeout: DWORD): Boolean;
var
  timeout: TTimeVal;
  fds: TFDSet;
  nStatus: Integer;
begin
  timeout.tv_sec := dwTimeout div 1000;
  timeout.tv_usec := (dwTimeout mod 1000) * 1000;
  FD_ZERO(fds);
  FD_SET(s, fds);
  nStatus := select(0, nil, @fds, nil, @timeout);
  if (nStatus = SOCKET_ERROR) then
  begin
    Result := False;
    Exit;
  end;

  Result := not (nStatus = 0);
end;

function GetIPAddressByHost(const Host: string; const Which: Integer): string;
var
  HostEnt: PHostEnt;
  iAddr: Integer;
begin
  if AnsiSameText(Host, 'LOCALHost') then
  begin
    Result := '127.0.0.1';
  end
  else if IsIPAddress(Host) then
  begin
    Result := Host;
  end
  else
  begin
    HostEnt := getHostbyname(PAnsiChar(Host));
    if Assigned(HostEnt) then
    begin
      if Which <= (HostEnt^.h_length div 4) then
      begin
        Move(PByteArray(HostEnt^.h_addr_list^)[(Which - 1) * 4], iAddr, 4);
        Result := inet_ntoa(TInAddr(iAddr));
      end
      else
        Result := '';
    end
    else
      Result := '';
  end;
end;



版权声明:本文为QQ1289671197原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。