Skip to content
Snippets Groups Projects
Commit 1687bbd9 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

ephid flag

parent 28794268
No related branches found
No related tags found
2 merge requests!510Release,!304pickup subcommand
...@@ -152,4 +152,5 @@ const ( ...@@ -152,4 +152,5 @@ const (
///////////////// pickup subcommand flags ////////////////////////////// ///////////////// pickup subcommand flags //////////////////////////////
pickupGW = "gateway" pickupGW = "gateway"
pickupID = "id" pickupID = "id"
pickupEphID = "ephid"
) )
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
package cmd package cmd
import ( import (
"encoding/binary"
"fmt" "fmt"
"time" "time"
...@@ -55,22 +56,37 @@ var pickupCmd = &cobra.Command{ ...@@ -55,22 +56,37 @@ var pickupCmd = &cobra.Command{
ndf := user.GetStorage().GetNDF() ndf := user.GetStorage().GetNDF()
gwID := getGatewayID(ndf) gwID := getGatewayID(ndf)
clientID := parseRecipient(viper.GetString(pickupID)) clientIDStr := viper.GetString(pickupID)
var clientID *id.ID
if clientIDStr != "" {
clientID = parseRecipient(viper.GetString(pickupID))
}
eID := viper.GetInt64(pickupEphID)
if eID != 0 {
fmt.Printf("EphID Override: %d\n", eID)
}
// First we get round info, then we use the timestamps to // First we get round info, then we use the timestamps to
// calculate the right ephID and retrieve the right bloom filter // calculate the right ephID and retrieve the right bloom filter
roundInfos := dumpRounds(roundIDs, user) roundInfos := dumpRounds(roundIDs, user)
for i := range roundInfos { for i := range roundInfos {
ri := roundInfos[i] ri := roundInfos[i]
ephIDs := getEphID(clientID, uint(ri.AddressSpaceSize), var ephIDs []ephemeral.Id
if clientID != nil {
ephIDs = getEphID(clientID,
uint(ri.AddressSpaceSize),
ri.Timestamps[states.QUEUED]) ri.Timestamps[states.QUEUED])
} else {
ephIDs = append(ephIDs, int2EphID(eID,
uint(ri.AddressSpaceSize)))
}
for j := range ephIDs { for j := range ephIDs {
ephID := ephIDs[j] ephID := ephIDs[j]
fmt.Printf("Getting messages for %s, %d\n", fmt.Printf("Getting messages for %s, %d\n",
ri.ID, ephID.Id.Int64()) ri.ID, ephID.Int64())
msgRsp, err := getMessagesFromRound(gwID, ri.ID, msgRsp, err := getMessagesFromRound(gwID, ri.ID,
ephID.Id, ephID,
user.GetComms()) user.GetComms())
if err != nil { if err != nil {
fmt.Printf("\n\nround pickup: %+v\n\n", fmt.Printf("\n\nround pickup: %+v\n\n",
...@@ -95,11 +111,37 @@ func init() { ...@@ -95,11 +111,37 @@ func init() {
"id to check") "id to check")
bindFlagHelper(pickupID, pickupCmd) bindFlagHelper(pickupID, pickupCmd)
pickupCmd.Flags().Int64P(pickupEphID, "e", 0,
"ignore id lookup and use this specific eph id (signed int)")
bindFlagHelper(pickupEphID, pickupCmd)
rootCmd.AddCommand(pickupCmd) rootCmd.AddCommand(pickupCmd)
} }
func int2EphID(in int64, addrSize uint) ephemeral.Id {
var out [8]byte
mask := uint64(0xFFFFFFFFFFFFFFFF) >> (64 - addrSize)
// NOTE: This is just reversing the Int64() function. I have
// no idea why it was done this way...
x := in
if x < 0 {
x = ^x
x = x << 1
x = x | 1
} else {
x = x << 1
}
shifted := uint64(x) & mask
fmt.Printf("Shifted: %d, %d, %d, %d\n", addrSize, mask, in, shifted)
binary.BigEndian.PutUint64(out[:], shifted)
return ephemeral.Id(out)
}
func getEphID(id *id.ID, addrSize uint, func getEphID(id *id.ID, addrSize uint,
roundStart time.Time) []ephemeral.ProtoIdentity { roundStart time.Time) []ephemeral.Id {
fmt.Printf("Getting EphIDs for %s", roundStart) fmt.Printf("Getting EphIDs for %s", roundStart)
...@@ -115,7 +157,12 @@ func getEphID(id *id.ID, addrSize uint, ...@@ -115,7 +157,12 @@ func getEphID(id *id.ID, addrSize uint,
jww.FATAL.Panicf("No ephemeral ids found!") jww.FATAL.Panicf("No ephemeral ids found!")
} }
return ephIDs eIDs := make([]ephemeral.Id, len(ephIDs))
for i := range ephIDs {
eIDs[i] = ephIDs[i].Id
}
return eIDs
} }
func getGatewayID(ndf *ndf.NetworkDefinition) *id.ID { func getGatewayID(ndf *ndf.NetworkDefinition) *id.ID {
gateways := ndf.Gateways gateways := ndf.Gateways
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment