1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Get proxy information :
getaddrinfo(port, ProxyHints) -> rv, servinfo (proxyInfo)
Get file socket descriptor + bind :
for(p=proxyInfo ; ; ) // search the first result
socket(p) -> sockProxy <br> Bind(p,sockProxy)
Listen(sockProxy)
While(1)
Accept(sockProxy) -> sockClient //we create a socket to manage the client
fork()
Close(sockProxy)
Recv(sockClient) -> http_request (string)
Extract host server name from http_request
Get web server information
getaddrinfo(host name, port 80, webServerHints) -> rv2, servWebInfo
Extract URL from http_request
Extract user agent from http_request
Create the new request (to send to the web server)
for(p2=servWebInfo) // search the first result
socket(p2) -> webServerSock //we create a socket to manage the web server
connect(webServerSock, servWebInfo)
send(new_request)
recv(information_from_web_server)
printf(information_from_web_server) |
Partager