About the author
I implemented a simple IP address banning system in one of my Web Services.
In the Web Services code, this is what I had to do.
var WebModule: TWebModule; Request: TWebRequest; TempIP, IP: string; IPNetwork: TIdNetworkCalculator; Banned1, Banned2: Boolean;begin WebModule := GetSOAPWebModule; Request := WebModule.Request; IP := Request.GetFieldByName('HTTP_X_FORWARDED_FOR'); if IP = '' then IP := Request.RemoteAddr; IPNetwork := TIdNetworkCalculator.Create(nil); try while Length(IP)>0 do begin TempIP := Fetch(IP, ', '); IPNetwork.NetworkAddress.AsString := '202.12.94.0'; IPNetwork.NetworkMaskLength := 23; Banned1 := IPNetwork.IsAddressInNetwork(TempIP);
IPNetwork.NetworkAddress.AsString := '172.16.0.0'; IPNetwork.NetworkMaskLength := 12; Banned2 := IPNetwork.IsAddressInNetwork(TempIP); if Banned1 or Banned2 then raise ERemotableException.Create('Your domain address is banned.'); end; finally IPNetwork.Free; end;end;
A method pointer is now the same as a global procedure, ie, procedure of object = procedure.