-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
gob.go
58 lines (47 loc) · 1.26 KB
/
gob.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
package core
import (
"encoding/gob"
"sync/atomic"
)
// Registration of some core types by the gob package in order to support encoding/decoding them.
var (
permTypesGobRegistered atomic.Bool
simpleValueTypesGobRegistered atomic.Bool
)
func RegisterSimpleValueTypesInGob() {
if !simpleValueTypesGobRegistered.CompareAndSwap(false, true) {
return
}
gob.Register(String(""))
gob.Register(Rune('a'))
gob.Register(Byte(0))
gob.Register(Port{})
gob.Register(Int(0))
gob.Register(Float(0))
gob.Register(Bool(true))
gob.Register(Path(""))
gob.Register(PathPattern(""))
gob.Register(Scheme(""))
gob.Register((""))
gob.Register(Host(""))
gob.Register(HostPattern(""))
gob.Register(URL(""))
gob.Register(URLPattern(""))
}
func RegisterPermissionTypesInGob() {
if !permTypesGobRegistered.CompareAndSwap(false, true) {
return
}
gob.Register([]Permission{})
gob.Register(FilesystemPermission{})
gob.Register(GlobalVarPermission{})
gob.Register(HttpPermission{})
gob.Register(DNSPermission{})
gob.Register(WebsocketPermission{})
gob.Register(LThreadPermission{})
gob.Register(DatabasePermission{})
gob.Register(EnvVarPermission{})
gob.Register(RawTcpPermission{})
gob.Register(SystemGraphAccessPermission{})
gob.Register(ValueVisibilityPermission{})
}