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

in prep for use by i2ptunnel
This commit is contained in:
zzz
2016-04-23 18:07:35 +00:00
parent f72753f3eb
commit 799d90e1b5
7 changed files with 15 additions and 15 deletions

View File

@ -30,6 +30,7 @@ import java.util.Map;
import java.util.regex.Pattern;
import net.i2p.I2PAppContext;
import net.i2p.client.naming.HostTxtEntry;
import net.i2p.util.EepGet;
import net.i2p.util.SecureFile;

View File

@ -32,6 +32,7 @@ import java.util.Properties;
import java.util.Set;
import net.i2p.I2PAppContext;
import net.i2p.client.naming.HostTxtEntry;
import net.i2p.client.naming.NamingService;
import net.i2p.client.naming.SingleFileNamingService;
import net.i2p.data.DataFormatException;

View File

@ -32,6 +32,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.NoSuchElementException;
import net.i2p.client.naming.HostTxtEntry;
import net.i2p.data.DataHelper;
/**

View File

@ -14,6 +14,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import net.i2p.client.naming.HostTxtEntry;
import net.i2p.data.DataHelper;
import net.i2p.util.SecureFile;
import net.i2p.util.SecureFileOutputStream;

View File

@ -26,6 +26,7 @@ import java.util.Iterator;
import java.util.List;
import net.i2p.I2PAppContext;
import net.i2p.client.naming.HostTxtEntry;
import net.i2p.util.PortMapper;
/**

View File

@ -1,4 +1,4 @@
package net.i2p.addressbook;
package net.i2p.client.naming;
import java.io.BufferedWriter;
import java.io.IOException;
@ -13,25 +13,27 @@ import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
import net.i2p.data.Signature;
import net.i2p.data.SigningPrivateKey;
import net.i2p.data.SigningPublicKey;
import net.i2p.util.OrderedProperties;
// for testing only
import java.io.File;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.util.Arrays;
import net.i2p.data.Base32;
import net.i2p.data.PrivateKeyFile;
import net.i2p.data.SigningPrivateKey;
import net.i2p.util.RandomSource;
/**
* 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
*/
class HostTxtEntry {
public class HostTxtEntry {
private final String name;
private final String dest;
@ -344,7 +346,6 @@ class HostTxtEntry {
/**
* Sign and set the "sig" property
* for testing only
*/
private void sign(SigningPrivateKey spk) {
signIt(spk, PROP_SIG);
@ -352,7 +353,6 @@ class HostTxtEntry {
/**
* Sign and set the "oldsig" property
* for testing only
*/
private void signInner(SigningPrivateKey spk) {
signIt(spk, PROP_OLDSIG);
@ -383,7 +383,6 @@ class HostTxtEntry {
}
/**
* for testing only
* @param sigprop The signature property to set
*/
private void signIt(SigningPrivateKey spk, String sigprop) {

View File

@ -59,10 +59,6 @@ public class SingleFileNamingService extends NamingService {
private long _lastWrite;
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) {
super(context);
File file = new File(filename);
@ -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).
* Does not write a newline.
*
@ -278,15 +274,15 @@ public class SingleFileNamingService extends NamingService {
boolean started = false;
for (Map.Entry<Object, Object> e : options.entrySet()) {
String k = (String) e.getKey();
if (!k.startsWith(RCVD_PROP_PREFIX))
if (!k.startsWith("="))
continue;
k = k.substring(1);
String v = (String) e.getValue();
if (started) {
out.write(PROP_SEPARATOR);
out.write(HostTxtEntry.PROP_SEPARATOR);
} else {
started = true;
out.write(PROPS_SEPARATOR);
out.write(HostTxtEntry.PROPS_SEPARATOR);
}
out.write(k);
out.write('=');