Code Monkey home page Code Monkey logo

mdns-listener's Introduction

mDNS Listener

Simple mDNS Listener to add .local hostnames to your machine

This script is tested on Linux and macOS. It should work on Windows as well.

Configuration

Create a file named /etc/hosts.mdns, place hostnames ending with .local on separate lines like so:

myhost1.local
myhost2.local

Whenever you change this file, you should restart the service.

Installation

git clone https://github.com/Richie765/mdns-listener
cd mdns-listener
npm install

Running manually

Just run

node mdns-listener.js

Automatic startup on boot (Linux, systemd)

cp mdns-listener.service-sample mdns-listener.service

# edit mdns-listener.service to mathch the paths on your system

sudo cp mdns-listener.service /etc/systemd/system

systemctl enable mdns-listener
systemctl start mdns-listener
journalctl -u mdns-listener.service

Automatic startup on login (macOS)

cp mdns-listener.plist-sample mdns-listener.plist

# edit mdns-listener.plist to match the paths on your system

cp mdns-listener.plist ~/Library/LaunchAgents/

launchctl load ~/Library/LaunchAgents/mdns-listener.plist

Logfiles are available in

  • /tmp/mdns-listener-error.log
  • /tmp/mdns-listener.log

Version History

1.0

  • Initial version

1.1

  • Fixed bug where certain requests wouldn't be answered (especially if they came from iOS)
  • Respond with CNAME instead of A (works better when you have multiple interfaces)
  • Changed path to hosts file to /etc/hosts.mdns
  • Added Windows compatability (not tested) - will read hosts.mdns from current directory
  • Added monitor.js, used for debugging and testing
  • Added Linux systemd auto start on boot

mdns-listener's People

Contributors

richie765 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

therealman

mdns-listener's Issues

.mdns-hosts not found

I tried to run this project but it throws an error I'm on windows by the way -- and how do I do the configuration step on my machine -- :

fs.js:646
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open 'C:\Users\xxxx\repos\mdns-listener\undefined\.mdns-hosts'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at Object.<anonymous> (C:\Users\Amine Bouzahar\repos\mdns-listener\mdns-listener.js:19:18)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.