Procházet zdrojové kódy

config: loosen parser to match reality

Mid-line comments, mixed case.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
master
Jason A. Donenfeld před 6 roky
committed by Samuel Holland
rodič
revize
b276833b33
2 změnil soubory, kde provedl 9 přidání a 5 odebrání
  1. +2
    -2
      app/src/main/java/com/wireguard/config/Attribute.java
  2. +7
    -3
      app/src/main/java/com/wireguard/config/Config.java

+ 2
- 2
app/src/main/java/com/wireguard/config/Attribute.java Zobrazit soubor

@@ -42,7 +42,7 @@ enum Attribute {
static {
KEY_MAP = new HashMap<>(Attribute.values().length);
for (final Attribute key : Attribute.values()) {
KEY_MAP.put(key.token, key);
KEY_MAP.put(key.token.toLowerCase(), key);
}
}

@@ -67,7 +67,7 @@ enum Attribute {
}

public static Attribute match(final CharSequence line) {
return KEY_MAP.get(SEPARATOR_PATTERN.split(line)[0]);
return KEY_MAP.get(SEPARATOR_PATTERN.split(line)[0].toLowerCase());
}

public static InetAddress parseIPString(final String address) {


+ 7
- 3
app/src/main/java/com/wireguard/config/Config.java Zobrazit soubor

@@ -41,12 +41,16 @@ public class Config {
String line;
boolean inInterfaceSection = false;
while ((line = reader.readLine()) != null) {
if (line.isEmpty() || line.startsWith("#"))
final int commentIndex = line.indexOf('#');
if (commentIndex != -1)
line = line.substring(0, commentIndex);
line = line.trim();
if (line.isEmpty())
continue;
if ("[Interface]".equals(line)) {
if ("[Interface]".toLowerCase().equals(line.toLowerCase())) {
currentPeer = null;
inInterfaceSection = true;
} else if ("[Peer]".equals(line)) {
} else if ("[Peer]".toLowerCase().equals(line.toLowerCase())) {
currentPeer = new Peer();
config.peers.add(currentPeer);
inInterfaceSection = false;


Načítá se…
Zrušit
Uložit