From b9fef76c2cafb4a90407dc2b66a5ecb6fc994a6a Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 1 Jan 2025 19:29:36 +0100 Subject: [PATCH] feat: README --- Readme.md | 26 ++++++++++++++++++++++++++ src/main.rs | 3 +-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 Readme.md diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..bd7e91b --- /dev/null +++ b/Readme.md @@ -0,0 +1,26 @@ +# MDNS Relay + +You ever wanted to split your network into multiple indepented ones, while still being able to find +your printer or join a spotify session in another network? Then this project is for you. + +The purpose of this program is to relay multicast DNS (mDNS) packets between multiple private networks. +Existing solution, such a avahi allow you to do this as well but only unconditionally, relaying all questions +and answers, with this you can decide what queries get relayed and which get blocked. + +## Usage +`mdns-relay -c ` where config is a json file containing these options: +```json +{ + "interfaces: "A regex used to filter interfaces on which to listen, to exclude for example the public net or VPNs completely", + // A list of rules to be applied to incoming packages" + "rules" : [ + { + "from": "A regex to match the incoming interface", + "to": "The exact name of the interface to which matching packets will be relayed", + "allow_questions": "Regex matching any questions", + "allow_answers": "Regex matching any answers", + } + ] +} +``` +To apply a rule has to either have a single matching question or answer. diff --git a/src/main.rs b/src/main.rs index 034a698..e7294b0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,11 +4,10 @@ use color_eyre::{eyre::bail, Result}; use pnet::datalink::{interfaces, NetworkInterface}; use pnet::ipnetwork::IpNetwork::{V4, V6}; use regex::Regex; -use serde::{Deserialize, Deserializer}; +use serde::Deserialize; use serde_json::from_reader; use simple_dns::Packet; use socket2::{Domain, Protocol, Socket, Type}; -use std::borrow::Cow; use std::fs::File; use std::io::BufReader; use std::{