Quellcode durchsuchen

NET-1932: Migration Fix (#3470)

* move relevant acl and tag code to CE and Pro pkgs

* intialise pro acl funcs

* list gateways by user access

* check user gw access by policies

* filter out user policies on CE

* filter out tagged policies on CE

* fix ce acl comms

* allow gateways tag

* allow gateway tag  on CE, remove failover and gw check on acl policy

* add gw rules func to pro

* add inet gw support on CE

* add egress acl API

* add egress acl API

* fix(go): set is_gw when converting api node to server node;

* fix(go): set is_gw when converting api node to server node;

* fix policy validity checker for inet gws

* move dns option to host model

* fix node removal from egress policy on delete

* add migration logic for ManageDNS

* fix dns json field

* fix nil error on node tags

* add egress info to relayed nodes

* fix default network user policy

* fix egress migration

* fix egress migration

---------

Co-authored-by: Vishal Dalwadi <[email protected]>
Abhishek K vor 3 Monaten
Ursprung
Commit
c1304aea5e
1 geänderte Dateien mit 13 neuen und 25 gelöschten Zeilen
  1. 13 25
      migrate/migrate.go

+ 13 - 25
migrate/migrate.go

@@ -502,11 +502,6 @@ func migrateToEgressV1() {
 				}
 				err = e.Create(db.WithContext(context.TODO()))
 				if err == nil {
-					node.IsEgressGateway = false
-					node.EgressGatewayRequest = models.EgressGatewayRequest{}
-					node.EgressGatewayNatEnabled = false
-					node.EgressGatewayRanges = []string{}
-					logic.UpsertNode(&node)
 					acl := models.Acl{
 						ID:          uuid.New().String(),
 						Name:        "egress node policy",
@@ -530,7 +525,7 @@ func migrateToEgressV1() {
 							},
 						},
 
-						AllowedDirection: models.TrafficDirectionUni,
+						AllowedDirection: models.TrafficDirectionBi,
 						Enabled:          true,
 						CreatedBy:        "auto",
 						CreatedAt:        time.Now().UTC(),
@@ -548,7 +543,7 @@ func migrateToEgressV1() {
 						Src: []models.AclPolicyTag{
 
 							{
-								ID:    models.UserGroupAclID,
+								ID:    models.UserAclID,
 								Value: "*",
 							},
 						},
@@ -559,7 +554,7 @@ func migrateToEgressV1() {
 							},
 						},
 
-						AllowedDirection: models.TrafficDirectionUni,
+						AllowedDirection: models.TrafficDirectionBi,
 						Enabled:          true,
 						CreatedBy:        "auto",
 						CreatedAt:        time.Now().UTC(),
@@ -568,6 +563,11 @@ func migrateToEgressV1() {
 				}
 
 			}
+			node.IsEgressGateway = false
+			node.EgressGatewayRequest = models.EgressGatewayRequest{}
+			node.EgressGatewayNatEnabled = false
+			node.EgressGatewayRanges = []string{}
+			logic.UpsertNode(&node)
 
 		}
 
@@ -585,9 +585,9 @@ func migrateToEgressV1() {
 					node.ID.String(): 256,
 				},
 				Tags:      make(datatypes.JSONMap),
-				Range:     "",
+				Range:     "*",
 				IsInetGw:  true,
-				Nat:       node.EgressGatewayRequest.NatEnabled == "yes",
+				Nat:       true,
 				Status:    true,
 				CreatedBy: user.UserName,
 				CreatedAt: time.Now().UTC(),
@@ -636,7 +636,7 @@ func migrateToEgressV1() {
 				acl = models.Acl{
 					ID:          uuid.New().String(),
 					Name:        "exit node policy",
-					MetaData:    "all traffic on source nodes will pass through the destination node in the policy",
+					MetaData:    "all traffic will pass through the destination node in the policy",
 					Default:     false,
 					ServiceType: models.Any,
 					NetworkID:   models.NetworkID(node.Network),
@@ -644,20 +644,8 @@ func migrateToEgressV1() {
 					RuleType:    models.UserPolicy,
 					Src: []models.AclPolicyTag{
 						{
-							ID:    models.UserGroupAclID,
-							Value: fmt.Sprintf("%s-%s-grp", node.Network, models.NetworkAdmin),
-						},
-						{
-							ID:    models.UserGroupAclID,
-							Value: fmt.Sprintf("global-%s-grp", models.NetworkAdmin),
-						},
-						{
-							ID:    models.UserGroupAclID,
-							Value: fmt.Sprintf("%s-%s-grp", node.Network, models.NetworkUser),
-						},
-						{
-							ID:    models.UserGroupAclID,
-							Value: fmt.Sprintf("global-%s-grp", models.NetworkUser),
+							ID:    models.UserAclID,
+							Value: "*",
 						},
 					},
 					Dst: []models.AclPolicyTag{