-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathserver.js
69 lines (57 loc) · 1.38 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var dhcpd = require('../lib/dhcp.js');
var s = dhcpd.createServer({
// System settings
range: [
"192.168.3.10", "192.168.3.99"
],
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"
},
// Option settings
netmask: '255.255.255.0',
router: [
'192.168.0.1'
],
timeServer: null,
nameServer: null,
dns: ["8.8.8.8", "8.8.4.4"],
hostname: "kacknup",
domainName: "xarg.org",
broadcast: '192.168.0.255',
server: '192.168.0.1', // This is us
maxMessageSize: 1500,
leaseTime: 86400,
renewalTime: 60,
rebindingTime: 120,
bootFile: function(req, res) {
// res.ip - the actual ip allocated for the client
if (req.clientId === 'foo bar') {
return 'x86linux.0';
} else {
return 'x64linux.0';
}
}
});
s.on('message', function(data) {
console.log(data);
});
s.on('bound', function(state) {
console.log("BOUND:");
console.log(state);
});
s.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);
});
s.on("close", function() {
console.log('close');
});
s.listen();
process.on('SIGINT', () => {
s.close();
});