Browse Source

Merge branch 'release-v0.90.0' of https://github.com/gravitl/netmaker into NET-2000

abhishek9686 5 months ago
parent
commit
6ba91e3e3f
5 changed files with 220 additions and 107 deletions
  1. 1 1
      controllers/network.go
  2. 1 0
      logic/gateway.go
  3. 10 1
      logic/zombie.go
  4. 2 2
      scripts/nm-quick.sh
  5. 206 103
      swagger.yaml

+ 1 - 1
controllers/network.go

@@ -436,7 +436,7 @@ func getNetworkACL(w http.ResponseWriter, r *http.Request) {
 // @Security    oauth
 // @Security    oauth
 // @Param       networkname path string true "Network name"
 // @Param       networkname path string true "Network name"
 // @Produce     json
 // @Produce     json
-// @Success     200 {object} acls.SuccessResponse
+// @Success     200 {object} models.SuccessResponse
 // @Failure     500 {object} models.ErrorResponse
 // @Failure     500 {object} models.ErrorResponse
 func getNetworkEgressRoutes(w http.ResponseWriter, r *http.Request) {
 func getNetworkEgressRoutes(w http.ResponseWriter, r *http.Request) {
 	var params = mux.Vars(r)
 	var params = mux.Vars(r)

+ 1 - 0
logic/gateway.go

@@ -70,6 +70,7 @@ func CreateIngressGateway(netid string, nodeid string, ingress models.IngressReq
 	}
 	}
 	node.IsIngressGateway = true
 	node.IsIngressGateway = true
 	node.IsGw = true
 	node.IsGw = true
+	node.IsRelay = true
 	if !servercfg.IsPro {
 	if !servercfg.IsPro {
 		node.IsInternetGateway = ingress.IsInternetGateway
 		node.IsInternetGateway = ingress.IsInternetGateway
 	}
 	}

+ 10 - 1
logic/zombie.go

@@ -77,7 +77,7 @@ func checkForZombieHosts(h *models.Host) {
 func ManageZombies(ctx context.Context, peerUpdate chan *models.Node) {
 func ManageZombies(ctx context.Context, peerUpdate chan *models.Node) {
 	logger.Log(2, "Zombie management started")
 	logger.Log(2, "Zombie management started")
 	go InitializeZombies()
 	go InitializeZombies()
-
+	go checkPendingRemovalNodes()
 	// Zombie Nodes Cleanup Four Times a Day
 	// Zombie Nodes Cleanup Four Times a Day
 	ticker := time.NewTicker(time.Hour * ZOMBIE_TIMEOUT)
 	ticker := time.NewTicker(time.Hour * ZOMBIE_TIMEOUT)
 
 
@@ -138,6 +138,15 @@ func ManageZombies(ctx context.Context, peerUpdate chan *models.Node) {
 		}
 		}
 	}
 	}
 }
 }
+func checkPendingRemovalNodes() {
+	nodes, _ := GetAllNodes()
+	for _, node := range nodes {
+		pendingDelete := node.PendingDelete || node.Action == models.NODE_DELETE
+		if pendingDelete {
+			DeleteNode(&node, true)
+		}
+	}
+}
 
 
 // InitializeZombies - populates the zombie quarantine list (should be called from initialization)
 // InitializeZombies - populates the zombie quarantine list (should be called from initialization)
 func InitializeZombies() {
 func InitializeZombies() {

+ 2 - 2
scripts/nm-quick.sh

@@ -501,8 +501,8 @@ set -e
 # set_install_vars - sets the variables that will be used throughout installation
 # set_install_vars - sets the variables that will be used throughout installation
 set_install_vars() {
 set_install_vars() {
 
 
-	IP_ADDR=$(curl -s -4 ifconfig.me || echo "")
-    IP6_ADDR=$(curl -s -6 ifconfig.me || echo "")
+	IP_ADDR=$(curl -s -4 api64.ipify.org || echo "")
+    IP6_ADDR=$(curl -s -6 api64.ipify.org || echo "")
 	if [ "$NETMAKER_BASE_DOMAIN" = "" ]; then
 	if [ "$NETMAKER_BASE_DOMAIN" = "" ]; then
 		NETMAKER_BASE_DOMAIN=nm.$(echo $IP_ADDR | tr . -).nip.io
 		NETMAKER_BASE_DOMAIN=nm.$(echo $IP_ADDR | tr . -).nip.io
 	fi
 	fi

+ 206 - 103
swagger.yaml

@@ -1,7 +1,6 @@
 definitions:
 definitions:
   acls.ACL:
   acls.ACL:
     additionalProperties:
     additionalProperties:
-      format: int32
       type: integer
       type: integer
     type: object
     type: object
   acls.ACLContainer:
   acls.ACLContainer:
@@ -56,15 +55,15 @@ definitions:
         type: string
         type: string
       egressesLimit:
       egressesLimit:
         type: integer
         type: integer
-      email_sender_addr:
+      emailSenderAddr:
         type: string
         type: string
-      email_sender_password:
+      emailSenderPassword:
         type: string
         type: string
-      email_sender_user:
+      emailSenderUser:
         type: string
         type: string
       emqxRestEndpoint:
       emqxRestEndpoint:
         type: string
         type: string
-      endpoint_detection:
+      endpointDetection:
         type: boolean
         type: boolean
       environment:
       environment:
         type: string
         type: string
@@ -91,6 +90,8 @@ definitions:
         type: string
         type: string
       metricsExporter:
       metricsExporter:
         type: string
         type: string
+      metricsPort:
+        type: integer
       mqpassword:
       mqpassword:
         type: string
         type: string
       mquserName:
       mquserName:
@@ -115,15 +116,17 @@ definitions:
         type: string
         type: string
       racAutoDisable:
       racAutoDisable:
         type: boolean
         type: boolean
+      racRestrictToSingleNetwork:
+        type: boolean
       restBackend:
       restBackend:
         type: string
         type: string
       server:
       server:
         type: string
         type: string
       serverBrokerEndpoint:
       serverBrokerEndpoint:
         type: string
         type: string
-      smtp_host:
+      smtpHost:
         type: string
         type: string
-      smtp_port:
+      smtpPort:
         type: integer
         type: integer
       sqlconn:
       sqlconn:
         type: string
         type: string
@@ -200,6 +203,14 @@ definitions:
         allOf:
         allOf:
         - $ref: '#/definitions/models.AllowedTrafficDirection'
         - $ref: '#/definitions/models.AllowedTrafficDirection'
         description: single or two-way
         description: single or two-way
+      dst:
+        items:
+          $ref: '#/definitions/net.IPNet'
+        type: array
+      dst6:
+        items:
+          $ref: '#/definitions/net.IPNet'
+        type: array
       id:
       id:
         type: string
         type: string
       ip_list:
       ip_list:
@@ -306,6 +317,10 @@ definitions:
         items:
         items:
           type: string
           type: string
         type: array
         type: array
+      egressgatewayranges_with_metric:
+        items:
+          $ref: '#/definitions/models.EgressRangeMetric'
+        type: array
       expdatetime:
       expdatetime:
         format: int64
         format: int64
         type: integer
         type: integer
@@ -424,9 +439,17 @@ definitions:
         items:
         items:
           type: string
           type: string
         type: array
         type: array
+      ranges_with_metric:
+        items:
+          $ref: '#/definitions/models.EgressRangeMetric'
+        type: array
     type: object
     type: object
   models.EgressInfo:
   models.EgressInfo:
     properties:
     properties:
+      egress_fw_rules:
+        additionalProperties:
+          $ref: '#/definitions/models.AclRule'
+        type: object
       egress_gateway_cfg:
       egress_gateway_cfg:
         $ref: '#/definitions/models.EgressGatewayRequest'
         $ref: '#/definitions/models.EgressGatewayRequest'
       egress_gw_addr:
       egress_gw_addr:
@@ -450,10 +473,26 @@ definitions:
         items:
         items:
           type: string
           type: string
         type: array
         type: array
+      egress_ranges_metric:
+        items:
+          $ref: '#/definitions/models.EgressRangeMetric'
+        type: array
+      network:
+        type: string
       node_addr:
       node_addr:
         $ref: '#/definitions/net.IPNet'
         $ref: '#/definitions/net.IPNet'
       node_addr6:
       node_addr6:
         $ref: '#/definitions/net.IPNet'
         $ref: '#/definitions/net.IPNet'
+      peer_key:
+        type: string
+    type: object
+  models.EgressRangeMetric:
+    properties:
+      network:
+        type: string
+      route_metric:
+        description: preffered range 1-999
+        type: integer
     type: object
     type: object
   models.EnrollmentKey:
   models.EnrollmentKey:
     properties:
     properties:
@@ -687,6 +726,7 @@ definitions:
   models.HostMqAction:
   models.HostMqAction:
     enum:
     enum:
     - UPGRADE
     - UPGRADE
+    - FORCE_UPGRADE
     - SIGNAL_HOST
     - SIGNAL_HOST
     - UPDATE_HOST
     - UPDATE_HOST
     - DELETE_HOST
     - DELETE_HOST
@@ -701,6 +741,7 @@ definitions:
     type: string
     type: string
     x-enum-varnames:
     x-enum-varnames:
     - Upgrade
     - Upgrade
+    - ForceUpgrade
     - SignalHost
     - SignalHost
     - UpdateHost
     - UpdateHost
     - DeleteHost
     - DeleteHost
@@ -724,6 +765,8 @@ definitions:
         type: boolean
         type: boolean
       listen_port:
       listen_port:
         type: integer
         type: integer
+      version:
+        type: string
     type: object
     type: object
   models.HostPull:
   models.HostPull:
     properties:
     properties:
@@ -821,8 +864,6 @@ definitions:
     type: object
     type: object
   models.IngressInfo:
   models.IngressInfo:
     properties:
     properties:
-      allow_all:
-        type: boolean
       egress_ranges:
       egress_ranges:
         items:
         items:
           $ref: '#/definitions/net.IPNet'
           $ref: '#/definitions/net.IPNet'
@@ -933,6 +974,10 @@ definitions:
         type: string
         type: string
       defaultudpholepunch:
       defaultudpholepunch:
         type: string
         type: string
+      dns_nameservers:
+        items:
+          type: string
+        type: array
       isipv4:
       isipv4:
         type: string
         type: string
       isipv6:
       isipv6:
@@ -1013,6 +1058,8 @@ definitions:
         type: string
         type: string
       is_fail_over:
       is_fail_over:
         type: boolean
         type: boolean
+      is_gw:
+        type: boolean
       is_static:
       is_static:
         type: boolean
         type: boolean
       is_user_node:
       is_user_node:
@@ -1090,6 +1137,7 @@ definitions:
     - warning
     - warning
     - error
     - error
     - unknown
     - unknown
+    - disconnected
     type: string
     type: string
     x-enum-varnames:
     x-enum-varnames:
     - OnlineSt
     - OnlineSt
@@ -1097,6 +1145,7 @@ definitions:
     - WarningSt
     - WarningSt
     - ErrorSt
     - ErrorSt
     - UnKnown
     - UnKnown
+    - Disconnected
   models.PeerMap:
   models.PeerMap:
     additionalProperties:
     additionalProperties:
       $ref: '#/definitions/models.IDandAddr'
       $ref: '#/definitions/models.IDandAddr'
@@ -1120,17 +1169,6 @@ definitions:
       server_config:
       server_config:
         $ref: '#/definitions/models.ServerConfig'
         $ref: '#/definitions/models.ServerConfig'
     type: object
     type: object
-  models.RelayRequest:
-    properties:
-      netid:
-        type: string
-      nodeid:
-        type: string
-      relayaddrs:
-        items:
-          type: string
-        type: array
-    type: object
   models.ReturnUser:
   models.ReturnUser:
     properties:
     properties:
       auth_type:
       auth_type:
@@ -1194,10 +1232,14 @@ definitions:
         type: string
         type: string
       dnsmode:
       dnsmode:
         type: string
         type: string
+      endpointDetection:
+        type: boolean
       manageDNS:
       manageDNS:
         type: boolean
         type: boolean
       metricInterval:
       metricInterval:
         type: string
         type: string
+      metricsPort:
+        type: integer
       mqpassword:
       mqpassword:
         type: string
         type: string
       mqport:
       mqport:
@@ -1293,7 +1335,6 @@ definitions:
           type: object
           type: object
         type: object
         type: object
       username:
       username:
-        maxLength: 40
         minLength: 3
         minLength: 3
         type: string
         type: string
     required:
     required:
@@ -1308,12 +1349,16 @@ definitions:
     type: object
     type: object
   models.UserRemoteGws:
   models.UserRemoteGws:
     properties:
     properties:
+      addresses:
+        type: string
       allowed_endpoints:
       allowed_endpoints:
         items:
         items:
           type: string
           type: string
         type: array
         type: array
       connected:
       connected:
         type: boolean
         type: boolean
+      dns_address:
+        type: string
       gw_client:
       gw_client:
         $ref: '#/definitions/models.ExtClient'
         $ref: '#/definitions/models.ExtClient'
       gw_listen_port:
       gw_listen_port:
@@ -1334,6 +1379,8 @@ definitions:
         type: array
         type: array
       remote_access_gw_id:
       remote_access_gw_id:
         type: string
         type: string
+      status:
+        $ref: '#/definitions/models.NodeStatus'
     type: object
     type: object
   models.UserRoleID:
   models.UserRoleID:
     enum:
     enum:
@@ -1390,7 +1437,6 @@ definitions:
       mask:
       mask:
         description: network mask
         description: network mask
         items:
         items:
-          format: int32
           type: integer
           type: integer
         type: array
         type: array
     type: object
     type: object
@@ -1427,7 +1473,6 @@ definitions:
           for this peer, if not nil.
           for this peer, if not nil.
 
 
           A non-nil value of 0 will clear the persistent keepalive interval.
           A non-nil value of 0 will clear the persistent keepalive interval.
-        format: int64
         type: integer
         type: integer
       presharedKey:
       presharedKey:
         description: |-
         description: |-
@@ -1826,6 +1871,28 @@ paths:
       summary: Get the current public IP address.
       summary: Get the current public IP address.
       tags:
       tags:
       - IP Service
       - IP Service
+  /api/host/{hostid}/peer_info:
+    get:
+      parameters:
+      - description: Host ID
+        in: path
+        name: hostid
+        required: true
+        type: string
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/models.SuccessResponse'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/models.ErrorResponse'
+      security:
+      - oauth: []
+      summary: Fetches host peerinfo
+      tags:
+      - Hosts
   /api/hosts:
   /api/hosts:
     get:
     get:
       responses:
       responses:
@@ -2006,6 +2073,10 @@ paths:
         name: hostid
         name: hostid
         required: true
         required: true
         type: string
         type: string
+      - description: Force upgrade
+        in: query
+        name: force
+        type: boolean
       responses:
       responses:
         "200":
         "200":
           description: passed message to upgrade host
           description: passed message to upgrade host
@@ -2067,6 +2138,35 @@ paths:
       summary: Update keys for all hosts
       summary: Update keys for all hosts
       tags:
       tags:
       - Hosts
       - Hosts
+  /api/hosts/sync:
+    post:
+      responses:
+        "200":
+          description: sync all hosts request received
+          schema:
+            type: string
+      security:
+      - oauth: []
+      summary: Requests all the hosts to pull
+      tags:
+      - Hosts
+  /api/hosts/upgrade:
+    post:
+      parameters:
+      - description: Force upgrade
+        in: query
+        name: force
+        type: boolean
+      responses:
+        "200":
+          description: upgrade all hosts request received
+          schema:
+            type: string
+      security:
+      - oauth: []
+      summary: Requests all the hosts to upgrade their version
+      tags:
+      - Hosts
   /api/networks:
   /api/networks:
     get:
     get:
       produces:
       produces:
@@ -2117,6 +2217,10 @@ paths:
         name: networkname
         name: networkname
         required: true
         required: true
         type: string
         type: string
+      - description: Force Delete
+        in: query
+        name: force
+        type: boolean
       produces:
       produces:
       - application/json
       - application/json
       responses:
       responses:
@@ -2280,6 +2384,30 @@ paths:
       summary: Update a network ACL (Access Control List)
       summary: Update a network ACL (Access Control List)
       tags:
       tags:
       - Networks
       - Networks
+  /api/networks/{networkname}/egress_routes:
+    get:
+      parameters:
+      - description: Network name
+        in: path
+        name: networkname
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/models.SuccessResponse'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/models.ErrorResponse'
+      security:
+      - oauth: []
+      summary: Get a network Egress routes
+      tags:
+      - Networks
   /api/nodes:
   /api/nodes:
     get:
     get:
       responses:
       responses:
@@ -2358,61 +2486,6 @@ paths:
       summary: Create an egress gateway
       summary: Create an egress gateway
       tags:
       tags:
       - Nodes
       - Nodes
-  /api/nodes/{network}/{nodeid}/createingress:
-    post:
-      responses:
-        "200":
-          description: OK
-          schema:
-            $ref: '#/definitions/models.ApiNode'
-        "500":
-          description: Internal Server Error
-          schema:
-            $ref: '#/definitions/models.ErrorResponse'
-      security:
-      - oauth2: []
-      summary: Create an remote access gateway
-      tags:
-      - Nodes
-  /api/nodes/{network}/{nodeid}/createrelay:
-    post:
-      consumes:
-      - application/json
-      parameters:
-      - description: Network ID
-        in: path
-        name: network
-        required: true
-        type: string
-      - description: Node ID
-        in: path
-        name: nodeid
-        required: true
-        type: string
-      - description: Relay request parameters
-        in: body
-        name: body
-        required: true
-        schema:
-          $ref: '#/definitions/models.RelayRequest'
-      produces:
-      - application/json
-      responses:
-        "200":
-          description: OK
-          schema:
-            $ref: '#/definitions/models.ApiNode'
-        "400":
-          description: Bad Request
-          schema:
-            $ref: '#/definitions/models.ErrorResponse'
-        "500":
-          description: Internal Server Error
-          schema:
-            $ref: '#/definitions/models.ErrorResponse'
-      summary: Create a relay
-      tags:
-      - PRO
   /api/nodes/{network}/{nodeid}/deletegateway:
   /api/nodes/{network}/{nodeid}/deletegateway:
     delete:
     delete:
       responses:
       responses:
@@ -2429,7 +2502,7 @@ paths:
       summary: Delete an egress gateway
       summary: Delete an egress gateway
       tags:
       tags:
       - Nodes
       - Nodes
-  /api/nodes/{network}/{nodeid}/deleteingress:
+  /api/nodes/{network}/{nodeid}/gateway:
     delete:
     delete:
       responses:
       responses:
         "200":
         "200":
@@ -2442,42 +2515,24 @@ paths:
             $ref: '#/definitions/models.ErrorResponse'
             $ref: '#/definitions/models.ErrorResponse'
       security:
       security:
       - oauth2: []
       - oauth2: []
-      summary: Delete an remote access gateway
+      summary: Delete a gateway
       tags:
       tags:
       - Nodes
       - Nodes
-  /api/nodes/{network}/{nodeid}/deleterelay:
-    delete:
-      consumes:
-      - application/json
-      parameters:
-      - description: Network ID
-        in: path
-        name: network
-        required: true
-        type: string
-      - description: Node ID
-        in: path
-        name: nodeid
-        required: true
-        type: string
-      produces:
-      - application/json
+    post:
       responses:
       responses:
         "200":
         "200":
           description: OK
           description: OK
           schema:
           schema:
             $ref: '#/definitions/models.ApiNode'
             $ref: '#/definitions/models.ApiNode'
-        "400":
-          description: Bad Request
-          schema:
-            $ref: '#/definitions/models.ErrorResponse'
         "500":
         "500":
           description: Internal Server Error
           description: Internal Server Error
           schema:
           schema:
             $ref: '#/definitions/models.ErrorResponse'
             $ref: '#/definitions/models.ErrorResponse'
-      summary: Remove a relay
+      security:
+      - oauth2: []
+      summary: Create a gateway
       tags:
       tags:
-      - PRO
+      - Nodes
   /api/nodes/{network}/{nodeid}/inet_gw:
   /api/nodes/{network}/{nodeid}/inet_gw:
     delete:
     delete:
       parameters:
       parameters:
@@ -3425,6 +3480,38 @@ paths:
       summary: Create failover node
       summary: Create failover node
       tags:
       tags:
       - PRO
       - PRO
+  /api/v1/node/{nodeid}/failover_check:
+    get:
+      consumes:
+      - application/json
+      parameters:
+      - description: Node ID
+        in: path
+        name: nodeid
+        required: true
+        type: string
+      - description: Failover request
+        in: body
+        name: body
+        required: true
+        schema:
+          $ref: '#/definitions/models.FailOverMeReq'
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/models.SuccessResponse'
+        "400":
+          description: Bad Request
+          schema:
+            $ref: '#/definitions/models.ErrorResponse'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/models.ErrorResponse'
+      summary: checkfailOverCtx
+      tags:
+      - PRO
   /api/v1/node/{nodeid}/failover_me:
   /api/v1/node/{nodeid}/failover_me:
     post:
     post:
       consumes:
       consumes:
@@ -3457,6 +3544,22 @@ paths:
       summary: Failover me
       summary: Failover me
       tags:
       tags:
       - PRO
       - PRO
+  /api/v1/nodes/{network}/status:
+    get:
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.ApiNode'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/models.ErrorResponse'
+      summary: Get all nodes status on the network
+      tags:
+      - Nodes
   /api/v1/tags:
   /api/v1/tags:
     delete:
     delete:
       consumes:
       consumes: