forked from I2P_Developers/i2p.i2p
* I2CP, HostsTxtNamingService, I2PTunnel:
Implement Base32 Hash hostnames, via the naming service. Names are of the form [52-characters].i2p, where the 52 characters are the Base32 representation of our 256-byte hash. The client requests a lookup of the hash via a brief I2CP session using new I2CP request/reply messages. The router looks up the leaseset for the hash to convert the hash to a dest. Convert the I2PTunnel 'preview' links to use Base32 hostnames as a demonstration.
This commit is contained in:
@@ -14,6 +14,7 @@ import net.i2p.I2PException;
|
||||
import net.i2p.client.I2PClient;
|
||||
import net.i2p.client.I2PClientFactory;
|
||||
import net.i2p.client.I2PSession;
|
||||
import net.i2p.data.Base32;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.Log;
|
||||
@@ -361,6 +362,19 @@ public class TunnelController implements Logging {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMyDestHashBase32() {
|
||||
if (_tunnel != null) {
|
||||
List sessions = _tunnel.getSessions();
|
||||
for (int i = 0; i < sessions.size(); i++) {
|
||||
I2PSession session = (I2PSession)sessions.get(i);
|
||||
Destination dest = session.getMyDestination();
|
||||
if (dest != null)
|
||||
return Base32.encode(dest.calculateHash().getData());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean getIsRunning() { return _running; }
|
||||
public boolean getIsStarting() { return _starting; }
|
||||
|
||||
|
@@ -437,6 +437,19 @@ public class IndexBean {
|
||||
}
|
||||
}
|
||||
|
||||
public String getDestHashBase32(int tunnel) {
|
||||
TunnelController tun = getController(tunnel);
|
||||
if (tun != null) {
|
||||
String rv = tun.getMyDestHashBase32();
|
||||
if (rv != null)
|
||||
return rv;
|
||||
else
|
||||
return "";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// bean props for form submission
|
||||
///
|
||||
|
@@ -180,13 +180,23 @@
|
||||
</div>
|
||||
<div class="targetField rowItem">
|
||||
<label>Points at:</label>
|
||||
<span class="text"><%=indexBean.getServerTarget(curServer)%></span>
|
||||
<span class="text">
|
||||
<%
|
||||
if ("httpserver".equals(indexBean.getInternalType(curServer))) {
|
||||
%>
|
||||
<a href="http://<%=indexBean.getServerTarget(curServer)%>/" title="Test HTTP server, bypassing I2P"><%=indexBean.getServerTarget(curServer)%></a>
|
||||
<%
|
||||
} else {
|
||||
%><%=indexBean.getServerTarget(curServer)%>
|
||||
<%
|
||||
}
|
||||
%></span>
|
||||
</div>
|
||||
<div class="previewField rowItem">
|
||||
<%
|
||||
if ("httpserver".equals(indexBean.getInternalType(curServer)) && indexBean.getTunnelStatus(curServer) == IndexBean.RUNNING) {
|
||||
%><label>Preview:</label>
|
||||
<a class="control" title="Preview this Tunnel" href="http://<%=(new java.util.Random()).nextLong()%>.i2p/?i2paddresshelper=<%=indexBean.getDestinationBase64(curServer)%>" target="_new">Preview</a>
|
||||
<a class="control" title="Test HTTP server through I2P" href="http://<%=indexBean.getDestHashBase32(curServer)%>.i2p">Preview</a>
|
||||
<%
|
||||
} else {
|
||||
%><span class="comment">No Preview</span>
|
||||
|
Reference in New Issue
Block a user