mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 19:22:14 -05:00
Merge pull request #408 from gogowitczak/master
Specifying connection port in KeyServer
This commit is contained in:
commit
32dcf86212
@ -18,24 +18,7 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.util;
|
package org.sufficientlysecure.keychain.util;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import android.text.Html;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
@ -51,7 +34,14 @@ import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
|||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
|
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
|
||||||
|
|
||||||
import android.text.Html;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO:
|
* TODO:
|
||||||
@ -82,7 +72,7 @@ public class HkpKeyServer extends KeyServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String mHost;
|
private String mHost;
|
||||||
private short mPort = 11371;
|
private short mPort;
|
||||||
|
|
||||||
// example:
|
// example:
|
||||||
// pub 2048R/<a href="/pks/lookup?op=get&search=0x887DF4BE9F5C9090">9F5C9090</a> 2009-08-17 <a
|
// pub 2048R/<a href="/pks/lookup?op=get&search=0x887DF4BE9F5C9090">9F5C9090</a> 2009-08-17 <a
|
||||||
@ -95,9 +85,25 @@ public class HkpKeyServer extends KeyServer {
|
|||||||
public static Pattern USER_ID_LINE = Pattern.compile("^ +(.+)$", Pattern.MULTILINE
|
public static Pattern USER_ID_LINE = Pattern.compile("^ +(.+)$", Pattern.MULTILINE
|
||||||
| Pattern.CASE_INSENSITIVE);
|
| Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
public HkpKeyServer(String host) {
|
private static final short PORT_DEFAULT = 11371;
|
||||||
mHost = host;
|
|
||||||
}
|
/**
|
||||||
|
* @param hostAndPort may be just "<code>hostname</code>" (eg. "<code>pool.sks-keyservers.net</code>"), then it will
|
||||||
|
* connect using {@link #PORT_DEFAULT}. However, port may be specified after colon
|
||||||
|
* ("<code>hostname:port</code>", eg. "<code>p80.pool.sks-keyservers.net:80</code>").
|
||||||
|
*/
|
||||||
|
public HkpKeyServer(String hostAndPort) {
|
||||||
|
String host = hostAndPort;
|
||||||
|
short port = PORT_DEFAULT;
|
||||||
|
final int colonPosition = hostAndPort.lastIndexOf(':');
|
||||||
|
if (colonPosition > 0) {
|
||||||
|
host = hostAndPort.substring(0, colonPosition);
|
||||||
|
final String portStr = hostAndPort.substring(colonPosition + 1);
|
||||||
|
port = Short.decode(portStr);
|
||||||
|
}
|
||||||
|
mHost = host;
|
||||||
|
mPort = port;
|
||||||
|
}
|
||||||
|
|
||||||
public HkpKeyServer(String host, short port) {
|
public HkpKeyServer(String host, short port) {
|
||||||
mHost = host;
|
mHost = host;
|
||||||
|
Loading…
Reference in New Issue
Block a user