config files, macOS support

This commit is contained in:
2026-07-25 12:47:55 +02:00
parent 2b1de6460a
commit 67e6333879
7 changed files with 161 additions and 52 deletions

31
shared/confparser.go Normal file
View File

@@ -0,0 +1,31 @@
package shared
import (
"fmt"
"os"
"strings"
)
func ParseConfFile(path string) (map[string]string, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, err
}
out := map[string]string{}
lines := strings.SplitSeq(strings.TrimSpace(string(data)), "\n")
for line := range lines {
line = strings.TrimSpace(line)
if len(line) == 0 || strings.HasPrefix(line, "#") {
continue
}
parts := strings.SplitN(line, "=", 2)
if len(parts) != 2 {
return nil, fmt.Errorf("expected '=' when parsing %s", path)
}
out[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1])
}
return out, nil
}

View File

@@ -15,7 +15,7 @@ const PROTO_VERSION uint16 = 1
// SYM = XChaCha20-Poly1305 with nonce prepended
// HMAC = HMAC-SHA-256
// hpke = HPKE(MLKEM768X25519, ChaCha20Poly1305, HKDF-SHA-256)
// ds = ML-DSA
// ds = ML-DSA-44
// packet format
// [ version - 2 bytes ] [ type - 2 bytes ] [ payload - see below ]