Skip to content

Commit ad8b6ec

Browse files
author
jvazquez-r7
committed
Avoid redefine builtin datastore options
1 parent ad1b9fb commit ad8b6ec

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

modules/post/windows/manage/portproxy.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ def initialize(info={})
2626

2727
register_options(
2828
[
29-
OptAddress.new('LADDRESS', [ true, 'IPv4/IPv6 address to which to listen.']),
30-
OptAddress.new('CADDRESS', [ true, 'IPv4/IPv6 address to which to connect.']),
31-
OptInt.new( 'CPORT', [ true, 'Port number to which to connect.']),
32-
OptInt.new( 'LPORT', [ true, 'Port number to which to listen.']),
29+
OptAddress.new('LOCAL_ADDRESS', [ true, 'IPv4/IPv6 address to which to listen.']),
30+
OptAddress.new('CONNECT_ADDRESS', [ true, 'IPv4/IPv6 address to which to connect.']),
31+
OptInt.new( 'CONNECT_PORT', [ true, 'Port number to which to connect.']),
32+
OptInt.new( 'LOCAL_PORT', [ true, 'Port number to which to listen.']),
3333
OptBool.new( 'IPV6_XP', [ true, 'Install IPv6 on Windows XP (needed for v4tov4).', true]),
3434
OptEnum.new( 'TYPE', [ true, 'Type of forwarding', 'v4tov4', ['v4tov4','v6tov6','v6tov4','v4tov6']])
3535
], self.class)
@@ -62,10 +62,10 @@ def enable_portproxy
6262
print_status("Setting PortProxy ...")
6363
netsh_args = "interface portproxy "
6464
netsh_args << "add #{datastore['TYPE']} "
65-
netsh_args << "listenport=#{datastore['LPORT']} "
66-
netsh_args << "listenaddress=#{datastore['LADDRESS']} "
67-
netsh_args << "connectport=#{datastore['CPORT']} "
68-
netsh_args << "connectaddress=#{datastore['CADDRESS']}"
65+
netsh_args << "listenport=#{datastore['LOCAL_PORT']} "
66+
netsh_args << "listenaddress=#{datastore['LOCAL_ADDRESS']} "
67+
netsh_args << "connectport=#{datastore['CONNECT_PORT']} "
68+
netsh_args << "connectaddress=#{datastore['CONNECT_ADDRESS']}"
6969
output = cmd_exec("netsh", netsh_args)
7070
if output.size > 2
7171
print_error("Setup error. Verify parameters and syntax.")
@@ -113,16 +113,16 @@ def check_ipv6
113113
end
114114

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

125-
if output =~ /^#{datastore['LPORT']} /
125+
if output =~ /^#{datastore['LOCAL_PORT']} /
126126
print_good("Port opened in Windows Firewall.")
127127
else
128128
print_error("There was an error enabling the port.")

0 commit comments

Comments
 (0)