penguins-eggs 9.3.26 → 9.3.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.oclif.manifest.json +1 -1
- package/conf/derivatives.yaml +7 -0
- package/dist/classes/bleach.js +26 -24
- package/dist/classes/compressors.js +7 -5
- package/dist/classes/daddy.js +38 -36
- package/dist/classes/distro.js +30 -27
- package/dist/classes/family/archlinux.js +21 -19
- package/dist/classes/family/debian.js +33 -31
- package/dist/classes/family/fedora.js +19 -17
- package/dist/classes/family/suse.js +19 -17
- package/dist/classes/incubation/branding.js +8 -6
- package/dist/classes/incubation/distros/bionic.js +5 -3
- package/dist/classes/incubation/distros/buster.js +5 -3
- package/dist/classes/incubation/distros/focal.js +5 -3
- package/dist/classes/incubation/distros/jessie.js +6 -4
- package/dist/classes/incubation/distros/rolling.js +9 -7
- package/dist/classes/incubation/fisherman-helper/displaymanager.js +5 -3
- package/dist/classes/incubation/fisherman-helper/packages.js +17 -15
- package/dist/classes/incubation/fisherman.js +19 -19
- package/dist/classes/incubation/incubator.js +37 -35
- package/dist/classes/incubation/installer.js +8 -6
- package/dist/classes/initrd.js +5 -3
- package/dist/classes/keyboards.js +25 -23
- package/dist/classes/locales.js +19 -17
- package/dist/classes/n8.js +4 -2
- package/dist/classes/network.js +9 -9
- package/dist/classes/ovary.js +280 -281
- package/dist/classes/pacman.js +128 -128
- package/dist/classes/pve-live.js +7 -5
- package/dist/classes/pxe.js +141 -138
- package/dist/classes/settings.js +34 -32
- package/dist/classes/sources_list.js +31 -31
- package/dist/classes/systemctl.js +16 -14
- package/dist/classes/tailor.js +255 -262
- package/dist/classes/tools.js +7 -5
- package/dist/classes/users.js +30 -28
- package/dist/classes/utils.js +22 -20
- package/dist/classes/xdg.js +60 -58
- package/dist/classes/yolk.js +33 -33
- package/dist/commands/adapt.js +14 -12
- package/dist/commands/analyze.js +48 -15
- package/dist/commands/calamares.js +28 -26
- package/dist/commands/config.js +77 -79
- package/dist/commands/cuckoo.js +19 -17
- package/dist/commands/dad.js +16 -14
- package/dist/commands/export/deb.js +19 -17
- package/dist/commands/export/iso.js +17 -15
- package/dist/commands/install.js +31 -29
- package/dist/commands/kill.js +17 -15
- package/dist/commands/mom.js +11 -9
- package/dist/commands/produce.js +30 -28
- package/dist/commands/status.js +7 -5
- package/dist/commands/syncfrom.js +41 -41
- package/dist/commands/syncto.js +77 -80
- package/dist/commands/tools/clean.js +13 -11
- package/dist/commands/tools/ppa.js +26 -24
- package/dist/commands/tools/skel.js +18 -16
- package/dist/commands/tools/stat.js +12 -10
- package/dist/commands/tools/yolk.js +13 -11
- package/dist/commands/update.js +29 -27
- package/dist/commands/wardrobe/get.js +14 -12
- package/dist/commands/wardrobe/list.js +25 -23
- package/dist/commands/wardrobe/show.js +25 -23
- package/dist/commands/wardrobe/wear.js +24 -22
- package/dist/components/elements/information.js +21 -19
- package/dist/components/elements/steps.js +4 -2
- package/dist/components/elements/title.js +4 -2
- package/dist/components/finished.js +10 -8
- package/dist/components/install.js +10 -8
- package/dist/components/keyboard.js +10 -8
- package/dist/components/location.js +10 -8
- package/dist/components/network.js +10 -8
- package/dist/components/partitions.js +10 -8
- package/dist/components/summary.js +10 -8
- package/dist/components/users.js +33 -8
- package/dist/components/welcome.js +10 -8
- package/dist/interfaces/i-packages.js +1 -1
- package/dist/interfaces/i-pxe.js +39 -0
- package/dist/krill/krill-prepare.js +92 -90
- package/dist/krill/krill-sequence.js +148 -145
- package/dist/krill/modules/add-user.js +11 -9
- package/dist/krill/modules/bootloader-config-ubuntu.js +25 -23
- package/dist/krill/modules/bootloader.js +11 -9
- package/dist/krill/modules/change-password.js +2 -2
- package/dist/krill/modules/del-live-user.js +8 -6
- package/dist/krill/modules/fstab.js +35 -33
- package/dist/krill/modules/grubcfg.js +8 -6
- package/dist/krill/modules/hostname.js +19 -17
- package/dist/krill/modules/initramfs-cfg.js +6 -4
- package/dist/krill/modules/initramfs.js +17 -15
- package/dist/krill/modules/locale-cfg.js +12 -10
- package/dist/krill/modules/locale.js +13 -11
- package/dist/krill/modules/m-keyboard.js +33 -31
- package/dist/krill/modules/m-timezone.js +7 -5
- package/dist/krill/modules/machine-id.js +8 -6
- package/dist/krill/modules/mkfs.js +7 -7
- package/dist/krill/modules/mount-fs.js +22 -22
- package/dist/krill/modules/mount-vfs.js +12 -12
- package/dist/krill/modules/network-cfg.js +21 -21
- package/dist/krill/modules/packages.js +20 -18
- package/dist/krill/modules/partition.js +148 -139
- package/dist/krill/modules/remove-installer-link.js +5 -3
- package/dist/krill/modules/umount.js +9 -7
- package/dist/krill/modules/unpackfs.js +8 -6
- package/dist/lib/cli-autologin.js +163 -163
- package/dist/lib/dependencies.js +10 -10
- package/dist/lib/get_address.js +6 -4
- package/dist/lib/get_dns.js +6 -4
- package/dist/lib/get_domain.js +6 -4
- package/dist/lib/get_gateway.js +6 -4
- package/dist/lib/get_hostname.js +6 -4
- package/dist/lib/get_netmask.js +6 -4
- package/dist/lib/get_password.js +8 -6
- package/dist/lib/get_root_password.js +7 -5
- package/dist/lib/get_userfullname.js +6 -4
- package/dist/lib/get_username.js +6 -4
- package/dist/lib/select_address_type.js +6 -4
- package/dist/lib/select_filesystem_type.js +8 -6
- package/dist/lib/select_installation_device.js +7 -5
- package/dist/lib/select_installation_mode.js +6 -4
- package/dist/lib/select_interface.js +6 -4
- package/dist/lib/select_keyboard_layout.js +10 -8
- package/dist/lib/select_keyboard_model.js +10 -8
- package/dist/lib/select_keyboard_option.js +10 -8
- package/dist/lib/select_keyboard_variant.js +10 -8
- package/dist/lib/select_languages.js +9 -7
- package/dist/lib/select_regions.js +6 -4
- package/dist/lib/select_user_swap_choice.js +8 -6
- package/dist/lib/select_zones.js +12 -10
- package/dist/lib/utils.js +3 -3
- package/package.json +12 -5
- package/dist/dhcpd/dhcpd.js +0 -222
- package/dist/dhcpd/index.js +0 -7
- package/dist/dhcpd/packet/converters.js +0 -377
- package/dist/dhcpd/packet/options.js +0 -2
- package/dist/dhcpd/packet/types.js +0 -2
- package/dist/dhcpd/packet.js +0 -251
- package/dist/dhcpd/proxy.js +0 -152
- package/dist/dhcpd/server.js +0 -152
- package/dist/dhcpd/sprintf.js +0 -170
- package/dist/dhcpd/utils.js +0 -190
- package/dist/interfaces/i-pxe-options.js +0 -2
package/dist/dhcpd/packet.js
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var utils = require('./utils');
|
|
3
|
-
var get_convert = require('./packet/converters');
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
class Packet {
|
|
8
|
-
constructor(array) {
|
|
9
|
-
var key;
|
|
10
|
-
for (key in array) {
|
|
11
|
-
if (array.hasOwnProperty(key)) {
|
|
12
|
-
this[key] = array[key];
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @returns
|
|
19
|
-
*/
|
|
20
|
-
getRequestedIPAddress() {
|
|
21
|
-
return this.options[50];
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* @param {*} op
|
|
26
|
-
* @returns
|
|
27
|
-
*/
|
|
28
|
-
op(op) {
|
|
29
|
-
this.op = op;
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @param {*} htype
|
|
35
|
-
* @returns
|
|
36
|
-
*/
|
|
37
|
-
htype(htype) {
|
|
38
|
-
this.htype = htype;
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
* @param {*} hlen
|
|
44
|
-
* @returns
|
|
45
|
-
*/
|
|
46
|
-
hlen(hlen) {
|
|
47
|
-
this.hlen = hlen;
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
hops(hops) {
|
|
51
|
-
this.hops = hops;
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
* @param {*} xid
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
xid(xid) {
|
|
60
|
-
this.xid = xid;
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
*
|
|
65
|
-
* @param {*} secs
|
|
66
|
-
* @returns
|
|
67
|
-
*/
|
|
68
|
-
secs(secs) {
|
|
69
|
-
this.secs = secs;
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
flags(flags) {
|
|
73
|
-
this.flags = flags;
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
*
|
|
78
|
-
* @param {*} ciaddr
|
|
79
|
-
* @returns
|
|
80
|
-
*/
|
|
81
|
-
ciaddr(ciaddr) {
|
|
82
|
-
this.ciaddr = ciaddr !== null ? ciaddr : '0.0.0.0';
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
*
|
|
87
|
-
* @param {*} yiaddr
|
|
88
|
-
* @returns
|
|
89
|
-
*/
|
|
90
|
-
yiaddr(yiaddr) {
|
|
91
|
-
this.yiaddr = yiaddr !== null ? yiaddr : '0.0.0.0';
|
|
92
|
-
return this;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
*
|
|
96
|
-
* @param {*} siaddr
|
|
97
|
-
* @returns
|
|
98
|
-
*/
|
|
99
|
-
siaddr(siaddr) {
|
|
100
|
-
this.siaddr = siaddr !== null ? siaddr : '0.0.0.0';
|
|
101
|
-
return this;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
* @param {*} giaddr
|
|
106
|
-
* @returns
|
|
107
|
-
*/
|
|
108
|
-
giaddr(giaddr) {
|
|
109
|
-
this.giaddr = giaddr !== null ? giaddr : '0.0.0.0';
|
|
110
|
-
return this;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
*
|
|
114
|
-
* @param {*} chaddr
|
|
115
|
-
* @returns
|
|
116
|
-
*/
|
|
117
|
-
chaddr(chaddr) {
|
|
118
|
-
this.chaddr = chaddr;
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
*
|
|
123
|
-
* @param {*} sname
|
|
124
|
-
* @returns
|
|
125
|
-
*/
|
|
126
|
-
sname(sname) {
|
|
127
|
-
this.sname = sname;
|
|
128
|
-
return this;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
*
|
|
132
|
-
* @param {*} fname
|
|
133
|
-
* @returns
|
|
134
|
-
*/
|
|
135
|
-
fname(fname) {
|
|
136
|
-
this.fname = fname;
|
|
137
|
-
return this;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
*
|
|
141
|
-
* @param {*} options
|
|
142
|
-
* @returns
|
|
143
|
-
*/
|
|
144
|
-
options(options) {
|
|
145
|
-
this.options = options;
|
|
146
|
-
return this;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
*
|
|
151
|
-
* @param {*} str
|
|
152
|
-
* @returns
|
|
153
|
-
*/
|
|
154
|
-
function stripBinNull(str) {
|
|
155
|
-
var pos;
|
|
156
|
-
pos = str.indexOf('\u0000');
|
|
157
|
-
if (pos === -1) {
|
|
158
|
-
return str;
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
return str.substr(0, pos);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
var fromBuffer = function (b) {
|
|
165
|
-
var i, optLen, optNum, optVal, options, ret, _ref;
|
|
166
|
-
ret = {
|
|
167
|
-
op: b[0],
|
|
168
|
-
htype: b[1],
|
|
169
|
-
hlen: b.readUInt8(2),
|
|
170
|
-
hops: b.readUInt8(3),
|
|
171
|
-
xid: b.readUInt32BE(4),
|
|
172
|
-
secs: b.readUInt16BE(8),
|
|
173
|
-
flags: b.readUInt16BE(10),
|
|
174
|
-
ciaddr: utils.readIp(b, 12),
|
|
175
|
-
yiaddr: utils.readIp(b, 16),
|
|
176
|
-
siaddr: utils.readIp(b, 20),
|
|
177
|
-
giaddr: utils.readIp(b, 24),
|
|
178
|
-
chaddr: utils.readMacAddress(b.slice(28, 28 + b.readUInt8(2))),
|
|
179
|
-
sname: stripBinNull(b.toString('ascii', 44, 108)),
|
|
180
|
-
fname: stripBinNull(b.toString('ascii', 108, 236)),
|
|
181
|
-
options: {}
|
|
182
|
-
};
|
|
183
|
-
_ref = [0, b.slice(240)];
|
|
184
|
-
i = _ref[0];
|
|
185
|
-
options = _ref[1];
|
|
186
|
-
while (i < options.length && options[i] !== 255) {
|
|
187
|
-
optNum = parseInt(options[i++], 10);
|
|
188
|
-
optLen = parseInt(options[i++], 10);
|
|
189
|
-
var converter = get_convert(optNum);
|
|
190
|
-
optVal = converter.decode(options.slice(i, i + optLen), optNum);
|
|
191
|
-
ret.options[optNum] = optVal;
|
|
192
|
-
i += optLen;
|
|
193
|
-
}
|
|
194
|
-
return new Packet(ret);
|
|
195
|
-
};
|
|
196
|
-
var toBuffer = function () {
|
|
197
|
-
var buffer, hex, i, key, octet, opt, padded, pos, value, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3;
|
|
198
|
-
buffer = new Buffer.alloc(512, 0x00, 'ascii');
|
|
199
|
-
buffer[0] = this.op;
|
|
200
|
-
buffer[1] = this.htype;
|
|
201
|
-
buffer.writeUInt8(this.hlen, 2);
|
|
202
|
-
buffer.writeUInt8(this.hops, 3);
|
|
203
|
-
buffer.writeUInt32BE(this.xid, 4);
|
|
204
|
-
buffer.writeUInt16BE(this.secs, 8);
|
|
205
|
-
buffer.writeUInt16BE(this.flags, 10);
|
|
206
|
-
pos = 12;
|
|
207
|
-
_ref = ["ciaddr", "yiaddr", "siaddr", "giaddr"];
|
|
208
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
209
|
-
key = _ref[_i];
|
|
210
|
-
_ref1 = (this[key] || "0.0.0.0").split(".");
|
|
211
|
-
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
|
212
|
-
octet = _ref1[_j];
|
|
213
|
-
buffer.writeUInt8(parseInt(octet, 10), pos++);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
_ref2 = this.chaddr.split(':');
|
|
217
|
-
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
|
218
|
-
hex = _ref2[_k];
|
|
219
|
-
buffer[pos++] = parseInt(hex, 16);
|
|
220
|
-
}
|
|
221
|
-
buffer.fill(0, 43, 235);
|
|
222
|
-
buffer.write(this.sname, 43, 64, 'ascii');
|
|
223
|
-
if (typeof this.fname === 'string' || this.fname instanceof String) {
|
|
224
|
-
buffer.write(this.fname, 108, 128, 'ascii');
|
|
225
|
-
}
|
|
226
|
-
pos = 236;
|
|
227
|
-
_ref3 = [99, 130, 83, 99];
|
|
228
|
-
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
|
|
229
|
-
i = _ref3[_l];
|
|
230
|
-
buffer[pos++] = i;
|
|
231
|
-
}
|
|
232
|
-
pos = 240;
|
|
233
|
-
for (opt in this.options) {
|
|
234
|
-
if (this.options.hasOwnProperty(opt)) {
|
|
235
|
-
value = this.options[opt];
|
|
236
|
-
var converter = get_convert(opt);
|
|
237
|
-
pos = converter.encode(buffer, opt, value, pos);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
buffer[pos] = 255;
|
|
241
|
-
padded = new Buffer.alloc(pos, 0x00, 'ascii');
|
|
242
|
-
buffer.copy(padded, 0, 0, pos);
|
|
243
|
-
return padded;
|
|
244
|
-
};
|
|
245
|
-
Packet.fromBuffer = fromBuffer;
|
|
246
|
-
Packet.prototype.toBuffer = toBuffer;
|
|
247
|
-
module.exports = {
|
|
248
|
-
Packet: Packet,
|
|
249
|
-
fromBuffer: fromBuffer,
|
|
250
|
-
toBuffer: toBuffer
|
|
251
|
-
};
|
package/dist/dhcpd/proxy.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var util = require('util');
|
|
3
|
-
var dhcp = require('./index');
|
|
4
|
-
var Socket = require('dgram').Socket;
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
class DHCPProxy {
|
|
9
|
-
constructor(type, opts) {
|
|
10
|
-
var _this = this;
|
|
11
|
-
DHCPProxy.super_.apply(this, [type]);
|
|
12
|
-
_this.broadcast = opts.broadcast;
|
|
13
|
-
this.on('error', function (err) {
|
|
14
|
-
console.dir(err);
|
|
15
|
-
});
|
|
16
|
-
this.on('message', function (buffer, remote) {
|
|
17
|
-
var event_name, packet, type;
|
|
18
|
-
packet = dhcp.Packet.fromBuffer(buffer);
|
|
19
|
-
if (packet.op === 1) {
|
|
20
|
-
type = {
|
|
21
|
-
id: packet.options[53] || 0,
|
|
22
|
-
name: dhcp.MessageTypes[packet.options[53] || 0]
|
|
23
|
-
};
|
|
24
|
-
util.log(("Proxy: Got " + type.name + " from") + (" " + remote.address + ":" + remote.port + " (" + packet.chaddr + ") ") + (" with packet length of " + buffer.length + " bytes"));
|
|
25
|
-
event_name = type.name.replace('DHCP', '').toLowerCase();
|
|
26
|
-
packet.remote = remote;
|
|
27
|
-
return _this._emitPacket(event_name, packet);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return console.log(" Unsupported message format");
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return _this;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @param {*} port
|
|
38
|
-
* @param {*} addr
|
|
39
|
-
* @param {*} cb
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
bind(port, addr, cb) {
|
|
43
|
-
var self = this;
|
|
44
|
-
var res;
|
|
45
|
-
res = DHCPProxy.super_.prototype.bind.call(this, port, addr, function () {
|
|
46
|
-
this.setBroadcast(true);
|
|
47
|
-
if (cb instanceof Function)
|
|
48
|
-
cb();
|
|
49
|
-
});
|
|
50
|
-
return res;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
* @param {*} event_name
|
|
55
|
-
* @param {*} ip
|
|
56
|
-
* @param {*} packet
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
_send(event_name, ip, packet) {
|
|
60
|
-
var buffer, _this = this;
|
|
61
|
-
buffer = packet.toBuffer();
|
|
62
|
-
util.log(("Proxy: Sending " + dhcp.MessageTypes[packet.options[53]]) + (" to " + ip + ":" + packet.remote.port + " (" + packet.chaddr + ")") + (" with packet length of " + buffer.length + " bytes"));
|
|
63
|
-
this.emit(event_name, packet);
|
|
64
|
-
return this.send(buffer, 0, buffer.length, packet.remote.port, ip, function (err, bytes) {
|
|
65
|
-
if (err) {
|
|
66
|
-
return _this.emit("" + event_name + "Error", err, packet);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
return _this.emit("" + event_name + "Sent", bytes, packet);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
*
|
|
75
|
-
* @param {*} message_type
|
|
76
|
-
* @param {*} packet
|
|
77
|
-
* @returns
|
|
78
|
-
*/
|
|
79
|
-
_emitPacket(message_type, packet) {
|
|
80
|
-
return this.emit(message_type, packet, packet.options[50] || null);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
*
|
|
84
|
-
* @param {*} packet
|
|
85
|
-
* @param {*} params
|
|
86
|
-
*/
|
|
87
|
-
discover(packet, params) {
|
|
88
|
-
console.log('Proxy: Got DHCP DISCOVER');
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
*
|
|
92
|
-
* @param {*} packet
|
|
93
|
-
* @param {*} params
|
|
94
|
-
* @returns
|
|
95
|
-
*/
|
|
96
|
-
offer(packet, params) {
|
|
97
|
-
if (params) {
|
|
98
|
-
packet.yiaddr = params.yiaddr;
|
|
99
|
-
packet.siaddr = params.siaddr;
|
|
100
|
-
packet.options = params.options;
|
|
101
|
-
}
|
|
102
|
-
packet.op = packet.options[53] = 2;
|
|
103
|
-
return this._send('offer', this.broadcast, packet);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
*
|
|
107
|
-
* @param {*} packet
|
|
108
|
-
* @param {*} params
|
|
109
|
-
* @returns
|
|
110
|
-
*/
|
|
111
|
-
ack(packet, params) {
|
|
112
|
-
if (params) {
|
|
113
|
-
packet.yiaddr = params.yiaddr;
|
|
114
|
-
packet.siaddr = params.siaddr;
|
|
115
|
-
packet.options = params.options;
|
|
116
|
-
}
|
|
117
|
-
packet.op = 2;
|
|
118
|
-
packet.options[53] = 5;
|
|
119
|
-
// return this._send('ack', this.broadcast, packet);
|
|
120
|
-
return this._send('ack', packet.ciaddr, packet);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
*
|
|
124
|
-
* @param {*} packet
|
|
125
|
-
* @param {*} params
|
|
126
|
-
* @returns
|
|
127
|
-
*/
|
|
128
|
-
nak(packet, params) {
|
|
129
|
-
packet.op = 2;
|
|
130
|
-
packet.options[53] = 6;
|
|
131
|
-
return this._send('nak', packet.ciaddr, packet);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
*
|
|
135
|
-
* @param {*} packet
|
|
136
|
-
* @param {*} params
|
|
137
|
-
* @returns
|
|
138
|
-
*/
|
|
139
|
-
inform(packet, params) {
|
|
140
|
-
if (params) {
|
|
141
|
-
packet.yiaddr = params.yiaddr;
|
|
142
|
-
packet.siaddr = params.siaddr;
|
|
143
|
-
packet.options = params.options;
|
|
144
|
-
}
|
|
145
|
-
packet.op = 2;
|
|
146
|
-
packet.options[53] = 5;
|
|
147
|
-
return this._send('inform', packet.ciaddr, packet);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
util.inherits(DHCPProxy, Socket);
|
|
151
|
-
DHCPProxy.Packet = dhcp.Packet;
|
|
152
|
-
module.exports = DHCPProxy;
|
package/dist/dhcpd/server.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var util = require('util');
|
|
3
|
-
var dhcp = require('./index');
|
|
4
|
-
var Socket = require('dgram').Socket;
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
class DHCPServer {
|
|
9
|
-
constructor(type, opts) {
|
|
10
|
-
var _this = this;
|
|
11
|
-
DHCPServer.super_.apply(this, [type]);
|
|
12
|
-
_this.broadcast = opts.broadcast;
|
|
13
|
-
this.on('error', function (err) {
|
|
14
|
-
console.dir(err);
|
|
15
|
-
});
|
|
16
|
-
this.on('message', function (buffer, remote) {
|
|
17
|
-
var event_name, packet, type;
|
|
18
|
-
packet = dhcp.Packet.fromBuffer(buffer);
|
|
19
|
-
if (packet.op === 1) {
|
|
20
|
-
type = {
|
|
21
|
-
id: packet.options[53] || 0,
|
|
22
|
-
name: dhcp.MessageTypes[packet.options[53] || 0]
|
|
23
|
-
};
|
|
24
|
-
util.log(("Got " + type.name + " from") + (" " + remote.address + ":" + remote.port + " (" + packet.chaddr + ") ") + (" with packet length of " + buffer.length + " bytes"));
|
|
25
|
-
event_name = type.name.replace('DHCP', '').toLowerCase();
|
|
26
|
-
packet.remote = remote;
|
|
27
|
-
return _this._emitPacket(event_name, packet);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return console.log(" Unsupported message format");
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return _this;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @param {*} port
|
|
38
|
-
* @param {*} addr
|
|
39
|
-
* @param {*} cb
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
bind(port, addr, cb) {
|
|
43
|
-
var self = this;
|
|
44
|
-
var res;
|
|
45
|
-
res = DHCPServer.super_.prototype.bind.call(this, port, addr, function () {
|
|
46
|
-
this.setBroadcast(true);
|
|
47
|
-
if (cb instanceof Function)
|
|
48
|
-
cb();
|
|
49
|
-
});
|
|
50
|
-
return res;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
* @param {*} event_name
|
|
55
|
-
* @param {*} ip
|
|
56
|
-
* @param {*} packet
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
_send(event_name, ip, packet) {
|
|
60
|
-
var buffer, _this = this;
|
|
61
|
-
buffer = packet.toBuffer();
|
|
62
|
-
util.log(("Sending " + dhcp.MessageTypes[packet.options[53]]) + (" to " + ip + ":68 (" + packet.chaddr + ")") + (" with packet length of " + buffer.length + " bytes"));
|
|
63
|
-
this.emit(event_name, packet);
|
|
64
|
-
return this.send(buffer, 0, buffer.length, 68, ip, function (err, bytes) {
|
|
65
|
-
if (err) {
|
|
66
|
-
return _this.emit("" + event_name + "Error", err, packet);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
return _this.emit("" + event_name + "Sent", bytes, packet);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
*
|
|
75
|
-
* @param {*} message_type
|
|
76
|
-
* @param {*} packet
|
|
77
|
-
* @returns
|
|
78
|
-
*/
|
|
79
|
-
_emitPacket(message_type, packet) {
|
|
80
|
-
return this.emit(message_type, packet, packet.options[50] || null);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
*
|
|
84
|
-
* @param {*} packet
|
|
85
|
-
* @param {*} params
|
|
86
|
-
*/
|
|
87
|
-
discover(packet, params) {
|
|
88
|
-
console.log('Got DHCP DISCOVER');
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
*
|
|
92
|
-
* @param {*} packet
|
|
93
|
-
* @param {*} params
|
|
94
|
-
* @returns
|
|
95
|
-
*/
|
|
96
|
-
offer(packet, params) {
|
|
97
|
-
if (params) {
|
|
98
|
-
packet.yiaddr = params.yiaddr;
|
|
99
|
-
packet.siaddr = params.siaddr;
|
|
100
|
-
packet.options = params.options;
|
|
101
|
-
}
|
|
102
|
-
packet.op = packet.options[53] = 2;
|
|
103
|
-
//return this._send('offer', this.broadcast, packet);
|
|
104
|
-
return this._send('offer', '255.255.255.255', packet);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
*
|
|
108
|
-
* @param {*} packet
|
|
109
|
-
* @param {*} params
|
|
110
|
-
* @returns
|
|
111
|
-
*/
|
|
112
|
-
ack(packet, params) {
|
|
113
|
-
if (params) {
|
|
114
|
-
packet.yiaddr = params.yiaddr;
|
|
115
|
-
packet.siaddr = params.siaddr;
|
|
116
|
-
packet.options = params.options;
|
|
117
|
-
}
|
|
118
|
-
packet.op = 2;
|
|
119
|
-
packet.options[53] = 5;
|
|
120
|
-
return this._send('ack', this.broadcast, packet);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
*
|
|
124
|
-
* @param {*} packet
|
|
125
|
-
* @param {*} params
|
|
126
|
-
* @returns
|
|
127
|
-
*/
|
|
128
|
-
nak(packet, params) {
|
|
129
|
-
packet.op = 2;
|
|
130
|
-
packet.options[53] = 6;
|
|
131
|
-
return this._send('nak', packet.ciaddr, packet);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
*
|
|
135
|
-
* @param {*} packet
|
|
136
|
-
* @param {*} params
|
|
137
|
-
* @returns
|
|
138
|
-
*/
|
|
139
|
-
inform(packet, params) {
|
|
140
|
-
if (params) {
|
|
141
|
-
packet.yiaddr = params.yiaddr;
|
|
142
|
-
packet.siaddr = params.siaddr;
|
|
143
|
-
packet.options = params.options;
|
|
144
|
-
}
|
|
145
|
-
packet.op = 2;
|
|
146
|
-
packet.options[53] = 5;
|
|
147
|
-
return this._send('inform', packet.ciaddr, packet);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
util.inherits(DHCPServer, Socket);
|
|
151
|
-
DHCPServer.Packet = dhcp.Packet;
|
|
152
|
-
module.exports = DHCPServer;
|