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

Side by Side Diff: runtime/bin/socket_patch.dart

Issue 76243002: Don't supply host names for the fixed internet addresses (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated after offline discussion Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/io/socket.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 patch class RawServerSocket { 5 patch class RawServerSocket {
6 /* patch */ static Future<RawServerSocket> bind(address, 6 /* patch */ static Future<RawServerSocket> bind(address,
7 int port, 7 int port,
8 {int backlog: 0, 8 {int backlog: 0,
9 bool v6Only: false}) { 9 bool v6Only: false}) {
10 return _RawServerSocket.bind(address, port, backlog, v6Only); 10 return _RawServerSocket.bind(address, port, backlog, v6Only);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 new _InternetAddress.fixed(_ADDRESS_LOOPBACK_IP_V4); 66 new _InternetAddress.fixed(_ADDRESS_LOOPBACK_IP_V4);
67 static _InternetAddress LOOPBACK_IP_V6 = 67 static _InternetAddress LOOPBACK_IP_V6 =
68 new _InternetAddress.fixed(_ADDRESS_LOOPBACK_IP_V6); 68 new _InternetAddress.fixed(_ADDRESS_LOOPBACK_IP_V6);
69 static _InternetAddress ANY_IP_V4 = 69 static _InternetAddress ANY_IP_V4 =
70 new _InternetAddress.fixed(_ADDRESS_ANY_IP_V4); 70 new _InternetAddress.fixed(_ADDRESS_ANY_IP_V4);
71 static _InternetAddress ANY_IP_V6 = 71 static _InternetAddress ANY_IP_V6 =
72 new _InternetAddress.fixed(_ADDRESS_ANY_IP_V6); 72 new _InternetAddress.fixed(_ADDRESS_ANY_IP_V6);
73 73
74 final InternetAddressType type; 74 final InternetAddressType type;
75 final String address; 75 final String address;
76 final String host; 76 final String _host;
77 final Uint8List _sockaddr_storage; 77 final Uint8List _sockaddr_storage;
78 78
79 String get host => _host != null ? _host : address;
80
79 bool get isLoopback { 81 bool get isLoopback {
80 switch (type) { 82 switch (type) {
81 case InternetAddressType.IP_V4: 83 case InternetAddressType.IP_V4:
82 return _sockaddr_storage[_IPV4_ADDR_OFFSET] == 127; 84 return _sockaddr_storage[_IPV4_ADDR_OFFSET] == 127;
83 85
84 case InternetAddressType.IP_V6: 86 case InternetAddressType.IP_V6:
85 for (int i = 0; i < _IPV6_ADDR_LENGTH - 1; i++) { 87 for (int i = 0; i < _IPV6_ADDR_LENGTH - 1; i++) {
86 if (_sockaddr_storage[_IPV6_ADDR_OFFSET + i] != 0) return false; 88 if (_sockaddr_storage[_IPV6_ADDR_OFFSET + i] != 0) return false;
87 } 89 }
88 int lastByteIndex = _IPV6_ADDR_OFFSET + _IPV6_ADDR_LENGTH - 1; 90 int lastByteIndex = _IPV6_ADDR_OFFSET + _IPV6_ADDR_LENGTH - 1;
(...skipping 12 matching lines...) Expand all
101 // Checking for fe80::/10. 103 // Checking for fe80::/10.
102 return _sockaddr_storage[_IPV6_ADDR_OFFSET] == 0xFE && 104 return _sockaddr_storage[_IPV6_ADDR_OFFSET] == 0xFE &&
103 (_sockaddr_storage[_IPV6_ADDR_OFFSET + 1] & 0xB0) == 0x80; 105 (_sockaddr_storage[_IPV6_ADDR_OFFSET + 1] & 0xB0) == 0x80;
104 } 106 }
105 } 107 }
106 108
107 Future<InternetAddress> reverse() => _NativeSocket.reverseLookup(this); 109 Future<InternetAddress> reverse() => _NativeSocket.reverseLookup(this);
108 110
109 _InternetAddress(InternetAddressType this.type, 111 _InternetAddress(InternetAddressType this.type,
110 String this.address, 112 String this.address,
111 String this.host, 113 String this._host,
112 List<int> this._sockaddr_storage); 114 List<int> this._sockaddr_storage);
113 115
114 factory _InternetAddress.fixed(int id) { 116 factory _InternetAddress.fixed(int id) {
115 var sockaddr = _fixed(id); 117 var sockaddr = _fixed(id);
116 switch (id) { 118 switch (id) {
117 case _ADDRESS_LOOPBACK_IP_V4: 119 case _ADDRESS_LOOPBACK_IP_V4:
118 return new _InternetAddress( 120 return new _InternetAddress(
119 InternetAddressType.IP_V4, "127.0.0.1", "localhost", sockaddr); 121 InternetAddressType.IP_V4, "127.0.0.1", null, sockaddr);
120 case _ADDRESS_LOOPBACK_IP_V6: 122 case _ADDRESS_LOOPBACK_IP_V6:
121 return new _InternetAddress( 123 return new _InternetAddress(
122 InternetAddressType.IP_V6, "::1", "ip6-localhost", sockaddr); 124 InternetAddressType.IP_V6, "::1", null, sockaddr);
123 case _ADDRESS_ANY_IP_V4: 125 case _ADDRESS_ANY_IP_V4:
124 return new _InternetAddress( 126 return new _InternetAddress(
125 InternetAddressType.IP_V4, "0.0.0.0", "0.0.0.0", sockaddr); 127 InternetAddressType.IP_V4, "0.0.0.0", "0.0.0.0", sockaddr);
126 case _ADDRESS_ANY_IP_V6: 128 case _ADDRESS_ANY_IP_V6:
127 return new _InternetAddress( 129 return new _InternetAddress(
128 InternetAddressType.IP_V6, "::", "::", sockaddr); 130 InternetAddressType.IP_V6, "::", "::", sockaddr);
129 default: 131 default:
130 assert(false); 132 assert(false);
131 throw new ArgumentError(); 133 throw new ArgumentError();
132 } 134 }
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 return localPort = nativeGetPort(); 438 return localPort = nativeGetPort();
437 } 439 }
438 440
439 int get remotePort { 441 int get remotePort {
440 return nativeGetRemotePeer()[1]; 442 return nativeGetRemotePeer()[1];
441 } 443 }
442 444
443 InternetAddress get remoteAddress { 445 InternetAddress get remoteAddress {
444 var result = nativeGetRemotePeer()[0]; 446 var result = nativeGetRemotePeer()[0];
445 var type = new InternetAddressType._from(result[0]); 447 var type = new InternetAddressType._from(result[0]);
446 return new _InternetAddress(type, result[1], "", result[2]); 448 return new _InternetAddress(type, result[1], null, result[2]);
447 } 449 }
448 450
449 // Multiplexes socket events to the socket handlers. 451 // Multiplexes socket events to the socket handlers.
450 void multiplex(int events) { 452 void multiplex(int events) {
451 canActivateEvents = false; 453 canActivateEvents = false;
452 for (int i = FIRST_EVENT; i <= LAST_EVENT; i++) { 454 for (int i = FIRST_EVENT; i <= LAST_EVENT; i++) {
453 if (((events & (1 << i)) != 0)) { 455 if (((events & (1 << i)) != 0)) {
454 if (i == CLOSED_EVENT && 456 if (i == CLOSED_EVENT &&
455 typeFlags != TYPE_LISTENING_SOCKET && 457 typeFlags != TYPE_LISTENING_SOCKET &&
456 !isClosing && 458 !isClosing &&
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 if (_detachReady != null) { 1220 if (_detachReady != null) {
1219 _detachReady.complete(null); 1221 _detachReady.complete(null);
1220 } else { 1222 } else {
1221 if (_raw != null) { 1223 if (_raw != null) {
1222 _raw.shutdown(SocketDirection.SEND); 1224 _raw.shutdown(SocketDirection.SEND);
1223 _disableWriteEvent(); 1225 _disableWriteEvent();
1224 } 1226 }
1225 } 1227 }
1226 } 1228 }
1227 } 1229 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/io/socket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698