Skip to content

Commit

Permalink
Expanded and small refactor to events
Browse files Browse the repository at this point in the history
  • Loading branch information
moloch-- committed Nov 22, 2020
1 parent 2d8d0cf commit 484b8bb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
18 changes: 10 additions & 8 deletions client/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,29 @@ const (

EventStr = "event"

ServerErrorStr = "server"
ServerErrorStr = "server-error"

// ConnectedEvent - Sliver Connected
SessionOpenedEvent = "connected"
SessionOpenedEvent = "session-connected"
// DisconnectedEvent - Sliver disconnected
SessionClosedEvent = "disconnected"
SessionClosedEvent = "session-disconnected"
// UpdateEvent - Sliver updated
SessionUpdateEvent = "updated"
SessionUpdateEvent = "session-updated"

// JoinedEvent - Player joined the game
JoinedEvent = "joined"
JoinedEvent = "client-joined"
// LeftEvent - Player left the game
LeftEvent = "left"
LeftEvent = "client-left"

// CanaryEvent - A DNS canary was triggered
CanaryEvent = "canary"

// StartedEvent - Job was started
JobStartedEvent = "started"
JobStartedEvent = "job-started"
// StoppedEvent - Job was stopped
JobStoppedEvent = "stopped"
JobStoppedEvent = "job-stopped"

BuildCompletedEvent = "build-completed"
)

// Commands
Expand Down
3 changes: 2 additions & 1 deletion server/core/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (s *Session) ToProtobuf() *clientpb.Session {
lastCheckin = s.LastCheckin.Format(time.RFC1123)

// Calculates how much time has passed in seconds and compares that to the ReconnectInterval+10 of the Implant.
// (ReconnectInterval+10 seconds is just abitrary padding to account for potential delays)
// (ReconnectInterval+10 seconds is just arbitrary padding to account for potential delays)
// If it hasn't checked in, flag it as DEAD.
var timePassed = uint32(math.Abs(s.LastCheckin.Sub(time.Now()).Seconds()))

Expand Down Expand Up @@ -145,6 +145,7 @@ func (s *Session) Request(msgType uint32, timeout time.Duration, data []byte) ([
return respEnvelope.Data, nil
}

// UpdateCheckin - Update a session's checkin time
func (s *Session) UpdateCheckin() {
now := time.Now()
s.LastCheckin = &now
Expand Down
8 changes: 8 additions & 0 deletions server/rpc/rpc-generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ package rpc
import (
"context"
"errors"
"fmt"
"io/ioutil"
"path"

consts "github.com/bishopfox/sliver/client/constants"
"github.com/bishopfox/sliver/protobuf/clientpb"
"github.com/bishopfox/sliver/protobuf/commonpb"
"github.com/bishopfox/sliver/server/core"
"github.com/bishopfox/sliver/server/db"
"github.com/bishopfox/sliver/server/generate"
)
Expand Down Expand Up @@ -67,6 +70,11 @@ func (rpc *Server) Generate(ctx context.Context, req *clientpb.GenerateReq) (*cl
return nil, err
}

core.EventBroker.Publish(core.Event{
EventType: consts.BuildCompletedEvent,
Data: []byte(fmt.Sprintf("%s build completed", filename)),
})

return &clientpb.Generate{
File: &commonpb.File{
Name: filename,
Expand Down

0 comments on commit 484b8bb

Please sign in to comment.