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

Unified Diff: runtime/bin/vmservice/server.dart

Issue 2515023002: Allow binding the vm service to IPv6 addresses. (Closed)
Patch Set: . Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/observatory/tests/service/auth_token1_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/server.dart
diff --git a/runtime/bin/vmservice/server.dart b/runtime/bin/vmservice/server.dart
index 826205326a4d1390e4f4987fff3738c4683c5dcc..9a48adf3bbe9bba32782e3ada6df2f8665368611 100644
--- a/runtime/bin/vmservice/server.dart
+++ b/runtime/bin/vmservice/server.dart
@@ -134,11 +134,8 @@ class Server {
}
var ip = _server.address.address;
var port = _server.port;
- if (useAuthToken) {
- return Uri.parse('http://$ip:$port/$serviceAuthToken/');
- } else {
- return Uri.parse('http://$ip:$port/');
- }
+ var path = useAuthToken ? "$serviceAuthToken/" : "/";
+ return new Uri(scheme: 'http', host: ip, port: port, path: path);
}
Server(this._service, this._ip, this._port, this._originCheckDisabled);
@@ -154,6 +151,7 @@ class Server {
// Explicitly add localhost and 127.0.0.1 on any port (necessary for
// adb port forwarding).
if ((uri.host == 'localhost') ||
+ (uri.host == '::1') ||
(uri.host == '127.0.0.1')) {
return true;
}
@@ -300,28 +298,34 @@ class Server {
}
}
- Future startup() {
+ Future startup() async {
if (_server != null) {
// Already running.
- return new Future.value(this);
+ return this;
}
- var address = new InternetAddress(_ip);
// Startup HTTP server.
- return HttpServer.bind(address, _port).then((s) {
- _server = s;
+ try {
+ var addresses = await InternetAddress.lookup(_ip);
+ var address;
+ // Prefer IPv4 addresses.
+ for (var i = 0; i < addresses.length; i++) {
+ address = addresses[i];
+ if (address.type == InternetAddressType.IP_V4) break;
+ }
+ _server = await HttpServer.bind(address, _port);
_server.listen(_requestHandler, cancelOnError: true);
print('Observatory listening on $serverAddress');
// Server is up and running.
_notifyServerState(serverAddress.toString());
onServerAddressChange('$serverAddress');
return this;
- }).catchError((e, st) {
+ } catch (e, st) {
print('Could not start Observatory HTTP server:\n$e\n$st\n');
_notifyServerState("");
onServerAddressChange(null);
return this;
- });
+ }
}
Future cleanup(bool force) {
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/observatory/tests/service/auth_token1_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698