Öffentliche Dateiansicht: Raw-Dateien, Tree, Releases und Issues sind ohne Login verfügbar.
certs/PreCheck.go
 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
package certs

import (
	"fmt"
	"os"
	"path/filepath"

	"github.com/adrian-lorenz/noxway/global"
	"github.com/adrian-lorenz/noxway/tools"
)

func CertExist(domain string) (string, string, error) {
	Path, err := os.Getwd()
	if err != nil {
		global.Log.Errorln("Failed to get current working directory:", err)
		return "", "", fmt.Errorf("failed to get current working directory: %v", err)
	}

	cPath := filepath.Join(Path, "certs", domain+".pem")
	kPath := filepath.Join(Path, "certs", domain+".key")

	_, err = os.Stat(cPath)
	if os.IsNotExist(err) {
		global.Log.Warningln("Certificate does not exist")
		return "", "", err
	}
	_, err = os.Stat(kPath)
	if os.IsNotExist(err) {
		global.Log.Errorln("Key does not exist")
		return "", "", err
	}
	global.Log.Infoln("Certificate and key exist")

	return cPath, kPath, nil
}

func CheckDNS(domain string) (bool, error) {
	extIP, err := tools.GetExtIP()
	if err != nil {
		global.Log.Errorln("Failed to get external IP:", err)
		return false, err
	}

	dnsIP, err := tools.GetDnsIP(domain)
	if err != nil {
		global.Log.Errorln("Failed to get DNS IP:", err)
		return false, err
	}
	global.Log.Infoln("External IP:", extIP, "DNS IP:", dnsIP)

	if extIP != dnsIP {
		global.Log.Errorln("External IP and DNS IP are not the same")
		return false, fmt.Errorf("external IP and DNS IP are mot the same")
	}
	return true, nil
}
Sprachen
Go 46%
JavaScript 45%
Markdown 3.3%
HTML 2.5%
YAML 1.7%
JSON 1.1%
Klonen
HTTPS