Commit 9de8dd58 authored by Loïck Bonniot's avatar Loïck Bonniot

Merge branch 'master' into 0.3

parents 4ee28acc 3fa6461a
......@@ -22,14 +22,15 @@ var unregisterCmd = &cobra.Command{
}
// Confirmation
var ready string
var passphrase, ready string
_ = readPassword(&passphrase, false)
readStringParam("Do you REALLY want to delete "+cert.Subject.CommonName+"? Type 'yes' to confirm", "", &ready)
if ready != "yes" {
fmt.Fprintln(os.Stderr, "Unregistering aborted!")
os.Exit(1)
}
err = user.Unregister()
err = user.Unregister(passphrase)
if err != nil {
fmt.Fprintln(os.Stderr, "Cannot unregister:", err.Error())
os.Exit(2)
......
package user
import (
"errors"
pb "dfss/dfssp/api"
"dfss/dfssc/common"
"dfss/dfssc/security"
"dfss/dfssp/api"
"dfss/net"
"github.com/spf13/viper"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
// Unregister a user from the platform
func Unregister() error {
client, err := connect()
func Unregister(passphrase string) error {
auth := security.NewAuthContainer(passphrase)
ca, cert, key, err := auth.LoadFiles()
if err != nil {
return err
}
conn, err := net.Connect(viper.GetString("platform_addrport"), cert, key, ca, nil)
if err != nil {
return err
}
// Stop the context if it takes too long for the platform to answer
client := api.NewPlatformClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), net.DefaultTimeout)
defer cancel()
response, err := client.Unregister(ctx, &pb.Empty{})
response, err := client.Unregister(ctx, &api.Empty{})
if err != nil {
return errors.New(grpc.ErrorDesc(err))
}
if response.Code != pb.ErrorCode_SUCCESS {
return errors.New(response.Message)
return err
}
return nil
return common.EvaluateErrorCodeResponse(response)
}
......@@ -33,8 +33,9 @@ var ReadySignTimeout = time.Minute
func ReadySign(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, ctx *context.Context, in *api.ReadySignRequest) *api.LaunchSignature {
roomID := "ready_" + in.ContractUuid
channel, _, first := rooms.Join(roomID)
cn := net.GetCN(ctx)
defer rooms.Unjoin(roomID, channel)
cn := net.GetCN(ctx)
// Check UUID
if !bson.IsObjectIdHex(in.ContractUuid) {
return &api.LaunchSignature{ErrorCode: &api.ErrorCode{Code: api.ErrorCode_INVARG}}
......@@ -71,10 +72,8 @@ func ReadySign(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, ctx *contex
return &api.LaunchSignature{ErrorCode: &api.ErrorCode{Code: api.ErrorCode_INVARG}}
}
case <-(*ctx).Done(): // Client's disconnection
rooms.Unjoin(roomID, channel)
return &api.LaunchSignature{ErrorCode: &api.ErrorCode{Code: api.ErrorCode_INVARG}}
case <-timeout: // Someone has not confirmed the signature within the delay
rooms.Unjoin(roomID, channel)
return &api.LaunchSignature{ErrorCode: &api.ErrorCode{Code: api.ErrorCode_TIMEOUT, Message: "timeout for ready signal"}}
}
}
......@@ -86,6 +85,7 @@ func ReadySign(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, ctx *contex
func masterReadyRoutine(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, contractUUID string) {
roomID := "ready_" + contractUUID
channel, oldMessages, _ := rooms.Join(roomID)
defer rooms.Unjoin(roomID, channel)
// Push oldMessages into the channel.
// It is safe as this sould be a very small slice (the room is just created).
......@@ -102,7 +102,6 @@ func masterReadyRoutine(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, co
ready: true,
data: "",
}) // This represents a "error" response
rooms.Unjoin(roomID, channel)
return
}
......@@ -132,7 +131,6 @@ func masterReadyRoutine(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, co
}
}
rooms.Unjoin(roomID, channel)
}
// FindAndUpdatePendingSigner is a utility function to return the state of current signers readiness.
......
......@@ -9,7 +9,7 @@ import (
)
// Version represents the current version of the DFSS software suite
const Version = "0.3.0"
const Version = "0.3.1"
// VersionCmd is the cobra command common to all dfss modules
var VersionCmd = &cobra.Command{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment