Skip to content

Commit

Permalink
Merge pull request #20 from sudheesh001/heroku-fix
Browse files Browse the repository at this point in the history
Setting go version for heroku build and disable need for CERT/KEY
  • Loading branch information
chris-wood authored May 21, 2021
2 parents 3654cb1 + 57b12c8 commit 7986d2f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: ./bin/odoh-server
web: ./bin/odoh-server-go
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/cloudflare/odoh-server-go

// +heroku goVersion go1.14
// +scalingo goVersion go1.14
go 1.14

require (
Expand Down
12 changes: 10 additions & 2 deletions odoh_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ func main() {
}

var keyFile string
enableTLSServe := true
if keyFile = os.Getenv(keyEnvironmentVariable); keyFile == "" {
keyFile = "key.pem"
enableTLSServe = false
}

keyPair, err := odoh.CreateKeyPairFromSeed(kemID, kdfID, aeadID, seed)
Expand Down Expand Up @@ -189,6 +191,12 @@ func main() {
http.HandleFunc(configEndpoint, target.configHandler)
http.HandleFunc("/", server.indexHandler)

log.Printf("Listening on port %v with cert %v and key %v\n", port, certFile, keyFile)
log.Fatal(http.ListenAndServeTLS(fmt.Sprintf(":%s", port), certFile, keyFile, nil))
if enableTLSServe {
log.Printf("Listening on port %v with cert %v and key %v\n", port, certFile, keyFile)
log.Fatal(http.ListenAndServeTLS(fmt.Sprintf(":%s", port), certFile, keyFile, nil))
} else {
log.Printf("Listening on port %v without enabling TLS\n", port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
}

}

0 comments on commit 7986d2f

Please sign in to comment.