Skip to content

Commit e6e0581

Browse files
committed
Use an OptAddress instead, revert back to client name
1 parent 66616ee commit e6e0581

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

modules/auxiliary/admin/upnp/soap_addportmapping.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def initialize
1919
register_options(
2020
[
2121
OptString.new('TARGETURI', [true, 'UPnP control URL', '/' ]),
22-
OptString.new('INTERNAL_IP', [false, 'New Internal Client']),
23-
OptString.new('EXTERNAL_IP', [false, 'New Internal Client']),
22+
OptAddress.new('INTERNAL_CLIENT', [false, 'Internal client hostname/IP']),
23+
OptAddress.new('EXTERNAL_CLIENT', [false, 'External client hostname/IP']),
2424
OptEnum.new('PROTOCOL', [true, 'Transport level protocol to map', 'TCP', %w(TCP UDP)]),
25-
OptInt.new('INTERNAL_PORT', [true, 'New Internal Port']),
26-
OptInt.new('EXTERNAL_PORT', [true, 'New External Port']),
25+
OptInt.new('INTERNAL_PORT', [true, 'Internal port']),
26+
OptInt.new('EXTERNAL_PORT', [true, 'External port']),
2727
OptInt.new('LEASE_DURATION', [true, 'Lease time for mapping, in seconds', 3600])
2828
],
2929
self.class
@@ -34,16 +34,16 @@ def internal_port
3434
@internal_port ||= datastore['INTERNAL_PORT']
3535
end
3636

37-
def internal_ip
38-
@internal_ip ||= datastore['INTERNAL_IP']
37+
def internal_client
38+
@internal_client ||= datastore['INTERNAL_CLIENT']
3939
end
4040

4141
def external_port
4242
@external_port ||= datastore['EXTERNAL_PORT']
4343
end
4444

45-
def external_ip
46-
@external_ip ||= datastore['EXTERNAL_IP']
45+
def external_client
46+
@external_client ||= datastore['EXTERNAL_CLIENT']
4747
end
4848

4949
def lease_duration
@@ -61,10 +61,10 @@ def run
6161
content << "<m:AddPortMapping xmlns:m=\"urn:schemas-upnp-org:service:WANIPConnection:1\">"
6262
content << "<NewPortMappingDescription>#{Rex::Text.rand_text_alpha(8)}</NewPortMappingDescription>"
6363
content << "<NewLeaseDuration>#{lease_duration}</NewLeaseDuration>"
64-
content << "<NewInternalClient>#{internal_ip}</NewInternalClient>"
64+
content << "<NewInternalClient>#{internal_client}</NewInternalClient>"
6565
content << "<NewEnabled>1</NewEnabled>"
6666
content << "<NewExternalPort>#{external_port}</NewExternalPort>"
67-
content << "<NewRemoteHost>#{external_ip}</NewRemoteHost>"
67+
content << "<NewRemoteHost>#{external_client}</NewRemoteHost>"
6868
content << "<NewProtocol>#{protocol}</NewProtocol>"
6969
content << "<NewInternalPort>#{internal_port}</NewInternalPort>"
7070
content << "</m:AddPortMapping>"
@@ -81,7 +81,7 @@ def run
8181
)
8282

8383
if res
84-
map = "#{rhost}:#{external_port}/#{protocol} -> #{internal_ip}:#{internal_port}/#{protocol}"
84+
map = "#{rhost}:#{external_port}/#{protocol} -> #{internal_client}:#{internal_port}/#{protocol}"
8585
if res.code == 200
8686
print_good("#{peer} successfully mapped #{map}")
8787
else

0 commit comments

Comments
 (0)