- A simple, multi-threaded
HTTP/1.0
proxy server. - It's the 7th and last lab of 15-213: Introduction to Computer Systems.
- It uses a cache of size
1MB
to store reciently used requests.
proxy.c
contains:
-
The
main
function which:- Opens a listening desctiotor for requesting clients requests.
- Initializes the cache.
- Accepts a connection with each client.
- Creates a peer thread for each client.
-
The
thread
function which:- Detaches itself from the
main thread
. - Reads client request and headers.
- If it's a valid request, it searches in the cache for the request, if present it sends it directly to the client
- If not present, then it parses the request.
- and opens a connection with the server the client requested.
- and serves the client, then forwards it content to it.
- lastly, it caches this request if it comes in the future.
- Detaches itself from the
- Compile and run
git clone https://github.com/Alighorab/Proxy-Server/
cd Proxy-Server/
make
./proxy <port> (e.g., 4000)
- Connect to proxy
- Using
TELNET
:
telnet localhost <port>
- Or adjust your browser to content to proxy and content to http sites.
- NOTE: use these sites and what is similar to them only:
http://www.example.com/
http://go.com/
http://www.washington.edu/
http://www.internic.com/
http://eu.httpbin.org/
http://neverssl.com/
http://info.cern.ch/
http://www.softwareqatest.com/
http://www.vulnweb.com/
- Use
driver.sh
driver.sh
testsproxy
using tiny
pushd .. &> /dev/null
git clone https://github.com/Alighorab/Tiny-Web-Server/
mv Tiny-Web-Server/ Proxy-Server/tiny/
popd &> /dev/null
./driver.sh
- Use
sdriver.sh
sdriver.sh
testsproxy
using the above sites
./sdriver.sh
├── cache
│ ├── cache.{c,h}: cache implementation.
│ ├── mm.{c,h}: dynaminc memory allocator to manage proxy cache.
│ └── memlib.{c,h}: a library for the allocator.
├── rio
│ └── rio.{c,h}: robust I/O package.
├── sock_interface
│ └── sock_interface.{c,h}: socket interface package.
├── proxy.c: proxy implementation.
├── Makefile
├── proxylab.pdf: proxy writeup.
├── driver.sh: The autograder for Basic, Concurrency, and Cache using tiny
├── nop-server.py: helper for the autograder.
└── sdriver.sh: The autograder for Basic, Concurrency, and Cache using http sites