diff --git a/flake.lock b/flake.lock index f1d265f..3625329 100644 --- a/flake.lock +++ b/flake.lock @@ -26,11 +26,11 @@ ] }, "locked": { - "lastModified": 1741396135, - "narHash": "sha256-wqmdLr7h4Bk8gyKutgaApJKOM8JVvywI5P48NuqJ9Jg=", + "lastModified": 1742209644, + "narHash": "sha256-jMy1XqXqD0/tJprEbUmKilTkvbDY/C0ZGSsJJH4TNCE=", "owner": "tweag", "repo": "gomod2nix", - "rev": "0983848bf2a7ccbfe24d874065adb8fd0f23729b", + "rev": "8f3534eb8f6c5c3fce799376dc3b91bae6b11884", "type": "github" }, "original": { @@ -41,11 +41,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1741513245, - "narHash": "sha256-7rTAMNTY1xoBwz0h7ZMtEcd8LELk9R5TzBPoHuhNSCk=", + "lastModified": 1742069588, + "narHash": "sha256-C7jVfohcGzdZRF6DO+ybyG/sqpo1h6bZi9T56sxLy+k=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e3e32b642a31e6714ec1b712de8c91a3352ce7e1", + "rev": "c80f6a7e10b39afcc1894e02ef785b1ad0b0d7e5", "type": "github" }, "original": { diff --git a/server/handlers/ssh_config/lsp/text-document-did-change.go b/server/handlers/ssh_config/lsp/text-document-did-change.go index 830315c..118ace6 100644 --- a/server/handlers/ssh_config/lsp/text-document-did-change.go +++ b/server/handlers/ssh_config/lsp/text-document-did-change.go @@ -20,7 +20,6 @@ func TextDocumentDidChange( document := sshconfig.DocumentParserMap[params.TextDocument.URI] document.Config.Clear() - println("reparsing everything") diagnostics := make([]protocol.Diagnostic, 0) errors := document.Config.Parse(content) diff --git a/server/utils/ip-host.go b/server/utils/ip-host.go index 84d3a05..0d8ccb0 100644 --- a/server/utils/ip-host.go +++ b/server/utils/ip-host.go @@ -35,10 +35,14 @@ func (t *iPv4Tree) addHostBits( } func (t *iPv4Tree) getFromHostBits(hostBits []bool) *context.Context { - if t.Context != nil || len(hostBits) == 0 { + if t.Context != nil { return &t.Context } + if len(hostBits) == 0 { + return nil + } + if hostBits[0] { if t.TrueNode == nil { return nil diff --git a/server/utils/ip-host_test.go b/server/utils/ip-host_test.go index 509978f..65c98e9 100644 --- a/server/utils/ip-host_test.go +++ b/server/utils/ip-host_test.go @@ -31,8 +31,8 @@ func TestPartialHostIpAddresses(t *testing.T) { hostSet.AddIP(netip.MustParsePrefix("10.0.0.2/32"), context.Background()) hostSet.AddIP(netip.MustParsePrefix("10.0.0.3/32"), context.Background()) - if ctx, _ := hostSet.ContainsIP(netip.MustParsePrefix("10.0.0.1/16")); ctx == nil { - t.Fatalf("Expected to find 10.0.0.1/16 in the host set") + if ctx, _ := hostSet.ContainsIP(netip.MustParsePrefix("10.0.0.1/16")); ctx != nil { + t.Fatalf("Didn't expect to find 10.0.0.1/16 in the host set") } if ctx, _ := hostSet.ContainsIP(netip.MustParsePrefix("192.168.0.1/16")); ctx != nil { @@ -48,12 +48,24 @@ func TestMixedHostIpAddresses(t *testing.T) { hostSet.AddIP(netip.MustParsePrefix("192.168.0.1/32"), context.Background()) if ctx, _ := hostSet.ContainsIP(netip.MustParsePrefix("10.0.0.2/32")); ctx == nil { - t.Fatalf("Expected to find 10.0.0.3/32 in the host set") + t.Fatalf("Expected to find 10.0.0.1/32 in the host set") } if ctx, _ := hostSet.ContainsIP(netip.MustParsePrefix("192.168.0.2/32")); ctx != nil { t.Fatalf("Expected NOT to find 192.168.0.2/32 in the host set") } + + if ctx, _ := hostSet.ContainsIP(netip.MustParsePrefix("10.0.0.2/32")); ctx == nil { + t.Fatalf("Expected to find 10.0.0.2/32 in the host set") + } + + if ctx, _ := hostSet.ContainsIP(netip.MustParsePrefix("10.0.1.2/32")); ctx == nil { + t.Fatalf("Expected to find 10.0.1.2/32 in the host set") + } + + if ctx, _ := hostSet.ContainsIP(netip.MustParsePrefix("10.0.0.1/30")); ctx == nil { + t.Fatalf("Expected to find 10.0.0.1/30 in the host set") + } } func TestSimpleExactCheck(t *testing.T) {