<%

# Note that this file is not a valid *.html file!
# It is intended to be a bottlepy - style template
# used for the scripting part of TheOnionBox!

tor = get('tor') if tor is None else tor

hs_configs = tor.get_hidden_service_conf(None)
# print(hs_configs)
# print(tor.get_info('config/names'))

hs_conf_params = [
    'HiddenServiceDir',
    'HiddenServicePort',
    'HiddenServiceVersion',
    'HiddenServiceAuthorizeClient',
    'HiddenServiceAllowUnknownPorts',
    'HiddenServiceMaxStreams',
    'HiddenServiceMaxStreamsCloseCircuit',
    'HiddenServiceDirGroupReadable',
    'HiddenServiceNumIntroductionPoints'
]

%>

% if hs_configs is not None and len(hs_configs) > 0:

    {{!header_row('Tor', 'Hidden Services', 'hiddenservice')}}

    % for hs_dir in hs_configs:
        % hs_conf = hs_configs[hs_dir]

        {{!group_row('Hidden Service Options')}}

        <div class = "row">
            <div class="{{box_datum_grid}} option_hover truncate">
                <a href="manpage.html#HiddenServiceDir" target="manpage_window">#</a> HiddenServiceDir
            </div>
            <div class="{{box_value_grid}} box_value_margin">
                {{hs_dir}}
            </div>
            <div class="{{box_right_grid}}"></div>
        </div>

        % for param in hs_conf_params:
            % if param in hs_conf:
                % out = hs_conf[param]
                % if param == 'HiddenServicePort':
                    % lines = out
                    % out = ''
                    % for line in lines:
                        % if len(out) > 0:
                            % out += '<br>'
                        % end
                        % out += '{} {}:{}'.format(line[0], line[1], line[2])
                    % end
                % end

                <div class = "row">
                    <div class="{{box_datum_grid}} option_hover truncate">
                        <a href="manpage.html#{{param}}" target="manpage_window">#</a> {{param}}
                    </div>
                    <div class="{{box_value_grid}} box_value_margin">
                        {{out}}
                    </div>
                    <div class="{{box_right_grid}}"></div>
                </div>
            % end
        % end
    % end

    <hr>

% end

