summaryrefslogtreecommitdiff
path: root/pkg/bitmask
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-09-08 03:32:46 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-09-08 20:09:48 +0200
commita0e67fe3feb5b3a2d6d0f8e5f33ff96007955b17 (patch)
treecda0ca1934af399385c21a67fe56b55577c7c2a5 /pkg/bitmask
parente591c3147e3c504611ff612e8918018125ffa2eb (diff)
[feat] lookup the config vars at runtime
- Resolves: #326
Diffstat (limited to 'pkg/bitmask')
-rw-r--r--pkg/bitmask/init.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/pkg/bitmask/init.go b/pkg/bitmask/init.go
index b86deb8..4907b2f 100644
--- a/pkg/bitmask/init.go
+++ b/pkg/bitmask/init.go
@@ -20,6 +20,7 @@ import (
"log"
"os"
"path"
+ "strconv"
"github.com/jmshal/go-locale"
"golang.org/x/text/message"
@@ -34,12 +35,46 @@ type ProviderInfo struct {
AppName string
}
+type ProviderOpts struct {
+ Provider string `json:"name"`
+ AppName string `json:"applicationName"`
+ BinaryName string `json:"binaryName"`
+ Auth string `json:"auth"`
+ ProviderURL string `json:"providerURL"`
+ DonateURL string `json:"donateURL"`
+ ApiURL string `json:"apiURL"`
+ TosURL string `json:"tosURL"`
+ HelpURL string `json:"helpURL"`
+ GeolocationURL string `json:"geolocationAPI"`
+ AskForDonations string `json:"askForDonations"`
+ CaCert string `json:"caCertString"`
+}
+
func GetConfiguredProvider() *ProviderInfo {
provider := config.Provider
appName := config.ApplicationName
return &ProviderInfo{provider, appName}
}
+func ConfigureProvider(opts *ProviderOpts) {
+ config.Provider = opts.ProviderURL
+ config.ProviderName = opts.Provider
+ config.ApplicationName = opts.AppName
+ config.BinaryName = opts.BinaryName
+ config.Auth = opts.Auth
+ config.DonateURL = opts.DonateURL
+ config.HelpURL = opts.HelpURL
+ config.TosURL = opts.TosURL
+ config.APIURL = opts.ApiURL
+ config.GeolocationAPI = opts.GeolocationURL
+ config.CaCert = []byte(opts.CaCert)
+
+ wantsDonations, err := strconv.ParseBool(opts.AskForDonations)
+ if err == nil {
+ config.AskForDonations = wantsDonations
+ }
+}
+
func InitializeLogger() {
_, err := config.ConfigureLogger(path.Join(config.LogPath))
if err != nil {