Skip to content

Commit 05863cb

Browse files
author
jvazquez-r7
committed
Delete vague exception handling only done on one place
1 parent 6b8c7cb commit 05863cb

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

modules/post/windows/manage/portproxy.rb

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,17 @@ def check_ipv6
112112

113113
def fw_enable_ports
114114
print_status ("Setting port #{datastore['LOCAL_PORT']} in Windows Firewall ...")
115-
begin
116-
if sysinfo["OS"] =~ /Windows 7|Vista|2008|2012/
117-
cmd_exec("netsh","advfirewall firewall add rule name=\"Windows Service\" dir=in protocol=TCP action=allow localport=\"#{datastore['LOCAL_PORT']}\"")
118-
else
119-
cmd_exec("netsh","firewall set portopening protocol=TCP port=\"#{datastore['LOCAL_PORT']}\"")
120-
end
121-
output = cmd_exec("netsh","firewall show state")
115+
if sysinfo["OS"] =~ /Windows 7|Vista|2008|2012/
116+
cmd_exec("netsh","advfirewall firewall add rule name=\"Windows Service\" dir=in protocol=TCP action=allow localport=\"#{datastore['LOCAL_PORT']}\"")
117+
else
118+
cmd_exec("netsh","firewall set portopening protocol=TCP port=\"#{datastore['LOCAL_PORT']}\"")
119+
end
120+
output = cmd_exec("netsh","firewall show state")
122121

123-
if output =~ /^#{datastore['LOCAL_PORT']} /
124-
print_good("Port opened in Windows Firewall.")
125-
else
126-
print_error("There was an error enabling the port.")
127-
end
128-
rescue ::Exception => e
129-
print_status("The following Error was encountered: #{e.class} #{e}")
122+
if output =~ /^#{datastore['LOCAL_PORT']} /
123+
print_good("Port opened in Windows Firewall.")
124+
else
125+
print_error("There was an error enabling the port.")
130126
end
131127
end
132128
end

0 commit comments

Comments
 (0)