zre 0.1.5.0 → 0.1.5.1
raw patch · 6 files changed
+134/−108 lines, 6 filesdep ~binary
Dependency ranges changed: binary
Files
- CHANGELOG.md +5/−0
- README.md +119/−0
- README.rst +0/−102
- src/Network/ZRE.hs +1/−1
- src/Network/ZRE/Types.hs +6/−2
- zre.cabal +3/−3
CHANGELOG.md view
@@ -1,3 +1,8 @@+# Version [0.1.5.1](https://github.com/sorki/haskell-zre/compare/0.1.5.0...0.1.5.1) (2023-11-28)++* Fix missing `void` import for GHC9.6.3+* Allow `binary >= 0.8`+ # Version [0.1.5.0](https://github.com/sorki/haskell-zre/compare/0.1.4.0...0.1.5.0) (2022-02-28) * Use `attoparsec 0.14`
+ README.md view
@@ -0,0 +1,119 @@+# zre++[](https://github.com/sorki/haskell-zre/actions/workflows/ci.yaml)+[](https://hackage.haskell.org/package/zre)+[](https://packdeps.haskellers.com/feed?needle=zre)++ZRE protocol implementation https://rfc.zeromq.org/spec:36/ZRE/++Peer-to-peer local area networking with reliable group messaging+and automatic peer discovery.++## Usage++Dependencies:++```+zeromq4+```++Clone and test++```sh+git clone https://github.com/sorki/haskell-zre/+cd haskell-zre+nix-build+./result/bin/zre+# in another terminal or networked computer+./result/bin/zre+```++Two zre peers should find each other and be able to send message between each other.+Firewall needs to allow traffic on UDP port 5670 and TCP port range 41000-41100.+Application picks random port from this range and advertises it to network.++## Applications++Few applications are provided to get you started:++ - zre - interact and dump events+ - zrecat <group> - cat messages for group++These can be installed locally using `pkgs.haskellPackage.zre`.++Try running multiple copies of `zre` and `zrecat` on+the same computer or computers on the local network++```sh+zre+# another terminal+zrecat test+# now in original terminal you can join testgroup with+> /join test+# or send messages to it+> /shout test msg+```++Send uptime periodically to uptime group++```sh+( while true; do uptime; sleep 1; done ) | zrecat uptime+```++Cat file to group++```sh+cat /etc/os-release | zrecat test+```++Interact manually++```sh+zre+# in zre shell following commands are supported:+> /join time+> /shout time test!+> /leave time+> /join uptime+> /whisper <uuid> message+```++## ZGossip++Implementation of gossip protocol is included in form of key value TTL server.+This allows connecting peers from different networks (or subnets) not reachable via multicast+beacon. This service requires TCP port 31337 and can be started with `zgossip-server` binary.++Run server++```sh+zgossip_server+```++Pass gossip endpoint to apps with++```sh+zre -g <gossip_ip>:31337+```++## Configuration++ZRE applications using `runZre` will automatically try to load configuration+file if `ZRECFG` environment variable points to it. See `zre.conf` for configuration+example::++```sh+ZRECFG=./zre.conf zrecat test+```++To be able to use one config for multiple apps and still be able to distinguish between+them you can also set `ZRENAME` environment variable which overrides name+from config or default config if `ZRECFG` is not used::++```sh+ZRENAME=zrenode1 zrecat test+```++## Demos++* https://asciinema.org/a/106340
− README.rst
@@ -1,102 +0,0 @@-zre-===--ZRE protocol implementation https://rfc.zeromq.org/spec:36/ZRE/--Peer-to-peer local area networking with reliable group messaging-and automatic peer discovery.--Usage--------Dependencies::-- zeromq4--Clone and test::-- git clone https://github.com/sorki/haskell-zre/- cd haskell-zre- nix-build- ./result/bin/zre- # in another terminal or networked computer- ./result/bin/zre--Two zre peers should find each other and be able to send message between each other.-Firewall needs to allow traffic on UDP port 5670 and TCP port range 41000-41100.-Application picks random port from this range and advertises it to network.--Applications---------------Few applications are provided to get you started:-- - zre - interact and dump events- - zrecat <group> - cat messages for group--These can be installed locally using `pkgs.haskellPackage.zre`.--Try running multiple copies of `zre` and `zrecat` on-the same computer or computers on the local network::-- zre- # another terminal- zrecat test- # now in original terminal you can join testgroup with- > /join test- # or send messages to it- > /shout test msg--Send uptime periodically to uptime group::-- ( while true; do uptime; sleep 1; done ) | zrecat uptime---Cat file to group::-- cat /etc/os-release | zrecat test--Interact manually::-- zre- # in zre shell following commands are supported:- > /join time- > /shout time test!- > /leave time- > /join uptime- > /whisper <uuid> message--ZGossip----------Implementation of gossip protocol is included in form of key value TTL server.-This allows connecting peers from different networks (or subnets) not reachable via multicast-beacon. This service requires TCP port 31337 and can be started with `zgossip-server` binary.--Run server::-- zgossip_server--Pass gossip endpoint to apps with::-- zre -g <gossip_ip>:31337--Configuration----------------ZRE applications using `runZre` will automatically try to load configuration-file if `ZRECFG` environment variable points to it. See `zre.conf` for configuration-example::-- ZRECFG=./zre.conf zrecat test--To be able to use one config for multiple apps and still be able to distinguish between-them you can also set `ZRENAME` environment variable which overrides name-from config or default config if `ZRECFG` is not used::-- ZRENAME=zrenode1 zrecat test--Demos--------* https://asciinema.org/a/106340
src/Network/ZRE.hs view
@@ -91,7 +91,7 @@ runZre :: ZRE a -> IO () runZre app = runZreParse (pure ()) (const app) --- | Run with config file loaded from the enviornment variable ENVCFG+-- | Run with config file loaded from the environment variable ENVCFG -- (@/etc/zre.conf@ or @~/.zre.conf@), possibly overriden by command-line options. -- -- Accepts another `optparse-applicative` `Parser` for extending
src/Network/ZRE/Types.hs view
@@ -1,9 +1,9 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}- {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-orphans #-}+ module Network.ZRE.Types where import Control.Monad.Reader@@ -20,6 +20,7 @@ import Data.ZRE hiding (Shout, Whisper) -- (Name, Seq, Group, Groups, GroupSeq, Headers, Content, ZRECmd, ZREMsg) import System.ZMQ4.Endpoint +import qualified Control.Monad isec :: (Num a) => a -> a isec = (*1000000)@@ -153,7 +154,10 @@ unReadZ :: Event -> ZRE () unReadZ x = do (e, _) <- ask- void $ liftIO $ atomically $ unGetTBQueue e x+ Control.Monad.void+ $ liftIO+ $ atomically+ $ unGetTBQueue e x writeZ :: API -> ZRE () writeZ x = do
zre.cabal view
@@ -1,5 +1,5 @@ name: zre-version: 0.1.5.0+version: 0.1.5.1 synopsis: ZRE protocol implementation description: Peer-to-peer local area networking with reliable group messaging and automatic peer discovery.@@ -17,7 +17,7 @@ cabal-version: 2.0 extra-source-files: CHANGELOG.md- README.rst+ README.md zre.conf flag examples@@ -57,7 +57,7 @@ , network-bsd ^>= 2.8 , network-info ^>= 0.2 , network-multicast ^>= 0.3- , binary ^>= 0.8+ , binary >= 0.8 , bytestring , containers , directory