Multiple port support

This commit is contained in:
Nate Choe
2022-06-21 23:34:13 -05:00
parent dc044b22e3
commit 47cf044858
19 changed files with 333 additions and 136 deletions

7
site/https.html Normal file
View File

@@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<body>
<p>You are a brave soul for trusting a self signed HTTPS
certificate. Don't do it again.</p>
</body>
</html>

View File

@@ -1,3 +1,3 @@
#!/bin/sh
../build/swebs -p swebs.pid -s sitefile -o logs -b 100 -j2
../build/swebs -p swebs.pid -s sitefile -o /dev/stdout -b 100 -j2

1
site/site/8001.html Normal file
View File

@@ -0,0 +1 @@
<p>Welcome to port 8001!</p>

View File

@@ -1,21 +1,49 @@
define port 8000
declare TCP 8000
declare TLS 8001
# We will use ports 8000 and 8001 with TCP and TLS respectively
key domain.key 8001
cert domain.crt 8001
# Port 8001 can have TLS, but it's self signed and very bad.
timeout 2000 8000
timeout 2000 8001
# Set these values for the ports
set port 8000
# The following pages will respond to port 8000
define transport TLS
define transport TCP
define key domain.key
define cert domain.crt
define timeout 2000
define library ./library.so
# Library calls should use ./library.so
set host localhost:8000
# The following pages will respond to the host localhost:8000
read / site/index.html
# The path / should be read from site/index.html
read /hello site/hello.html
# The path /hello should be read from site/hello.html
throw /blog/forbidden 403
# The path /blog/forbidden should throw error code 403
read /blog/.* site/blog/
#/blog/2021-1-25.html turns into site/blog//blog/2021-1-25.html
# /blog/2021-1-25.html turns into site/blog//blog/2021-1-25.html
linked /library
# The path /library should be dynamically loaded from the library (library.so)
set host 127.0.0.1:8000
# The following pages will respond to the host 127.0.0.1:8000
read / site/easteregg.html
# The path / should be read from site/easteregg.html
read /egg.png site/egg.png
# The path /egg.png should be read from site/egg.png
set host .*
# The following pages will respond to all hosts (regex)
read /alldomains site/alldomains.html
# The path /alldomains should be read from /site/alldomains.html
set port 8001
# The following pages will respond to port 8001
read / site/8001.html
# The path / should be read from site/8001.html