Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: sdk/lib/io/secure_socket.dart

Issue 17381012: Ensure that there is no "hidden" DNS lookup in secure socket code (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/secure_socket.dart
diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart
index d6f573429f5f1ab21f747b12622b29e87f4c1233..d11b1028789782e5b438b6add5b5d5a57e79b987 100644
--- a/sdk/lib/io/secure_socket.dart
+++ b/sdk/lib/io/secure_socket.dart
@@ -57,7 +57,7 @@ abstract class SecureSocket implements Socket {
*
* If the [socket] already has a subscription, this subscription
* will no longer receive and events. In most cases calling
- * [:pause:] on this subscription before starting TLS handshake is
+ * `pause` on this subscription before starting TLS handshake is
* the right thing to do.
*
* If the [host] argument is passed it will be used as the host name
@@ -65,6 +65,12 @@ abstract class SecureSocket implements Socket {
* the [socket] will be used. The [host] can be either a [String] or
* an [InternetAddress].
*
+ * Calling this function will _not_ cause a DNS host lookup. If the
+ * [host] passed is a [String] the [InternetAddress] for the
+ * resulting [SecureSocket] will have the passed in [host] as its
+ * host value and the internet address of the already connected
+ * socket as its address value.
+ *
* See [connect] for more information on the arguments.
*
*/
@@ -246,7 +252,19 @@ abstract class RawSecureSocket implements RawSocket {
* If the [socket] already has a subscription, pass the existing
* subscription in the [subscription] parameter. The secure socket
* will take over the subscription and process any subsequent
- * events.
+ * events. In most cases calling `pause` on this subscription before
+ * starting TLS handshake is the right thing to do.
+ *
+ * If the [host] argument is passed it will be used as the host name
+ * for the TLS handshake. If [host] is not passed the host name from
+ * the [socket] will be used. The [host] can be either a [String] or
+ * an [InternetAddress].
+ *
+ * Calling this function will _not_ cause a DNS host lookup. If the
+ * [host] passed is a [String] the [InternetAddress] for the
+ * resulting [SecureSocket] will have this passed in [host] as its
+ * host value and the internet address of the already connected
+ * socket as its address value.
*
* See [connect] for more information on the arguments.
*
@@ -398,7 +416,12 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
bool onBadCertificate(X509Certificate certificate)}) {
var future;
if (host is String) {
- future = InternetAddress.lookup(host).then((addrs) => addrs.first);
+ if (socket != null) {
+ future = new Future.value(
+ (socket.address as dynamic)._cloneWithNewHost(host));
+ } else {
+ future = InternetAddress.lookup(host).then((addrs) => addrs.first);
+ }
} else {
future = new Future.value(host);
}
@@ -470,6 +493,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
}
_connectPending = true;
_secureFilter.connect(address.host,
+ (address as dynamic)._sockaddr_storage,
port,
is_server,
certificateName,
@@ -964,6 +988,7 @@ abstract class _SecureFilter {
external factory _SecureFilter();
void connect(String hostName,
+ Uint8List addr,
int port,
bool is_server,
String certificateName,
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698