This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
100 lines (80 loc) · 2.27 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package main
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/semihalev/gin-stats"
"os"
)
var (
router *gin.Engine
app *config
)
const (
portDefault = "8000"
)
type config struct {
Server string
DeviceName string
}
func main() {
//A unique name for the device can configured. It is used as prefix for img names
name := os.Getenv("RFANAME")
server := os.Getenv("RFASERVER")
if server == "" {
//Set default
server = "odroid@192.168.0.11"
}
app = &config{server, name}
gin.SetMode(gin.DebugMode)
//Uncomment the next line if you need gin debug output like handled requests by gin
//gin.DefaultWriter = ioutil.Discard
//Set the router as default
router = gin.Default()
//Load static html content
router.LoadHTMLFiles("web/index.html")
router.Static("/css", "web/css")
router.Static("/js", "web/js")
router.Static("/fonts", "web/fonts")
/*USE ONLY FOR LAB ENVIRONMENT, BUILD OWN CONFIG FOR PRODUCTIVE BUILD:
https://github.com/gin-contrib/cors*/
router.Use(cors.Default())
router.Use(stats.RequestStats())
// Define Simple test route
initRoutes()
//Hardware Rec
/*err,disks := getDisksWithoutBootPart()
if (err != nil){
fmt.Printf("Err while trying to retriev Block/Disk info", err)
}
for _,disk := range disks{
fmt.Printf(disk.String())l
}
*/
port := os.Getenv("RFAPORT")
if port == "" {
port = portDefault
}
router.Run(":" + port)
//router.RunTLS(":5443", "/etc/ssl/certs/server.crt","/etc/ssl/private/server.key")
}
/*
DC3DD needs to be installed on client and server
To avoid password prompting for ssh while using dd or dc3dd generate ssh key pair and share to client:
$ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.
Copy your keys to the target server:
$ ssh-copy-id id@server
id@server's password:
Now try logging into the machine, with ssh 'id@server', and check in:
.ssh/authorized_keys
to make sure we haven’t added extra keys that you weren’t expecting.
Finally check logging in…
$ ssh id@server
id@server:~$
"
*/