Browse Source

auto delete timestamp works

afeiszli 4 years ago
parent
commit
5725530d56
7 changed files with 97 additions and 71 deletions
  1. 9 11
      controllers/common.go
  2. 1 0
      controllers/nodeGrpcController.go
  3. 62 53
      grpc/node.pb.go
  4. 1 0
      grpc/node.proto
  5. 8 0
      models/node.go
  6. 1 0
      models/structs.go
  7. 15 7
      netclient/functions/common.go

+ 9 - 11
controllers/common.go

@@ -137,6 +137,9 @@ func UpdateNode(nodechange models.Node, node models.Node) (models.Node, error) {
     if nodechange.ListenPort != 0 {
     if nodechange.ListenPort != 0 {
         node.ListenPort = nodechange.ListenPort
         node.ListenPort = nodechange.ListenPort
     }
     }
+    if nodechange.ExpirationDateTime != 0 {
+        node.ExpirationDateTime = nodechange.ExpirationDateTime
+    }
     if nodechange.PreUp != "" {
     if nodechange.PreUp != "" {
         node.PreUp = nodechange.PreUp
         node.PreUp = nodechange.PreUp
     }
     }
@@ -197,6 +200,7 @@ func UpdateNode(nodechange models.Node, node models.Node) (models.Node, error) {
                         {"listenport", node.ListenPort},
                         {"listenport", node.ListenPort},
                         {"publickey", node.PublicKey},
                         {"publickey", node.PublicKey},
                         {"keyupdatetimestamp", node.KeyUpdateTimeStamp},
                         {"keyupdatetimestamp", node.KeyUpdateTimeStamp},
+                        {"expdatetime", node.ExpirationDateTime},
                         {"endpoint", node.Endpoint},
                         {"endpoint", node.Endpoint},
                         {"postup", node.PostUp},
                         {"postup", node.PostUp},
                         {"preup", node.PreUp},
                         {"preup", node.PreUp},
@@ -387,23 +391,17 @@ func NodeCheckIn(node models.Node, groupName string) (models.CheckInResponse, er
 	if nkeyupdate < gkeyupdate {
 	if nkeyupdate < gkeyupdate {
 		response.NeedKeyUpdate = true
 		response.NeedKeyUpdate = true
 	}
 	}
-	/*
-	if postchanges {
-		parentnode, err = UpdateNode(node, parentnode)
-	        if err != nil{
-			err = fmt.Errorf("%w; Couldnt Update Node: ", err)
-			return response, err
-		} else {
-			response.NodeUpdated = true
-		}
-	}
-	*/
+        if time.Now().Unix() > parentnode.ExpirationDateTime {
+                response.NeedDelete = true
+		_, err =  DeleteNode(node.MacAddress, groupName)
+        } else {
 	err = TimestampNode(parentnode, true,  false, false)
 	err = TimestampNode(parentnode, true,  false, false)
 
 
 	if err != nil{
 	if err != nil{
 		err = fmt.Errorf("%w; Couldnt Timestamp Node: ", err)
 		err = fmt.Errorf("%w; Couldnt Timestamp Node: ", err)
 		return response, err
 		return response, err
 	}
 	}
+	}
 	response.Success = true
 	response.Success = true
 
 
         return response, err
         return response, err

+ 1 - 0
controllers/nodeGrpcController.go

@@ -171,6 +171,7 @@ func (s *NodeServiceServer) CheckIn(ctx context.Context, req *nodepb.CheckInReq)
                 Checkinresponse: &nodepb.CheckInResponse{
                 Checkinresponse: &nodepb.CheckInResponse{
                         Success:  checkinresponse.Success,
                         Success:  checkinresponse.Success,
                         Needpeerupdate:  checkinresponse.NeedPeerUpdate,
                         Needpeerupdate:  checkinresponse.NeedPeerUpdate,
+                        Needdelete:  checkinresponse.NeedDelete,
                         Needconfigupdate:  checkinresponse.NeedConfigUpdate,
                         Needconfigupdate:  checkinresponse.NeedConfigUpdate,
                         Needkeyupdate:  checkinresponse.NeedKeyUpdate,
                         Needkeyupdate:  checkinresponse.NeedKeyUpdate,
                         Nodemessage:  checkinresponse.NodeMessage,
                         Nodemessage:  checkinresponse.NodeMessage,

+ 62 - 53
grpc/node.pb.go

@@ -312,6 +312,7 @@ type CheckInResponse struct {
 	Nodemessage          string   `protobuf:"bytes,4,opt,name=nodemessage,proto3" json:"nodemessage,omitempty"`
 	Nodemessage          string   `protobuf:"bytes,4,opt,name=nodemessage,proto3" json:"nodemessage,omitempty"`
 	Ispending            bool     `protobuf:"varint,5,opt,name=ispending,proto3" json:"ispending,omitempty"`
 	Ispending            bool     `protobuf:"varint,5,opt,name=ispending,proto3" json:"ispending,omitempty"`
 	Needkeyupdate        bool     `protobuf:"varint,6,opt,name=needkeyupdate,proto3" json:"needkeyupdate,omitempty"`
 	Needkeyupdate        bool     `protobuf:"varint,6,opt,name=needkeyupdate,proto3" json:"needkeyupdate,omitempty"`
+	Needdelete           bool     `protobuf:"varint,7,opt,name=needdelete,proto3" json:"needdelete,omitempty"`
 	XXX_NoUnkeyedLiteral struct{} `json:"-"`
 	XXX_NoUnkeyedLiteral struct{} `json:"-"`
 	XXX_unrecognized     []byte   `json:"-"`
 	XXX_unrecognized     []byte   `json:"-"`
 	XXX_sizecache        int32    `json:"-"`
 	XXX_sizecache        int32    `json:"-"`
@@ -384,6 +385,13 @@ func (m *CheckInResponse) GetNeedkeyupdate() bool {
 	return false
 	return false
 }
 }
 
 
+func (m *CheckInResponse) GetNeeddelete() bool {
+	if m != nil {
+		return m.Needdelete
+	}
+	return false
+}
+
 type PeersResponse struct {
 type PeersResponse struct {
 	Publickey            string   `protobuf:"bytes,5,opt,name=publickey,proto3" json:"publickey,omitempty"`
 	Publickey            string   `protobuf:"bytes,5,opt,name=publickey,proto3" json:"publickey,omitempty"`
 	Endpoint             string   `protobuf:"bytes,6,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
 	Endpoint             string   `protobuf:"bytes,6,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
@@ -978,57 +986,58 @@ func init() {
 func init() { proto.RegisterFile("grpc/node.proto", fileDescriptor_d13bd996b67da4ef) }
 func init() { proto.RegisterFile("grpc/node.proto", fileDescriptor_d13bd996b67da4ef) }
 
 
 var fileDescriptor_d13bd996b67da4ef = []byte{
 var fileDescriptor_d13bd996b67da4ef = []byte{
-	// 827 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x5b, 0x6f, 0xe3, 0x44,
-	0x14, 0x56, 0xba, 0xb9, 0x9e, 0x34, 0x4d, 0x77, 0xda, 0x45, 0x23, 0x6b, 0xb5, 0x8a, 0x2c, 0x84,
-	0xb2, 0x88, 0x26, 0xa5, 0x48, 0x88, 0x37, 0x24, 0x8a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 0x72, 0xd9, 0x1a,
-	0xc1, 0xce, 0x6b, 0x23, 0xea, 0xbb, 0xe5, 0x1f, 0x37, 0xb1, 0x10, 0x71, 0x8a, 0x8b, 0x58, 0xa4,
-	0x8c, 0xc7, 0x0b, 0x91, 0xc5, 0x4b, 0xf3, 0xcd, 0xb3, 0x2a, 0xd6, 0xcb, 0xfc, 0x41, 0xa2, 0x5a,
-	0x6e, 0xb8, 0xf8, 0xc0, 0xcd, 0xd7, 0x90, 0x5c, 0xad, 0xfa, 0xe6, 0xf1, 0xab, 0x7f, 0x03, 0x00,
-	0x00, 0xff, 0xff, 0x32, 0x60, 0x03, 0x3b, 0x23, 0x09, 0x00, 0x00,
+	// 839 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xdd, 0x6e, 0xe3, 0x44,
+	0x14, 0x56, 0xb2, 0x49, 0xe3, 0x9c, 0x34, 0x6d, 0x77, 0xda, 0x45, 0x23, 0x6b, 0xb5, 0x8a, 0x2c,
+	0x84, 0xb2, 0x88, 0x26, 0xa5, 0x48, 0x88, 0x3b, 0x24, 0x8a, 0x84, 0x40, 0xb0, 0x42, 0x46, 0xdc,
+	0x70, 0x37, 0xb1, 0x4f, 0xbc, 0x56, 0x9c, 0x99, 0x89, 0xc7, 0xce, 0xaa, 0x0f, 0xc0, 0xa3, 0xf1,
+	0x46, 0x5c, 0x72, 0x81, 0xe6, 0xc7, 0xf1, 0x4f, 0x43, 0xb7, 0xf4, 0x2e, 0xe7, 0x9b, 0xf3, 0x7f,
+	0xbe, 0x73, 0x62, 0x38, 0x4f, 0x72, 0x19, 0x2d, 0xb9, 0x88, 0x71, 0x21, 0x73, 0x51, 0x08, 0x32,
+	0xd0, 0xbf, 0x83, 0x9f, 0xe0, 0xf4, 0x67, 0x91, 0xa4, 0x3c, 0xc4, 0x5d, 0x89, 0xaa, 0x20, 0x6f,
+	0x00, 0xb6,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 0x43, 0x09, 0x00, 0x00,
 }
 }

+ 1 - 0
grpc/node.proto

@@ -50,6 +50,7 @@ message CheckInResponse {
     string nodemessage = 4;
     string nodemessage = 4;
     bool ispending = 5;
     bool ispending = 5;
     bool needkeyupdate = 6;
     bool needkeyupdate = 6;
+    bool needdelete = 7;
 }
 }
 
 
 message PeersResponse {
 message PeersResponse {

+ 8 - 0
models/node.go

@@ -32,6 +32,7 @@ type Node struct {
 	Interface	string `json:"interface" bson:"interface"`
 	Interface	string `json:"interface" bson:"interface"`
 	LastModified	int64 `json:"lastmodified" bson:"lastmodified"`
 	LastModified	int64 `json:"lastmodified" bson:"lastmodified"`
 	KeyUpdateTimeStamp	int64 `json:"keyupdatetimestamp" bson:"keyupdatetimestamp"`
 	KeyUpdateTimeStamp	int64 `json:"keyupdatetimestamp" bson:"keyupdatetimestamp"`
+	ExpirationDateTime	int64 `json:"expdatetime" bson:"expdatetime"`
 	LastPeerUpdate	int64 `json:"lastpeerupdate" bson:"lastpeerupdate"`
 	LastPeerUpdate	int64 `json:"lastpeerupdate" bson:"lastpeerupdate"`
 	LastCheckIn	int64 `json:"lastcheckin" bson:"lastcheckin"`
 	LastCheckIn	int64 `json:"lastcheckin" bson:"lastcheckin"`
 	MacAddress	string `json:"macaddress" bson:"macaddress" validate:"required,macaddress_valid,macaddress_unique"`
 	MacAddress	string `json:"macaddress" bson:"macaddress" validate:"required,macaddress_valid,macaddress_unique"`
@@ -82,6 +83,11 @@ func(node *Node) SetLastPeerUpdate(){
         node.LastPeerUpdate = time.Now().Unix()
         node.LastPeerUpdate = time.Now().Unix()
 }
 }
 
 
+func(node *Node) SetExpirationDateTime(){
+        node.ExpirationDateTime = time.Unix(1<<63-62135596801, 999999999).Unix()
+}
+
+
 func(node *Node) SetDefaultName(){
 func(node *Node) SetDefaultName(){
     if node.Name == "" {
     if node.Name == "" {
         nodeid := StringWithCharset(5, charset)
         nodeid := StringWithCharset(5, charset)
@@ -97,6 +103,8 @@ func(node *Node) SetDefaults() {
     //TODO: Maybe I should make Group a part of the node struct. Then we can just query the Group object for stuff.
     //TODO: Maybe I should make Group a part of the node struct. Then we can just query the Group object for stuff.
     parentGroup, _ := node.GetGroup()
     parentGroup, _ := node.GetGroup()
 
 
+    node.ExpirationDateTime = time.Unix(1<<63-62135596801, 999999999).Unix()
+
     if node.ListenPort == 0 {
     if node.ListenPort == 0 {
         node.ListenPort = parentGroup.DefaultListenPort
         node.ListenPort = parentGroup.DefaultListenPort
     }
     }

+ 1 - 0
models/structs.go

@@ -85,6 +85,7 @@ type CheckInResponse struct{
     NeedPeerUpdate bool `json:"needpeerupdate" bson:"needpeerupdate"`
     NeedPeerUpdate bool `json:"needpeerupdate" bson:"needpeerupdate"`
     NeedConfigUpdate bool `json:"needconfigupdate" bson:"needconfigupdate"`
     NeedConfigUpdate bool `json:"needconfigupdate" bson:"needconfigupdate"`
     NeedKeyUpdate bool `json:"needkeyupdate" bson:"needkeyupdate"`
     NeedKeyUpdate bool `json:"needkeyupdate" bson:"needkeyupdate"`
+    NeedDelete bool `json:"needdelete" bson:"needdelete"`
     NodeMessage string `json:"nodemessage" bson:"nodemessage"`
     NodeMessage string `json:"nodemessage" bson:"nodemessage"`
     IsPending bool `json:"ispending" bson:"ispending"`
     IsPending bool `json:"ispending" bson:"ispending"`
 }
 }

+ 15 - 7
netclient/functions/common.go

@@ -327,7 +327,7 @@ func Install(accesskey string, password string, server string, group string, noa
                 return err
                 return err
         }
         }
 	fmt.Println("retrived peers, setting wireguard config.")
 	fmt.Println("retrived peers, setting wireguard config.")
-	err = storePrivKey(privkeystring)
+	err = storePrivKey(privkeystring, group)
         if err != nil {
         if err != nil {
                 return err
                 return err
         }
         }
@@ -613,7 +613,7 @@ func setWGKeyConfig(network string, serveraddr string) error {
 
 
 	node.Publickey = publickey.String()
 	node.Publickey = publickey.String()
 
 
-	err = storePrivKey(privkeystring)
+	err = storePrivKey(privkeystring, network)
         if err != nil {
         if err != nil {
                 return err
                 return err
         }
         }
@@ -657,7 +657,7 @@ func setWGConfig(network string) error {
         if err != nil {
         if err != nil {
                 return err
                 return err
         }
         }
-	privkey, err := retrievePrivKey()
+	privkey, err := retrievePrivKey(network)
         if err != nil {
         if err != nil {
                 return err
                 return err
         }
         }
@@ -670,14 +670,14 @@ func setWGConfig(network string) error {
 	return err
 	return err
 }
 }
 
 
-func storePrivKey(key string) error{
+func storePrivKey(key string, network string) error{
 	d1 := []byte(key)
 	d1 := []byte(key)
-	err := ioutil.WriteFile("/etc/netclient/wgkey", d1, 0644)
+	err := ioutil.WriteFile("/etc/netclient/wgkey-" + network, d1, 0644)
 	return err
 	return err
 }
 }
 
 
-func retrievePrivKey() (string, error) {
-	dat, err := ioutil.ReadFile("/etc/netclient/wgkey")
+func retrievePrivKey(network string) (string, error) {
+	dat, err := ioutil.ReadFile("/etc/netclient/wgkey-" + network)
 	return string(dat), err
 	return string(dat), err
 }
 }
 
 
@@ -929,6 +929,14 @@ func CheckIn(network string) error {
                 }
                 }
 		setupcheck = false
 		setupcheck = false
         }
         }
+	if checkinres.Checkinresponse.Needdelete {
+		fmt.Println("This machine got the delete signal. Deleting.")
+                err := Remove(network)
+                if err != nil {
+                        return err
+                        log.Fatalf("Error: %v", err)
+                }
+	}
 	if setupcheck {
 	if setupcheck {
 	iface := nodecfg.Interface
 	iface := nodecfg.Interface
 	_, err := net.InterfaceByName(iface)
 	_, err := net.InterfaceByName(iface)