'(destaddr, destport) = r-xform(listenaddr, listenport)
* Each of the identifiers above specifies a variable for the plug-in
(1) Prompt for Listen IP            - Likely the ultimate redirector\'s IP
(2) Prompt for Listen Port          - Likely the ultimate redirector\'s port
(3) Prompt for Destination          - Likely 0.0.0.0
(4) Prompt for Destination Port     - Likely a local port
Lookup the variables specified by listenaddr and listenport, transform them with
a given transform function, and substitute the resulting values into the
variables specified by destaddr and destport.
The plug-in will then have to open a port to listen on using the variables
specified by the destnation IP and destination port'

def redirect_remote(self, r, plugin, session_data):

    params = iDict(plugin.getParameters())
    lport = self.conv_param(r.listenport, params, session_data['params'])
    dport = self.conv_param(r.destport, params, session_data['params'])
    laddr = self.conv_param(r.listenaddr, params, session_data['params'])
    daddr = self.conv_param(r.destaddr, params, session_data['params'])
    if (None in (lport, dport, laddr, daddr)):
        for (p, n) in ((laddr, r.listenaddr), (lport, r.listenport), (daddr, r.destaddr), (dport, r.destport)):
            if (p == None):
                self.io.print_warning(('Parameter    %s    referenced    by    tunnel    %s    not    found.    This    tunnel    will    be    ignored' % (n, r.name)))
        return
    if ((not lport) or (lport == '0')):
        lport = rand_port()
    self.io.print_success(('Remote    Tunnel    -    %s' % r.name))
    callbackip = self.prompt_redir(plugin, r.listenaddr, 'Listen    IP', laddr)
    callbackport = self.prompt_redir(plugin, r.listenport, 'Listen    Port', lport)
    session_data['params'][r.listenaddr] = callbackip
    session_data['params'][r.listenport] = callbackport
    callbacklocalip = self.prompt_redir_fake('Destination    IP', daddr)
    if (not dport):
        dport = callbackport
    callbacklocalport = self.prompt_redir(plugin, r.destport, 'Destination    Port', dport)
    session_data['params'][r.destport] = callbacklocalport
    session_data['remote'].append(RemoteRedirection(r.protocol, callbackip, callbacklocalport, listenport=callbackport, destaddr=callbacklocalip, name=r.name))
    self.io.print_success(('(%s)    Remote    %s:%s    ->    %s:%s' % (r.protocol, callbackip, callbackport, callbacklocalip, callbacklocalport)))
