Skip to content

Commit

Permalink
Add default unrevoked option
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Andersen committed Sep 19, 2018
1 parent 7d5898a commit 45ef2a1
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 17 deletions.
3 changes: 3 additions & 0 deletions consts/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ var WAVEMQPSETBytes = "\x1b\x20\x14\x33\x74\xb3\x2f\xd2\x74\x39\x54\xfe\x47\x86\
//Granting this permission with the wave builtin pset allows the recipient
//to decrypt end-to-end encrypted messages
var WaveBuiltinE2EE = "decrypt"

//This can actually be changed
var DefaultToUnrevoked = false
23 changes: 11 additions & 12 deletions engine/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,18 @@ func (e *Engine) syncLoop() {
syncup <- true
resolvedEnt, st, err := e.ws.GetEntityByHashSchemeInstanceP(e.ctx, &iapi.HashSchemeInstance_Keccak_256{Val: ent[:]})
if err != nil {
panic(err)
}

if resolvedEnt == nil {
panic("synchronize nil entity?")
}
if st.ValidActive {
//fmt.Printf(">syncE\n")
err = e.synchronizeEntity(e.ctx, resolvedEnt)
if err != nil {
panic(err)
fmt.Printf("Failed to synchronize entity: %v\n", err)
} else if resolvedEnt == nil {
fmt.Printf("Failed to synchronize entity: not found\n")
} else {
if st.ValidActive {
//fmt.Printf(">syncE\n")
err = e.synchronizeEntity(e.ctx, resolvedEnt)
if err != nil {
fmt.Printf("Failed to synchronize entity: %v\n", err)
}
//fmt.Printf("<syncE\n")
}
//fmt.Printf("<syncE\n")
}
e.totalMutex.Lock()
e.totalCompletedSyncs++
Expand Down
8 changes: 8 additions & 0 deletions engine/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package engine

import (
"context"
"fmt"
"time"

"github.com/immesys/wave/consts"
"github.com/immesys/wave/iapi"
)

Expand Down Expand Up @@ -87,6 +89,7 @@ func (e *Engine) revoked(r iapi.RevocationSchemeInstance) (bool, error) {
if isCachedRevocationCheck(r.Id()) {
return false, nil
}

ts, err := e.ws.GetRevocationCheck(e.ctx, r.Id())
if err != nil {
return false, err
Expand All @@ -106,6 +109,11 @@ func (e *Engine) revoked(r iapi.RevocationSchemeInstance) (bool, error) {
if docheck {
isRevoked, err := r.IsRevoked(e.ctx, iapi.SI())
if err != nil {
if consts.DefaultToUnrevoked {
fmt.Printf("WARNING: Got Storage Error: %v APPLYING DEFAULT UNREVOKED\n", err)
cacheRevocationCheck(r.Id())
return false, nil
}
return false, err
}
if !isRevoked {
Expand Down
11 changes: 6 additions & 5 deletions waved/configparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
)

type Configuration struct {
Database string
ListenIP string
HTTPListenIP string
ListenUnix string
Storage map[string]map[string]string
Database string
ListenIP string
HTTPListenIP string
ListenUnix string
DefaultToUnrevoked bool
Storage map[string]map[string]string
}

func ParseConfig(file string) (*Configuration, error) {
Expand Down
5 changes: 5 additions & 0 deletions waved/wave.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ database = "/var/lib/wave/db"
listenIp = "127.0.0.1:777"
httpListenIp = "127.0.0.1:778"

# If you cannot reach storage, is the entity revoked or not?
defaultToUnrevoked = false

[storage]


# This is the default development server
[storage.default]
provider = "http_v1"
Expand Down
3 changes: 3 additions & 0 deletions waved/waved.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"time"

"github.com/immesys/wave/consts"
"github.com/immesys/wave/eapi"
"github.com/immesys/wave/iapi"
"github.com/immesys/wave/localdb/lls"
Expand Down Expand Up @@ -53,6 +54,8 @@ func MainWithConfig(c *Configuration) {
os.Exit(1)
}

consts.DefaultToUnrevoked = c.DefaultToUnrevoked

iapi.InjectStorageInterface(si)

ws := poc.NewPOC(llsdb)
Expand Down

0 comments on commit 45ef2a1

Please sign in to comment.