forked from sandia-minimega/minimega
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ron.go
62 lines (52 loc) · 1.29 KB
/
ron.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
// Copyright 2015-2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain
// rights in this software.
package ron
import (
"regexp"
"strings"
log "minilog"
)
const (
HEARTBEAT_RATE = 5
REAPER_RATE = 30
CLIENT_RECONNECT_RATE = 5
CLIENT_EXPIRED = 30
RESPONSE_PATH = "miniccc_responses"
)
type Process struct {
PID int
Command []string
}
type VM interface {
GetNamespace() string
GetUUID() string
SetCCActive(bool)
GetTags() map[string]string
SetTag(string, string)
Info(string) (string, error)
}
func unmangle(uuid string) string {
// string must be in the form:
// XXXXXXXX-XXXX-XXXX-YYYY-YYYYYYYYYYYY
// the X characters are reversed at 2 byte intervals (big/little endian for a uuid?)
var ret string
re := regexp.MustCompile("[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}")
u := re.FindString(strings.ToLower(uuid))
if uuid == "" {
log.Fatal("uuid failed to match uuid format: %v", uuid)
}
ret += u[6:8]
ret += u[4:6]
ret += u[2:4]
ret += u[:2]
ret += "-"
ret += u[11:13]
ret += u[9:11]
ret += "-"
ret += u[16:18]
ret += u[14:16]
ret += u[18:]
log.Debug("mangled/unmangled uuid: %v %v", u, ret)
return ret
}