Course Name : Computer Networks Course Code : CPSC 441 Semester : Winter 2022 Assignment : 1 Title : Clown Proxy Author : Apostolos Scondrianis Introduction : The intent of this program is to act as a proxy server between the browser and the server that we are requesting information from and forward the result of the request back to the browser. It should only handle GET HTTP Requests. If it finds the word "Happy" int the text content of the HTTP response from the server it should replace the word "Happy" with the word "Silly". If the proxy detects that the browser is requesting an image of .jpg or .jpeg format it should replace it with a clown image. How to run: - Upload the file proxy.c to your desired web server. - Compile the program using the command : gcc proxy.c -o proxy - Run the program using the command : ./proxy - The program will give you the IP address of the server you are running the proxy on. - After that the program prompts you to enter a port to run the program from and also give you the address of the server that runs the program you selected. Try 9000 , or 8000 or anything between 1024 and 44444. If the program is not able to bind on that port it will prompt you to try another PORT. - You will need the server IP address that was given to you on the command line, and also the port number you entered. - Go to the browser settings of the browser you wish to use and go to your proxy settings. - Use the Manual Proxy Configuration Selection : You will need to set your HTTP Proxy : XXX.XXX.XXX.XXX as the address given to you by the command prompt when you initiated the proxy program. And use the PORT number that you successfully inputted. - Make sure that your browser is not automatically updating your links to HTTPS web links. - In order to terminate the program use the command Control+C or Control+Z Note : Make sure to clear your browser cache before you run the program so you can see the full effect of the browser. If you don't and your browser has pre cached the request, you will just received a non modified request from the server and the browser will just load saved data from the browser cache. What the program actually does : 1) It successfully forwards HTTP GET requests from the browser through the PROXY to the requested SERVER 2) It successfully forwards the HTTP response of the SERVER through the proxy to the browser. 3) It successfully detects the string "Happy" and replaces it with "Silly" 4) It successfully detects HTTP Get requets of .jpg or .jpeg images and replaces them with either 5) The replacement of the jpg images is randomized between the following 2 images : a) http://pages.cpsc.ucalgary.ca/~carey/CPSC441/ass1/clown1.png b) http://pages.cpsc.ucalgary.ca/~carey/CPSC441/ass1/clown2.png 6) Works properly for HTTP 1.1 and it also works for HTTP 1.0 as far as I have tested, as long as the hostname is included in the HTTP request header for HTTP 1.0 requests. 7) Signal handling is added to the program in order to close the sockets and free the linked lists used if the program is terminated using the commands : Control+C or Control+Z Links that the program has been tested on and works for sure : On the CPSC441 website and every page it has : http://pages.cpsc.ucalgary.ca/~carey/CPSC441/ The tests that the assignment requires have been successfully tested and work : http://pages.cpsc.ucalgary.ca/~carey/CPSC441/ass1/test1.html http://pages.cpsc.ucalgary.ca/~carey/CPSC441/ass1/test2.html http://pages.cpsc.ucalgary.ca/~carey/CPSC441/ass1/test3.html http://pages.cpsc.ucalgary.ca/~carey/CPSC441/ass1/test4.html http://pages.cpsc.ucalgary.ca/~carey/CPSC441/ass1/test5.html http://pages.cpsc.ucalgary.ca/~carey/index.htm http://pages.cpsc.ucalgary.ca/~carey/CPSC441/ass1/Floppy.jpg Known Errors : None known as of January 28th, 2022. Also tested on the old website of cern : http://info.cern.ch/ Resources used for the code: http://beej.us/guide/bgnet/ for socket management https://www.geeksforgeeks.org/c-program-display-hostname-ip-address/ to get the IP address and hostname of the server the proxy is ran on. Thank you for using my program!