forked from I2P_Developers/i2p.i2p
Go over about the first half of the 'hostname' mentions and decide whether they need to specify something like 'hostname or IP address' or whether 'address' would be a more-self-evident term
This commit is contained in:
@ -246,19 +246,19 @@ class AddressBook implements Iterable<Map.Entry<String, HostTxtEntry>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Do basic validation of the hostname
|
||||
* hostname was already converted to lower case by HostTxtParser.parse()
|
||||
* Do basic validation of the address
|
||||
* address was already converted to lower case by HostTxtParser.parse()
|
||||
*/
|
||||
public static boolean isValidKey(String host) {
|
||||
return
|
||||
host.endsWith(".i2p") &&
|
||||
host.length() > 4 &&
|
||||
host.length() <= 67 && // 63 + ".i2p"
|
||||
host.endsWith(".i2p") &&
|
||||
host.length() > 4 &&
|
||||
host.length() <= 67 && // 63 + ".i2p"
|
||||
(! host.startsWith(".")) &&
|
||||
(! host.startsWith("-")) &&
|
||||
host.indexOf(".-") < 0 &&
|
||||
host.indexOf("-.") < 0 &&
|
||||
host.indexOf("..") < 0 &&
|
||||
host.indexOf("..") < 0 &&
|
||||
// IDN - basic check, not complete validation
|
||||
(host.indexOf("--") < 0 || host.startsWith("xn--") || host.indexOf(".xn--") > 0) &&
|
||||
HOST_PATTERN.matcher(host).matches() &&
|
||||
@ -275,19 +275,19 @@ class AddressBook implements Iterable<Map.Entry<String, HostTxtEntry>> {
|
||||
(! host.endsWith(".proxy.i2p")) &&
|
||||
(! host.endsWith(".router.i2p")) &&
|
||||
(! host.endsWith(".console.i2p"))
|
||||
;
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do basic validation of the b64 dest, without bothering to instantiate it
|
||||
*/
|
||||
private static boolean isValidDest(String dest) {
|
||||
return
|
||||
return
|
||||
// null cert ends with AAAA but other zero-length certs would be AA
|
||||
((dest.length() == MIN_DEST_LENGTH && dest.endsWith("AA")) ||
|
||||
(dest.length() > MIN_DEST_LENGTH && dest.length() <= MAX_DEST_LENGTH)) &&
|
||||
// B64 comes in groups of 2, 3, or 4 chars, but never 1
|
||||
((dest.length() % 4) != 1) &&
|
||||
((dest.length() == MIN_DEST_LENGTH && dest.endsWith("AA")) ||
|
||||
(dest.length() > MIN_DEST_LENGTH && dest.length() <= MAX_DEST_LENGTH)) &&
|
||||
// B64 comes in groups of 2, 3, or 4 chars, but never 1
|
||||
((dest.length() % 4) != 1) &&
|
||||
B64_PATTERN.matcher(dest).matches()
|
||||
;
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ public interface I2PSession {
|
||||
* Ask the router to lookup a Destination by hostname.
|
||||
* Blocking. Waits a max of 10 seconds by default.
|
||||
*
|
||||
* This only makes sense for a b32 hostname, OR outside router context.
|
||||
* This only makes sense for a b32 address, OR outside router context.
|
||||
* Inside router context, just query the naming service.
|
||||
* Outside router context, this does NOT query the context naming service.
|
||||
* Do that first if you expect a local addressbook.
|
||||
|
@ -300,10 +300,10 @@ class SubSession extends I2PSessionMuxedImpl {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask the router to lookup a Destination by hostname.
|
||||
* Ask the router to lookup a Destination by address.
|
||||
* Blocking. Waits a max of 10 seconds by default.
|
||||
*
|
||||
* This only makes sense for a b32 hostname, OR outside router context.
|
||||
* This only makes sense for a b32 address, OR outside router context.
|
||||
* Inside router context, just query the naming service.
|
||||
* Outside router context, this does NOT query the context naming service.
|
||||
* Do that first if you expect a local addressbook.
|
||||
|
@ -89,22 +89,22 @@ public abstract class NamingService {
|
||||
public String reverseLookup(Hash h) { return null; }
|
||||
|
||||
/**
|
||||
* If the hostname is a valid Base64 encoded destination, return the
|
||||
* If the address is a valid Base64 encoded destination, return the
|
||||
* decoded Destination. Useful as a "fallback" in custom naming
|
||||
* implementations.
|
||||
* This is misnamed as it isn't a "lookup" at all, but
|
||||
* a simple conversion from a Base64 string to a Destination.
|
||||
*
|
||||
* @param hostname 516+ character Base 64
|
||||
* @param address 516+ character Base 64
|
||||
* @return Destination or null on error
|
||||
*/
|
||||
protected Destination lookupBase64(String hostname) {
|
||||
protected Destination lookupBase64(String address) {
|
||||
try {
|
||||
Destination result = new Destination();
|
||||
result.fromBase64(hostname);
|
||||
result.fromBase64(address);
|
||||
return result;
|
||||
} catch (DataFormatException dfe) {
|
||||
if (_log.shouldLog(Log.WARN)) _log.warn("Bad B64 dest [" + hostname + "]", dfe);
|
||||
if (_log.shouldLog(Log.WARN)) _log.warn("Bad B64 dest [" + address + "]", dfe);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -534,12 +534,12 @@ public abstract class NamingService {
|
||||
* This implementation returns null.
|
||||
* See also lookup(Hash, int).
|
||||
*
|
||||
* @param hostname must be {52 chars}.b32.i2p
|
||||
* @param address must be {52 chars}.b32.i2p
|
||||
* @param timeout in seconds; <= 0 means use router default
|
||||
* @return dest or null
|
||||
* @since 0.8.7
|
||||
*/
|
||||
public Destination lookupBase32(String hostname, int timeout) {
|
||||
public Destination lookupBase32(String address, int timeout) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class SOCKS5Client {
|
||||
* Caller must close sock on success.
|
||||
*
|
||||
* @param sock socket to the proxy
|
||||
* @param connHostName hostname for the proxy to connect to
|
||||
* @param connHostName hostname or IP for the proxy to connect to
|
||||
* @param connPort port for the proxy to connect to
|
||||
*/
|
||||
public static void connect(Socket sock, String connHostName, int connPort) throws IOException {
|
||||
@ -48,7 +48,7 @@ public class SOCKS5Client {
|
||||
* Caller must close sock on success.
|
||||
*
|
||||
* @param sock socket to the proxy
|
||||
* @param connHostName hostname for the proxy to connect to
|
||||
* @param connHostName hostname or IP for the proxy to connect to
|
||||
* @param connPort port for the proxy to connect to
|
||||
* @param configUser username for proxy authentication or null
|
||||
* @param configPW password for proxy authentication or null
|
||||
@ -76,7 +76,7 @@ public class SOCKS5Client {
|
||||
*
|
||||
* @param pin input stream from the proxy
|
||||
* @param pout output stream to the proxy
|
||||
* @param connHostName hostname for the proxy to connect to
|
||||
* @param connHostName hostname or IP for the proxy to connect to
|
||||
* @param connPort port for the proxy to connect to
|
||||
*/
|
||||
public static void connect(InputStream pin, OutputStream pout, String connHostName, int connPort) throws IOException {
|
||||
@ -91,7 +91,7 @@ public class SOCKS5Client {
|
||||
*
|
||||
* @param pin input stream from the proxy
|
||||
* @param pout output stream to the proxy
|
||||
* @param connHostName hostname for the proxy to connect to
|
||||
* @param connHostName hostname or IP for the proxy to connect to
|
||||
* @param connPort port for the proxy to connect to
|
||||
* @param configUser username for proxy authentication or null
|
||||
* @param configPW password for proxy authentication or null
|
||||
|
@ -390,8 +390,8 @@ public abstract class Addresses {
|
||||
|
||||
/**
|
||||
* Caching version of InetAddress.getByName(host).getAddress(), which is slow.
|
||||
* Caches numeric hostnames only.
|
||||
* Will resolve but not cache DNS hostnames.
|
||||
* Caches numeric addresses only.
|
||||
* Will resolve but not cache DNS addresses.
|
||||
*
|
||||
* Unlike InetAddress.getByName(), we do NOT allow numeric IPs
|
||||
* of the form d.d.d, d.d, or d, as these are almost certainly mistakes.
|
||||
@ -402,7 +402,7 @@ public abstract class Addresses {
|
||||
* InetAddress.getByName() also returns 127.0.0.1 for a host "",
|
||||
* but this is undocumented; as of 0.9.49, here we return null.
|
||||
*
|
||||
* @param host DNS or IPv4 or IPv6 hostname; if null or empty returns null
|
||||
* @param host DNS or IPv4 or IPv6 address; if null or empty returns null
|
||||
* @return IP or null
|
||||
* @since 0.9.3
|
||||
*/
|
||||
@ -480,7 +480,7 @@ public abstract class Addresses {
|
||||
* else the other type if available.
|
||||
* Will resolve but not cache DNS hostnames.
|
||||
*
|
||||
* @param host DNS or IPv4 or IPv6 hostname; if null returns null
|
||||
* @param host DNS or IPv4 or IPv6 address; if null returns null
|
||||
* @return IP or null
|
||||
* @since 0.9.28
|
||||
*/
|
||||
@ -533,7 +533,7 @@ public abstract class Addresses {
|
||||
* Number of results may also change based on caching at various layers,
|
||||
* even if the ultimate name server results did not change.
|
||||
*
|
||||
* @param host DNS or IPv4 or IPv6 hostname; if null returns null
|
||||
* @param host DNS or IPv4 or IPv6 address; if null returns null
|
||||
* @return non-empty list IPs, or null if none
|
||||
* @since 0.9.28
|
||||
*/
|
||||
|
Reference in New Issue
Block a user