Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions linodecli/plugins/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def call(args, context): # pylint: disable=too-many-branches
action="store_true",
help="If given, uses the Linode's SLAAC address for SSH.",
)
parser.add_argument(
"-d",
action="store_true",
help="If given, uses the Lindoe's domain name for SSH",
)

parsed, args = parser.parse_known_args(args)

Expand Down Expand Up @@ -147,4 +152,7 @@ def parse_target_address(
if ip.startswith("192.168"):
continue

if getattr(parsed, "d"):
ip = ip.replace(".", "-") + ".ip.linodeusercontent.com"

return ip
8 changes: 7 additions & 1 deletion tests/unit/test_plugin_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,17 @@ def test_parse_target_address():
"ipv6": "c001:d00d::1337/128",
}

test_namespace = argparse.Namespace(**{"6": False})
test_namespace = argparse.Namespace(**{"6": False, "d": False})

address = plugin.parse_target_address(test_namespace, test_target)
assert address == "123.123.123.123"

# Hack to work around invalid key
setattr(test_namespace, "d", True)

address = plugin.parse_target_address(test_namespace, test_target)
assert address == "123-123-123-123.ip.linodeusercontent.com"

# Hack to work around invalid key
setattr(test_namespace, "6", True)

Expand Down