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

Side by Side Diff: dart/sdk/lib/io/secure_server_socket.dart

Issue 625953002: Support for the ALPN extension of the TLS protocol for Client and Server (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | « dart/runtime/bin/secure_socket_unsupported.cc ('k') | dart/sdk/lib/io/secure_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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * The [SecureServerSocket] is a server socket, providing a stream of high-level 8 * The [SecureServerSocket] is a server socket, providing a stream of high-level
9 * [Socket]s. 9 * [Socket]s.
10 * 10 *
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 * SecureSocket.peerCertificate after connecting. If no certificate 59 * SecureSocket.peerCertificate after connecting. If no certificate
60 * was received, the result will be null. 60 * was received, the result will be null.
61 */ 61 */
62 static Future<SecureServerSocket> bind( 62 static Future<SecureServerSocket> bind(
63 address, 63 address,
64 int port, 64 int port,
65 String certificateName, 65 String certificateName,
66 {int backlog: 0, 66 {int backlog: 0,
67 bool v6Only: false, 67 bool v6Only: false,
68 bool requestClientCertificate: false, 68 bool requestClientCertificate: false,
69 bool requireClientCertificate: false}) { 69 bool requireClientCertificate: false,
70 List<String> supportedProtocols}) {
70 return RawSecureServerSocket.bind( 71 return RawSecureServerSocket.bind(
71 address, 72 address,
72 port, 73 port,
73 certificateName, 74 certificateName,
74 backlog: backlog, 75 backlog: backlog,
75 v6Only: v6Only, 76 v6Only: v6Only,
76 requestClientCertificate: requestClientCertificate, 77 requestClientCertificate: requestClientCertificate,
77 requireClientCertificate: requireClientCertificate).then( 78 requireClientCertificate: requireClientCertificate,
79 supportedProtocols: supportedProtocols).then(
78 (serverSocket) => new SecureServerSocket._(serverSocket)); 80 (serverSocket) => new SecureServerSocket._(serverSocket));
79 } 81 }
80 82
81 StreamSubscription<SecureSocket> listen(void onData(SecureSocket socket), 83 StreamSubscription<SecureSocket> listen(void onData(SecureSocket socket),
82 {Function onError, 84 {Function onError,
83 void onDone(), 85 void onDone(),
84 bool cancelOnError}) { 86 bool cancelOnError}) {
85 return _socket.map((rawSocket) => new SecureSocket._(rawSocket)) 87 return _socket.map((rawSocket) => new SecureSocket._(rawSocket))
86 .listen(onData, 88 .listen(onData,
87 onError: onError, 89 onError: onError,
(...skipping 27 matching lines...) Expand all
115 * 117 *
116 * See [RawSecureSocket] for more info. 118 * See [RawSecureSocket] for more info.
117 */ 119 */
118 class RawSecureServerSocket extends Stream<RawSecureSocket> { 120 class RawSecureServerSocket extends Stream<RawSecureSocket> {
119 RawServerSocket _socket; 121 RawServerSocket _socket;
120 StreamController<RawSecureSocket> _controller; 122 StreamController<RawSecureSocket> _controller;
121 StreamSubscription<RawSocket> _subscription; 123 StreamSubscription<RawSocket> _subscription;
122 final String certificateName; 124 final String certificateName;
123 final bool requestClientCertificate; 125 final bool requestClientCertificate;
124 final bool requireClientCertificate; 126 final bool requireClientCertificate;
127 final List<String> supportedProtocols;
125 bool _closed = false; 128 bool _closed = false;
126 129
127 RawSecureServerSocket._(RawServerSocket serverSocket, 130 RawSecureServerSocket._(RawServerSocket serverSocket,
128 this.certificateName, 131 this.certificateName,
129 this.requestClientCertificate, 132 this.requestClientCertificate,
130 this.requireClientCertificate) { 133 this.requireClientCertificate,
134 this.supportedProtocols) {
131 _socket = serverSocket; 135 _socket = serverSocket;
132 _controller = new StreamController<RawSecureSocket>( 136 _controller = new StreamController<RawSecureSocket>(
133 sync: true, 137 sync: true,
134 onListen: _onSubscriptionStateChange, 138 onListen: _onSubscriptionStateChange,
135 onPause: _onPauseStateChange, 139 onPause: _onPauseStateChange,
136 onResume: _onPauseStateChange, 140 onResume: _onPauseStateChange,
137 onCancel: _onSubscriptionStateChange); 141 onCancel: _onSubscriptionStateChange);
138 } 142 }
139 143
140 /** 144 /**
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 * check SecureSocket.peerCertificate after connecting. If no certificate 184 * check SecureSocket.peerCertificate after connecting. If no certificate
181 * was received, the result will be null. 185 * was received, the result will be null.
182 */ 186 */
183 static Future<RawSecureServerSocket> bind( 187 static Future<RawSecureServerSocket> bind(
184 address, 188 address,
185 int port, 189 int port,
186 String certificateName, 190 String certificateName,
187 {int backlog: 0, 191 {int backlog: 0,
188 bool v6Only: false, 192 bool v6Only: false,
189 bool requestClientCertificate: false, 193 bool requestClientCertificate: false,
190 bool requireClientCertificate: false}) { 194 bool requireClientCertificate: false,
195 List<String> supportedProtocols}) {
191 return RawServerSocket.bind(address, port, backlog: backlog, v6Only: v6Only) 196 return RawServerSocket.bind(address, port, backlog: backlog, v6Only: v6Only)
192 .then((serverSocket) => new RawSecureServerSocket._( 197 .then((serverSocket) => new RawSecureServerSocket._(
193 serverSocket, 198 serverSocket,
194 certificateName, 199 certificateName,
195 requestClientCertificate, 200 requestClientCertificate,
196 requireClientCertificate)); 201 requireClientCertificate,
202 supportedProtocols));
197 } 203 }
198 204
199 StreamSubscription<RawSecureSocket> listen(void onData(RawSecureSocket s), 205 StreamSubscription<RawSecureSocket> listen(void onData(RawSecureSocket s),
200 {Function onError, 206 {Function onError,
201 void onDone(), 207 void onDone(),
202 bool cancelOnError}) { 208 bool cancelOnError}) {
203 return _controller.stream.listen(onData, 209 return _controller.stream.listen(onData,
204 onError: onError, 210 onError: onError,
205 onDone: onDone, 211 onDone: onDone,
206 cancelOnError: cancelOnError); 212 cancelOnError: cancelOnError);
(...skipping 27 matching lines...) Expand all
234 // Do nothing - connection is closed. 240 // Do nothing - connection is closed.
235 return; 241 return;
236 } 242 }
237 _RawSecureSocket.connect( 243 _RawSecureSocket.connect(
238 connection.address, 244 connection.address,
239 remotePort, 245 remotePort,
240 certificateName, 246 certificateName,
241 is_server: true, 247 is_server: true,
242 socket: connection, 248 socket: connection,
243 requestClientCertificate: requestClientCertificate, 249 requestClientCertificate: requestClientCertificate,
244 requireClientCertificate: requireClientCertificate) 250 requireClientCertificate: requireClientCertificate,
251 supportedProtocols: supportedProtocols)
245 .then((RawSecureSocket secureConnection) { 252 .then((RawSecureSocket secureConnection) {
246 if (_closed) { 253 if (_closed) {
247 secureConnection.close(); 254 secureConnection.close();
248 } else { 255 } else {
249 _controller.add(secureConnection); 256 _controller.add(secureConnection);
250 } 257 }
251 }).catchError((e) { 258 }).catchError((e) {
252 if (!_closed) { 259 if (!_closed) {
253 _controller.addError(e); 260 _controller.addError(e);
254 } 261 }
(...skipping 23 matching lines...) Expand all
278 onError: _onError); 285 onError: _onError);
279 } else { 286 } else {
280 close(); 287 close();
281 } 288 }
282 } 289 }
283 290
284 void set _owner(owner) { (_socket as dynamic)._owner = owner; } 291 void set _owner(owner) { (_socket as dynamic)._owner = owner; }
285 } 292 }
286 293
287 294
OLDNEW
« no previous file with comments | « dart/runtime/bin/secure_socket_unsupported.cc ('k') | dart/sdk/lib/io/secure_socket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698