refactor(server): Improve Wireguard indexes

Signed-off-by: Myzel394 <github.7a2op@simplelogin.co>
This commit is contained in:
Myzel394 2025-02-23 21:54:52 +01:00 committed by Myzel394
parent eb076dbf53
commit 020cc8ad67
No known key found for this signature in database
GPG Key ID: B603E877F73D4ABB
2 changed files with 29 additions and 0 deletions

View File

@ -1 +1,8 @@
package indexes package indexes
import "config-lsp/handlers/wireguard/ast"
type WGIndexes struct {
// map of: section name -> WGSection
SectionsByName map[string][]*ast.WGSection
}

View File

@ -0,0 +1,22 @@
package indexes
import (
"config-lsp/common"
"config-lsp/handlers/wireguard/ast"
)
func CreateIndexes(config *ast.WGConfig) (*WGIndexes, []common.LSPError) {
errs := make([]common.LSPError, 0)
indexes := &WGIndexes{
SectionsByName: make(map[string][]*ast.WGSection),
}
for _, section := range config.Sections {
indexes.SectionsByName[section.Header.Name] = append(
indexes.SectionsByName[section.Header.Name],
section,
)
}
return indexes, errs
}