<% // NOTE: Do the header carefully so there is no whitespace before the <%@page pageEncoding="UTF-8" %><%@page contentType="text/html" import="java.io.InputStream,net.i2p.i2ptunnel.web.EditBean,net.i2p.servlet.RequestWrapper,net.i2p.client.I2PSessionException,net.i2p.client.naming.HostTxtEntry,net.i2p.data.PrivateKeyFile,net.i2p.data.SigningPrivateKey,net.i2p.util.OrderedProperties" %><%@page %> <% /* right now using EditBean instead of IndexBean for getSpoofedHost() */ /* but might want to POST to it anyway ??? */ %> <% RequestWrapper wrequest = new RequestWrapper(request); String tun = wrequest.getParameter("tunnel"); int curTunnel = -1; if (tun != null) { try { curTunnel = Integer.parseInt(tun); } catch (NumberFormatException nfe) { curTunnel = -1; } } %> <%=intl._t("Hidden Services Manager")%> - <%=intl._t("Registration Helper")%> <% if (editBean.allowCSS()) { %> <% } %> <% if (editBean.isInitialized()) { %>
<% String tunnelTypeName; String tunnelType; boolean valid = false; if (curTunnel >= 0) { tunnelTypeName = editBean.getTunnelType(curTunnel); tunnelType = editBean.getInternalType(curTunnel); %>

<%=intl._t("Registration Helper")%> (<%=editBean.getTunnelName(curTunnel)%>)

<% } else { tunnelTypeName = "new"; tunnelType = "new"; %>

Fail

Tunnel not found

<% } String b64 = editBean.getDestinationBase64(curTunnel); String name = editBean.getSpoofedHost(curTunnel); if (name == null || name.equals("")) name = editBean.getTunnelName(curTunnel); %> <% if (!"new".equals(tunnelType)) { %> <% if (("httpserver".equals(tunnelType)) || ("httpbidirserver".equals(tunnelType))) { %> <% } %> <% if (b64 == null || b64.length() < 516) { %><% } else if (name == null || name.equals("") || name.contains(" ") || !name.endsWith(".i2p")) { if (("httpserver".equals(tunnelType)) || ("httpbidirserver".equals(tunnelType))) { %><% } else { %><% } } else { SigningPrivateKey spk = editBean.getSigningPrivateKey(curTunnel); if (spk == null) { %><% } else if (spk.isOffline()) { %><% } else { valid = true; OrderedProperties props = new OrderedProperties(); HostTxtEntry he = new HostTxtEntry(name, b64, props); he.sign(spk); %>
<%=intl._t("Please be sure to select, copy, and paste the entire contents of the appropriate authentication data into the form of your favorite registration site")%>
<%=intl._t("Tunnel name")%>: <%=editBean.getTunnelName(curTunnel)%>
<%=intl._t("Website name")%>: <%=editBean.getSpoofedHost(curTunnel)%>
<%=intl._t("Local destination is not available. Start the tunnel.")%>
<%=intl._t("To enable registration verification, edit tunnel and set name (or website name) to a valid host name ending in '.i2p'")%>
<%=intl._t("To enable registration verification, edit tunnel and set name to a valid host name ending in '.i2p'")%>
<%=intl._t("Destination signing key is not available. Start the tunnel.")%>
<%=intl._t("Destination signing key is offline. Use CLI tools on the offline machine.")%>
<%=intl._t("Authentication for adding host {0}", name)%>
"><% he.write(out); %>

<%=intl._t("Advanced authentication strings")%>

<% props.remove(HostTxtEntry.PROP_SIG); props.setProperty(HostTxtEntry.PROP_ACTION, HostTxtEntry.ACTION_REMOVE); he.signRemove(spk); %> <% String oldname = wrequest.getParameter("oldname"); String olddestfile = wrequest.getFilename("olddestfile"); SigningPrivateKey spk2 = null; String olddest = null; if (olddestfile != null) { InputStream destIn = wrequest.getInputStream("olddestfile"); if (destIn.available() > 0) { try { PrivateKeyFile pkf2 = new PrivateKeyFile(destIn); String oldb64 = pkf2.getDestination().toBase64(); if (!b64.equals(oldb64)) { // disallow dup olddest = oldb64; spk2 = pkf2.getSigningPrivKey(); } } catch (I2PSessionException ise) { throw new IllegalStateException("Unable to open private key file " + olddestfile, ise); } } } props.remove(HostTxtEntry.PROP_SIG); %> <% if (oldname != null && oldname.length() > 0 && !oldname.equals(name)) { props.setProperty(HostTxtEntry.PROP_ACTION, HostTxtEntry.ACTION_CHANGENAME); props.setProperty(HostTxtEntry.PROP_OLDNAME, oldname); he.sign(spk); %> <% } else { %> <% } %> <% props.remove(HostTxtEntry.PROP_SIG); %> <% if (oldname != null && oldname.length() > 0 && !oldname.equals(name)) { props.setProperty(HostTxtEntry.PROP_ACTION, HostTxtEntry.ACTION_ADDNAME); props.setProperty(HostTxtEntry.PROP_OLDNAME, oldname); he.sign(spk); %> <% } else { %> <% } %> <% props.remove(HostTxtEntry.PROP_SIG); props.remove(HostTxtEntry.PROP_OLDNAME); %> <% if (spk2 != null) { props.setProperty(HostTxtEntry.PROP_ACTION, HostTxtEntry.ACTION_CHANGEDEST); props.setProperty(HostTxtEntry.PROP_OLDDEST, olddest); he.signInner(spk2); he.sign(spk); %> <% } else { %> <% } %> <% props.remove(HostTxtEntry.PROP_SIG); props.remove(HostTxtEntry.PROP_OLDSIG); %> <% if (spk2 != null) { props.setProperty(HostTxtEntry.PROP_ACTION, HostTxtEntry.ACTION_ADDDEST); props.setProperty(HostTxtEntry.PROP_OLDDEST, olddest); he.signInner(spk2); he.sign(spk); %> <% } else { // If set, use the configured alternate destination as the new alias destination, // and the configured primary destination as the inner signer. // This is backwards from all the other ones, so we have to make a second HostTxtEntry just for this. SigningPrivateKey spk3 = null; String altdest = null; String altdestfile = editBean.getAltPrivateKeyFile(curTunnel); if (altdestfile.length() > 0) { try { PrivateKeyFile pkf3 = new PrivateKeyFile(altdestfile); altdest = pkf3.getDestination().toBase64(); if (!b64.equals(altdest)) { // disallow dup spk3 = pkf3.getSigningPrivKey(); } } catch (Exception e) {} } if (spk3 != null) { OrderedProperties props2 = new OrderedProperties(); HostTxtEntry he2 = new HostTxtEntry(name, altdest, props2); props2.setProperty(HostTxtEntry.PROP_ACTION, HostTxtEntry.ACTION_ADDDEST); props2.setProperty(HostTxtEntry.PROP_OLDDEST, b64); he2.signInner(spk); he2.sign(spk3); %> <% } else { %> <% } // spk3 } // spk2 %> <% props.remove(HostTxtEntry.PROP_SIG); props.remove(HostTxtEntry.PROP_OLDSIG); %> <% if (oldname != null && oldname.length() > 0 && !oldname.equals(name) && spk2 != null) { props.setProperty(HostTxtEntry.PROP_ACTION, HostTxtEntry.ACTION_ADDSUBDOMAIN); props.setProperty(HostTxtEntry.PROP_OLDNAME, oldname); props.setProperty(HostTxtEntry.PROP_OLDDEST, olddest); he.signInner(spk2); he.sign(spk); %> <% } else { %> <% } %> <% } // spk != null } // valid b64 and name } // !"new".equals(tunnelType) if (!valid && curTunnel >= 0) { %> <% } %> <% if (valid) { %> <% String oldname = wrequest.getParameter("oldname"); if (oldname == null) oldname = ""; %> <% } // valid %>
<%=intl._t("Authentication for removing host {0}", name)%>
"><% he.writeRemove(out); %>
<%=intl._t("Authentication for changing name")%>
"><% he.write(out); %>
<%=intl._t("This will change the name from {0} to {1}, using the same destination", oldname, name)%>
<%=intl._t("This tunnel must be configured with the new host name.")%>  <%=intl._t("Enter old hostname below.")%>
<%=intl._t("Authentication for adding alias")%>
"><% he.write(out); %>
<%=intl._t("This will add an alias {0} for {1}, using the same destination", name, oldname)%>
<%=intl._t("This tunnel must be configured with the new host name.")%>  <%=intl._t("Enter old hostname below.")%>
<%=intl._t("Authentication for changing destination")%>
"><% he.write(out); %>
<%=intl._t("This will change the destination for {0}", name)%>
<%=intl._t("This tunnel must be configured with the new destination.")%>  <%=intl._t("Enter old destination below.")%>
<%=intl._t("Authentication for adding alternate destination")%>
"><% he.write(out); %>
<%=intl._t("This will add an alternate destination for {0}", name)%>
"><% he2.write(out); %>
<%=intl._t("This will add an alternate destination for {0}", name)%>
<%=intl._t("This tunnel must be configured with the new destination.")%>  <%=intl._t("Enter old destination below.")%>
<%=intl._t("Authentication for adding subdomain")%>
"><% he.write(out); %>
<%=intl._t("This will add a subdomain {0} of {1}, with a different destination", name, oldname)%>
<%=intl._t("This tunnel must be configured with the new subdomain and destination.")%>  <%=intl._t("Enter higher-level domain and destination below.")%>
<%=intl._t("Go back and edit the tunnel")%>
<%=intl._t("Specify old name and destination")%>
<%=intl._t("This is only required for advanced authentication.")%>  <%=intl._t("See above for required items.")%>
<%=intl._t("Old hostname")%>:
<%=intl._t("Private Key File for old Destination")%>:
<%=intl._t("Cancel")%>
<% } else { %>
<%=intl._t("Tunnels are not initialized yet, please reload in two minutes.")%>
<% } // isInitialized() %>