Hi Matthew,
Ok, so what you are talking about is "limiting the IP address of the client to a specific value, or range". In other words, you have say a network, but only 1 ip address is allowed to connect to the server. All other IP addresses are explicitly rejected. Right?
To do this, add some code to the .Process method in the WebServer procedure. This goes before the parent call.
self._Wait()
case self.Packet.PacketType
! --------------------------
of NET:SimpleNewConnection
if not IPOK(self.packet.FromIP)
self.CloseServerConnection(self.packet.OnSocket, self.packet.SockID)
end
end
self._Release()
In the above code the IPOK function is something you create to decide if the IP address is acceptable or not. Obviously that could be as simple as an IF statement, or longer, depending on your method.
BIG WARNING - as you can see this happens inside a critical section (the Wait, and Release). So absolutely no Windows here, or Messages, or anything else of that nature. And make the code as fast as possible.
If you would prefer to send back something more constructive - not just kill the connection, then you can expand it to something like this;
self._Wait()
case self.Packet.PacketType
! --------------------------
of NET:SimpleNewConnection
if not IPOK(self.packet.FromIP)
self.packet.binData = self._MakeErrorPacket(401, 'Unauthorized', 'You are Unauthorized to use this resource.')
self.packet.binDataLen = len (clip(self.packet.binData))
self.packet.ToIP = self.packet.FromIP
self.Send()
self.CloseServerConnection(self.packet.OnSocket, self.packet.SockID)
end
end
self._Release()
cheers
Bruce