forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservices.go
123 lines (104 loc) · 3.31 KB
/
services.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
/*
Velociraptor - Hunting Evil
Copyright (C) 2019 Velocidex Innovations.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package services
import (
config_proto "www.velocidex.com/golang/velociraptor/config/proto"
"www.velocidex.com/golang/velociraptor/notifications"
"www.velocidex.com/golang/velociraptor/users"
)
// A manager responsible for starting and shutting down all the
// services in an orderly fashion.
type ServicesManager struct {
hunt_manager *HuntManager
hunt_dispatcher *HuntDispatcher
user_manager *users.UserNotificationManager
stats_collector *StatsCollector
server_monitoring *EventTable
server_artifacts *ServerArtifactsRunner
dyn_dns *DynDNSService
interrogation *InterrogationService
sanity_checker *SanityChecks
vfs_service *VFSService
}
func (self *ServicesManager) Close() {
self.hunt_manager.Close()
self.hunt_dispatcher.Close()
self.user_manager.Close()
self.stats_collector.Close()
self.server_monitoring.Close()
self.server_artifacts.Close()
self.dyn_dns.Close()
self.interrogation.Close()
self.sanity_checker.Close()
self.vfs_service.Close()
}
// Start all the server services.
func StartServices(
config_obj *config_proto.Config,
notifier *notifications.NotificationPool) (*ServicesManager, error) {
result := &ServicesManager{}
hunt_manager, err := startHuntManager(config_obj)
if err != nil {
return nil, err
}
result.hunt_manager = hunt_manager
hunt_dispatcher, err := StartHuntDispatcher(config_obj)
if err != nil {
return nil, err
}
result.hunt_dispatcher = hunt_dispatcher
user_manager, err := users.StartUserNotificationManager(config_obj)
if err != nil {
return nil, err
}
result.user_manager = user_manager
stats_collector, err := startStatsCollector(config_obj)
if err != nil {
return nil, err
}
result.stats_collector = stats_collector
server_monitoring, err := startServerMonitoringService(config_obj)
if err != nil {
return nil, err
}
result.server_monitoring = server_monitoring
server_artifacts, err := startServerArtifactService(config_obj, notifier)
if err != nil {
return nil, err
}
result.server_artifacts = server_artifacts
err = StartClientMonitoringService(config_obj)
if err != nil {
return nil, err
}
dyndns, err := startDynDNSService(config_obj)
if err != nil {
return nil, err
}
result.dyn_dns = dyndns
interrogation := startInterrogationService(config_obj)
result.interrogation = interrogation
sanity_checker, err := startSanityCheckService(config_obj)
if err != nil {
return nil, err
}
result.sanity_checker = sanity_checker
vfs_service, err := startVFSService(config_obj)
if err != nil {
return nil, err
}
result.vfs_service = vfs_service
return result, nil
}