Package: morty / 0.2.0-1

0001-enh-add-environment-variable-support-to-configure-li.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From 21d656b41f0cea9f0723c555c47a1eb1763e39cc Mon Sep 17 00:00:00 2001
From: Adam Tauber <asciimoo@gmail.com>
Date: Wed, 30 May 2018 17:14:37 +0200
Subject: [PATCH] [enh] add environment variable support to configure listen
 address and secret key - closes #56

---
 morty.go | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/morty.go b/morty.go
index 5be14ee..8b4729a 100644
--- a/morty.go
+++ b/morty.go
@@ -13,6 +13,7 @@ import (
 	"log"
 	"mime"
 	"net/url"
+	"os"
 	"path/filepath"
 	"regexp"
 	"strings"
@@ -967,9 +968,13 @@ func (p *Proxy) serveMainPage(ctx *fasthttp.RequestCtx, statusCode int, err erro
 }
 
 func main() {
-
-	listen := flag.String("listen", "127.0.0.1:3000", "Listen address")
-	key := flag.String("key", "", "HMAC url validation key (hexadecimal encoded) - leave blank to disable")
+	default_listen_addr := os.Getenv("MORTY_ADDRESS")
+	if default_listen_addr == "" {
+		default_listen_addr = "127.0.0.1:3000"
+	}
+	default_key := os.Getenv("MORTY_KEY")
+	listen := flag.String("listen", default_listen_addr, "Listen address")
+	key := flag.String("key", default_key, "HMAC url validation key (hexadecimal encoded) - leave blank to disable validation")
 	ipv6 := flag.Bool("ipv6", false, "Allow IPv6 HTTP requests")
 	version := flag.Bool("version", false, "Show version")
 	requestTimeout := flag.Uint("timeout", 2, "Request timeout")
-- 
2.16.1