-
Notifications
You must be signed in to change notification settings - Fork 5
/
server.go
28 lines (23 loc) · 812 Bytes
/
server.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
// This file defines the OpenSnitch UI Server as per gRPC proto specification
package main
import (
"context"
"github.com/evilsocket/opensnitch/daemon/ui/protocol"
"google.golang.org/grpc"
)
// Server represents an OpenSnitch UI Server
type osServer struct {
server *grpc.Server
osApp *osApp
}
// Ping reply to an OpenSnitch daemon client ping request and send to statChan the
// data received.
func (s *osServer) Ping(ctx context.Context, pr *protocol.PingRequest) (*protocol.PingReply, error) {
statChan <- pr.GetStats()
return &protocol.PingReply{Id: pr.GetId()}, nil
}
// AskRule ask to the UI application for a Rule for the specified connection
func (s *osServer) AskRule(ctx context.Context, conn *protocol.Connection) (*protocol.Rule, error) {
r, _ := s.osApp.AskRule(conn)
return r, nil
}