~gsthnz/satellite

ref: 08c1a5a59b68a33880f45218cdfad85b6e1b7c65 satellite/config.go -rw-r--r-- 516 bytes
08c1a5a5Paper Set minimum TLS version to TLS 1.2 1 year, 7 months ago
                                                                                
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
package main

import (
	"github.com/pelletier/go-toml"
)

type Route struct {
	Match string
	Root  string
}

type Domain struct {
	Name  string
	Root  string
	Route []Route
}

type TLS struct {
	Directory string
}

type Config struct {
	Listen  string
	CertDir string
	TLS     TLS
	Domain  []Domain
}

func LoadConfig(file string) (*Config, error) {
	c := new(Config)
	tree, err := toml.LoadFile(file)
	if err != nil {
		return c, err
	}
	err = tree.Unmarshal(c)
	if err != nil {
		return c, err
	}
	return c, nil
}