infusion / node-dhcp Goto Github PK
View Code? Open in Web Editor NEWA DHCP server and client written in pure JavaScript
Home Page: https://raw.org/article/a-pure-javascript-dhcp-implementation/
License: MIT License
A DHCP server and client written in pure JavaScript
Home Page: https://raw.org/article/a-pure-javascript-dhcp-implementation/
License: MIT License
For some reason in several places of your code you call _selectAddress
function without providing req
object to it.
Is that intentional?
It looks like a mistake to me. At least it makes my static
function logic fail.
HI,
Would it be possible to better handle requests that come in with options that are not present in the options.js file?
events.js:173
throw err; // Unhandled 'error' event
^
Error [ERR_UNHANDLED_ERROR]: Unhandled error. (Unknown option 150)
at Server.emit (events.js:171:17)
at Server._getOptions (/usr/local/lib/node_modules/dhcp/lib/dhcp.js:206:16)
at Server.sendOffer (/usr/local/lib/node_modules/dhcp/lib/dhcp.js:370:21)
at Server.handleDiscover (/usr/local/lib/node_modules/dhcp/lib/dhcp.js:348:10)
at Socket. (/usr/local/lib/node_modules/dhcp/lib/dhcp.js:91:16)
at Socket.emit (events.js:182:13)
at UDP.onMessage [as onmessage] (dgram.js:628:8)
root@spike:~/node-dhcp #
It would be handy to maybe have it print out an error saying: "unknown option , value: ".
plx&thnx :>
I saw the package.json
denotes as node version *
. But new Buffer()
was deprecated since v6.
I recommend to use safe-buffer to have full-compatibility.
just run your client example.
out:
Client Listening: 0.0.0.0:68
{ op: 1,
htype: 1,
hlen: 6,
hops: 0,
xid: 1,
secs: 0,
flags: 0,
ciaddr: '0.0.0.0',
yiaddr: '0.0.0.0',
siaddr: '0.0.0.0',
giaddr: '0.0.0.0',
chaddr: 'C4-85-08-47-09-05',
sname: '',
file: '',
magicCookie: 1669485411,
options:
{ '53': 1, '55': [ 0 ], '57': 1500, '61': 'c4:85:08:47:09:05' } }
Unknown option 0 undefined
it's connected to features object in your config.
Hello everyone,
Is there any way to detect that the local IP Address has changed?
Let's suppose that machine's IP is 192.168.150.5 and somehow the machine receives another IP and now has 192.168.150.6 from DHCP. Is there any listener which 'listens' that kind of changes?
-I have set up ONLY a dhcp client (from DHCP module) -and not a dhcp server from the module - and I receive IPs from default DCHP(router's).
Is there any way to achieve that??
Thanks in advance
A Dockerfile should be added that allows this package to run as a container
It seems that the static bindings are not "reserved".
In the _selectAdress function, if a static binding exists, then the IP is returned, but it's never checked if the IP is already in lease or not.
Two possibilities to solve :
Let the static return like that, but if the address is already in lease, force the client who owns this address to change (renew)
Get all the static addresses and add them in the "known addresses" so that it is reserved to the binded MAC, something like :
for(var bind in static) {
ips.push(static[bind]);
}
This solution seems impossible if the static option in the config is a function ...
Let me know if I'm wrong on this issue.
The DHCP crashes when a DCHP-request is sent with options in the 224-254 range.
According to iana, this space is reserved for private use. Microsoft happens to use this range (249 for classless static route), which makes the DHCP-server incompatible with my OS, Windows 10.
I have fixed this by editing line 206 in dhcp.js:
this.emit('error', 'Unknown option ' + req);
becomes
if(!(req >= 224 && req <= 255))
{
this.emit('error', 'Unknown option ' + req);
}
I don't know if this is the correct/best solution, but it works for me.
I'm not sure if this is expected or not, on windows 10 with the example dhcpd from the readme, it will fail
.....\node_modules\dhcp\lib\dhcp.js:180
throw new Error('Required option ' + Options.opts[req].config + ' does not have a value set');
^
Error: Required option server does not have a value set
at Server._getOptions (.....\node_modules\dhcp\lib\dhcp.js:180:17)
at Server.sendOffer (.....\node_modules\dhcp\lib\dhcp.js:370:21)
at Server.handleDiscover (.....\node_modules\dhcp\lib\dhcp.js:349:10)
at Socket.<anonymous> (.....\node_modules\dhcp\lib\dhcp.js:91:16)
at Socket.emit (events.js:182:13)
at UDP.onMessage [as onmessage] (dgram.js:678:8)
The error goes away if I specify my computer's IP in createServer:
var s = dhcp.createServer({
server: '192.168.100.20', // my computer's local IP
// rest unchanged
I went to dhcp.js around line 345 and tried reading config('server')
, but it was simply 0
. I didn't find where and if this should be set manually under normal circumstances.
If this is expected, I would like to request adding it to the readme. If this is unexpected, I would like find and squish that bug.
Hello,
If packet is malformed node-dhcp crashes, do you have some thoughts how to handle this?
TypeError: Cannot read property 'join' of null
at SeqBuffer.getMAC (.../node-dhcp/lib/seqbuffer.js:162:42)
at Object.parse (.../node-dhcp/lib/protocol.js:23:18)
at Socket.<anonymous> (.../node-dhcp/lib/dhcp.js:66:24)
at emitTwo (events.js:125:13)
at Socket.emit (events.js:213:7)
at UDP.onMessage [as onmessage] (dgram.js:623:8)
Keep up the good work :)
Implement session storage of the server in either
The code has this:
forceOptions: ['hostname'], // Options that need to be sent, even if they were not requested
randomIP: true, // Get random new IP from pool instead of keeping one ip
static: {
"11:22:33:44:55:66": "192.168.3.100"
},
That doesn't work because server has different style (which it does record console.log even too at chaddr:).
Working example:
"11-22-33-44-55-66":"192.168.3.100"
And with that MAC style it works correctly to passing static ip listed there to client and not new available IP.
Hello sorry for the generic title but my issue is bit strange.
-The goal
In my network i want some clients getting (static like) ip from my dhcp server to leverage network booting, and the rest ( unidentified ) clients to get an ip from my dynamic range. The static bindings are outside of this range driven by a config file that constantly changes (thus the function).
-The config
I have created a dhcp server and im giving addresses with this example config:
{ range: [ 'xxx.xxx.xxx.29', 'xxx.xxx.xxx.30' ], static: [Function: bound ], dns: [ '1.1.1.1', '8.8.8.8' ], netmask: '255.255.255.192', router: [ 'xxx.xxx.xxx.62' ], broadcast: 'xxx.xxx.xxx.63', bootFile: 'sarantis.kpxe', tftpServer: 'xxx.xxx.xxx', server: 'xxx.xxx.xxx.25', randomIP: true }
-The issue
first of all i get alot this error that crashes the server on its first discovery
`projectRoot\node_modules\dhcp\lib\dhcp.js:302
const ip = this._state[oldestMac].address;
^
TypeError: Cannot read property 'address' of undefined`
also i am having an issue that after some time the server stops responding or getting (tested via listeners on 'message') without any error or exception.
I managed to narrow it down that if i give away all the dynamic ips from the range dhcp-server stops working for both dynamic and static-like clients.
If you have any ideas on how i could probably solve this issue i would like to check it out.
Thank in advance.
Update:
Maybe i have managed to narrow down the first issue: it happens when the first discovery is on windows with static-like ip ( 70% sure)
Hi,
How can I perform client authentication on DHCP server?
In rfc3118 option 90 is added for client authentication. but in lib/options.js option 90 is not configured.
I also tried to add same in options.js but whenever I add username and password with simple PWD mode my server doesn't listen to that request or some this wrong with my client conficuration. I am using Cantos 7.8 for both my server and client.
How to send an ACK packet with custom options?
https://github.com/infusion/node-dhcp/blob/master/lib/seqbuffer.js#L157
In getMAC code assumes that chaddr is of length 6 however it doesn't check htype and hlen fields before to make this assumption true.
Maybe allow only htype === 1 and hlen === 6 ?
Then in getMAC use hlen value instead of hardcoded value of 6 ?
I'm attempting to run a DHCP server from Windows 10 and I get an error thrown from dhcp.js line 224 saying "Unknown option 249". There was a similar issue (#62) along with a potential fix but I will be submitting a PR that handles these options through options.js as opposed to a condition over the error handler.
Hello,
how can i mute this errors messages ?
Unknown option 128 undefined
Unknown option 129 undefined
Unknown option 130 undefined
Unknown option 131 undefined
Unknown option 132 undefined
Unknown option 133 undefined
Unknown option 134 undefined
Unknown option 135 undefined
Got here so best open new ticket as so different than earlier issue which was fixed already.
Now i have configs which works so that it does provide IP's. But i don't get internet connection. Not sure does it get send but feels like not result back in..?
-WinXP laptop still fails get IP-#Other problem
Maybe i have little problem still with config.. i have tried done:
sudo route add -host 255.255.255.255 -interface en4
No network (yet..)
I get to send request of ping from inside this network but it doesn't get answer (or other way around.. i can't say myself). There is no response to ping 8.8.8.8 dns even.
wireshark picture under..
Trying just:
I thought fake how InternetSharing does it.. combine dns to router address
Now i get port unreachable.. so better or worse?
Any ideas? #Update InternetSharing does create bridge0 too.
Do i need have manual config in SystemPreferences and what style? if it makes differences..
Update:
Been log how InternetShare does all.
At DHCP offer it gives
Internet Protocol Version 4, Src: 192.168.2.1, Dst: 192.168.2.4
So there is Src: Router IP, Dst: New device IP
this dhcp gives when i try WinXP laptop:
Internet Protocol Version 4, Src: 1.1.1.11, Dst: 1.1.1.255
So it is.. Router IP but the Broadcast ip? Hmm..
from sudo tcpdump -i en0
17:40:56.796391 IP 1.1.1.11.bootps > 1.1.1.255.bootpc: BOOTP/DHCP, Reply, length 290
17:40:56.796760 IP 0.0.0.0.bootpc > broadcasthost.bootps: BOOTP/DHCP, Request from 00:1f:PS3 (oui Unknown), length 300
17:40:56.797664 IP 1.1.1.11.bootps > 1.1.1.255.bootpc: BOOTP/DHCP, Reply, length 290
17:40:56.797891 ARP, Probe 1.1.1.79, length 46
17:40:57.297002 ARP, Announcement 1.1.1.79, length 46
17:40:57.297162 ARP, Announcement 1.1.1.79, length 46
17:40:57.485661 ARP, Request who-has 1.1.1.11 tell 1.1.1.79, length 46
17:40:57.485694 ARP, Reply 1.1.1.11 is-at 8c:ethernet (oui Unknown), length 28
17:40:57.485949 IP 1.1.1.79.49556 > dns.google.domain: 55586+ A? feu01.ps3.update.playstation.net. (50)
Hi,
Had a weird issue happen today with the following output:
flags: 0,
ciaddr: '0.0.0.0',
yiaddr: '0.0.0.0',
siaddr: '0.0.0.0',
giaddr: '0.0.0.0',
chaddr: '98-4B-E1-6D-20-51',
sname: '',
file: '',
magicCookie: 1669485411,
options:
{ '12': 'finnix',
'53': 1,
'55': [ 1, 28, 2, 3, 15, 6, 119, 12, 44, 47, 26, 121, 42 ] } }
/home/nistor/node_modules/dhcp/lib/dhcp.js:302
const ip = this._state[oldestMac].address;
^
TypeError: Cannot read property 'address' of undefined
at Server._selectAddress (/home/nistor/node_modules/dhcp/lib/dhcp.js:302:41)
at Server.handleDiscover (/home/nistor/node_modules/dhcp/lib/dhcp.js:343:26)
at Socket. (/home/nistor/node_modules/dhcp/lib/dhcp.js:91:16)
at Socket.emit (events.js:182:13)
at UDP.onMessage [as onmessage] (dgram.js:628:8)
What is interesting is that it doesn't happen all that often from that host. Any idea?
In the newest node versions static
is a reserved word: https://github.com/infusion/node-dhcp/blob/master/lib/dhcp.js#L264
Consider renaming it in _static
or something like that.
Has any performance testing been implemented?
How many clients could be supported?
How many leases per second?
Your README.md issues
For noobs big headache.
Running Sierra macOS here
Simple DHCP Server
var dhcp = require('dhcp');
var s = dhcpd.createServer({
ReferenceError: dhcpd is not defined
Your website you wrote this example:
var dhcpd = require('dhcp');
var s = dhcpd.createServer({
Then we get
events.js:180
throw er; // Unhandled 'error' event
^
Error: bind EACCES 0.0.0.0:67
at dgram.js:321:18
at processTicksAndRejections (internal/process/task_queues.js:77:11)
Emitted 'error' event at:
at dgram.js:322:14
at processTicksAndRejections (internal/process/task_queues.js:77:11) {
errno: 'EACCES',
code: 'EACCES',
syscall: 'bind',
address: '0.0.0.0',
port: 67
}
What next?
Hi!
Looks like when you specific an IP to bind to the broadcast DHCP requests are ignored, for example:
var dhcp = require('dhcp');
var s = dhcp.createBroadcastHandler();
s.on('message', function (data) {
if (data.options[53] === dhcp.DHCPDISCOVER)
{
console.log('DHCP Discover from ' + data.chaddr );
} else {
console.log('DHCP Other from ' + data.chaddr );
}
});
s.listen();
This code snip-ip works fine:
DHCP Discover from 98-4B-E1-61-23-CE
DHCP Discover from 98-4B-E1-61-41-A6
However when trying to bind with:
s.listen(null,bind);
Packet captures show DHCP but there are no responses from the node instance.
The daemon should become more and more a real daemon. So logging and PID management should be implemented.
I removed the debug output, dhcp.js was producing. But I liked it to see what the server/client is actual doing. I think exposing a state
event to show the process, the server/client is in, would make sense.
If we have this, a reasonable cli output should be made. Maybe with several verbosity levels.
Couldn't find a way to configure several subnets for different interfaces. Is it possible?
When i use my mac to connect to the network with wifi by DHCP, i can see the error:
Unknown option 95
I tried Android and Debian, those were OK.
I was thinking why my Thinkpad WinXP laptop doesn't understand DHCP offer or Xbox 360 and https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol example here i noticed that it sends message like this:
Option 1 : Subnet Mask
Option 3: Router
Option 6:Domain Name Server
Option 12:Host Name
Option 51:IP address Lease time
Option 53:DHCP Message Type
Option 54:DHCP Server Identifier
Option 255:-End-
When example macOS InternetSharing makes too message like in wikipedia:
Option 53:DHCP Message Type
Option 54:DHCP Server Identifier
Option 51:IP address Lease time
Option 1 : Subnet Mask
Option 3: Router
Option 6:Domain Name Server
Option 12:Host Name (not actually send on it)
Option 255:-End-
Maybe solves that issue when rearranged? I tried take a look how it is done but sorry i didn't get the code honestly now myself how to fix it... at least yet.
At the
_getOptions: function(pre, required, requested) {
Function.
Hi,
Thank for this project.
I'm trying to replace my ugly dnsmask configuration + nodejs front, by an pure nodejs solution.
I forked your source for some changes, but I make a loooooooot of changes.
the final version should be a kind of pure typescript router (PAC + http-proxy + dhcp + dynamic public IP switch + live http blocking features)
on the dhcp server the change include:
I think that this fork solve 3 of the current opened issue.
special:
Maybe we will be able to merge one day, but you will have to switch to typescript.
I plane to deploy a first version next week.
https://github.com/UrielCh/node-dhcp
give me your feedback
Thank you so much for creating this amazing package, I have been having fun with it! :)
I have ran into one issue though.. I am trying to get a raspberry pi to broadcast it's own wifi to have an "intranet" of sorts and as such, it is not connected to any other network.
The wifi interface is configured with the following:
{
interface: 'wlan0',
ipv4_address: '10.10.10.1',
ipv4_broadcast: '10.10.10.255',
ipv4_subnet_mask: '255.255.255.0',
}
Here are the options I pass to dhcp.createServer(dhcpOptions)
.
const dhcpOptions = {
range: ['10.10.10.1', '10.10.10.100'],
static: {
'b8:27:eb:46:50:32': '10.10.10.1'
},
netmask: '255.255.255.0',
router: ['10.10.10.1'],
dns: [ '4.4.4.4', '8.8.8.8' ],
server: '10.10.10.1',
randomIP: false,
};
And then here is the error message I am getting:
Send Offer
{ Error: send ENETUNREACH 255.255.255.255:68
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at SendWrap.afterSend [as oncomplete] (dgram.js:474:11)
code: 'ENETUNREACH',
errno: 'ENETUNREACH',
syscall: 'send',
address: '255.255.255.255',
port: 68 }
This error comes after it is handling a discovery...I know I am missing some small piece of the puzzle, but I can't figure it out and am wondering if I have maybe misconfigured something. Thanks in advance!
Visualize current leases with socket.io on a browser
A Docker image should be published to dockerhub
Hello all!
How should the server correctly be closed after an IP address was bound?
I actually added it to the on bound
but not sure if this is the correct place, because the following error appears "Error: Not running." Without the server.close()
in the on bound
no error appears but I am also not able to close the server :D
Example code:
server.on('bound', function(state) {
console.log("bound ip address.");
server.close();
});
This shows the "Error: Not running".
process.on('uncaughtException', (err) => {
console.log(err.stack);
});
Hello,
the options function doesnt work.
The arguments are not passed.
// merge options
let options = merge({
range: ["172.16.0.100", "172.16.0.200"],
netmask: "255.255.255.0",
router: ["172.16.0.254"],
...
domainName: "magic-boot.lan",
bootFile: function (req, res) {
// req & res = undefined
console.log("-- BOOTFILE", arguments);
return "pxelinux.0"
}
}, config.options);
So the example/server.js dosnt work neither:
if (req.clientId === 'foo bar') {
^
TypeError: Cannot read property 'clientId' of undefined
Problem seems for me this line:
https://github.com/infusion/node-dhcp/blob/master/lib/dhcp.js#L144
I need to tell pxelinux/syslinux what config file should be loaded, this is DHCP option 209.
(https://wiki.syslinux.org/wiki/index.php?title=PXELINUX#DHCP_options)
Could there be a helper function to define custom options ?
This would solve the problem for "unknown options" #17 too,
just write a empty function for them
Hi,
I have the instance running as follows:
dhcpd --range 10.15.32.242-10.15.32.254 --netmask 255.255.255.240 --server 10.10.50.150 --bind 10.10.50.150
I can see that packets are coming from the switch via ip helper into the DHCP server, I can see the reply:
16:33:53.064216 IP 10.15.32.241.67 > 10.11.50.150.67: BOOTP/DHCP, Request from 98:4b:e1:61:41:a6, length 300
16:33:53.077447 IP 10.11.50.150.67 > 10.15.32.255.68: BOOTP/DHCP, Reply, length 284
However there's no actual bind happening on the end systems, when I expand on the tcpdump I can see (bad udp cksum):
16:37:05.671276 IP (tos 0x0, ttl 251, id 49902, offset 0, flags [none], proto UDP (17), length 328)
10.15.32.241.67 > 10.11.50.150.67: [udp sum ok] BOOTP/DHCP, Request from 98:4b:e1:61:41:a6, length 300, hops 1, xid 0x6713910d, secs 65535, Flags [none] (0x0000)
Gateway-IP 10.15.32.241
Client-Ethernet-Address 98:4b:e1:61:41:a6
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Discover
Client-ID Option 61, length 7: ether 98:4b:e1:61:41:a6
MSZ Option 57, length 2: 576
Parameter-Request Option 55, length 7:
Subnet-Mask, Default-Gateway, Domain-Name-Server, Domain-Name
TFTP, BF, RN
16:37:05.672099 IP (tos 0x0, ttl 64, id 50425, offset 0, flags [none], proto UDP (17), length 312)
10.11.50.150.67 > 10.15.32.255.68: [bad udp cksum 0x3874 -> 0x0e13!] BOOTP/DHCP, Reply, length 284, xid 0x6713910d, Flags [none] (0x0000)
Your-IP 10.15.32.243
Server-IP 10.11.50.150
Gateway-IP 10.15.32.241
Client-Ethernet-Address 98:4b:e1:61:41:a6
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
Subnet-Mask Option 1, length 4: 255.255.255.240
Default-Gateway Option 3, length 4: 10.15.32.242
Domain-Name-Server Option 6, length 8: 8.8.8.8,8.8.4.4
Lease-Time Option 51, length 4: 86400
DHCP-Message Option 53, length 1: Offer
Server-ID Option 54, length 4: 1011.50.150
RN Option 58, length 4: 3600
Any idea why it might be throwing the bad checksum? NIC offloading or packing of UDP frame issue?
Hello
I am using the DHCP server on a linux box with libvirt and lxc installed. Both of these have their own DCHP server, which binds to specific virtual interfaces. However, this prevents node-dhcp server from binding to port 67. Suggest to create the server socket with reuseAddr set to true.
Thanks
the Issue #37 is closed.
I try to use 2 UDP socket, but that not enough. I did not find valid solution to bypass this lack of feature.
Should I use raw-socket or ffi patch ?
any point of view ?
hello,
thank you for this library, i was wondering if there is a way to create a function for the static ips array to be dynamically changed during dhcp run. what i want to do is give out specified ips to macs but my config could change.
Thanks in advance.
Hi Does this library support sub-options ?
i.e. option 82 sub-option 9 etc
Hi
Any plans to support unicast querying instead of just broadcasts - for switches that require helpers for example.
dchappelle@L164:~/macgyver2/node-dhcp/examples$ node server.js
/home/dchappelle/macgyver2/node-dhcp/examples/server.js:65
s.listen();
^
TypeError: s.listen is not a function
at Object. (/home/dchappelle/macgyver2/node-dhcp/examples/server.js:65:3)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:974:3
On my windows PC I have two NICs and when I try to run the client (dhcp
) from command line I get an error because there are too many network interfaces.
Error: Too many network interfaces, set mac address manually:
client = dhcp.createClient({mac: "12:23:34:45:56:67"});
at Client.config (C:\Users\cjacobs\AppData\Roaming\npm\node_modules\dhcp\lib\dhcp.js:526:23)
at Client.sendDiscover (C:\Users\cjacobs\AppData\Roaming\npm\node_modules\dhcp\lib\dhcp.js:577:20)
at Object.<anonymous> (C:\Users\cjacobs\AppData\Roaming\npm\node_modules\dhcp\bin\dhcp-cli.js:32:8)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
I cannot proceed from CLI because there is no command line option for MAC addresses.
dhcp-proxy is useful when we need to implement a boot server in a LAN with a pre-existant server dhcp (the majority of uses cases)
I followed this PXE specification to write this document
PXE-CLIENT -> DHCP (DHCP Discover to port 67 Contains “PXEClient” extension)
DHCP -> PXE-CLIENT (DHCP Offer to port 68 Contains [other DHCP option tags] + Client IP addr)
PXE-CLIENT -> DHCP (DHCP Request to port 67)
DHCP -> PXE-CLIENT (DHCP Ack to port 68)
PXE-CLIENT -> DHCP-PROXY (Discover to port 67 Contains “PXEClient” extension) * initial DHCPREQUEST
DHCP-PROXY -> PXE-CLIENT (DHCP Offer to port 68 Client IP addr set to 0.0.0.0)
PXE-CLIENT -> DHCP-PROXY (DHCP Request to port 4011 Contains “PXEClient” extension)
DHCP-PROXY -> PXE-CLIENT (DHCP Ack reply to port client’s port Contains “PXEClient” extension tags + pxelinux.0 file)
PXE-CLIENT -> TFTP (pxelinux.0 download request to TFTP port 69 or MTFTP port assigned in DHCP Ack w/ pxelinux.0 file)
TFTP -> PXE-CLIENT (pxelinux.0 download to client’s port)
The PXE client knows to interrogate the Proxy DHCP service because the DHCPOFFER from the DHCP service contains an Option #60 “PXEClient” tag without corresponding Option #43 tags or a boot file name
93: {
name: 'Client system architecture.',
type: 'UInt8',
enum: {
0: 'IA_X86_PC',
1: 'NEC98_PC',
2: 'IA_64_PC',
3: 'ALPHA',
4: 'ARC_X86',
5: `INTEL_LEAN_CLIENT`
},
attr: 'csa'
},
This is just an example, I introduced the variables dhcpProxy and req.csa (client system architecture)
var dhcpd = require('../lib/dhcp.js');
var p = dhcpd.createServer({
dhcpProxy: true,
range: [
"192.168.3.10", "192.168.3.99"
],
server: '192.168.3.2', // This is bootserver
bootFile: function (req, res) {
if (req.csa === '0') {
return 'x86linux.0';
} else {
return 'x64linux.0';
}
}
});
p.on('message', function (data) {
console.log(data);
});
p.on('bound', function(state) {
console.log("BOUND:");
console.log(state);
});
p.on("error", function (err, data) {
console.log(err, data);
});
s.on("listening", function (sock) {
var address = sock.address();
console.info('Server Listening: ' + address.address + ':' + address.port);
});
p.on("close", function () {
console.log('close');
});
p.listen();
process.on('SIGINT', () => {
p.close();
});
I've been following the example code, below :
var address = sock.address();
console.info('Server Listening: ' + address.address + ':' + address.port);
});
however, I want to get the data out of sock.address() in to global variable like this
var address = null
s.on("listening", function(sock) {
address = sock.address();
});
console.log(address)
however, I get undefined from it any idea what can I do.
For a DHCP server, it would be ideal to be able to bind an instance to an interface . (or perhaps a group of interfaces). If you were building a router, you only wan DHCP offered on LAN ports, not the WAN ports.
Thanks for taking the time to build this project, it's been very helpful!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.