I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 799d90e1 authored by zzz's avatar zzz
Browse files

Addressbook: Move HostTxtEntry to net.i2p.client.naming,

in prep for use by i2ptunnel
parent f72753f3
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,7 @@ import java.util.Map; ...@@ -30,6 +30,7 @@ import java.util.Map;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.client.naming.HostTxtEntry;
import net.i2p.util.EepGet; import net.i2p.util.EepGet;
import net.i2p.util.SecureFile; import net.i2p.util.SecureFile;
......
...@@ -32,6 +32,7 @@ import java.util.Properties; ...@@ -32,6 +32,7 @@ import java.util.Properties;
import java.util.Set; import java.util.Set;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.client.naming.HostTxtEntry;
import net.i2p.client.naming.NamingService; import net.i2p.client.naming.NamingService;
import net.i2p.client.naming.SingleFileNamingService; import net.i2p.client.naming.SingleFileNamingService;
import net.i2p.data.DataFormatException; import net.i2p.data.DataFormatException;
......
...@@ -32,6 +32,7 @@ import java.util.Locale; ...@@ -32,6 +32,7 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import net.i2p.client.naming.HostTxtEntry;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
/** /**
......
...@@ -14,6 +14,7 @@ import java.util.List; ...@@ -14,6 +14,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import net.i2p.client.naming.HostTxtEntry;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
import net.i2p.util.SecureFile; import net.i2p.util.SecureFile;
import net.i2p.util.SecureFileOutputStream; import net.i2p.util.SecureFileOutputStream;
......
...@@ -26,6 +26,7 @@ import java.util.Iterator; ...@@ -26,6 +26,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.client.naming.HostTxtEntry;
import net.i2p.util.PortMapper; import net.i2p.util.PortMapper;
/** /**
......
package net.i2p.addressbook; package net.i2p.client.naming;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.IOException; import java.io.IOException;
...@@ -13,25 +13,27 @@ import net.i2p.data.DataFormatException; ...@@ -13,25 +13,27 @@ import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
import net.i2p.data.Destination; import net.i2p.data.Destination;
import net.i2p.data.Signature; import net.i2p.data.Signature;
import net.i2p.data.SigningPrivateKey;
import net.i2p.data.SigningPublicKey; import net.i2p.data.SigningPublicKey;
import net.i2p.util.OrderedProperties; import net.i2p.util.OrderedProperties;
// for testing only // for testing only
import java.io.File; import java.io.File;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.util.Arrays; import java.util.Arrays;
import net.i2p.data.Base32; import net.i2p.data.Base32;
import net.i2p.data.PrivateKeyFile; import net.i2p.data.PrivateKeyFile;
import net.i2p.data.SigningPrivateKey;
import net.i2p.util.RandomSource; import net.i2p.util.RandomSource;
/** /**
* A hostname, b64 destination, and optional properties. * A hostname, b64 destination, and optional properties.
* Includes methods to sign and verify the entry.
* Used by addressbook to parse subscription data,
* and by i2ptunnel to generate signed metadata.
* *
* @since 0.9.26 * @since 0.9.26
*/ */
class HostTxtEntry { public class HostTxtEntry {
private final String name; private final String name;
private final String dest; private final String dest;
...@@ -344,7 +346,6 @@ class HostTxtEntry { ...@@ -344,7 +346,6 @@ class HostTxtEntry {
/** /**
* Sign and set the "sig" property * Sign and set the "sig" property
* for testing only
*/ */
private void sign(SigningPrivateKey spk) { private void sign(SigningPrivateKey spk) {
signIt(spk, PROP_SIG); signIt(spk, PROP_SIG);
...@@ -352,7 +353,6 @@ class HostTxtEntry { ...@@ -352,7 +353,6 @@ class HostTxtEntry {
/** /**
* Sign and set the "oldsig" property * Sign and set the "oldsig" property
* for testing only
*/ */
private void signInner(SigningPrivateKey spk) { private void signInner(SigningPrivateKey spk) {
signIt(spk, PROP_OLDSIG); signIt(spk, PROP_OLDSIG);
...@@ -383,7 +383,6 @@ class HostTxtEntry { ...@@ -383,7 +383,6 @@ class HostTxtEntry {
} }
/** /**
* for testing only
* @param sigprop The signature property to set * @param sigprop The signature property to set
*/ */
private void signIt(SigningPrivateKey spk, String sigprop) { private void signIt(SigningPrivateKey spk, String sigprop) {
......
...@@ -59,10 +59,6 @@ public class SingleFileNamingService extends NamingService { ...@@ -59,10 +59,6 @@ public class SingleFileNamingService extends NamingService {
private long _lastWrite; private long _lastWrite;
private volatile boolean _isClosed; private volatile boolean _isClosed;
private static final String RCVD_PROP_PREFIX = "=";
private static final String PROPS_SEPARATOR = "#!";
private static final char PROP_SEPARATOR = '#';
public SingleFileNamingService(I2PAppContext context, String filename) { public SingleFileNamingService(I2PAppContext context, String filename) {
super(context); super(context);
File file = new File(filename); File file = new File(filename);
...@@ -267,7 +263,7 @@ public class SingleFileNamingService extends NamingService { ...@@ -267,7 +263,7 @@ public class SingleFileNamingService extends NamingService {
} }
/** /**
* Write the subscription options part of the line (after the #!). * Write the subscription options part of the line (including the #!).
* Only options starting with '=' (if any) are written (with the '=' stripped). * Only options starting with '=' (if any) are written (with the '=' stripped).
* Does not write a newline. * Does not write a newline.
* *
...@@ -278,15 +274,15 @@ public class SingleFileNamingService extends NamingService { ...@@ -278,15 +274,15 @@ public class SingleFileNamingService extends NamingService {
boolean started = false; boolean started = false;
for (Map.Entry<Object, Object> e : options.entrySet()) { for (Map.Entry<Object, Object> e : options.entrySet()) {
String k = (String) e.getKey(); String k = (String) e.getKey();
if (!k.startsWith(RCVD_PROP_PREFIX)) if (!k.startsWith("="))
continue; continue;
k = k.substring(1); k = k.substring(1);
String v = (String) e.getValue(); String v = (String) e.getValue();
if (started) { if (started) {
out.write(PROP_SEPARATOR); out.write(HostTxtEntry.PROP_SEPARATOR);
} else { } else {
started = true; started = true;
out.write(PROPS_SEPARATOR); out.write(HostTxtEntry.PROPS_SEPARATOR);
} }
out.write(k); out.write(k);
out.write('='); out.write('=');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment