aboutsummaryrefslogtreecommitdiffstats
path: root/src/Network/WireGuard/Internal
diff options
context:
space:
mode:
authorBaylac-Jacqué Félix <felix@alternativebit.fr>2017-09-13 15:35:23 +0200
committerBaylac-Jacqué Félix <felix@alternativebit.fr>2017-09-16 17:11:27 +0200
commit43f42bd29d9c3aa304785f32c228c4fa23b8c959 (patch)
tree9f204e51b6a6cb0032ffb3163d6f4ba272e0dd04 /src/Network/WireGuard/Internal
parentImplemented RPC parsers. (diff)
downloadwireguard-hs-43f42bd29d9c3aa304785f32c228c4fa23b8c959.tar.xz
wireguard-hs-43f42bd29d9c3aa304785f32c228c4fa23b8c959.zip
Implemented RPC set's payload parser.
Diffstat (limited to 'src/Network/WireGuard/Internal')
-rw-r--r--src/Network/WireGuard/Internal/Data/RpcTypes.hs2
-rw-r--r--src/Network/WireGuard/Internal/RpcParsers.hs8
2 files changed, 7 insertions, 3 deletions
diff --git a/src/Network/WireGuard/Internal/Data/RpcTypes.hs b/src/Network/WireGuard/Internal/Data/RpcTypes.hs
index d45d38e..a78d9df 100644
--- a/src/Network/WireGuard/Internal/Data/RpcTypes.hs
+++ b/src/Network/WireGuard/Internal/Data/RpcTypes.hs
@@ -31,7 +31,7 @@ data RpcRequest = RpcRequest {
data RpcSetPayload = RpcSetPayload {
devicePayload :: !RpcDevicePayload,
peersPayload :: [RpcPeerPayload]
-}
+} deriving (Eq, Show)
-- | Device related payload sent together with a set RPC operation.
data RpcDevicePayload = RpcDevicePayload {
diff --git a/src/Network/WireGuard/Internal/RpcParsers.hs b/src/Network/WireGuard/Internal/RpcParsers.hs
index c5179c8..e5e38d1 100644
--- a/src/Network/WireGuard/Internal/RpcParsers.hs
+++ b/src/Network/WireGuard/Internal/RpcParsers.hs
@@ -3,7 +3,8 @@
module Network.WireGuard.Internal.RpcParsers(
requestParser,
deviceParser,
- peerParser
+ peerParser,
+ setPayloadParser
) where
import Control.Applicative ((*>), (<|>))
import Control.Monad (join)
@@ -48,7 +49,10 @@ requestTypeParser = "get=1" *> return Get
<|> "set=1" *> return Set
setPayloadParser :: Parser RpcSetPayload
-setPayloadParser = undefined
+setPayloadParser = do
+ dev <- deviceParser
+ peers <- many' peerParser
+ return $ RpcSetPayload dev peers
deviceParser :: Parser RpcDevicePayload
deviceParser = do