From 0d5262dfd01e9138d2df7ae55a0ba93a7d1ed94e Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 17 Oct 2020 12:39:21 -0400 Subject: [PATCH] config: add GetOrigin function This implements the same behavior as Python's srht.config.get_origin. --- config/config.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/config.go b/config/config.go index 080aa4ebafd3210b0d16415826eb9903fa9b85d0..ad157751547f7f64e765ab53b8251062c2d0027d 100644 --- a/config/config.go +++ b/config/config.go @@ -50,3 +50,16 @@ func LoadConfig(defaultAddr string) ini.File { crypto.InitCrypto(config) return config } + +func GetOrigin(conf ini.File, svc string, external bool) string { + if external { + origin, _ := conf.Get(svc, "origin") + return origin + } + origin, ok := conf.Get(svc, "internal-origin") + if ok { + return origin + } + origin, _ = conf.Get(svc, "origin") + return origin +}