From 536e7402aa95d698dd48a8a7f0209e2f9b004f51 Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Thu, 8 Jun 2017 12:10:52 +0200 Subject: [PATCH] cmd/client-api-proxy: Optionally listen for HTTPS --- .../matrix-org/dendrite/cmd/client-api-proxy/main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/cmd/client-api-proxy/main.go b/src/github.com/matrix-org/dendrite/cmd/client-api-proxy/main.go index a9b359315..8aab6575d 100644 --- a/src/github.com/matrix-org/dendrite/cmd/client-api-proxy/main.go +++ b/src/github.com/matrix-org/dendrite/cmd/client-api-proxy/main.go @@ -51,6 +51,8 @@ var ( clientAPIURL = flag.String("client-api-server-url", "", "The base URL of the listening 'dendrite-client-api-server' process. E.g. 'http://localhost:4321'") mediaAPIURL = flag.String("media-api-server-url", "", "The base URL of the listening 'dendrite-media-api-server' process. E.g. 'http://localhost:7779'") bindAddress = flag.String("bind-address", ":8008", "The listening port for the proxy.") + certFile = flag.String("tls-cert", "server.crt", "The PEM formatted X509 certificate to use for TLS") + keyFile = flag.String("tls-key", "server.key", "The PEM private key to use for TLS") ) func makeProxy(targetURL string) (*httputil.ReverseProxy, error) { @@ -148,6 +150,9 @@ func main() { fmt.Println(" /_matrix/media/v1 => ", *mediaAPIURL+"/api/_matrix/media/v1") fmt.Println(" /* => ", *clientAPIURL+"/api/*") fmt.Println("Listening on ", *bindAddress) - srv.ListenAndServe() - + if *certFile != "" && *keyFile != "" { + panic(srv.ListenAndServeTLS(*certFile, *keyFile)) + } else { + panic(srv.ListenAndServe()) + } }