~bigbes/core-go

0d5262dfd01e9138d2df7ae55a0ba93a7d1ed94e — Drew DeVault 5 years ago 910a861
config: add GetOrigin function

This implements the same behavior as Python's srht.config.get_origin.
1 files changed, 13 insertions(+), 0 deletions(-)

M config/config.go
M config/config.go => config/config.go +13 -0
@@ 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
}