Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure all servers run forever #37

Merged
merged 2 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ You will need to have golang installed.
You will need to clone this repository on the `src` directory of your
`$GOPATH`. To learn your `$GOPATH`, use `go env`.

Tests are run with `docker-compose`. To run a test, you must first build the
endpoints. For example, to build a boringSSL server and Cloudflare-Go client:

```
env SERVER_SRC=./impl-endpoints SERVER=boringssl \
CLIENT_SRC=./impl-endpoints CLIENT=cloudflare-go \
docker-compose build
```

Tests require certificates and other cryptographic artifacts to be generated
beforehand.

Expand All @@ -39,12 +30,18 @@ This command will generate:
* A delegated credential
* ECH configuration files

Tests are run with `docker-compose`, with the artifacts copied into a virtual
volume. To run a test, you must first build the endpoints. For example, to build
a BoringSSL server and Cloudflare-Go client:

```
./build.sh cloudflare-go boringssl
```

You're now ready to run tests. The test case is also specified by setting an
environment variable. For example, to run the server-side delegated credential
test:

```
env SERVER_SRC=./impl-endpoints SERVER=boringssl \
CLIENT_SRC=./impl-endpoints CLIENT=cloudflare-go \
TESTCASE=dc docker-compose up
./run.sh cloudflare-go boringssl dc
```
13 changes: 13 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

if [ "$#" -ne 2 ]; then
echo "usage: $0 <client> <server>"
echo
echo "where <client> and <server> are one of the following:"
echo "boringssl, cloudflare-go, nss, rustls"
exit 1
fi

env SERVER_SRC=./impl-endpoints SERVER=$2 \
CLIENT_SRC=./impl-endpoints CLIENT=$1 \
docker-compose build
2 changes: 1 addition & 1 deletion impl-endpoints/boringssl/run_endpoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ else
echo "Running BoringSSL server."
echo "Server params: $SERVER_PARAMS"
echo "Test case: $TESTCASE"
bssl server -accept 4433 -cert /test-inputs/example.crt -key /test-inputs/example.key -subcert /test-inputs/dc.txt
bssl server -loop -accept 4433 -cert /test-inputs/example.crt -key /test-inputs/example.key -subcert /test-inputs/dc.txt
fi
33 changes: 23 additions & 10 deletions impl-endpoints/cloudflare-go/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ func doClient(t TestHandler) error {
if err == nil {
defer c.Close()
}
return t.ConnectionHandler(c, err)

err = t.ConnectionHandler(c, err)
if err != nil {
log.Print(err)
}
return nil
}

func doServer(t TestHandler) error {
Expand All @@ -179,17 +184,25 @@ func doServer(t TestHandler) error {
defer ln.Close()
log.Print("Listening at ", ln.Addr())

conn, err := ln.Accept()
if err != nil {
return err
}
for {
conn, err := ln.Accept()
if err != nil {
return err
}

s := tls.Server(conn, config)
err = s.Handshake()
if err == nil {
defer s.Close()
go func() {
s := tls.Server(conn, config)
err = s.Handshake()
if err == nil {
defer s.Close()
}
err = t.ConnectionHandler(s, err)
if err != nil {
log.Print(err)
}
}()
}
return t.ConnectionHandler(s, err)
return nil
}

func main() {
Expand Down
23 changes: 23 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# After typing Ctrl-C, Docker waits this number of seconds to interrupt the
# containers.
TIMEOUT=0

if [ "$#" -ne 3 ]; then
echo "usage: $0 <client> <server> <testcase>"
echo
echo "where <client> and <server> are one of the following:"
echo "boringssl, cloudflare-go, nss, rustls"
echo
echo "and <testcase> is one of the following:"
echo "dc, ech-accept, ech-reject"
exit 1
fi

env SERVER_SRC=./impl-endpoints SERVER=$2 \
CLIENT_SRC=./impl-endpoints CLIENT=$1 \
TESTCASE=$3 \
docker-compose up --timeout $TIMEOUT

docker-compose stop