config files, macOS support
This commit is contained in:
31
shared/confparser.go
Normal file
31
shared/confparser.go
Normal 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
|
||||
}
|
||||
@@ -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 ]
|
||||
|
||||
Reference in New Issue
Block a user