'Configure whether the plug-in should perform redirection
plugin - An instance of a plugin
do_redir - Should we do redirection? (True or False)'

def config_redirect(self, plugin, do_redir):

    redir = plugin.getRedirection()
    session_data = {'params': {}, 'remote': [], 'local': []}
    if do_redir:
        id = uuid.uuid4()
    else:
        id = 0
    try:
        self.io.newline()
        self.io.print_success('Configure    Plugin    Local    Tunnels')
        for l in redir['local']:
            if do_redir:
                self.redirect_local(l, plugin, session_data)
            else:
                self.straight_local(l, plugin)
        self.io.newline()
        self.io.print_success('Configure    Plugin    Remote    Tunnels')
        for r in redir['remote']:
            if do_redir:
                self.redirect_remote(r, plugin, session_data)
            else:
                self.straight_remote(r, plugin)
    except exception.PromptErr:
        for (key, val) in session_data['params'].items():
            plugin.set(key, val)
        raise
    self.io.newline()
    if id:
        self.session_cache[id] = session_data
    return id
