Skip to content
Snippets Groups Projects
Commit 9b86c3b0 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

minor bug fixes and logging improvements

parent fbcdd950
No related branches found
No related tags found
2 merge requests!53Release,!26Protonet
......@@ -247,10 +247,7 @@ var rootCmd = &cobra.Command{
}
}
fmt.Printf("Received %d\n", receiveCnt)
jww.DEBUG.Printf("TestPrintthisshit")
fmt.Printf("Verbose round information: %s",
client.GetNetworkInterface().GetVerboseRounds())
jww.DEBUG.Printf("printedVerboseRounds")
roundsNotepad.INFO.Printf("\n%s", client.GetNetworkInterface().GetVerboseRounds())
err = client.StopNetworkFollower()
if err != nil {
jww.WARN.Printf(
......@@ -663,16 +660,19 @@ func initLog(threshold uint, logPath string) {
jww.SetLogOutput(logOutput)
}
if threshold > 1 {
jww.INFO.Printf("log level set to: TRACE")
jww.SetStdoutThreshold(jww.LevelTrace)
jww.SetLogThreshold(jww.LevelTrace)
jww.SetFlags(log.LstdFlags | log.Lmicroseconds)
initRoundLog(logPath)
} else if threshold == 1 {
jww.INFO.Printf("log level set to: DEBUG")
jww.SetStdoutThreshold(jww.LevelDebug)
jww.SetLogThreshold(jww.LevelDebug)
jww.SetFlags(log.LstdFlags | log.Lmicroseconds)
initRoundLog(logPath)
} else {
jww.INFO.Printf("log level set to: INFO")
jww.SetStdoutThreshold(jww.LevelInfo)
......@@ -696,6 +696,18 @@ func askToCreateChannel(recipientID *id.ID) bool {
}
}
var roundsNotepad *jww.Notepad
func initRoundLog(logPath string) {
parts := strings.Split(logPath,".")
path := parts[0] + "-rounds." + parts[1]
logOutput, err := os.OpenFile(path,
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
panic(err.Error())
}
roundsNotepad = jww.NewNotepad(jww.LevelInfo,jww.LevelInfo,ioutil.Discard,logOutput,"",log.Ldate|log.Ltime)
}
// init is the initialization function for Cobra which defines commands
// and flags.
func init() {
......
......@@ -269,7 +269,7 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source,
}
if len(pollResp.Filters.Filters) == 0 {
jww.TRACE.Printf("No filters found for the passed ID %d (%s), "+
jww.WARN.Printf("No filters found for the passed ID %d (%s), "+
"skipping processing.", identity.EphId.Int64(), identity.Source)
return
}
......@@ -279,6 +279,7 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source,
//check if there are any valid filters returned
if outOfBounds {
jww.WARN.Printf("No filters processed, none in valid range")
return
}
......@@ -304,7 +305,15 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source,
// move the earliest unknown round tracker forward to the earliest
// tracked round if it is behind
earliestTrackedRound := id.Round(pollResp.EarliestRound)
updated, _ := identity.ER.Set(earliestTrackedRound)
updated, old, _ := identity.ER.Set(earliestTrackedRound)
if old == 0 {
if gwRoundsState.GetLastChecked()> id.Round(m.param.KnownRoundsThreshold){
updated = gwRoundsState.GetLastChecked() - id.Round(m.param.KnownRoundsThreshold)
}else{
updated = 1
}
identity.ER.Set(updated)
}
// loop through all rounds the client does not know about and the gateway
// does, checking the bloom filter for the user to see if there are
......@@ -312,7 +321,8 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source,
//threshold is the earliest round that will not be excluded from earliest remaining
earliestRemaining, roundsWithMessages, roundsUnknown := gwRoundsState.RangeUnchecked(updated,
m.param.KnownRoundsThreshold, roundChecker)
_, changed := identity.ER.Set(earliestRemaining)
_, _, changed := identity.ER.Set(earliestRemaining)
if changed {
jww.TRACE.Printf("External returns of RangeUnchecked: %d, %v, %v", earliestRemaining, roundsWithMessages, roundsUnknown)
jww.DEBUG.Printf("New Earliest Remaining: %d", earliestRemaining)
......
......@@ -52,8 +52,13 @@ func (s *Sender) SendToAny(sendFunc func(host *connect.Host) (interface{}, error
jww.WARN.Printf("Unable to SendToAny via %s: proxy could not contact requested host: %s",
proxies[proxy].GetId().String(), err)
}else if replaced, checkReplaceErr := s.checkReplace(proxies[proxy].GetId(), err); replaced{
jww.WARN.Printf("Unable to SendToAny, replaced a proxy %s: %s",
if checkReplaceErr!=nil{
jww.WARN.Printf("Unable to SendToAny, replaced a proxy %s with error %s",
proxies[proxy].GetId().String(), checkReplaceErr)
}else{
jww.WARN.Printf("Unable to SendToAny, replaced a proxy %s",
proxies[proxy].GetId().String())
}
}else{
return nil, errors.WithMessage(err,"Received error from remote")
}
......@@ -79,10 +84,20 @@ func (s *Sender) SendToPreferred(targets []*id.ID,
return result, nil
} else if strings.Contains(err.Error(),"unable to connect to target host") {
// Retry of the proxy could not communicate
jww.WARN.Printf("Unable to SendToPreferred first pass %s via %s: %s, proxy could not contact requested host",
jww.WARN.Printf("Unable to SendToPreferred first pass %s via %s: %s, " +
"proxy could not contact requested host",
targets[i], targetHosts[i].GetId(), err)
continue
} else if replaced, checkReplaceErr := s.checkReplace(targetHosts[i].GetId(), err); replaced {
if checkReplaceErr!=nil{
jww.WARN.Printf("Unable to SendToPreferred first pass %s via %s, " +
"proxy failed, was replaced with error: %s",
targets[i], targetHosts[i].GetId(), checkReplaceErr)
}else{
jww.WARN.Printf("Unable to SendToPreferred first pass %s via %s, " +
"proxy failed, was replaced",
targets[i], targetHosts[i].GetId())
}
jww.WARN.Printf("Unable to SendToPreferred first pass %s via %s: %s, proxy failed, was replaced",
targets[i], targetHosts[i].GetId(), checkReplaceErr)
continue
......@@ -128,12 +143,20 @@ func (s *Sender) SendToPreferred(targets []*id.ID,
return result, nil
} else if strings.Contains(err.Error(),"unable to connect to target host") {
// Retry of the proxy could not communicate
jww.WARN.Printf("Unable to SendToPreferred second pass %s via %s: %s, proxy could not contact requested host",
jww.WARN.Printf("Unable to SendToPreferred second pass %s via %s: %s," +
" proxy could not contact requested host",
target, proxy, err)
continue
} else if replaced, checkReplaceErr := s.checkReplace(proxy.GetId(), err); replaced {
jww.WARN.Printf("Unable to SendToPreferred second pass %s via %s: %s, proxy failed, was replaced",
target, proxy.GetId(), checkReplaceErr)
if checkReplaceErr!=nil{
jww.WARN.Printf("Unable to SendToPreferred second pass %s via %s," +
"proxy failed, was replaced with error: %s", target, proxy.GetId(),
checkReplaceErr)
}else{
jww.WARN.Printf("Unable to SendToPreferred second pass %s via %s, " +
"proxy failed, was replaced", target, proxy.GetId())
}
badProxies[proxy.String()] = nil
continue
} else {
......
......@@ -25,7 +25,6 @@ import (
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
"gitlab.com/xx_network/primitives/netTime"
"strings"
)
// WARNING: Potentially Unsafe
......@@ -151,16 +150,12 @@ func sendCmixHelper(sender *gateway.Sender, msg format.Message,
//if the comm errors or the message fails to send, continue retrying.
if err != nil {
if !strings.Contains(err.Error(), unrecoverableError) {
jww.ERROR.Printf("SendCmix failed to send to EphID %d (%s) on "+
"round %d, trying a new round: %+v", ephID.Int64(), recipient,
bestRound.ID, err)
continue
}
return 0, ephemeral.Id{}, err
}
// Return if it sends properly
gwSlotResp := result.(*pb.GatewaySlotResponse)
if gwSlotResp.Accepted {
......
......@@ -71,16 +71,19 @@ func (ur *EarliestRound) save() {
}
}
func (ur *EarliestRound) Set(rid id.Round) (id.Round, bool) {
// Set returns the updated earliest round, the old earliest round, and if they are changed.
// Updates the earliest round if it is newer than stored one
func (ur *EarliestRound) Set(rid id.Round) (id.Round, id.Round, bool) {
ur.mux.Lock()
defer ur.mux.Unlock()
changed := false
old := ur.rid
if rid > ur.rid {
changed = true
ur.rid = rid
ur.save()
}
return ur.rid, changed
return ur.rid, old, changed
}
func (ur *EarliestRound) Get() id.Round {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment