M
minzhongshan
Unregistered / Unconfirmed
GUEST, unregistred user!
现在小人正在做一个过滤IP程序,现在想过滤域名的.但我只能做到IP过滤.请问怎样做呢!我只能用下面的程序来取得数据包的信息
//从一个TSocket对象中取出IP、Port和本地port信息,并从参数ip、port、localport中传出
procedure GetIPAndPort(s: TSocket; var ip: string; var port: integer; var localport: integer);
var
name: TSockAddr;
namelen: Integer;
begin
try
namelen := sizeof(name);
getpeername(s, name, namelen); //从TSocket中取得地址信息并保存到TSockAddr对象中
ip := inet_ntoa(name.sin_addr); //取IP信息
port := ntohs(name.sin_port); //取Port信息
getsockname(s, name, namelen); //取本地的地址信息
localport := ntohs(name.sin_port);
except
SendIpcMessage('PSMFirewall', Pchar(' Error at GetIPAndPort()'#0), length(' Error at GetIPAndPort()'#0), nil, 0);
SysUtils.Beep;
end;
end;
并且下面的函数是做意思.那里有这方面的介绍.
function accept; external winsocket name 'accept';
function bind; external winsocket name 'bind';
function closesocket; external winsocket name 'closesocket';
function connect; external winsocket name 'connect';
function getpeername; external winsocket name 'getpeername';
function getsockname; external winsocket name 'getsockname';
function getsockopt; external winsocket name 'getsockopt';
function htonl; external winsocket name 'htonl';
function htons; external winsocket name 'htons';
function inet_addr; external winsocket name 'inet_addr';
function inet_ntoa; external winsocket name 'inet_ntoa';
function ioctlsocket; external winsocket name 'ioctlsocket';
function listen; external winsocket name 'listen';
function ntohl; external winsocket name 'ntohl';
function ntohs; external winsocket name 'ntohs';
function recv; external winsocket name 'recv';
function recvfrom; external winsocket name 'recvfrom';
function select; external winsocket name 'select';
function send; external winsocket name 'send';
function sendto; external winsocket name 'sendto';
function setsockopt; external winsocket name 'setsockopt';
function shutdown; external winsocket name 'shutdown';
function socket; external winsocket name 'socket';
function gethostbyaddr; external winsocket name 'gethostbyaddr';
function gethostbyname; external winsocket name 'gethostbyname';
function getprotobyname; external winsocket name 'getprotobyname';
function getprotobynumber; external winsocket name 'getprotobynumber';
function getservbyname; external winsocket name 'getservbyname';
function getservbyport; external winsocket name 'getservbyport';
function gethostname; external winsocket name 'gethostname';
function WSAAsyncSelect; external winsocket name 'WSAAsyncSelect';
function WSARecvEx; external winsocket name 'WSARecvEx';
function WSAAsyncGetHostByAddr; external winsocket name 'WSAAsyncGetHostByAddr';
function WSAAsyncGetHostByName; external winsocket name 'WSAAsyncGetHostByName';
function WSAAsyncGetProtoByNumber; external winsocket name 'WSAAsyncGetProtoByNumber';
function WSAAsyncGetProtoByName; external winsocket name 'WSAAsyncGetProtoByName';
function WSAAsyncGetServByPort; external winsocket name 'WSAAsyncGetServByPort';
function WSAAsyncGetServByName; external winsocket name 'WSAAsyncGetServByName';
function WSACancelAsyncRequest; external winsocket name 'WSACancelAsyncRequest';
function WSASetBlockingHook; external winsocket name 'WSASetBlockingHook';
function WSAUnhookBlockingHook; external winsocket name 'WSAUnhookBlockingHook';
function WSAGetLastError; external winsocket name 'WSAGetLastError';
procedure WSASetLastError; external winsocket name 'WSASetLastError';
function WSACancelBlockingCall; external winsocket name 'WSACancelBlockingCall';
function WSAIsBlocking; external winsocket name 'WSAIsBlocking';
function WSAStartup; external winsocket name 'WSAStartup';
function WSACleanup; external winsocket name 'WSACleanup';
function __WSAFDIsSet; external winsocket name '__WSAFDIsSet';
function TransmitFile; external winsocket name 'TransmitFile';
function AcceptEx; external winsocket name 'AcceptEx';
procedure GetAcceptExSockaddrs; external winsocket name 'GetAcceptExSockaddrs';
//从一个TSocket对象中取出IP、Port和本地port信息,并从参数ip、port、localport中传出
procedure GetIPAndPort(s: TSocket; var ip: string; var port: integer; var localport: integer);
var
name: TSockAddr;
namelen: Integer;
begin
try
namelen := sizeof(name);
getpeername(s, name, namelen); //从TSocket中取得地址信息并保存到TSockAddr对象中
ip := inet_ntoa(name.sin_addr); //取IP信息
port := ntohs(name.sin_port); //取Port信息
getsockname(s, name, namelen); //取本地的地址信息
localport := ntohs(name.sin_port);
except
SendIpcMessage('PSMFirewall', Pchar(' Error at GetIPAndPort()'#0), length(' Error at GetIPAndPort()'#0), nil, 0);
SysUtils.Beep;
end;
end;
并且下面的函数是做意思.那里有这方面的介绍.
function accept; external winsocket name 'accept';
function bind; external winsocket name 'bind';
function closesocket; external winsocket name 'closesocket';
function connect; external winsocket name 'connect';
function getpeername; external winsocket name 'getpeername';
function getsockname; external winsocket name 'getsockname';
function getsockopt; external winsocket name 'getsockopt';
function htonl; external winsocket name 'htonl';
function htons; external winsocket name 'htons';
function inet_addr; external winsocket name 'inet_addr';
function inet_ntoa; external winsocket name 'inet_ntoa';
function ioctlsocket; external winsocket name 'ioctlsocket';
function listen; external winsocket name 'listen';
function ntohl; external winsocket name 'ntohl';
function ntohs; external winsocket name 'ntohs';
function recv; external winsocket name 'recv';
function recvfrom; external winsocket name 'recvfrom';
function select; external winsocket name 'select';
function send; external winsocket name 'send';
function sendto; external winsocket name 'sendto';
function setsockopt; external winsocket name 'setsockopt';
function shutdown; external winsocket name 'shutdown';
function socket; external winsocket name 'socket';
function gethostbyaddr; external winsocket name 'gethostbyaddr';
function gethostbyname; external winsocket name 'gethostbyname';
function getprotobyname; external winsocket name 'getprotobyname';
function getprotobynumber; external winsocket name 'getprotobynumber';
function getservbyname; external winsocket name 'getservbyname';
function getservbyport; external winsocket name 'getservbyport';
function gethostname; external winsocket name 'gethostname';
function WSAAsyncSelect; external winsocket name 'WSAAsyncSelect';
function WSARecvEx; external winsocket name 'WSARecvEx';
function WSAAsyncGetHostByAddr; external winsocket name 'WSAAsyncGetHostByAddr';
function WSAAsyncGetHostByName; external winsocket name 'WSAAsyncGetHostByName';
function WSAAsyncGetProtoByNumber; external winsocket name 'WSAAsyncGetProtoByNumber';
function WSAAsyncGetProtoByName; external winsocket name 'WSAAsyncGetProtoByName';
function WSAAsyncGetServByPort; external winsocket name 'WSAAsyncGetServByPort';
function WSAAsyncGetServByName; external winsocket name 'WSAAsyncGetServByName';
function WSACancelAsyncRequest; external winsocket name 'WSACancelAsyncRequest';
function WSASetBlockingHook; external winsocket name 'WSASetBlockingHook';
function WSAUnhookBlockingHook; external winsocket name 'WSAUnhookBlockingHook';
function WSAGetLastError; external winsocket name 'WSAGetLastError';
procedure WSASetLastError; external winsocket name 'WSASetLastError';
function WSACancelBlockingCall; external winsocket name 'WSACancelBlockingCall';
function WSAIsBlocking; external winsocket name 'WSAIsBlocking';
function WSAStartup; external winsocket name 'WSAStartup';
function WSACleanup; external winsocket name 'WSACleanup';
function __WSAFDIsSet; external winsocket name '__WSAFDIsSet';
function TransmitFile; external winsocket name 'TransmitFile';
function AcceptEx; external winsocket name 'AcceptEx';
procedure GetAcceptExSockaddrs; external winsocket name 'GetAcceptExSockaddrs';