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 d359194
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/lib/y2firewall/clients/installation_finish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,32 @@ 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

# 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 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

# 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 Down

0 comments on commit d359194

Please sign in to comment.