diff --git a/asyncssh/config.py b/asyncssh/config.py index d481cc2..351648d 100644 --- a/asyncssh/config.py +++ b/asyncssh/config.py @@ -447,6 +447,8 @@ def _match_val(self, match: str) -> object: return self._local_user elif match == 'user': return self._options.get('User', self._local_user) + elif match == 'tagged': + return self._options.get('Tag', '') else: return None @@ -561,6 +563,7 @@ def _set_tokens(self) -> None: ('ServerAliveCountMax', SSHConfig._set_int), ('ServerAliveInterval', SSHConfig._set_int), ('SetEnv', SSHConfig._append_string_list), + ('Tag', SSHConfig._set_string), ('TCPKeepAlive', SSHConfig._set_bool), ('User', SSHConfig._set_string), ('UserKnownHostsFile', SSHConfig._set_string_list) diff --git a/tests/test_config.py b/tests/test_config.py index d06eec6..b781d21 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -349,6 +349,17 @@ def test_set_and_match_user(self): self.assertEqual(config.get('BindAddress'), 'addr') self.assertEqual(config.get('Port'), 2222) + def test_tag(self): + """Test setting and matching a tag""" + + config = self._parse_config('Tag tag2\n' + 'Match tagged tag1\n' + ' Port 1111\n' + 'Match tagged tag*\n' + ' Port 2222') + + self.assertEqual(config.get('Port'), 2222) + def test_port_already_set(self): """Test that port is ignored if set outside of the config"""