-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtypes.go
162 lines (143 loc) · 3.99 KB
/
types.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package main
import (
"net/http"
"net/url"
"time"
)
// Config type defines the file configuration data
type Config struct {
Mode string `yaml:"mode"`
Cluster ClusterConfig `yaml:"cluster"`
KV KVConfig `yaml:"kv"`
API APIConfig `yaml:"api"`
UI UIConfig `yaml:"ui"`
SSL SSLConfig `yaml:"ssl"`
Perf PerfConfig `yaml:"performance"`
Auth AuthConfig `yaml:"auth"`
Plugin PluginAppConfig `yaml:"plugin"`
}
// Cave struct wraps all the app functions
type Cave struct {
Config *Config
Logger *Log
Cluster *Cluster
KV *KV
KVInit bool
API *API
Crypto *Crypto
Plugins *Plugins
TokenStore *TokenStore
updates chan Message
sync chan Message
tokens chan Message
sharedKey *AESKey
}
//ClusterConfig type holds the cluster interface objects.
type ClusterConfig struct {
Port uint16 `yaml:"port"`
DiscoveryHost string `yaml:"discovery_host"`
Host string `yaml:"host"`
SyncPort uint16 `yaml:"sync_port"`
}
//KVConfig type holds the key-value engine objects.
type KVConfig struct {
Encryption bool `yaml:"enable_encryption"`
DBPath string `yaml:"db_path"`
}
//APIConfig type holds the API engine objects
type APIConfig struct {
Enable bool `yaml:"enable"`
Port uint16 `yaml:"port"`
Authentication bool `yaml:"authentication"`
EnableMetrics bool `yaml:"enable_metrics"`
}
//UIConfig struct holds the UI engine objects
type UIConfig struct {
Enable bool `yaml:"enable"`
Port uint16 `yaml:"port"`
Authentication bool `yaml:"authentication"`
}
//LoggerConfig handles all the logging facilities
type LoggerConfig struct {
}
//SSLConfig holds the SSL configuration
type SSLConfig struct {
Enable bool `yaml:"enable"`
Certificate string `yaml:"ssl_certificate"`
Key string `yaml:"ssl_key"`
}
//PerfConfig holds performance configs
type PerfConfig struct {
EnableMetrics bool `yaml:"enable_metrics"`
EnableHTTPLogs bool `yaml:"enable_http_logs"`
BufferSize uint64 `yaml:"buffer_size"`
}
// AuthConfig type
type AuthConfig struct {
Provider string `yaml:"provider"`
}
// PluginAppConfig type
type PluginAppConfig struct {
PluginPath string `yaml:"plugin_path"`
AllowUnsigned bool `yaml:"allow_unsigned"`
Blacklist []string `yaml:"blacklist"`
SocketPrefix string `yaml:"socket_prefix"`
}
// Message type represents a message on the wire
type Message struct {
Epoch uint64 `json:"epoch"`
ID string `json:"id"`
Type string `json:"type"`
Origin string `json:"origin"`
Data []byte `json:"data"`
DataType string `json:"data_type"`
}
type node struct {
ID string
Address string
Distance time.Duration
}
// PluginConfig type
type PluginConfig struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
ExeName string `yaml:"exe_name"`
Type string `yaml:"type"` // authenticator, api, etc.
SubType string `yaml:"subtype"` // LDAP, Basic, PAM, etc.
Env map[string]string `yaml:"env"`
Config map[string]interface{} `yaml:"config"`
StartupDelay int `yaml:"startup_delay"`
}
// APIRequest type
type APIRequest struct {
URL *url.URL
Body []byte
Headers http.Header
Host string
UserAgent string
Cookies []*http.Cookie
}
// Token type
type Token struct {
IssueTime time.Time
ExpireTime time.Time
UID string
Token string
IssuedBy string
Type string
}
// MultiQuery type
type MultiQuery struct {
ID string `json:"id"`
Query []QueryObject `json:"query"`
QueryErrors bool `json:"query_errors"`
Error error `json:"error"`
}
// QueryObject type
type QueryObject struct {
Key string `json:"key"`
Verb string `json:"verb"`
Value string `json:"value"`
Secret bool `json:"secret"`
Error string `json:"error"`
}