diff --git a/system.go b/system.go index 7634a7a..817f9bc 100644 --- a/system.go +++ b/system.go @@ -40,7 +40,7 @@ func SystemSSHEnabled() (bool, error) { return false, fmt.Errorf("failed to read ssh config: %w", err) } - return strings.Contains(string(data), "127.0.0.1:22"), nil + return !strings.Contains(string(data), "127.0.0.1:22"), nil } // SystemEnableSSH server diff --git a/system_test.go b/system_test.go index bdf39c8..0c5adf2 100644 --- a/system_test.go +++ b/system_test.go @@ -43,12 +43,12 @@ func TestSystemSSHEnabled(t *testing.T) { ass.NoError(ioutil.WriteFile(systemDropbearConfig, []byte("test"), os.ModePerm)) value, err := SystemSSHEnabled() ass.NoError(err) - ass.False(value) + ass.True(value) ass.NoError(ioutil.WriteFile(systemDropbearConfig, []byte("DROPBEAR_OPTS=\"-p 127.0.0.1:22\""), os.ModePerm)) value, err = SystemSSHEnabled() ass.NoError(err) - ass.True(value) + ass.False(value) _ = os.Remove(systemDropbearConfig) }