reid il y a 2 ans
Parent
commit
e85285ba52
4 fichiers modifiés avec 47 ajouts et 49 suppressions
  1. 34 35
      config/config.go
  2. 3 3
      main.go
  3. 0 1
      setup/setup.go
  4. 10 10
      structs/structs.go

+ 34 - 35
config/config.go

@@ -2,39 +2,38 @@ package config
 
 import (
 	"encoding/json"
+	"fmt"
 	"goseg/structs"
+	"io/ioutil"
 	"log/slog"
+	"net"
+	"net/http"
 	"os"
 	"path/filepath"
 	"sync"
-	"net/http"
-	"io/ioutil"
-	"net"
 	"time"
-	"fmt"
 )
 
 var (
-	globalConfig 	  structs.SysConfig
-	logger            = slog.New(slog.NewJSONHandler(os.Stdout, nil))
-	basePath		  = "/home/nativeplanet/gits"
-	Version           = "v2.0.0"
-	Ready             = false
+	globalConfig       structs.SysConfig
+	logger             = slog.New(slog.NewJSONHandler(os.Stdout, nil))
+	basePath           = "/home/nativeplanet/gits"
+	Version            = "v2.0.0"
+	Ready              = false
 	VersionServerReady = false
-	VersionInfo       structs.Version
-	Ram               int
-	Cpu               int
-	CoreTemp          int
-	Disk              int
-	WifiEnabled       = false
-	ActiveNetwork     string
-	WifiNetworks      []string
-	HttpOpen          = false
-	UploadSecret      string
-	confMutex		  sync.Mutex
+	VersionInfo        structs.Version
+	Ram                int
+	Cpu                int
+	CoreTemp           int
+	Disk               int
+	WifiEnabled        = false
+	ActiveNetwork      string
+	WifiNetworks       []string
+	HttpOpen           = false
+	UploadSecret       string
+	confMutex          sync.Mutex
 )
 
-
 func init() {
 	confPath := filepath.Join(basePath, "settings", "system2.json")
 	file, err := os.Open(confPath)
@@ -118,20 +117,20 @@ func createDefaultConf() error {
 			Interval: "week",
 			Previous: false,
 		},
-		DockerData:   "/var/lib/docker",
-		WgOn:         false,
-		WgRegistered: false,
-		PwHash:       "",
-		C2cInterval:  0,
-		FirstBoot:    false,
-		WgRegisterd:  false,
-		GsVersion:    Version,
-		CfgDir:       "",
+		DockerData:     "/var/lib/docker",
+		WgOn:           false,
+		WgRegistered:   false,
+		PwHash:         "",
+		C2cInterval:    0,
+		FirstBoot:      false,
+		WgRegisterd:    false,
+		GsVersion:      Version,
+		CfgDir:         "",
 		UpdateInterval: 0,
-		BinHash:      "",
-		Pubkey:       "",
-		Privkey:      "",
-		Salt:         "",
+		BinHash:        "",
+		Pubkey:         "",
+		Privkey:        "",
+		Salt:           "",
 	}
 	path := filepath.Join(basePath, "settings", "system2.json")
 	if err := os.MkdirAll(filepath.Dir(path), os.ModePerm); err != nil {
@@ -221,4 +220,4 @@ func CheckVersion() bool {
 		return true
 	}
 	return false
-}
+}

+ 3 - 3
main.go

@@ -1,10 +1,10 @@
 package main
 
 import (
+	"fmt"
 	"goseg/config"
 	"log/slog"
 	"os"
-	"fmt"
 )
 
 var (
@@ -12,7 +12,7 @@ var (
 )
 
 func main() {
-	for _, arg := range os.Args[1:] { 
+	for _, arg := range os.Args[1:] {
 		if arg == "dev" {
 			logger.Info("Starting GroundSeg in debug mode")
 		}
@@ -21,7 +21,7 @@ func main() {
 	logger.Info("Urbit is love <3")
 	conf := config.Conf()
 	internetAvailable := config.NetCheck("1.1.1.1:53")
-	availMsg := fmt.Sprintf("Internet available: %t",internetAvailable)
+	availMsg := fmt.Sprintf("Internet available: %t", internetAvailable)
 	logger.Info(availMsg)
 	versionUpdateChannel := make(chan bool)
 	if conf.UpdateMode == "auto" {

+ 0 - 1
setup/setup.go

@@ -1,2 +1 @@
 package setup
-

+ 10 - 10
structs/structs.go

@@ -21,7 +21,7 @@ type SysConfig struct {
 	SwapVal      int      `json:"swapVal"`
 	SwapFile     string   `json:"swapFile"`
 	KeyFile      string   `json:"keyFile"`
-	Sessions struct {
+	Sessions     struct {
 		Authorized   map[string]SessionInfo `json:"authorized"`
 		Unauthorized map[string]SessionInfo `json:"unauthorized"`
 	} `json:"sessions"`
@@ -47,19 +47,19 @@ type SysConfig struct {
 }
 
 type LoginStatus struct {
-	Locked		bool
-	End			time.Time
-	Attempts	int	
+	Locked   bool
+	End      time.Time
+	Attempts int
 }
 
 type LoginKeys struct {
-	Old	struct {
-		Pub 	string
-		Priv	string
+	Old struct {
+		Pub  string
+		Priv string
 	}
 	Cur struct {
-		Pub		string
-		Priv	string
+		Pub  string
+		Priv string
 	}
 }
 
@@ -103,4 +103,4 @@ type VersionDetails struct {
 	Patch       int    `json:"patch,omitempty"`
 	Repo        string `json:"repo,omitempty"`
 	Tag         string `json:"tag,omitempty"`
-}
+}