|
|
|
@ -119,26 +119,18 @@ class InterfaceConfiguration |
|
|
|
|
property aliasses_v4 : Array(IPAddress) |
|
|
|
|
property aliasses_v6 : Array(IPAddress) |
|
|
|
|
property wireless_networks : Hash(String, WirelessAPSetup) |
|
|
|
|
property dns : NetworkCommands::DNS |
|
|
|
|
|
|
|
|
|
def initialize (@name, @up, |
|
|
|
|
@description, |
|
|
|
|
@mtu, |
|
|
|
|
@main_ip_v4, @main_ip_v6, aliasses, |
|
|
|
|
@wireless_networks, |
|
|
|
|
@dns |
|
|
|
|
) |
|
|
|
|
property dns : NetworkCommands::DNS? |
|
|
|
|
property command_lines : Array(String) |
|
|
|
|
|
|
|
|
|
def initialize (@name) |
|
|
|
|
@up = false |
|
|
|
|
@aliasses_v4 = Array(IPAddress).new |
|
|
|
|
@aliasses_v6 = Array(IPAddress).new |
|
|
|
|
|
|
|
|
|
aliasses.each do |ip| |
|
|
|
|
if ip.ipv4? |
|
|
|
|
aliasses_v4 << ip |
|
|
|
|
else |
|
|
|
|
aliasses_v6 << ip |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
@command_lines = Array(String).new |
|
|
|
|
@main_ip_v4 = NotSetup.new |
|
|
|
|
@main_ip_v6 = NotSetup.new |
|
|
|
|
@wireless_networks = Hash(String, WirelessAPSetup).new |
|
|
|
|
@wireless_networks = Hash(String, WirelessAPSetup).new |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def to_s(io : IO) |
|
|
|
@ -191,7 +183,13 @@ class InterfaceConfiguration |
|
|
|
|
str << "\t#{CRED}Should main ipv6 be obtained from autoconfiguration? DHCP? Static configuration?#{CRESET}\n" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
str << indent(1, dns.to_s) unless dns.addresses.empty? |
|
|
|
|
thedns = @dns |
|
|
|
|
if thedns.nil? |
|
|
|
|
else |
|
|
|
|
unless thedns.addresses.empty? |
|
|
|
|
str << indent(1, thedns.to_s) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
unless wireless_networks.empty? |
|
|
|
|
wireless_networks.each do |k,v| |
|
|
|
@ -251,6 +249,14 @@ class InterfaceConfiguration |
|
|
|
|
return |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
unless command_lines.empty? |
|
|
|
|
puts "Launch these lines:" |
|
|
|
|
command_lines.each do |cmd| |
|
|
|
|
puts "cmd: #{cmd}" |
|
|
|
|
Do.runsh cmd |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
unless mtu.nil? |
|
|
|
|
NetworkCommands.mtu name, mtu |
|
|
|
|
end |
|
|
|
@ -261,9 +267,9 @@ class InterfaceConfiguration |
|
|
|
|
|
|
|
|
|
# TODO: treat differently wireless and non-wireless interfaces |
|
|
|
|
if @wireless_networks.empty? |
|
|
|
|
puts "interface #{name} is not wireless" |
|
|
|
|
# puts "interface #{name} is not wireless" |
|
|
|
|
else |
|
|
|
|
puts "interface #{name} is wireless: connection to the access point" |
|
|
|
|
# puts "interface #{name} is wireless: connection to the access point" |
|
|
|
|
store_access_point_keys |
|
|
|
|
access_point_connection |
|
|
|
|
end |
|
|
|
@ -313,7 +319,8 @@ class InterfaceConfiguration |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# DNS configuration |
|
|
|
|
dns.execute |
|
|
|
|
thedns = @dns |
|
|
|
|
thedns.execute unless thedns.nil? |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def down |
|
|
|
|