-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.go
More file actions
56 lines (48 loc) · 1.02 KB
/
main.go
File metadata and controls
56 lines (48 loc) · 1.02 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* MIT License
* Copyright (c) 2024-2026 Zuplu
*/
package main
import (
_ "embed"
"regexp"
"runtime/debug"
"strings"
"github.com/Zuplu/postfix-tlspol/internal"
)
var (
Version string = "undefined"
//go:embed LICENSE
LicenseText string
//go:embed configs/config.default.yaml
defaultConfigYaml []byte
)
func cleanVersion(raw string) string {
re := regexp.MustCompile(`^v?(\d+\.\d+\.\d+)(?:-[\d.]+-[a-f0-9]+)?(?:\+.*dirty)?$`)
match := re.FindStringSubmatch(raw)
if len(match) >= 2 {
base := match[1]
if strings.Contains(raw, "dirty") || strings.Contains(raw, "-0.") {
return base + "-dev"
}
return base
}
return raw
}
func init() {
if Version == "undefined" || len(Version) == 0 {
if info, ok := debug.ReadBuildInfo(); ok {
if info.Main.Version != "" {
Version = info.Main.Version
}
}
}
Version = cleanVersion(Version)
if strings.HasPrefix(Version, "v") {
Version = Version[1:]
}
}
func main() {
tlspol.SetDefaultConfig(defaultConfigYaml)
tlspol.StartDaemon(Version, LicenseText)
}