-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #371 from dantol29/slombard/web-312-add-ipv6-addre…
…ssees-to-the-multi-server-test Slombard/web 312 add ipv6 addressees to the multi server test
- Loading branch information
Showing
10 changed files
with
347 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
server { | ||
listen 0.0.0.0:8081; | ||
listen [::]:8081; | ||
server_name www.development_site; | ||
root /var/www/html; | ||
} | ||
|
||
server { | ||
listen 127.0.0.1:8080; | ||
listen [::1]:8080; | ||
server_name www.saladbook; | ||
root /var/www/html; | ||
} | ||
|
||
server { | ||
listen 127.0.0.1:8082; | ||
listen [::1]:8082; | ||
server_name www.python_site.com; | ||
root /var/www/html; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
server { | ||
listen 0.0.0.0:8081; | ||
server_name www.development_site; | ||
root /var/www/html; | ||
} | ||
|
||
server { | ||
listen 127.0.0.1:8080; | ||
server_name www.saladbook; | ||
root /var/www/html; | ||
} | ||
|
||
server { | ||
listen 127.0.0.1:8082; | ||
server_name www.python_site.com; | ||
root /var/www/html; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
server { | ||
listen [::]:8081; | ||
server_name www.development_site; | ||
root /var/www/html; | ||
} | ||
|
||
server { | ||
listen [::1]:8080; | ||
server_name www.saladbook; | ||
root /var/www/html; | ||
} | ||
|
||
server { | ||
listen [::1]:8082; | ||
server_name www.python_site.com; | ||
root /var/www/html; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
server { | ||
listen 0.0.0.0:8081; | ||
server_name www.development_site; | ||
root /var/www/html; | ||
} | ||
|
||
server { | ||
listen [::1]:8080; | ||
server_name www.saladbook; | ||
root /var/www/html; | ||
} | ||
|
||
server { | ||
listen [::1]:8082; | ||
server_name www.python_site.com; | ||
root /var/www/html; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
|
||
# Colors for output | ||
GREEN='\033[0;32m' | ||
RED='\033[0;31m' | ||
NC='\033[0m' # No Color | ||
|
||
# Check if the webserv binary exists | ||
if [ ! -f ./../../webserv ]; then | ||
echo -e "${RED}Error: webserv binary not found!${NC}" | ||
exit 1 | ||
fi | ||
|
||
echo "Starting test script..." | ||
|
||
# Modify /etc/hosts to add the new localhost aliases | ||
echo "127.0.0.2 localhost2" >> /etc/hosts | ||
echo "127.0.0.3 localhost3" >> /etc/hosts | ||
echo "::2 localhost2" >> /etc/hosts | ||
echo "::3 localhost3" >> /etc/hosts | ||
|
||
# Start the server | ||
echo "Starting the server..." | ||
./../../webserv ./../../multiIPv4+IPv6.conf & | ||
SERVER_PID=$! | ||
sleep 2 # Wait for the server to start | ||
|
||
# Check if the server started successfully | ||
if ! ps -p $SERVER_PID > /dev/null; then | ||
echo -e "${RED}Failed to start the server.${NC}" | ||
exit 1 | ||
fi | ||
|
||
# Function to store response | ||
store_response() { | ||
local url=$1 | ||
local expected=$2 | ||
local response=$(curl -s -o /dev/null -w "%{http_code}" $url) | ||
if [ "$response" == "$expected" ]; then | ||
echo -e "$url - Expected $expected - HTTP status code: $response ${GREEN}✔${NC}" >> results.txt | ||
else | ||
echo -e "$url - Expected $expected - HTTP status code: $response ${RED}✘${NC}" >> results.txt | ||
fi | ||
} | ||
|
||
# Run curl commands and store responses | ||
store_response "127.0.0.1:8080" "404" | ||
store_response "0.0.0.0:8081" "404" | ||
store_response "127.0.0.1:8082" "404" | ||
store_response "127.0.0.2:8080" "000" | ||
store_response "127.0.0.3:8080" "000" | ||
store_response "127.0.0.1:8081" "404" | ||
store_response "[::1]:8080" "404" | ||
store_response "[::]:8081" "404" | ||
store_response "[::1]:8082" "404" | ||
store_response "[::2]:8080" "000" | ||
store_response "[::3]:8080" "000" | ||
store_response "[::1]:8081" "404" | ||
|
||
# Stop the server | ||
echo "Stopping the server..." | ||
kill $SERVER_PID | ||
|
||
# Print all responses | ||
echo "Test results:" | ||
cat results.txt | ||
rm results.txt | ||
|
||
echo "Test script completed." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/bin/bash | ||
|
||
# Colors for output | ||
GREEN='\033[0;32m' | ||
RED='\033[0;31m' | ||
NC='\033[0m' # No Color | ||
|
||
# Install net-tools if not present | ||
if ! command -v netstat &> /dev/null; then | ||
echo "Installing net-tools..." | ||
apt-get update && apt-get install -y net-tools | ||
fi | ||
|
||
# Check if the webserv binary exists | ||
if [ ! -f ./../../webserv ]; then | ||
echo -e "${RED}Error: webserv binary not found!${NC}" | ||
exit 1 | ||
fi | ||
|
||
echo "Starting test script..." | ||
|
||
# Modify /etc/hosts to add the new localhost aliases | ||
echo "::2 localhost2" >> /etc/hosts | ||
echo "::3 localhost3" >> /etc/hosts | ||
|
||
# Start the server | ||
echo "Starting the server..." | ||
./../../webserv ./../../multiIPv6.conf & | ||
SERVER_PID=$! | ||
sleep 2 # Wait for the server to start | ||
|
||
# Check if the server started successfully | ||
if ! ps -p $SERVER_PID > /dev/null; then | ||
echo -e "${RED}Failed to start the server.${NC}" | ||
exit 1 | ||
fi | ||
|
||
# Verify server is listening on the expected address and port | ||
echo "Checking server listening ports..." | ||
netstat -tuln | grep 8081 >> netstat_results.txt | ||
netstat -tuln | grep 8080 >> netstat_results.txt | ||
netstat -tuln | grep 8082 >> netstat_results.txt | ||
|
||
# Check IPv6 configuration | ||
echo "IPv6 configuration:" | ||
ip -6 addr > ipv6_config.txt | ||
ip -6 route >> ipv6_config.txt | ||
|
||
|
||
# Function to store response | ||
store_response() { | ||
local url=$1 | ||
local expected=$2 | ||
local response=$(curl -s -o /dev/null -w "%{http_code}" $url) | ||
if [ "$response" == "$expected" ]; then | ||
echo -e "$url - Expected $expected - HTTP status code: $response ${GREEN}✔${NC}" >> results.txt | ||
else | ||
echo -e "$url - Expected $expected - HTTP status code: $response ${RED}✘${NC}" >> results.txt | ||
fi | ||
} | ||
|
||
# Run curl commands and store responses | ||
store_response "[::1]:8080" "404" | ||
# store_response "[::]:8081" "404" | ||
store_response "[::0]:8081" "404" | ||
store_response "[::1]:8082" "404" | ||
store_response "[::2]:8080" "000" | ||
store_response "[::3]:8080" "000" | ||
store_response "[::1]:8081" "404" | ||
|
||
# Stop the server | ||
echo "Stopping the server..." | ||
kill $SERVER_PID | ||
|
||
# Print all responses | ||
echo "Test results:" | ||
cat results.txt | ||
rm results.txt | ||
|
||
# Print netstat results | ||
echo "Netstat results:" | ||
cat netstat_results.txt | ||
rm netstat_results.txt | ||
|
||
# Print IPv6 configuration | ||
echo "IPv6 configuration:" | ||
cat ipv6_config.txt | ||
rm ipv6_config.txt | ||
|
||
|
||
|
||
echo "Test script completed." |
Oops, something went wrong.