Skip to content
Snippets Groups Projects
Commit f5ddfa0a authored by Jake Taylor's avatar Jake Taylor
Browse files

bug fixes

parent 72fb92a6
No related branches found
No related tags found
No related merge requests found
......@@ -244,6 +244,8 @@ func (h *HostPool) pruneHostPool() error {
}
poolIdx++
}
} else {
poolIdx++
}
}
return nil
......
......@@ -38,23 +38,30 @@ func NewSender(poolParams PoolParams, rng io.Reader, ndf *ndf.NetworkDefinition,
// SendToSpecific Call given sendFunc to a specific Host in the HostPool,
// attempting with up to numProxies destinations in case of failure
func (m *Sender) SendToSpecific(target *id.ID,
sendFunc func(host *connect.Host, target *id.ID) (interface{}, error)) (interface{}, error) {
sendFunc func(host *connect.Host, target *id.ID) (interface{}, bool, error)) (interface{}, error) {
host, ok := m.getSpecific(target)
if ok {
result, err := sendFunc(host, target)
result, didAbort, err := sendFunc(host, target)
if err == nil {
return result, m.forceAdd([]*id.ID{host.GetId()})
} else {
if didAbort {
return nil, errors.WithMessagef(err, "Aborted SendToSpecific gateway %s", host.GetId().String())
}
jww.WARN.Printf("Unable to SendToSpecific %s: %+v", host.GetId().String(), err)
}
}
proxies := m.getAny(m.poolParams.ProxyAttempts, []*id.ID{target})
for proxyIdx := 0; proxyIdx < len(proxies); proxyIdx++ {
result, err := sendFunc(proxies[proxyIdx], target)
result, didAbort, err := sendFunc(proxies[proxyIdx], target)
if err == nil {
return result, nil
} else {
if didAbort {
return nil, errors.WithMessagef(err, "Aborted SendToSpecific gateway proxy %s",
host.GetId().String())
}
jww.WARN.Printf("Unable to SendToSpecific proxy %s: %+v", proxies[proxyIdx].GetId().String(), err)
}
}
......
......@@ -181,21 +181,16 @@ func sendCmixHelper(sender *gateway.Sender, msg format.Message, recipient *id.ID
encMsg.Digest(), firstGateway.String())
// Send the payload
result, err := sender.SendToSpecific(firstGateway, func(host *connect.Host, target *id.ID) (interface{}, error) {
result, err := sender.SendToSpecific(firstGateway, func(host *connect.Host, target *id.ID) (interface{}, bool, error) {
wrappedMsg.Target = target.Marshal()
return comms.SendPutMessage(host, wrappedMsg)
})
gwSlotResp := result.(*pb.GatewaySlotResponse)
//if the comm errors or the message fails to send, continue retrying.
//return if it sends properly
result, err := comms.SendPutMessage(host, wrappedMsg)
if err != nil {
if strings.Contains(err.Error(),
"try a different round.") {
jww.WARN.Printf("Failed to send to %s (msgDigest: %s) "+
"due to round error with round %d, retrying: %+v",
recipient, msg.Digest(), bestRound.ID, err)
continue
return nil, true, err
} else if strings.Contains(err.Error(),
"Could not authenticate client. Is the client registered "+
"with this node?") {
......@@ -210,12 +205,21 @@ func sendCmixHelper(sender *gateway.Sender, msg format.Message, recipient *id.ID
session.Cmix().Remove(nodeID)
//trigger
go handleMissingNodeKeys(instance, nodeRegistration, []*id.ID{nodeID})
continue
return nil, true, err
}
}
return result, false, err
})
jww.FATAL.Printf("TEST500")
gwSlotResp := result.(*pb.GatewaySlotResponse)
//if the comm errors or the message fails to send, continue retrying.
//return if it sends properly
if err != nil {
jww.ERROR.Printf("Failed to send to EphID %d (%s) on "+
"round %d, bailing: %+v", ephID.Int64(), recipient,
"round %d, trying a new round: %+v", ephID.Int64(), recipient,
bestRound.ID, err)
return 0, ephemeral.Id{}, errors.WithMessage(err, "Failed to put cmix message")
continue
} else if gwSlotResp.Accepted {
jww.INFO.Printf("Successfully sent to EphID %v (source: %s) "+
"in round %d", ephID.Int64(), recipient, bestRound.ID)
......
......@@ -127,7 +127,7 @@ func registerWithNode(sender *gateway.Sender, comms RegisterNodeCommsInterface,
serverPubDH := store.GetGroup().NewIntFromBytes(dhPub)
// Confirm received nonce
jww.INFO.Println("Register: Confirming received nonce from node %s", nodeID.String())
jww.INFO.Printf("Register: Confirming received nonce from node %s", nodeID.String())
err = confirmNonce(sender, comms, uci.GetTransmissionID().Bytes(),
nonce, uci.GetTransmissionRSA(), gatewayID)
if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment