<%@page contentType="text/html" import="net.i2p.i2ptunnel.web.EditBean"
%><%@page trimDirectiveWhitespaces="true"
%><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<jsp:useBean class="net.i2p.i2ptunnel.web.EditBean" id="editBean" scope="request" />
<jsp:useBean class="net.i2p.i2ptunnel.web.Messages" id="intl" scope="request" />
<% String tun = request.getParameter("tunnel");
   int curTunnel = -1;
   if (tun != null) {
     try {
       curTunnel = Integer.parseInt(tun);
     } catch (NumberFormatException nfe) {
       curTunnel = -1;
     }
   }
%>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title><%=intl._t("Hidden Services Manager")%> - <%=intl._t("Edit Hidden Service")%></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
    <link href="/themes/console/images/favicon.ico" type="image/x-icon" rel="shortcut icon" />

    <% if (editBean.allowCSS()) {
  %><link rel="icon" href="<%=editBean.getTheme()%>images/favicon.ico" />
    <link href="<%=editBean.getTheme()%>default.css?<%=net.i2p.CoreVersion.VERSION%>" rel="stylesheet" type="text/css" /> 
    <link href="<%=editBean.getTheme()%>i2ptunnel.css?<%=net.i2p.CoreVersion.VERSION%>" rel="stylesheet" type="text/css" />
    <% }
  %>
<style type='text/css'>
input.default { width: 1px; height: 1px; visibility: hidden; }
</style>
</head>
<body id="tunnelEditPage">
    <div id="pageHeader">
    </div>
<%

  if (editBean.isInitialized()) {

%>
    <form method="post" action="list">

        <div id="tunnelEditPanel" class="panel">
            <div class="header">
                <%
                String tunnelTypeName;
                String tunnelType;
                if (curTunnel >= 0) {
                    tunnelTypeName = editBean.getTunnelType(curTunnel);
                    tunnelType = editBean.getInternalType(curTunnel);
                  %><h4><%=intl._t("Edit server settings")%></h4><% 
                } else {
                    tunnelTypeName = editBean.getTypeName(request.getParameter("type"));
                    tunnelType = net.i2p.data.DataHelper.stripHTML(request.getParameter("type"));
                  %><h4><%=intl._t("New server settings")%></h4><% 
                } %>
                <input type="hidden" name="tunnel" value="<%=curTunnel%>" />
                <input type="hidden" name="nonce" value="<%=net.i2p.i2ptunnel.web.IndexBean.getNextNonce()%>" />
                <input type="hidden" name="type" value="<%=tunnelType%>" />
                <%
                // these are four keys that are generated automatically on first save,
                // and we want to persist in i2ptunnel.config, but don't want to
                // show clogging up the custom options form.
                String key = editBean.getKey1(curTunnel);
                if (key != null && key.length() > 0) { %>
                    <input type="hidden" name="key1" value="<%=key%>" />
                <% }
                key = editBean.getKey2(curTunnel);
                if (key != null && key.length() > 0) { %>
                    <input type="hidden" name="key2" value="<%=key%>" />
                <% }
                key = editBean.getKey3(curTunnel);
                if (key != null && key.length() > 0) { %>
                    <input type="hidden" name="key3" value="<%=key%>" />
                <% }
                key = editBean.getKey4(curTunnel);
                if (key != null && key.length() > 0) { %>
                    <input type="hidden" name="key4" value="<%=key%>" />
                <% } %>
                <input type="submit" class="default" name="action" value="Save changes" />
            </div>
      
            <div class="separator">
                <hr />
            </div>

            <div id="nameField" class="rowItem">
                <label for="name" accesskey="N">
                    <%=intl._t("Name")%>(<span class="accessKey">N</span>):
                </label>
                <input type="text" size="30" maxlength="50" name="name" id="name" title="Tunnel Name" value="<%=editBean.getTunnelName(curTunnel)%>" class="freetext" />               
            </div>
            <div id="typeField" class="rowItem">
                <label><%=intl._t("Type")%>:</label>
                <span class="text"><%=tunnelTypeName%></span>
            </div>
            <div id="descriptionField" class="rowItem">
                <label for="description" accesskey="e">
                    <%=intl._t("Description")%>(<span class="accessKey">e</span>):
                </label>
                <input type="text" size="60" maxlength="80" name="nofilter_description"  id="description" title="Tunnel Description" value="<%=editBean.getTunnelDescription(curTunnel)%>" class="freetext" />                
            </div>
            <div id="startupField" class="rowItem">
                <label for="startOnLoad" accesskey="a">
                    <%=intl._t("Auto Start")%>(<span class="accessKey">A</span>):
                </label>
                <input value="1" type="checkbox" id="startOnLoad" name="startOnLoad" title="Start Tunnel Automatically"<%=(editBean.startAutomatically(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />                
                <span class="comment"><%=intl._t("(Check the Box for 'YES')")%></span>
            </div>
                 
            <div class="subdivider">
                <hr />
            </div>
                 
            <div id="targetField" class="rowItem">
         <% if ("streamrserver".equals(tunnelType)) { %>
                <label><%=intl._t("Access Point")%>:</label>
         <% } else { %>
                <label><%=intl._t("Target")%>:</label>
         <% } %>
            </div>
         <% if (!"streamrserver".equals(tunnelType)) { %>
            <div id="hostField" class="rowItem">
                <label for="targetHost" accesskey="H">
                    <%=intl._t("Host")%>(<span class="accessKey">H</span>):
                </label>
                <input type="text" size="20" id="targetHost" name="targetHost" title="Target Hostname or IP" value="<%=editBean.getTargetHost(curTunnel)%>" class="freetext" />                
            </div>
         <% } /* !streamrserver */ %>
            <div id="portField" class="rowItem">
                <label for="targetPort" accesskey="P">
                    <%=intl._t("Port")%>(<span class="accessKey">P</span>):
                    <% String value = editBean.getTargetPort(curTunnel);
                       if (value == null || "".equals(value.trim())) {
                           out.write(" <font color=\"red\">(");
                           out.write(intl._t("required"));
                           out.write(")</font>");
                       }   
                     %>
                </label>
                <input type="text" size="6" maxlength="5" id="targetPort" name="targetPort" title="Target Port Number" value="<%=editBean.getTargetPort(curTunnel)%>" class="freetext" />               
            </div>
         <% if (!"streamrserver".equals(tunnelType)) { %>
            <div id="portField" class="rowItem">
                <label>
                    <%=intl._t("Use SSL?")%>
                </label>
                <input value="1" type="checkbox" id="startOnLoad" name="useSSL" title="Use SSL to connect to target" <%=(editBean.isSSLEnabled(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />                
            </div>
         <% } /* !streamrserver */ %>
            
         <% if ("httpbidirserver".equals(tunnelType)) { %>
            <div class="subdivider">
                <hr />
            </div>
            <div id="accessField" class="rowItem">
                <label><%=intl._t("Access Point")%>:</label>
            </div> 
            <div id="portField" class="rowItem">
           	<label for="port" accesskey="P">
           	     <span class="accessKey">P</span>ort:
           	     <% String value4 = editBean.getClientPort(curTunnel);
           	        if (value4 == null || "".equals(value4.trim())) {
           	            out.write(" <font color=\"red\">(");
           	            out.write(intl._t("required"));
           	            out.write(")</font>");
           	        }
               	      %>
              	 </label>
                 <input type="text" size="6" maxlength="5" id="port" name="port" title="Access Port Number" value="<%=editBean.getClientPort(curTunnel)%>" class="freetext" />
            </div>
         <% } /* httpbidirserver */ %>
         <% if ("httpbidirserver".equals(tunnelType) || "streamrserver".equals(tunnelType)) { %>
            <div id="reachField" class="rowItem">
                <label for="reachableBy" accesskey="r">
                    <%=intl._t("Reachable by")%>(<span class="accessKey">R</span>):
                </label>
                <select id="reachableBy" name="reachableBy" title="IP for Client Access" class="selectbox">
              <%
                    String clientInterface = editBean.getClientInterface(curTunnel);
                    for (String ifc : editBean.interfaceSet()) {
                        out.write("<option value=\"");
                        out.write(ifc);
                        out.write('\"');
                        if (ifc.equals(clientInterface))
                            out.write(" selected=\"selected\"");
                        out.write('>');
                        out.write(ifc);
                        out.write("</option>\n");
                    }
              %>
                </select>                
            </div>
         <% } /* httpbidirserver || streamrserver */ %>

            <div class="subdivider">
                <hr />
            </div>
            
            <% if (("httpserver".equals(tunnelType)) || ("httpbidirserver".equals(tunnelType))) {
          %><div id="websiteField" class="rowItem">
                <label for="spoofedHost" accesskey="W">
                    <%=intl._t("Website name")%>(<span class="accessKey">W</span>):
                </label>
                <input type="text" size="20" id="targetHost" name="spoofedHost" title="Website Host Name" value="<%=editBean.getSpoofedHost(curTunnel)%>" class="freetext" />                
                <span class="comment"><%=intl._t("(leave blank for outproxies)")%></span>
            </div>
            <% }
          %><div id="privKeyField" class="rowItem">
                <label for="privKeyFile" accesskey="k">
                    <%=intl._t("Private key file")%>(<span class="accessKey">k</span>):
                    <% String value3 = editBean.getPrivateKeyFile(curTunnel);
                       if (value3 == null || "".equals(value3.trim())) {
                           out.write(" <font color=\"red\">(");
                           out.write(intl._t("required"));
                           out.write(")</font>");
                       }
                     %>
                </label>
                <input type="text" size="30" id="privKeyFile" name="privKeyFile" title="Path to Private Key File" value="<%=editBean.getPrivateKeyFile(curTunnel)%>" class="freetext" />               
            </div>

            <div id="destinationField" class="rowItem">
                <label for="localDestination" accesskey="L">
                    <%=intl._t("Local destination")%>(<span class="accessKey">L</span>):
                </label>
                <textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Read Only: Local Destination (if known)" wrap="off" spellcheck="false"><%=editBean.getDestinationBase64(curTunnel)%></textarea>               
            </div>

<%
  /******
%>
            <% if (("httpserver".equals(tunnelType)) || ("httpbidirserver".equals(tunnelType))) {
                   String sig = editBean.getNameSignature(curTunnel);
                   if (sig.length() > 0) {
          %><div id="sigField" class="rowItem">
                <label for="signature">
                    <%=intl._t("Hostname Signature")%>
                </label>
                <input type="text" size="30" readonly="readonly" title="Use to prove that the website name is for this destination" value="<%=sig%>" wrap="off" class="freetext" />                
            </div>
         <%
                   }  // sig
               }  // type
  ****/

            String b64 = editBean.getDestinationBase64(curTunnel);
            if (!"".equals(b64)) {
         %>
            <div id="destinationField" class="rowItem">
        <%
                b64 = b64.replace("=", "%3d");
                String name = editBean.getSpoofedHost(curTunnel);
                if (name == null || name.equals(""))
                    name = editBean.getTunnelName(curTunnel);
                // mysite.i2p is set in the installed i2ptunnel.config
                if (name != null && !name.equals("") && !name.equals("mysite.i2p") && !name.contains(" ") && name.endsWith(".i2p")) {
         %>
              <label>
              <a class="control" title="<%=intl._t("Generate QR Code")%>" href="/imagegen/qr?s=320&amp;t=<%=name%>&amp;c=http%3a%2f%2f<%=name%>%2f%3fi2paddresshelper%3d<%=b64%>" target="_top"><%=intl._t("Generate QR Code")%></a>
              </label>
              <a class="control" href="/susidns/addressbook.jsp?book=private&amp;hostname=<%=name%>&amp;destination=<%=b64%>#add"><%=intl._t("Add to local addressbook")%></a>    
              &nbsp;&nbsp;&nbsp;&nbsp;
              <a class="control" href="register?tunnel=<%=curTunnel%>"><%=intl._t("Registration Authentication")%></a>    
        <%
                } else {
          %>
              <label> </label>
              <span class="comment"><%=intl._t("Set name with .i2p suffix to enable QR code generation")%></span>
              <span class="comment"><%=intl._t("Set name with .i2p suffix to enable registration authentication")%></span>
        <%
                }  // name
         %>
            </div>
        <%
            }  // b64

         %>
            <div class="footer">
            </div>
        </div>

        <div id="tunnelAdvancedNetworking" class="panel">
            <div class="header">
                <h4><%=intl._t("Advanced networking options")%></h4>
            </div>

            <div class="separator">
                <hr />
            </div>
            
            <div id="tunnelOptionsField" class="rowItem">
                <label><%=intl._t("Tunnel Options")%>:</label>
            </div>
            <div id="depthField" class="rowItem">
                <label for="tunnelDepth" accesskey="t">
                    <%=intl._t("Length")%>(<span class="accessKey">t</span>):
                </label>
                <select id="tunnelDepth" name="tunnelDepth" title="Length of each Tunnel" class="selectbox">
                    <% int tunnelDepth = editBean.getTunnelDepth(curTunnel, 3);
                  %><option value="0"<%=(tunnelDepth == 0 ? " selected=\"selected\"" : "") %>><%=intl._t("0 hop tunnel (no anonymity)")%></option>
                    <option value="1"<%=(tunnelDepth == 1 ? " selected=\"selected\"" : "") %>><%=intl._t("1 hop tunnel (low anonymity)")%></option>
                    <option value="2"<%=(tunnelDepth == 2 ? " selected=\"selected\"" : "") %>><%=intl._t("2 hop tunnel (medium anonymity)")%></option>
                    <option value="3"<%=(tunnelDepth == 3 ? " selected=\"selected\"" : "") %>><%=intl._t("3 hop tunnel (high anonymity)")%></option>
                <% if (editBean.isAdvanced()) {
                  %><option value="4"<%=(tunnelDepth == 4 ? " selected=\"selected\"" : "") %>>4 hop tunnel</option>
                    <option value="5"<%=(tunnelDepth == 5 ? " selected=\"selected\"" : "") %>>5 hop tunnel</option>
                    <option value="6"<%=(tunnelDepth == 6 ? " selected=\"selected\"" : "") %>>6 hop tunnel</option>
                    <option value="7"<%=(tunnelDepth == 7 ? " selected=\"selected\"" : "") %>>7 hop tunnel</option>
                <% } else if (tunnelDepth > 3) { 
                %>    <option value="<%=tunnelDepth%>" selected="selected"><%=tunnelDepth%> <%=intl._t("hop tunnel (very poor performance)")%></option>
                <% }
              %></select>
            </div>
            <div id="varianceField" class="rowItem">
                <label for="tunnelVariance" accesskey="v">
                    <%=intl._t("Variance")%>(<span class="accessKey">V</span>):
                </label>
                <select id="tunnelVariance" name="tunnelVariance" title="Level of Randomization for Tunnel Depth" class="selectbox">
                    <% int tunnelVariance = editBean.getTunnelVariance(curTunnel, 0);
                  %><option value="0"<%=(tunnelVariance  ==  0 ? " selected=\"selected\"" : "") %>><%=intl._t("0 hop variance (no randomization, consistent performance)")%></option>
                    <option value="1"<%=(tunnelVariance  ==  1 ? " selected=\"selected\"" : "") %>><%=intl._t("+ 0-1 hop variance (medium additive randomization, subtractive performance)")%></option>
                    <option value="2"<%=(tunnelVariance  ==  2 ? " selected=\"selected\"" : "") %>><%=intl._t("+ 0-2 hop variance (high additive randomization, subtractive performance)")%></option>
                    <option value="-1"<%=(tunnelVariance == -1 ? " selected=\"selected\"" : "") %>><%=intl._t("+/- 0-1 hop variance (standard randomization, standard performance)")%></option>
                    <option value="-2"<%=(tunnelVariance == -2 ? " selected=\"selected\"" : "") %>><%=intl._t("+/- 0-2 hop variance (not recommended)")%></option>
                <% if (tunnelVariance > 2 || tunnelVariance < -2) {
                %>    <option value="<%=tunnelVariance%>" selected="selected"><%= (tunnelVariance > 2 ? "+ " : "+/- ") %>0-<%=tunnelVariance%> <%=intl._t("hop variance")%></option>
                <% }
              %></select>                
            </div>
            <div id="countField" class="rowItem">
                <label for="tunnelQuantity" accesskey="C">
                    <%=intl._t("Count")%>(<span class="accessKey">C</span>):
                </label>
                <select id="tunnelQuantity" name="tunnelQuantity" title="Number of Tunnels in Group" class="selectbox">
                    <%=editBean.getQuantityOptions(curTunnel)%>
                </select>                
            </div>
            <div id="backupField" class="rowItem">
                <label for="tunnelBackupQuantity" accesskey="b">
                    <%=intl._t("Backup Count")%>(<span class="accessKey">B</span>):
                </label>
                <select id="tunnelBackupQuantity" name="tunnelBackupQuantity" title="Number of Reserve Tunnels" class="selectbox">
                    <% int tunnelBackupQuantity = editBean.getTunnelBackupQuantity(curTunnel, 0);
                  %><option value="0"<%=(tunnelBackupQuantity == 0 ? " selected=\"selected\"" : "") %>><%=intl._t("0 backup tunnels (0 redundancy, no added resource usage)")%></option>
                    <option value="1"<%=(tunnelBackupQuantity == 1 ? " selected=\"selected\"" : "") %>><%=intl._t("1 backup tunnel each direction (low redundancy, low resource usage)")%></option>
                    <option value="2"<%=(tunnelBackupQuantity == 2 ? " selected=\"selected\"" : "") %>><%=intl._t("2 backup tunnels each direction (medium redundancy, medium resource usage)")%></option>
                    <option value="3"<%=(tunnelBackupQuantity == 3 ? " selected=\"selected\"" : "") %>><%=intl._t("3 backup tunnels each direction (high redundancy, high resource usage)")%></option>
                <% if (tunnelBackupQuantity > 3) {
                %>    <option value="<%=tunnelBackupQuantity%>" selected="selected"><%=tunnelBackupQuantity%> <%=intl._t("backup tunnels")%></option>
                <% }
              %></select>                
            </div>
                            
            <div class="subdivider">
                <hr />
            </div>
            
         <% if (!"streamrserver".equals(tunnelType)) { %>
            <div id="profileField" class="rowItem">
                <label for="profile" accesskey="f">
                    <%=intl._t("Profile")%>(<span class="accessKey">f</span>):
                </label>
                <select id="profile" name="profile" title="Connection Profile" class="selectbox">
                    <% boolean interactiveProfile = editBean.isInteractive(curTunnel);
                  %><option <%=(interactiveProfile == true  ? "selected=\"selected\" " : "")%>value="interactive"><%=intl._t("interactive connection")%> </option>
                    <option <%=(interactiveProfile == false ? "selected=\"selected\" " : "")%>value="bulk"><%=intl._t("bulk connection (downloads/websites/BT)")%> </option>
                </select>                
            </div> 

            <div class="subdivider">
                <hr />
            </div>
         <% } /* !streamrserver */ %>

            <div id="optionsField" class="rowItem">
                <label><%=intl._t("Router I2CP Address")%>:</label>
            </div>
            <div id="optionsHostField" class="rowItem">
                <label for="clientHost" accesskey="o">
                    <%=intl._t("Host")%>(<span class="accessKey">o</span>):
                </label>
                <input type="text" id="clientHost" name="clientHost" size="20" title="I2CP Hostname or IP" value="<%=editBean.getI2CPHost(curTunnel)%>" class="freetext" <% if (editBean.isRouterContext()) { %> readonly="readonly" <% } %> />                
            </div>
            <div id="optionsPortField" class="rowItem">
                <label for="clientPort" accesskey="r">
                    <%=intl._t("Port")%>(<span class="accessKey">r</span>):
                </label>
                <input type="text" id="clientPort" name="clientport" size="20" title="I2CP Port Number" value="<%=editBean.getI2CPPort(curTunnel)%>" class="freetext" <% if (editBean.isRouterContext()) { %> readonly="readonly" <% } %> />                
            </div>
            
            <div class="subdivider">
                <hr />
            </div>
           
            <div id="optionsField" class="rowItem">
                <label for="encrypt" accesskey="e">
                    <%=intl._t("Encrypt Leaseset")%>(<span class="accessKey">E</span>):
                </label>
            </div>
            <div id="portField" class="rowItem">
                <label for="encrypt" accesskey="e">
                    <%=intl._t("Enable")%>:
                </label>
                <input value="1" type="checkbox" id="startOnLoad" name="encrypt" title="ONLY clients with the encryption key will be able to connect"<%=(editBean.getEncrypt(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />                
            </div>
            <div id="portField" class="rowItem">
                <label for="encrypt" accesskey="e">
                    <%=intl._t("Encryption Key")%>:
                </label>
                <textarea rows="1" style="height: 3em;" cols="44" id="portField" name="encryptKey" title="Encrypt Key" wrap="off" spellcheck="false"><%=editBean.getEncryptKey(curTunnel)%></textarea>               
            </div>
            <div id="portField" class="rowItem">
                <label for="force" accesskey="c">
                    <%=intl._t("Generate New Key")%>:
                </label>
                <button accesskey="S" class="control" type="submit" name="action" value="Generate" title="Generate New Key Now"><%=intl._t("Generate")%></button>
                <span class="comment"><%=intl._t("(Tunnel must be stopped first)")%></span>
            </div>
                 
            <div class="subdivider">
                <hr />
            </div>
           
            <div id="optionsField" class="rowItem">
                <label for="access" accesskey="s">
                    <%=intl._t("Restricted Access List")%>(<span class="accessKey">s</span>):
                </label>
            </div>
            <div id="portField" class="rowItem">
                <% /* can't use <label> here */ %>
                <p><input value="0" type="radio" id="startOnLoad" name="accessMode" title="Allow all clients"<%=(editBean.getAccessMode(curTunnel).equals("0") ? " checked=\"checked\"" : "")%> class="tickbox" />                
                <b><%=intl._t("Disable")%></b></p>
                <p><input value="2" type="radio" id="startOnLoad" name="accessMode" title="Reject listed clients"<%=(editBean.getAccessMode(curTunnel).equals("2") ? " checked=\"checked\"" : "")%> class="tickbox" />                
                <b><%=intl._t("Blacklist")%></b></p>
                <p><input value="1" type="radio" id="startOnLoad" name="accessMode" title="Allow listed clients only"<%=(editBean.getAccessMode(curTunnel).equals("1") ? " checked=\"checked\"" : "")%> class="tickbox" />                
                <b><%=intl._t("Whitelist")%></b></p>
            </div>
            <div id="accessListField" class="rowItem">
                <label for="accessList" accesskey="s">
                    <%=intl._t("Access List")%>:
                </label>
                <textarea rows="2" style="height: 8em;" cols="60" name="accessList" title="Access List" wrap="off" spellcheck="false"><%=editBean.getAccessList(curTunnel)%></textarea>               
            </div>
                 
            <% if (("httpserver".equals(tunnelType)) || ("httpbidirserver".equals(tunnelType))) {
            %><div class="rowItem">
                <div id="optionsField" class="rowItem">
                    <label>
                        <%=intl._t("Block Access via Inproxies")%>:
                    </label>
                </div>
                <div id="portField" class="rowItem">
                    <label for="access" accesskey="d">
                        <%=intl._t("Enable")%>:
                    </label>
                    <input value="1" type="checkbox" id="startOnLoad" name="rejectInproxy" title="Deny inproxy access when enabled"<%=(editBean.isRejectInproxy(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />                
                </div>
              </div>
            <div class="rowItem">
                <div id="optionsField" class="rowItem">
                    <label>
                        <%=intl._t("Block Accesses containing Referers")%>:
                    </label>
                </div>
                <div id="portField" class="rowItem">
                    <label for="access" accesskey="d">
                        <%=intl._t("Enable")%>:
                    </label>
                    <input value="1" type="checkbox" id="startOnLoad" name="rejectReferer" title="Deny accesseses with referers (probably from inproxies)"<%=(editBean.isRejectReferer(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />                
                </div>
              </div>
            <div class="rowItem">
                <div id="optionsField" class="rowItem">
                    <label>
                        <%=intl._t("Block these User-Agents")%>:
                    </label>
                </div>
                <div id="portField" class="rowItem">
                    <label for="access" accesskey="d">
                        <%=intl._t("Enable")%>:
                    </label>
                    <input value="1" type="checkbox" id="startOnLoad" name="rejectUserAgents" title="Deny User-Agents matching these strings (probably from inproxies)"<%=(editBean.isRejectUserAgents(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />                
                </div>
                <div id="optionsHostField" class="rowItem">
                    <input type="text" id="userAgents" name="userAgents" size="20" title="comma separated, e.g. Mozilla,Opera (case-sensitive)" value="<%=editBean.getUserAgents(curTunnel)%>" class="freetext" />                
                </div>
              </div>
            <% } // httpserver
            %><div class="rowItem">
                <div id="optionsField" class="rowItem">
                    <label>
                        <%=intl._t("Unique Local Address per Client")%>:
                    </label>
                </div>
                <div id="portField" class="rowItem">
                    <label for="access" accesskey="d">
                        <%=intl._t("Enable")%>:
                    </label>
                    <input value="1" type="checkbox" id="startOnLoad" name="uniqueLocal" title="Use unique IP addresses for each connecting client (local non-SSL servers only)"<%=(editBean.getUniqueLocal(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />                
                </div>
            </div>
            <div class="rowItem">
                <div id="optionsField" class="rowItem">
                    <label>
                        <%=intl._t("Optimize for Multihoming")%>:
                    </label>
                </div>
                <div id="portField" class="rowItem">
                    <label for="access" accesskey="d">
                        <%=intl._t("Enable")%>:
                    </label>
                    <input value="1" type="checkbox" id="startOnLoad" name="multihome" title="Only enable if you are hosting this service on multiple routers"<%=(editBean.getMultihome(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />                
                </div>
            </div>
            <div class="subdivider">
                <hr />
            </div>

            <div class="rowItem">
              <div id="optionsField" class="rowItem">
                  <label><%=intl._t("Inbound connection limits (0=unlimited)")%><br /><%=intl._t("Per client")%>:</label>
              </div>
              <div id="portField" class="rowItem">
                  <label><%=intl._t("Per minute")%>:</label>
                  <input type="text" id="port" name="limitMinute" value="<%=editBean.getLimitMinute(curTunnel)%>" class="freetext" />                
              </div>
              <div id="portField" class="rowItem">
                  <label><%=intl._t("Per hour")%>:</label>
                  <input type="text" id="port" name="limitHour" value="<%=editBean.getLimitHour(curTunnel)%>" class="freetext" />                
              </div>
              <div id="portField" class="rowItem">
                  <label><%=intl._t("Per day")%>:</label>
                  <input type="text" id="port" name="limitDay" value="<%=editBean.getLimitDay(curTunnel)%>" class="freetext" />                
              </div>
            </div>
            <div class="rowItem">
              <div id="optionsField" class="rowItem">
                  <label><%=intl._t("Total")%>:</label>
              </div>
              <div id="portField" class="rowItem">
                  <input type="text" id="port" name="totalMinute" value="<%=editBean.getTotalMinute(curTunnel)%>" class="freetext" />                
              </div>
              <div id="portField" class="rowItem">
                  <input type="text" id="port" name="totalHour" value="<%=editBean.getTotalHour(curTunnel)%>" class="freetext" />                
              </div>
              <div id="portField" class="rowItem">
                  <input type="text" id="port" name="totalDay" value="<%=editBean.getTotalDay(curTunnel)%>" class="freetext" />                
              </div>
            </div>
            <div class="rowItem">
              <div id="optionsField" class="rowItem">
                  <label><%=intl._t("Max concurrent connections (0=unlimited)")%>:</label>
              </div>
              <div id="portField" class="rowItem">
                  <input type="text" id="port" name="maxStreams" value="<%=editBean.getMaxStreams(curTunnel)%>" class="freetext" />                
              </div>
            </div>

            <% if (("httpserver".equals(tunnelType)) || ("httpbidirserver".equals(tunnelType))) {
              %><div class="rowItem">
                  <div id="optionsField" class="rowItem">
                      <label><%=intl._t("POST limits (0=unlimited)")%><br /><%=intl._t("Per client")%>:</label>
                  </div>
                  <div id="portField" class="rowItem">
                      <label><%=intl._t("Per period")%>:</label>
                      <input type="text" id="port" name="postMax" value="<%=editBean.getPostMax(curTunnel)%>" class="freetext" />                
                  </div>
                  <div id="portField" class="rowItem">
                      <label><%=intl._t("Ban minutes")%>:</label>
                      <input type="text" id="port" name="postBanTime" value="<%=editBean.getPostBanTime(curTunnel)%>" class="freetext" />                
                  </div>
                </div>
                <div class="rowItem">
                  <div id="optionsField" class="rowItem">
                      <label><%=intl._t("Total")%>:</label>
                  </div>
                  <div id="portField" class="rowItem">
                      <input type="text" id="port" name="postTotalMax" value="<%=editBean.getPostTotalMax(curTunnel)%>" class="freetext" />                
                  </div>
                  <div id="portField" class="rowItem">
                      <input type="text" id="port" name="postTotalBanTime" value="<%=editBean.getPostTotalBanTime(curTunnel)%>" class="freetext" />                
                  </div>
                </div>
                <div class="rowItem">
                  <div id="optionsField" class="rowItem">
                      <label><%=intl._t("POST limit period (minutes)")%>:</label>
                  </div>
                  <div id="portField" class="rowItem">
                      <input type="text" id="port" name="postCheckTime" value="<%=editBean.getPostCheckTime(curTunnel)%>" class="freetext" />                
                  </div>
                </div>
            <% } // httpserver
          %><div class="subdivider">
                <hr />
            </div>
           
            <div id="optionsField" class="rowItem">
                <label for="reduce" accesskey="d">
                    <%=intl._t("Reduce tunnel quantity when idle")%>(<span class="accessKey">d</span>):
                </label>
            </div>
            <div id="portField" class="rowItem">
                <label for="access" accesskey="d">
                    <%=intl._t("Enable")%>:
                </label>
                <input value="1" type="checkbox" id="startOnLoad" name="reduce" title="Reduce Tunnels"<%=(editBean.getReduce(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />                
            </div>
            <div id="portField" class="rowItem">
                <label for="reduceCount" accesskey="d">
                    <%=intl._t("Reduced tunnel count")%>:
                </label>
                <input type="text" id="port" name="reduceCount" size="1" maxlength="1" title="Reduced Tunnel Count" value="<%=editBean.getReduceCount(curTunnel)%>" class="freetext" />                
            </div>
            <div id="portField" class="rowItem">
                <label for="reduceTime" accesskey="d">
                    <%=intl._t("Idle minutes")%>:
                </label>
                <input type="text" id="port" name="reduceTime" size="4" maxlength="4" title="Reduced Tunnel Idle Time" value="<%=editBean.getReduceTime(curTunnel)%>" class="freetext" />                
            </div>

            <div class="subdivider">
                <hr />
            </div>
           
<% /***************** %>
            <div id="tunnelOptionsField" class="rowItem">
                <label for="cert" accesskey="c">
                    <%=intl._t("New Certificate type")%>(<span class="accessKey">C</span>):
                </label>
            </div>
            <div id="hostField" class="rowItem">
              <div id="portField" class="rowItem">
                <label><%=intl._t("None")%></label>
                <input value="0" type="radio" id="startOnLoad" name="cert" title="No Certificate"<%=(editBean.getCert(curTunnel)==0 ? " checked=\"checked\"" : "")%> class="tickbox" />                
              </div>
              <div id="portField" class="rowItem">
                <label><%=intl._t("Hashcash (effort)")%></label>
                <input value="1" type="radio" id="startOnLoad" name="cert" title="Hashcash Certificate"<%=(editBean.getCert(curTunnel)==1 ? " checked=\"checked\"" : "")%> class="tickbox" />                
                <input type="text" id="port" name="effort" size="2" maxlength="2" title="Hashcash Effort" value="<%=editBean.getEffort(curTunnel)%>" class="freetext" />                
              </div>
            </div>
            <div id="portField" class="rowItem">
                <label for="force" accesskey="c">
                    <%=intl._t("Hashcash Calc Time")%>:
                </label>
                <button accesskey="S" class="control" type="submit" name="action" value="Estimate" title="Estimate Calculation Time"><%=intl._t("Estimate")%></button>
            </div>
            <div id="hostField" class="rowItem">
              <div id="portField" class="rowItem">
                <label><%=intl._t("Hidden")%></label>
                <input value="2" type="radio" id="startOnLoad" name="cert" title="Hidden Certificate"<%=(editBean.getCert(curTunnel)==2 ? " checked=\"checked\"" : "")%> class="tickbox" />                
              </div>
              <div id="portField" class="rowItem">
                <label for="signer" accesskey="c">
                    <%=intl._t("Signed (signed by)")%>:
                </label>
                <input value="3" type="radio" id="startOnLoad" name="cert" title="Signed Certificate"<%=(editBean.getCert(curTunnel)==3 ? " checked=\"checked\"" : "")%> class="tickbox" />                
                <input type="text" id="port" name="signer" size="50" title="Cert Signer" value="<%=editBean.getSigner(curTunnel)%>" class="freetext" />                
              </div>
            </div>
            <div id="portField" class="rowItem">
                <label for="force" accesskey="c">
                    <%=intl._t("Modify Certificate")%>:
                </label>
                <button accesskey="S" class="control" type="submit" name="action" value="Modify" title="Force New Cert Now"><%=intl._t("Modify")%></button>
                <span class="comment"><%=intl._t("(Tunnel must be stopped first)")%></span>
            </div>
<% **********************/ %>

         <%
            int currentSigType = editBean.getSigType(curTunnel, tunnelType);
            if (true /* editBean.isAdvanced() */ ) {
           %>
            <div id="tunnelOptionsField" class="rowItem">
                <label>
                    <%=intl._t("Signature type")%>
                    (<%=intl._t("Experts only! Changes B32!")%>)
                </label>
            </div>
            <div id="hostField" class="rowItem">
              <div id="portField" class="rowItem">
                <label>DSA-SHA1</label>
                <input value="0" type="radio" id="startOnLoad" name="sigType" title="Default"<%=(currentSigType==0 ? " checked=\"checked\"" : "")%> class="tickbox" />                
              </div>
           <% if (editBean.isSigTypeAvailable(1)) { %>
              <div id="portField" class="rowItem">
                <label>ECDSA-P256</label>
                <input value="1" type="radio" id="startOnLoad" name="sigType" title="Advanced users only"<%=(currentSigType==1 ? " checked=\"checked\"" : "")%> class="tickbox" />                
              </div>
           <% }
              if (editBean.isSigTypeAvailable(2)) { %>
              <div id="portField" class="rowItem">
                <label>ECDSA-P384</label>
                <input value="2" type="radio" id="startOnLoad" name="sigType" title="Advanced users only"<%=(currentSigType==2 ? " checked=\"checked\"" : "")%> class="tickbox" />                
              </div>
           <% }
              if (editBean.isSigTypeAvailable(3)) { %>
              <div id="portField" class="rowItem">
                <label>ECDSA-P521</label>
                <input value="3" type="radio" id="startOnLoad" name="sigType" title="Advanced users only"<%=(currentSigType==3 ? " checked=\"checked\"" : "")%> class="tickbox" />                
              </div>
           <% }
              if (editBean.isSigTypeAvailable(7)) { %>
              <div id="portField" class="rowItem">
                <label>Ed25519-SHA-512</label>
                <input value="7" type="radio" id="startOnLoad" name="sigType" title="Advanced users only"<%=(currentSigType==7 ? " checked=\"checked\"" : "")%> class="tickbox" />                
              </div>
           <% }   // isAvailable %>
            </div>
                 
            <div class="subdivider">
                <hr />
            </div>
         <% } // isAdvanced %>

         <%
            /* alternate dest, only if current dest is set and is DSA_SHA1 */

            if (currentSigType == 0 && !"".equals(b64) && !"streamrserver".equals(tunnelType)) {
          %><div id="privKeyField" class="rowItem">
                <label for="privKeyFile"><%=intl._t("Alternate private key file")%> (Ed25519-SHA-512):</label>
                <input type="text" size="30" id="privKeyFile" name="altPrivKeyFile" title="Path to Private Key File" value="<%=editBean.getAltPrivateKeyFile(curTunnel)%>" class="freetext" />               
            </div>

         <%
              String ab64 = editBean.getAltDestinationBase64(curTunnel);
              if (!"".equals(ab64)) {
          %><div id="destinationField" class="rowItem">
                <label for="localDestination"><%=intl._t("Alternate local destination")%>:</label>
                <textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Read Only: Alternate Local Destination" wrap="off" spellcheck="false"><%=ab64%></textarea>               
            </div>
            <div id="destinationField" class="rowItem">
                <label> </label>
                <span class="comment"><%=editBean.getAltDestHashBase32(curTunnel)%></span>
            </div>
            <div id="destinationField" class="rowItem">
        <%
                ab64 = ab64.replace("=", "%3d");
                String name = editBean.getSpoofedHost(curTunnel);
                if (name == null || name.equals(""))
                    name = editBean.getTunnelName(curTunnel);
                // mysite.i2p is set in the installed i2ptunnel.config
                if (name != null && !name.equals("") && !name.equals("mysite.i2p") && !name.contains(" ") && name.endsWith(".i2p")) {
           %><label>
              <a class="control" title="<%=intl._t("Generate QR Code")%>" href="/imagegen/qr?s=320&amp;t=<%=name%>&amp;c=http%3a%2f%2f<%=name%>%2f%3fi2paddresshelper%3d<%=ab64%>" target="_top"><%=intl._t("Generate QR Code")%></a>
              </label>
              <a class="control" href="/susidns/addressbook.jsp?book=private&amp;hostname=<%=name%>&amp;destination=<%=ab64%>#add"><%=intl._t("Add to local addressbook")%></a>
        <%
                } else {
            %><label> </label>
              <span class="comment"><%=intl._t("Set name with .i2p suffix to enable QR code generation")%></span>
        <%
                }  // name
          %></div>
        <%
              }  // ab64
          %><div class="subdivider"><hr /></div>
         <% } // currentSigType %>
                 
            <div id="customOptionsField" class="rowItem">
                <label for="customOptions" accesskey="u">
                    <%=intl._t("Custom options")%>(<span class="accessKey">u</span>):
                </label>
                <input type="text" id="customOptions" name="nofilter_customOptions" size="60" title="Custom Options" value="<%=editBean.getCustomOptions(curTunnel)%>" class="freetext" spellcheck="false"/>                
            </div>
            
            <div class="footer">
            </div>
        </div>
        <div id="globalOperationsPanel" class="panel">
            <div class="header"></div>
            <div class="footer">
                <div class="toolbox">
                    <input type="hidden" value="true" name="removeConfirm" />
                    <button id="controlCancel" class="control" type="submit" name="action" value="" title="Cancel"><%=intl._t("Cancel")%></button>
                    <button id="controlDelete" <%=(editBean.allowJS() ? "onclick=\"if (!confirm('Are you sure you want to delete?')) { return false; }\" " : "")%>accesskey="D" class="control" type="submit" name="action" value="Delete this proxy" title="Delete this Proxy"><%=intl._t("Delete")%>(<span class="accessKey">D</span>)</button>
                    <button id="controlSave" accesskey="S" class="control" type="submit" name="action" value="Save changes" title="Save Changes"><%=intl._t("Save")%>(<span class="accessKey">S</span>)</button>
                </div>
            </div> 
        </div>
    </form>
    <div id="pageFooter">
    </div>
<%

  } else {
     %>Tunnels are not initialized yet, please reload in two minutes.<%
  }  // isInitialized()

%>
</body>
</html>
