public final class Config
extends java.lang.Object
Instances of this class are immutable.
Modifier and Type | Class and Description |
---|---|
static class |
Config.Builder |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
Interface |
getInterface()
Returns the interface section of the configuration.
|
java.util.List<Peer> |
getPeers()
Returns a list of the configuration's peer sections.
|
int |
hashCode() |
static Config |
parse(java.io.BufferedReader reader)
Parses an series of "Interface" and "Peer" sections into a
Config . |
static Config |
parse(java.io.InputStream stream)
Parses an series of "Interface" and "Peer" sections into a
Config . |
java.lang.String |
toString()
Converts the
Config into a string suitable for debugging purposes. |
java.lang.String |
toWgQuickString()
Converts the
Config into a string suitable for use as a wg-quick
configuration file. |
java.lang.String |
toWgUserspaceString()
Serializes the
Config for use with the WireGuard cross-platform userspace API. |
public static Config parse(java.io.InputStream stream) throws java.io.IOException, BadConfigException
Config
. Throws
BadConfigException
if the input is not well-formed or contains data that cannot
be parsed.stream
- a stream of UTF-8 text that is interpreted as a WireGuard configurationConfig
instance representing the supplied configurationjava.io.IOException
BadConfigException
public static Config parse(java.io.BufferedReader reader) throws java.io.IOException, BadConfigException
Config
. Throws
BadConfigException
if the input is not well-formed or contains data that cannot
be parsed.reader
- a BufferedReader of UTF-8 text that is interpreted as a WireGuard configurationConfig
instance representing the supplied configurationjava.io.IOException
BadConfigException
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public Interface getInterface()
public java.util.List<Peer> getPeers()
Peer
spublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
Config
into a string suitable for debugging purposes. The Config
is identified by its interface's public key and the number of peers it has.toString
in class java.lang.Object
Config
public java.lang.String toWgQuickString()
Config
into a string suitable for use as a wg-quick
configuration file.Config
represented as one [Interface] and zero or more [Peer] sectionspublic java.lang.String toWgUserspaceString()
Config
for use with the WireGuard cross-platform userspace API.Config
represented as a series of "key=value" lines