Skip to content

Commit

Permalink
Reduced configure_firewall method complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Feb 26, 2020
1 parent aefc5e7 commit e50e6aa
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/lib/y2firewall/clients/installation_finish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,22 @@ def write
# Modifies the configuration of the firewall according to the current
# settings
def configure_firewall
if Yast::Mode.installation
@settings.enable_firewall ? @firewalld.enable! : @firewalld.disable!
end
configure_service
configure_ssh
configure_vnc
end

if @settings.open_ssh
@firewalld.api.add_service(@settings.default_zone, "ssh")
else
@firewalld.api.remove_service(@settings.default_zone, "ssh")
end
# Convenience method to enable / disable the firewalld service depending
# on the proposal settings
def configure_service
return unless Yast::Mode.installation

@settings.enable_firewall ? @firewalld.enable! : @firewalld.disable!
end

# Convenience method to open the vnc ports in firewalld depending on the
# proposal settings
def configure_vnc
if @settings.open_vnc
if @firewalld.api.service_supported?("tigervnc")
@firewalld.api.add_service(@settings.default_zone, "tigervnc")
Expand All @@ -84,6 +90,16 @@ def configure_firewall
end
end
end

# Convenience method to open the ssh ports in firewalld depending on the
# proposal settings
def configure_ssh
if @settings.open_ssh
@firewalld.api.add_service(@settings.default_zone, "ssh")
else
@firewalld.api.remove_service(@settings.default_zone, "ssh")
end
end
end
end
end

0 comments on commit e50e6aa

Please sign in to comment.