diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-03-13 13:20:21 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-03-13 13:20:34 -0600 |
commit | dbf0e9f5ade65e139732f752f55737dabcb16795 (patch) | |
tree | af7ee32f8c76546898a0dbd0b935336018126b85 /tunnel | |
parent | 43cf8aed09d1b516ddc1466b96b9860186d2085d (diff) |
config: show missing section error correctly
Diffstat (limited to 'tunnel')
-rw-r--r-- | tunnel/src/main/java/com/wireguard/config/Config.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tunnel/src/main/java/com/wireguard/config/Config.java b/tunnel/src/main/java/com/wireguard/config/Config.java index c45dccb6..df344b1c 100644 --- a/tunnel/src/main/java/com/wireguard/config/Config.java +++ b/tunnel/src/main/java/com/wireguard/config/Config.java @@ -69,6 +69,7 @@ public final class Config { final Collection<String> peerLines = new ArrayList<>(); boolean inInterfaceSection = false; boolean inPeerSection = false; + boolean seenInterfaceSection = false; @Nullable String line; while ((line = reader.readLine()) != null) { final int commentIndex = line.indexOf('#'); @@ -86,6 +87,7 @@ public final class Config { if ("[Interface]".equalsIgnoreCase(line)) { inInterfaceSection = true; inPeerSection = false; + seenInterfaceSection = true; } else if ("[Peer]".equalsIgnoreCase(line)) { inInterfaceSection = false; inPeerSection = true; @@ -104,7 +106,7 @@ public final class Config { } if (inPeerSection) builder.parsePeer(peerLines); - else if (!inInterfaceSection) + if (!seenInterfaceSection) throw new BadConfigException(Section.CONFIG, Location.TOP_LEVEL, Reason.MISSING_SECTION, null); // Combine all [Interface] sections in the file. |