Selaa lähdekoodia

gluon-next-node: make IPv4 next-node address optional

If next_node.ip4 is not set or gluon-next-node is not used, prefix4 will
now be optional as well.
Matthias Schiffer 8 vuotta sitten
vanhempi
commit
b902ddd8df

+ 0 - 1
package/gluon-core/check_site.lua

@@ -19,7 +19,6 @@ need_string 'timezone'
 
 need_string_array('ntp_servers', false)
 
-need_string_match('prefix4', '^%d+.%d+.%d+.%d+/%d+$')
 need_string_match('prefix6', '^[%x:]+/%d+$')
 
 

+ 4 - 1
package/gluon-next-node/check_site.lua

@@ -1,4 +1,7 @@
-need_string_match('next_node.ip4', '^%d+.%d+.%d+.%d+$')
+if need_string_match('next_node.ip4', '^%d+.%d+.%d+.%d+$', false) then
+	need_string_match('prefix4', '^%d+.%d+.%d+.%d+/%d+$')
+end
+
 need_string_match('next_node.ip6', '^[%x:]+$')
 
 need_string_match('next_node.mac', '^%x[02468aAcCeE]:%x%x:%x%x:%x%x:%x%x:%x%x$')

+ 9 - 3
package/gluon-next-node/files/lib/gluon/upgrade/400-next-node

@@ -17,14 +17,20 @@ c:section('network', 'device', 'local_node_dev',
 	  }
 )
 
-local prefix4 = ip.IPv4(site.prefix4)
+local ip4, netmask
+
+if site.next_node.ip4 then
+	ip4 = site.next_node.ip4
+	netmask = ip.IPv4(site.prefix4):mask():string()
+end
+
 c:delete('network', 'local_node')
 c:section('network', 'interface', 'local_node',
 	  {
 		  ifname = 'local-node',
 		  proto = 'static',
-		  ipaddr = site.next_node.ip4,
-		  netmask = prefix4:mask():string(),
+		  ipaddr = ip4,
+		  netmask = netmask,
 		  ip6addr = site.next_node.ip6 .. '/128',
 	  }
 )