Hello
As a part of our N/W course assignment we are to implement a proxy server which should be able to restrict access to some websites.
As a part of the implementation, I am reading the sites to be blocked from a text file and storing them in an array. When I get a http request packet I parse the packet to get the value in the Host Name field and compare it with the array. If I find a match I simply block it else I forward it.
A loop hole with this implementation is if any one enters the ip-address of the blocked sites the packet gets forwarded. To avoid this, during the creation of the array am using
to get the ip address of the server to be blocked and will compare the requested server-address with this list of ip's also.
However, the problem began when I started to try to block www.facebook.com
I stored www.fb.com as one of the sites to be blocked in the text file and also will get its ip address during the creation of the array. Now when some one enters www.facebook.com, it will be allowed becoz i have blocked ony fb.com
As I understand, I now have to use gethostbyname for the requested server address also and then compare the ips obtained with those in the array and then decide whether to forward or not.
However this comparison is time consuming and it would be nice if anyone could suggest some other implementation for the same.
Also if possible please gimme links where I can read up more on how blocking can be achieved.
Thanks