From 950c018b187aa13edbea4d8acbb2022fd2f13319 Mon Sep 17 00:00:00 2001 From: Kioubit <96532606+Kioubit@users.noreply.github.com> Date: Tue, 18 Jan 2022 04:03:09 -0500 Subject: [PATCH] Confirm that bird access was restricted (#49) Co-authored-by: Kioubit --- proxy/bird.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/proxy/bird.go b/proxy/bird.go index e74a00b..70a16d7 100644 --- a/proxy/bird.go +++ b/proxy/bird.go @@ -1,9 +1,11 @@ package main import ( + "bytes" "io" "net" "net/http" + "strings" ) // Read a line from bird socket, removing preceding status number, output it. @@ -67,7 +69,13 @@ func birdHandler(httpW http.ResponseWriter, httpR *http.Request) { birdReadln(bird, nil) birdWriteln(bird, "restrict") - birdReadln(bird, nil) + var restrictedConfirmation bytes.Buffer + birdReadln(bird, &restrictedConfirmation) + if !strings.Contains(restrictedConfirmation.String(), "Access restricted") { + httpW.WriteHeader(http.StatusInternalServerError) + httpW.Write([]byte("could not verify that bird access was restricted")) + return + } birdWriteln(bird, query) for birdReadln(bird, httpW) { }