message: Use the LocalRemote for local, but external interfaces
diff: # Copyright (c) Microsoft Corporation. All rights reserved.
  # Licensed under the Apache 2.0 License.
  -from contextlib import contextmanager
  +from contextlib import contextmanager, closing
  from enum import Enum
  import infra.remote
  import infra.net
  import infra.path
  import infra.clients
  import os
  +import socket
  from loguru import logger as LOG
  @@ -24,6 +25,15 @@ class NodeStatus(Enum):
  RETIRED = 2
  +def is_addr_local(host, port):
  + with closing(socket.socket()) as s:
  + try:
  + s.bind((host, port or 0))
  + return True
  + except OSError:
  + return False
  +
  +
  class Node:
  def __init__(self, node_id, host, binary_dir=".", debug=False, perf=False):
  self.node_id = node_id
  @@ -41,6 +51,8 @@ class Node:
  if self.host == "localhost":
  self.host = infra.net.expand_localhost()
  +
  + if is_addr_local(self.host, self.rpc_port):
  self.remote_impl = infra.remote.LocalRemote
  else:
  self.remote_impl = infra.remote.SSHRemote
  