Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
language: node_js
node_js:
- "stable"
script: npm test
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@

![node-dhcp](https://github.com/infusion/node-dhcp/blob/master/res/logo.png?raw=true "JavaScript DHCP Server")

[![NPM Package](https://img.shields.io/npm/v/dhcp.svg?style=flat)](https://npmjs.org/package/dhcp "View this project on npm")
[![Build Status](https://travis-ci.org/infusion/node-dhcp.svg?branch=master)](https://travis-ci.org/infusion/node-dhcp)
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)

node-dhcp is a RFC compliant DHCP client and server implementation on top of node.js.


UPDATES - XantheFIN
===
*Fixed Static IP handling with MAC address at examples/server.js

*Fixed DHCP Offer message *in work* for Microsoft devices (fails to get DHCP Offer message right)

*Fixed to send 'hostname' option too via DHCP Offer message right way


*Keep it simple always

*If you need on macOS Sierra or later to have internet shared over this subnet it is possible. Just send me msg - XantheFIN*



Big thanks to original developer(s) :)



Motivation
===

Expand Down Expand Up @@ -206,10 +224,9 @@ Besides options listed in the `lib/options.js` file (with the `config` key), a f
- `forceOptions`: Array of options that are forced to be sent
- `static`: A static IP binding object of the form `mac -> ip`

Not yet implemented features
===

node-dhcp does not set timers already on the client to periodically send RENEW or REBIND messages. If you need this feature, please file a bug ticket.



Troubleshooting
===
Expand All @@ -224,6 +241,9 @@ No data is received

A broadcast is typically not spread across all interfaces. In order to route the broadcast to a specific interface, you can reroute 255.255.255.255.


*macOS Sierra i haven't needed route but left still if someone needs -XantheFIN

Linux
---

Expand Down Expand Up @@ -252,14 +272,7 @@ name: "Test Option"
});
```

Testing
===

If you plan to enhance the library, make sure you add test cases and all the previous tests are passing. You can test the library with

```bash
npm test
```

Copyright and licensing
===
Expand Down
4 changes: 2 additions & 2 deletions examples/server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

var dhcpd = require('../lib/dhcp.js');
var dhcp = require('../lib/dhcp.js');

var s = dhcpd.createServer({
var s = dhcp.createServer({
// System settings
range: [
"192.168.3.10", "192.168.3.99"
Expand Down
4 changes: 2 additions & 2 deletions lib/dhcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ Server.prototype = {
siaddr: this.config('server'), // next server in bootstrap. That's us
giaddr: req.giaddr,
chaddr: req.chaddr, // Client mac address
sname: '',
file: '',
sname: this.config('hostname'), //Server host name
file: '', //Boot file
options: this._getOptions({
53: DHCPOFFER
}, [
Expand Down
17 changes: 11 additions & 6 deletions lib/seqbuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ SeqBuffer.prototype = {
}

this._r += 10; // + 10 since field is 16 byte and only 6 are used for htype=1
return mac.toUpperCase().match(/../g).join('-');
return mac.toUpperCase().match(/../g).join(':');
},
//
addBool: function() {
Expand All @@ -186,13 +186,18 @@ SeqBuffer.prototype = {
//
addOptions: function(opts) {

for (let i in opts) {

var order = [53, 54, 51, 1, 3, 6];
fLen = order.length;

for (i = 0; i < fLen; i++) {
let n = order[i];

if (opts.hasOwnProperty(i)) {
if (opts.hasOwnProperty(n)) {

const opt = Options[i];
const opt = Options[n];
let len = 0;
let val = opts[i];
let val = opts[n];

if (val === null) {
continue;
Expand Down Expand Up @@ -250,7 +255,7 @@ SeqBuffer.prototype = {
}

// Write code
this.addUInt8(i);
this.addUInt8(n);

// Write length
this.addUInt8(len);
Expand Down
Loading