Finished project on Linux
This commit is contained in:
parent
e6a1c34695
commit
5d3dda1df6
@ -32,9 +32,12 @@ void PipeSockets(int sender_s, int receiver_s) {
|
|||||||
|| (strstr(in_buf, hazardous_contents_CS_02) != NULL)) {
|
|| (strstr(in_buf, hazardous_contents_CS_02) != NULL)) {
|
||||||
std::cerr << "LOG (warn) - Hazardous contents detected" << std::endl;
|
std::cerr << "LOG (warn) - Hazardous contents detected" << std::endl;
|
||||||
strcpy(in_buf, FORBIDDEN_403);
|
strcpy(in_buf, FORBIDDEN_403);
|
||||||
send(receiver_s, in_buf, strlen(in_buf), 0);
|
send(sender_s, in_buf, strlen(in_buf), 0);
|
||||||
strcpy(in_buf, MESS_403);
|
strcpy(in_buf, MESS_403);
|
||||||
send(receiver_s, in_buf, strlen(in_buf), 0);
|
send(sender_s, in_buf, strlen(in_buf), 0);
|
||||||
|
close(sender_s);
|
||||||
|
close(receiver_s);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send
|
// Send
|
||||||
@ -50,6 +53,7 @@ void ProxySockets(int sender_s, int receiver_s) {
|
|||||||
ssize_t buf_len; // Buffer length for file reads
|
ssize_t buf_len; // Buffer length for file reads
|
||||||
|
|
||||||
// Pass response along from server to browser
|
// Pass response along from server to browser
|
||||||
|
sleep(1);
|
||||||
std::cout << "Attempting to send to browser" << std::endl;
|
std::cout << "Attempting to send to browser" << std::endl;
|
||||||
do {
|
do {
|
||||||
// Receive
|
// Receive
|
||||||
@ -68,6 +72,9 @@ void ProxySockets(int sender_s, int receiver_s) {
|
|||||||
send(receiver_s, out_buf, strlen(out_buf), 0);
|
send(receiver_s, out_buf, strlen(out_buf), 0);
|
||||||
strcpy(out_buf, MESS_403);
|
strcpy(out_buf, MESS_403);
|
||||||
send(receiver_s, out_buf, strlen(out_buf), 0);
|
send(receiver_s, out_buf, strlen(out_buf), 0);
|
||||||
|
close(sender_s);
|
||||||
|
close(receiver_s);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send
|
// Send
|
||||||
|
@ -32,12 +32,6 @@ int main(void)
|
|||||||
auto newThreadRequest2 = std::async(std::launch::async, ProxySockets, webserver.socketFD, browser.socketFD);
|
auto newThreadRequest2 = std::async(std::launch::async, ProxySockets, webserver.socketFD, browser.socketFD);
|
||||||
pending_futures.push_back(std::move(newThreadRequest1));
|
pending_futures.push_back(std::move(newThreadRequest1));
|
||||||
pending_futures.push_back(std::move(newThreadRequest2));
|
pending_futures.push_back(std::move(newThreadRequest2));
|
||||||
/*
|
|
||||||
auto newThreadRequest = std::async(std::launch::async, TestSockets, browser.socketFD, webserver.socketFD);
|
|
||||||
pending_futures.push_back(std::move(newThreadRequest));
|
|
||||||
std::cout << "Returned from creating threads, continuing..." << std::endl;
|
|
||||||
*/
|
|
||||||
//TestSockets(browser.socketFD, webserver.socketFD);
|
|
||||||
}
|
}
|
||||||
proxy.Close();
|
proxy.Close();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -122,6 +122,10 @@ void ClientRequest(int client_s) {
|
|||||||
retcode = recv(client_s, in_buf, BUF_SIZE, 0);
|
retcode = recv(client_s, in_buf, BUF_SIZE, 0);
|
||||||
|
|
||||||
if (retcode == -1) { std::cerr << "ERROR (info) - recv" << std::endl; }
|
if (retcode == -1) { std::cerr << "ERROR (info) - recv" << std::endl; }
|
||||||
|
if (retcode == 0) {
|
||||||
|
std::cout << "LOG (info) - Webserver received no data" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Handle the GET if there is one (see note #3 in the header)
|
// Handle the GET if there is one (see note #3 in the header)
|
||||||
// Parse out the filename from the GET request
|
// Parse out the filename from the GET request
|
||||||
strtok(in_buf, " ");
|
strtok(in_buf, " ");
|
||||||
|
Loading…
Reference in New Issue
Block a user