Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
version bump 0.4.1 - see changelog for more information
Browse files Browse the repository at this point in the history
  • Loading branch information
djcas9 committed May 13, 2015
1 parent bca94ee commit 20c2fd0
Show file tree
Hide file tree
Showing 13 changed files with 325 additions and 129 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Changelog

## 0.4.1 2015-04-18
## 0.4.1 2015-05-13

+ Add loading indicator for system information
request
+ bug fixes
+ store envdb version for nodes
+ Allow nodes list to scroll if needed.
+ Update MakeFile version parsing logic.
+ Revert removing debug symbols from build

## 0.4.0 2015-04-18

Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ NAME="envdb"
DESCRIPTION="Ask your environment questions"
WEBSITE="http://envdb.io"

VERSION=$(shell cat $(NAME).go | grep -oP "Version\s+?\=\s?\"\K.*?(?=\"$|$\)")
VERSION=$(shell cat $(NAME).go | grep "Version =" | sed 's/Version\ \=//' | sed 's/"//g' | tr -d '[[:space:]]')
CWD=$(shell pwd)

GITHUB_USER=mephux
Expand All @@ -29,7 +29,7 @@ all: bindata
@$(ECHO) "$(OK_COLOR)==> Building $(NAME) $(VERSION) $(NO_COLOR)"
@godep go build -ldflags "-s" -o bin/$(NAME)
@chmod +x bin/$(NAME)
@$(ECHO) "$(OK_COLOR)==> Done$(NO_COLOR)"
@$(ECHO) "$(OK_COLOR)==> Done building$(NO_COLOR)"

build: bindata all
@$(ECHO) "$(OK_COLOR)==> Installing dependencies$(NO_COLOR)"
Expand All @@ -42,7 +42,7 @@ updatedeps:
@godep update ...

bindata:
@$(ECHO) "$(OK_COLOR)==> Embedding Assets$(NO_COLOR)"
@$(ECHO) "$(OK_COLOR)==> Embedding assets$(NO_COLOR)"
@go-bindata web/...

test:
Expand All @@ -53,21 +53,21 @@ goxBuild:
@CGO_ENABLED=1 gox -os="$(CCOS)" -arch="$(CCARCH)" -build-toolchain

gox:
@$(ECHO) "$(OK_COLOR)==> Cross Compiling $(NAME)$(NO_COLOR)"
@$(ECHO) "$(OK_COLOR)==> Cross compiling $(NAME)$(NO_COLOR)"
@mkdir -p Godeps/_workspace/src/github.com/$(GITHUB_USER)/$(NAME)
@cp -R *.go Godeps/_workspace/src/github.com/$(GITHUB_USER)/$(NAME)
@CGO_ENABLED=1 GOPATH=$(shell godep path) gox -ldflags "-s" -os="$(CCOS)" -arch="$(CCARCH)" -output=$(CCOUTPUT)
@rm -rf Godeps/_workspace/src/github.com/$(GITHUB_USER)/$(NAME)

release: clean bindata test gox setup package
release: clean all test gox setup package
@for os in $(CCOS); do \
for arch in $(CCARCH); do \
cd pkg/$$os-$$arch/; \
tar -zcvf ../../release/$(NAME)-$$os-$$arch.tar.gz $(NAME)* > /dev/null 2>&1; \
cd ../../; \
done \
done
@$(ECHO) "$(OK_COLOR)==> Done Cross Compiling $(NAME)$(NO_COLOR)"
@$(ECHO) "$(OK_COLOR)==> Done cross compiling $(NAME)$(NO_COLOR)"

clean:
@$(ECHO) "$(OK_COLOR)==> Cleaning$(NO_COLOR)"
Expand All @@ -80,7 +80,7 @@ clean:
@rm -rf package/

setup:
@$(ECHO) "$(OK_COLOR)==> Building Packages $(NAME)$(NO_COLOR)"
@$(ECHO) "$(OK_COLOR)==> Building packages $(NAME)$(NO_COLOR)"
@echo $(VERSION) > .Version
@mkdir -p package/root/usr/bin
@cp -R pkg/linux-amd64/$(NAME) package/root/usr/bin
Expand Down
5 changes: 4 additions & 1 deletion envdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
Name = "envdb"

// Version application version number
Version = "0.4.0"
Version = "0.4.1"

// DefaultServerPort the default tcp server port
DefaultServerPort = 3636
Expand Down Expand Up @@ -64,6 +64,9 @@ var (
// debug logging and serving assets from disk
// is enabled.
DevMode bool

// TestMode
TestMode bool
)

func initLogger() {
Expand Down
1 change: 1 addition & 0 deletions envdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var (
)

func TestMain(m *testing.M) {
TestMode = true
*quiet = true
initLogger()

Expand Down
54 changes: 54 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"os"
"regexp"
"runtime"
"strconv"
"strings"
)

const (
Expand Down Expand Up @@ -48,3 +50,55 @@ func IsExist(path string) bool {
_, err := os.Stat(path)
return err == nil || os.IsExist(err)
}

// VersionCheck
func VersionCheck(base, version string) bool {
if version == base {
return true
}

sv := strings.Split(version, ".")
cv := strings.Split(base, ".")

if len(sv) != 3 {
return false
}

svi, err := strconv.Atoi(sv[0])

cvi, err := strconv.Atoi(cv[0])

if err != nil {
return false
}

if svi < cvi {
return false
}

svi2, err := strconv.Atoi(sv[1])

cvi2, err := strconv.Atoi(cv[1])

if err != nil {
return false
}

if svi2 < cvi2 {
return false
}

svi3, err := strconv.Atoi(sv[1])

cvi3, err := strconv.Atoi(cv[1])

if err != nil {
return false
}

if svi3 < cvi3 {
return false
}

return true
}
4 changes: 4 additions & 0 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ func NewWebServer(webPort int, server *Server) {
return server.Disconnect(id)
})

gotalk.Handle("disconnect-dead", func(id string) error {
return server.DisconnectDead(id)
})

gotalk.Handle("delete", func(id string) error {
return server.Delete(id)
})
Expand Down
29 changes: 16 additions & 13 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (node *Node) Handlers() {
handlers.HandleBufferNotification("die", func(s *gotalk.Sock, name string, b []byte) {
KillClient = true
node.Socket.Close()
Log.Warn(string(b))
Connection <- true
})

Expand Down Expand Up @@ -96,17 +97,17 @@ func (node *Node) Handlers() {
node.Config.WriteCache()
}

has, version := OsQueryInfo()
info := OsQueryInfo()

Log.Infof("osquery enabled: %t", has)
Log.Infof("osquery enabled: %t", info.Enabled)

if has {
Log.Infof("osquery version: %s", version)
if info.Enabled {
Log.Infof("osquery version: %s", info.Version)
}

if !CheckOsQueryVersion(version) {
if !VersionCheck(MinOsQueryVersion, info.Version) {
Log.Errorf("%s requires osqueryi version %s or later.", Name, MinOsQueryVersion)
has = false
info.Enabled = false
}

var hostname = "n/a"
Expand All @@ -129,13 +130,15 @@ func (node *Node) Handlers() {
rmsg := Message{
Error: err,
Data: map[string]interface{}{
"name": node.Name,
"id": node.Id,
"osquery": has,
"osquery-version": version,
"ip": ip,
"hostname": hostname,
"os": os,
"envdb-version": Version,
"name": node.Name,
"id": node.Id,
"osquery": info.Enabled,
"osquery-version": info.Version,
"osquery-config-path": info.ConfigPath,
"ip": ip,
"hostname": hostname,
"os": os,
},
}

Expand Down
60 changes: 44 additions & 16 deletions node_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,47 @@ import (
type NodeDb struct {
Id int64

NodeId string
Name string
Ip string
Hostname string
Os string
NodeId string
EnvdbVersion string
Name string
Ip string
Hostname string
Os string

Online bool

OsQuery bool
OsQueryVersion string
OsQuery bool
OsQueryVersion string
OsQueryConfigPath string

PendingDelete bool

Created time.Time `xorm:"CREATED"`
Updated time.Time `xorm:"UPDATED"`
}

// NodeUpdateOnlineStatus will update a nodes connection
// state on server start to clean up nodes that didn't properly disconnect
// if the server is killed without running cleanup.
func NodeUpdateOnlineStatus() error {
nodes, err := AllNodes()

if err != nil {
return err
}

for _, node := range nodes {
if node.Online {
node.Online = false
if err := node.Update(); err != nil {
return err
}
}
}

return nil
}

// AllNodes Return all nodes in the database
func AllNodes() ([]*NodeDb, error) {
var nodes []*NodeDb
Expand Down Expand Up @@ -72,11 +96,13 @@ func NodeUpdateOrCreate(node *NodeData) (*NodeDb, error) {
Log.Debug("Found existing node record.")

find.Name = node.Name
find.EnvdbVersion = node.EnvdbVersion
find.Ip = node.Ip
find.Hostname = node.Hostname
find.Os = node.Os
find.OsQuery = node.OsQuery
find.OsQueryVersion = node.OsQueryVersion
find.OsQueryConfigPath = node.OsQueryConfigPath
find.Online = node.Online
find.PendingDelete = node.PendingDelete

Expand All @@ -99,15 +125,17 @@ func NodeUpdateOrCreate(node *NodeData) (*NodeDb, error) {
Log.Debugf("Creating a new record.")

a := &NodeDb{
NodeId: node.Id,
Name: node.Name,
Ip: node.Ip,
Hostname: node.Hostname,
Os: node.Os,
Online: node.Online,
OsQuery: node.OsQuery,
OsQueryVersion: node.OsQueryVersion,
PendingDelete: false,
NodeId: node.Id,
Name: node.Name,
EnvdbVersion: node.EnvdbVersion,
Ip: node.Ip,
Hostname: node.Hostname,
Os: node.Os,
Online: node.Online,
OsQuery: node.OsQuery,
OsQueryVersion: node.OsQueryVersion,
OsQueryConfigPath: node.OsQueryConfigPath,
PendingDelete: false,
}

if _, err := sess.Insert(a); err != nil {
Expand Down
Loading

0 comments on commit 20c2fd0

Please sign in to comment.