aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/conf
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-01-25 21:11:31 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-02-01 16:55:02 +0100
commitb95b36756ebfcdfaab6a403d93bc6514f3a3b2e2 (patch)
treee74ac26517b4c1eae2868d5351bee24746666f7b /conf
parentversion: adjust x/sys/windows type name (diff)
downloadwireguard-windows-b95b36756ebfcdfaab6a403d93bc6514f3a3b2e2.tar.xz
wireguard-windows-b95b36756ebfcdfaab6a403d93bc6514f3a3b2e2.zip
manager: pipeline UAPI requests
This avoids the somewhat expensive pipe setup. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'conf')
-rw-r--r--conf/parser.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/conf/parser.go b/conf/parser.go
index d26bdea4..dd0ee317 100644
--- a/conf/parser.go
+++ b/conf/parser.go
@@ -6,8 +6,10 @@
package conf
import (
+ "bufio"
"encoding/base64"
"encoding/hex"
+ "io"
"net"
"strconv"
"strings"
@@ -367,8 +369,7 @@ func FromWgQuickWithUnknownEncoding(s string, name string) (*Config, error) {
return nil, firstErr
}
-func FromUAPI(s string, existingConfig *Config) (*Config, error) {
- lines := strings.Split(s, "\n")
+func FromUAPI(reader io.Reader, existingConfig *Config) (*Config, error) {
parserState := inInterfaceSection
conf := Config{
Name: existingConfig.Name,
@@ -380,9 +381,15 @@ func FromUAPI(s string, existingConfig *Config) (*Config, error) {
},
}
var peer *Peer
- for _, line := range lines {
+ lineReader := bufio.NewReader(reader)
+ for {
+ line, err := lineReader.ReadString('\n')
+ if err != nil {
+ return nil, err
+ }
+ line = line[:len(line)-1]
if len(line) == 0 {
- continue
+ break
}
equals := strings.IndexByte(line, '=')
if equals < 0 {