>> A client has asked that access to a NT 11.24 Web Server be restricted to just a few specific IP Address. I believe this is best handled at the router/firewall but I will have very limited access to the physical server. So, how can I do this in my NT web server app itself?
It largely depends on what you mean by "a few". Bearing in mind that you need to do this test for every single incoming request, and hence there is a performance penalty to be paid by valid users for each and every single request.
For maximum performance the list should be as small as possible - and I recommend using a queue (ie in memory). Going to disk would be slow. You could load the queue from JSON and then edit the JSON file directly in notepad if you wanted to add more items. (A reload button on the server window would reload it on demand after editing.)
The best place to do the check is in the webServer procedure, so the queue can be local to that procedure, and hence threadsafe.
Put this code in the .Process method, before the parent call.
if self.packet.PacketType = NET:SimpleNewConnection
if self.packet.FromIP not in approved list then
self.closeServerConnection(self.packet.OnSocket,self.packet.SockID)
return
end
end
I'll leave you do define the queue, populate it, and do the appropriate code to test the list against self.packet.fromIP
Cheers
Bruce