summaryrefslogtreecommitdiffstats
path: root/adb/socket_spec.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2016-08-25 16:00:22 -0700
committerJosh Gao <jmgao@google.com>2016-09-01 15:49:06 -0700
commit9c869b58a8cf4f7c3bc88931fbd27d3f5187b2db (patch)
tree4016ec3aa65e79122025d8bdf4f3185c2b6aaf1a /adb/socket_spec.cpp
parent924d35a8d5f82e2d2f7e4dcedaa60791306b5fb5 (diff)
downloadsystem_core-9c869b58a8cf4f7c3bc88931fbd27d3f5187b2db.tar.gz
system_core-9c869b58a8cf4f7c3bc88931fbd27d3f5187b2db.tar.bz2
system_core-9c869b58a8cf4f7c3bc88931fbd27d3f5187b2db.zip
adb: allow use of arbitrary socket specs for command socket.
Bug: http://b/30445394 Change-Id: I474ede35ec3c56ad86da503c9703f83ef5e80862
Diffstat (limited to 'adb/socket_spec.cpp')
-rw-r--r--adb/socket_spec.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/adb/socket_spec.cpp b/adb/socket_spec.cpp
index f8bbbb325..18e6e6d88 100644
--- a/adb/socket_spec.cpp
+++ b/adb/socket_spec.cpp
@@ -131,6 +131,22 @@ bool is_socket_spec(const std::string& spec) {
return StartsWith(spec, "tcp:");
}
+bool is_local_socket_spec(const std::string& spec) {
+ for (const auto& it : kLocalSocketTypes) {
+ std::string prefix = it.first + ":";
+ if (StartsWith(spec, prefix.c_str())) {
+ return true;
+ }
+ }
+
+ std::string error;
+ std::string hostname;
+ if (!parse_tcp_spec(spec, &hostname, nullptr, &error)) {
+ return false;
+ }
+ return tcp_host_is_local(hostname);
+}
+
int socket_spec_connect(const std::string& spec, std::string* error) {
if (StartsWith(spec, "tcp:")) {
std::string hostname;