Prepare, configure, and manage Firecracker microVMs in seconds!
virtualization linux microvm firecracker

Add Mosquitto and MQTT support; refactor CoreDNS and NextDHCP setup

- Introduced Mosquitto setup functionality with installation checks.
- Added MQTT message handling for dynamic IP assignment in CoreDNS.
- Refactored NextDHCP configuration to include MQTT integration.
- Updated dependencies in Cargo.toml for rumqttc and tokio.

+493 -74
+349 -10
Cargo.lock
··· 130 checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" 131 132 [[package]] 133 name = "backtrace" 134 version = "0.3.75" 135 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 157 checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" 158 159 [[package]] 160 name = "bitflags" 161 version = "1.3.2" 162 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 204 source = "registry+https://github.com/rust-lang/crates.io-index" 205 checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7" 206 dependencies = [ 207 "shlex", 208 ] 209 210 [[package]] 211 name = "cfg-if" 212 version = "1.0.1" 213 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 225 "num-traits", 226 "serde", 227 "wasm-bindgen", 228 - "windows-link", 229 ] 230 231 [[package]] ··· 295 checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" 296 297 [[package]] 298 name = "colorchoice" 299 version = "1.0.4" 300 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 314 version = "0.9.6" 315 source = "registry+https://github.com/rust-lang/crates.io-index" 316 checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" 317 318 [[package]] 319 name = "core-foundation-sys" ··· 441 checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" 442 443 [[package]] 444 name = "either" 445 version = "1.15.0" 446 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 541 "num_cpus", 542 "owo-colors", 543 "rand", 544 "serde_json", 545 ] 546 547 [[package]] ··· 565 ] 566 567 [[package]] 568 name = "flume" 569 version = "0.11.1" 570 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 591 ] 592 593 [[package]] 594 name = "futures-channel" 595 version = "0.3.31" 596 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 680 dependencies = [ 681 "cfg-if", 682 "libc", 683 - "wasi", 684 ] 685 686 [[package]] ··· 961 checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" 962 963 [[package]] 964 name = "itoa" 965 version = "1.0.15" 966 source = "registry+https://github.com/rust-lang/crates.io-index" 967 checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" 968 969 [[package]] 970 name = "js-sys" 971 version = "0.3.77" 972 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 990 version = "0.2.174" 991 source = "registry+https://github.com/rust-lang/crates.io-index" 992 checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" 993 994 [[package]] 995 name = "libm" ··· 1079 checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" 1080 1081 [[package]] 1082 name = "miniz_oxide" 1083 version = "0.8.9" 1084 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1094 checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" 1095 dependencies = [ 1096 "libc", 1097 - "wasi", 1098 "windows-sys 0.59.0", 1099 ] 1100 ··· 1109 ] 1110 1111 [[package]] 1112 name = "num-bigint-dig" 1113 version = "0.8.4" 1114 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1185 version = "1.70.1" 1186 source = "registry+https://github.com/rust-lang/crates.io-index" 1187 checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" 1188 1189 [[package]] 1190 name = "option-ext" ··· 1306 ] 1307 1308 [[package]] 1309 name = "proc-macro-error" 1310 version = "1.0.4" 1311 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1348 ] 1349 1350 [[package]] 1351 name = "rand" 1352 version = "0.8.5" 1353 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1374 source = "registry+https://github.com/rust-lang/crates.io-index" 1375 checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 1376 dependencies = [ 1377 - "getrandom", 1378 ] 1379 1380 [[package]] ··· 1392 source = "registry+https://github.com/rust-lang/crates.io-index" 1393 checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" 1394 dependencies = [ 1395 - "getrandom", 1396 "libredox", 1397 "thiserror 2.0.12", 1398 ] ··· 1434 dependencies = [ 1435 "cc", 1436 "cfg-if", 1437 - "getrandom", 1438 "libc", 1439 "untrusted", 1440 "windows-sys 0.52.0", ··· 1461 ] 1462 1463 [[package]] 1464 name = "rustc-demangle" 1465 version = "0.1.26" 1466 source = "registry+https://github.com/rust-lang/crates.io-index" 1467 checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" 1468 1469 [[package]] 1470 name = "rustls" 1471 version = "0.23.29" 1472 source = "registry+https://github.com/rust-lang/crates.io-index" 1473 checksum = "2491382039b29b9b11ff08b76ff6c97cf287671dbb74f0be44bda389fffe9bd1" 1474 dependencies = [ 1475 "once_cell", 1476 "ring", 1477 "rustls-pki-types", 1478 - "rustls-webpki", 1479 "subtle", 1480 "zeroize", 1481 ] 1482 1483 [[package]] 1484 name = "rustls-pki-types" 1485 version = "1.12.0" 1486 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1491 1492 [[package]] 1493 name = "rustls-webpki" 1494 version = "0.103.4" 1495 source = "registry+https://github.com/rust-lang/crates.io-index" 1496 checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc" 1497 dependencies = [ 1498 "ring", 1499 "rustls-pki-types", 1500 "untrusted", ··· 1522 ] 1523 1524 [[package]] 1525 name = "scopeguard" 1526 version = "1.2.0" 1527 source = "registry+https://github.com/rust-lang/crates.io-index" 1528 checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 1529 1530 [[package]] 1531 name = "serde" 1532 version = "1.0.219" 1533 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2073 ] 2074 2075 [[package]] 2076 name = "tokio-stream" 2077 version = "0.1.17" 2078 source = "registry+https://github.com/rust-lang/crates.io-index" 2079 checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" 2080 dependencies = [ 2081 "futures-core", 2082 "pin-project-lite", 2083 "tokio", 2084 ] ··· 2245 checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" 2246 2247 [[package]] 2248 name = "wasite" 2249 version = "0.1.0" 2250 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2375 dependencies = [ 2376 "windows-implement", 2377 "windows-interface", 2378 - "windows-link", 2379 "windows-result", 2380 "windows-strings", 2381 ] ··· 2409 checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" 2410 2411 [[package]] 2412 name = "windows-result" 2413 version = "0.3.4" 2414 source = "registry+https://github.com/rust-lang/crates.io-index" 2415 checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" 2416 dependencies = [ 2417 - "windows-link", 2418 ] 2419 2420 [[package]] ··· 2423 source = "registry+https://github.com/rust-lang/crates.io-index" 2424 checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" 2425 dependencies = [ 2426 - "windows-link", 2427 ] 2428 2429 [[package]] ··· 2451 checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 2452 dependencies = [ 2453 "windows-targets 0.52.6", 2454 ] 2455 2456 [[package]] ··· 2588 dependencies = [ 2589 "winapi", 2590 ] 2591 2592 [[package]] 2593 name = "writeable"
··· 130 checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" 131 132 [[package]] 133 + name = "aws-lc-rs" 134 + version = "1.14.0" 135 + source = "registry+https://github.com/rust-lang/crates.io-index" 136 + checksum = "94b8ff6c09cd57b16da53641caa860168b88c172a5ee163b0288d3d6eea12786" 137 + dependencies = [ 138 + "aws-lc-sys", 139 + "zeroize", 140 + ] 141 + 142 + [[package]] 143 + name = "aws-lc-sys" 144 + version = "0.31.0" 145 + source = "registry+https://github.com/rust-lang/crates.io-index" 146 + checksum = "0e44d16778acaf6a9ec9899b92cebd65580b83f685446bf2e1f5d3d732f99dcd" 147 + dependencies = [ 148 + "bindgen", 149 + "cc", 150 + "cmake", 151 + "dunce", 152 + "fs_extra", 153 + ] 154 + 155 + [[package]] 156 name = "backtrace" 157 version = "0.3.75" 158 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 180 checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" 181 182 [[package]] 183 + name = "bindgen" 184 + version = "0.72.1" 185 + source = "registry+https://github.com/rust-lang/crates.io-index" 186 + checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" 187 + dependencies = [ 188 + "bitflags 2.9.1", 189 + "cexpr", 190 + "clang-sys", 191 + "itertools", 192 + "log", 193 + "prettyplease", 194 + "proc-macro2", 195 + "quote", 196 + "regex", 197 + "rustc-hash", 198 + "shlex", 199 + "syn 2.0.104", 200 + ] 201 + 202 + [[package]] 203 name = "bitflags" 204 version = "1.3.2" 205 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 247 source = "registry+https://github.com/rust-lang/crates.io-index" 248 checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7" 249 dependencies = [ 250 + "jobserver", 251 + "libc", 252 "shlex", 253 ] 254 255 [[package]] 256 + name = "cexpr" 257 + version = "0.6.0" 258 + source = "registry+https://github.com/rust-lang/crates.io-index" 259 + checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" 260 + dependencies = [ 261 + "nom", 262 + ] 263 + 264 + [[package]] 265 name = "cfg-if" 266 version = "1.0.1" 267 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 279 "num-traits", 280 "serde", 281 "wasm-bindgen", 282 + "windows-link 0.1.3", 283 + ] 284 + 285 + [[package]] 286 + name = "clang-sys" 287 + version = "1.8.1" 288 + source = "registry+https://github.com/rust-lang/crates.io-index" 289 + checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" 290 + dependencies = [ 291 + "glob", 292 + "libc", 293 + "libloading", 294 ] 295 296 [[package]] ··· 360 checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" 361 362 [[package]] 363 + name = "cmake" 364 + version = "0.1.54" 365 + source = "registry+https://github.com/rust-lang/crates.io-index" 366 + checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" 367 + dependencies = [ 368 + "cc", 369 + ] 370 + 371 + [[package]] 372 name = "colorchoice" 373 version = "1.0.4" 374 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 388 version = "0.9.6" 389 source = "registry+https://github.com/rust-lang/crates.io-index" 390 checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" 391 + 392 + [[package]] 393 + name = "core-foundation" 394 + version = "0.10.1" 395 + source = "registry+https://github.com/rust-lang/crates.io-index" 396 + checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" 397 + dependencies = [ 398 + "core-foundation-sys", 399 + "libc", 400 + ] 401 402 [[package]] 403 name = "core-foundation-sys" ··· 525 checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" 526 527 [[package]] 528 + name = "dunce" 529 + version = "1.0.5" 530 + source = "registry+https://github.com/rust-lang/crates.io-index" 531 + checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" 532 + 533 + [[package]] 534 name = "either" 535 version = "1.15.0" 536 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 631 "num_cpus", 632 "owo-colors", 633 "rand", 634 + "rumqttc", 635 "serde_json", 636 + "tokio", 637 ] 638 639 [[package]] ··· 657 ] 658 659 [[package]] 660 + name = "fixedbitset" 661 + version = "0.5.7" 662 + source = "registry+https://github.com/rust-lang/crates.io-index" 663 + checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" 664 + 665 + [[package]] 666 name = "flume" 667 version = "0.11.1" 668 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 689 ] 690 691 [[package]] 692 + name = "fs_extra" 693 + version = "1.3.0" 694 + source = "registry+https://github.com/rust-lang/crates.io-index" 695 + checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" 696 + 697 + [[package]] 698 name = "futures-channel" 699 version = "0.3.31" 700 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 784 dependencies = [ 785 "cfg-if", 786 "libc", 787 + "wasi 0.11.1+wasi-snapshot-preview1", 788 + ] 789 + 790 + [[package]] 791 + name = "getrandom" 792 + version = "0.3.3" 793 + source = "registry+https://github.com/rust-lang/crates.io-index" 794 + checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" 795 + dependencies = [ 796 + "cfg-if", 797 + "libc", 798 + "r-efi", 799 + "wasi 0.14.5+wasi-0.2.4", 800 ] 801 802 [[package]] ··· 1077 checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" 1078 1079 [[package]] 1080 + name = "itertools" 1081 + version = "0.13.0" 1082 + source = "registry+https://github.com/rust-lang/crates.io-index" 1083 + checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" 1084 + dependencies = [ 1085 + "either", 1086 + ] 1087 + 1088 + [[package]] 1089 name = "itoa" 1090 version = "1.0.15" 1091 source = "registry+https://github.com/rust-lang/crates.io-index" 1092 checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" 1093 1094 [[package]] 1095 + name = "jobserver" 1096 + version = "0.1.34" 1097 + source = "registry+https://github.com/rust-lang/crates.io-index" 1098 + checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" 1099 + dependencies = [ 1100 + "getrandom 0.3.3", 1101 + "libc", 1102 + ] 1103 + 1104 + [[package]] 1105 name = "js-sys" 1106 version = "0.3.77" 1107 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1125 version = "0.2.174" 1126 source = "registry+https://github.com/rust-lang/crates.io-index" 1127 checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" 1128 + 1129 + [[package]] 1130 + name = "libloading" 1131 + version = "0.8.8" 1132 + source = "registry+https://github.com/rust-lang/crates.io-index" 1133 + checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" 1134 + dependencies = [ 1135 + "cfg-if", 1136 + "windows-targets 0.52.6", 1137 + ] 1138 1139 [[package]] 1140 name = "libm" ··· 1224 checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" 1225 1226 [[package]] 1227 + name = "minimal-lexical" 1228 + version = "0.2.1" 1229 + source = "registry+https://github.com/rust-lang/crates.io-index" 1230 + checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" 1231 + 1232 + [[package]] 1233 name = "miniz_oxide" 1234 version = "0.8.9" 1235 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1245 checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" 1246 dependencies = [ 1247 "libc", 1248 + "wasi 0.11.1+wasi-snapshot-preview1", 1249 "windows-sys 0.59.0", 1250 ] 1251 ··· 1260 ] 1261 1262 [[package]] 1263 + name = "nom" 1264 + version = "7.1.3" 1265 + source = "registry+https://github.com/rust-lang/crates.io-index" 1266 + checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" 1267 + dependencies = [ 1268 + "memchr", 1269 + "minimal-lexical", 1270 + ] 1271 + 1272 + [[package]] 1273 name = "num-bigint-dig" 1274 version = "0.8.4" 1275 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1346 version = "1.70.1" 1347 source = "registry+https://github.com/rust-lang/crates.io-index" 1348 checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" 1349 + 1350 + [[package]] 1351 + name = "openssl-probe" 1352 + version = "0.1.6" 1353 + source = "registry+https://github.com/rust-lang/crates.io-index" 1354 + checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" 1355 1356 [[package]] 1357 name = "option-ext" ··· 1473 ] 1474 1475 [[package]] 1476 + name = "prettyplease" 1477 + version = "0.2.36" 1478 + source = "registry+https://github.com/rust-lang/crates.io-index" 1479 + checksum = "ff24dfcda44452b9816fff4cd4227e1bb73ff5a2f1bc1105aa92fb8565ce44d2" 1480 + dependencies = [ 1481 + "proc-macro2", 1482 + "syn 2.0.104", 1483 + ] 1484 + 1485 + [[package]] 1486 name = "proc-macro-error" 1487 version = "1.0.4" 1488 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1525 ] 1526 1527 [[package]] 1528 + name = "r-efi" 1529 + version = "5.3.0" 1530 + source = "registry+https://github.com/rust-lang/crates.io-index" 1531 + checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" 1532 + 1533 + [[package]] 1534 name = "rand" 1535 version = "0.8.5" 1536 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1557 source = "registry+https://github.com/rust-lang/crates.io-index" 1558 checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 1559 dependencies = [ 1560 + "getrandom 0.2.16", 1561 ] 1562 1563 [[package]] ··· 1575 source = "registry+https://github.com/rust-lang/crates.io-index" 1576 checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" 1577 dependencies = [ 1578 + "getrandom 0.2.16", 1579 "libredox", 1580 "thiserror 2.0.12", 1581 ] ··· 1617 dependencies = [ 1618 "cc", 1619 "cfg-if", 1620 + "getrandom 0.2.16", 1621 "libc", 1622 "untrusted", 1623 "windows-sys 0.52.0", ··· 1644 ] 1645 1646 [[package]] 1647 + name = "rumqttc" 1648 + version = "0.25.0" 1649 + source = "registry+https://github.com/rust-lang/crates.io-index" 1650 + checksum = "128f632072dc89ced3359668399026d90eadc06c65c807c298d15ff3d1eacf63" 1651 + dependencies = [ 1652 + "bytes", 1653 + "fixedbitset", 1654 + "flume", 1655 + "futures-util", 1656 + "log", 1657 + "rustls-native-certs", 1658 + "rustls-pemfile", 1659 + "rustls-webpki 0.102.8", 1660 + "thiserror 2.0.12", 1661 + "tokio", 1662 + "tokio-rustls", 1663 + "tokio-stream", 1664 + "tokio-util", 1665 + ] 1666 + 1667 + [[package]] 1668 name = "rustc-demangle" 1669 version = "0.1.26" 1670 source = "registry+https://github.com/rust-lang/crates.io-index" 1671 checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" 1672 1673 [[package]] 1674 + name = "rustc-hash" 1675 + version = "2.1.1" 1676 + source = "registry+https://github.com/rust-lang/crates.io-index" 1677 + checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" 1678 + 1679 + [[package]] 1680 name = "rustls" 1681 version = "0.23.29" 1682 source = "registry+https://github.com/rust-lang/crates.io-index" 1683 checksum = "2491382039b29b9b11ff08b76ff6c97cf287671dbb74f0be44bda389fffe9bd1" 1684 dependencies = [ 1685 + "aws-lc-rs", 1686 + "log", 1687 "once_cell", 1688 "ring", 1689 "rustls-pki-types", 1690 + "rustls-webpki 0.103.4", 1691 "subtle", 1692 "zeroize", 1693 ] 1694 1695 [[package]] 1696 + name = "rustls-native-certs" 1697 + version = "0.8.1" 1698 + source = "registry+https://github.com/rust-lang/crates.io-index" 1699 + checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" 1700 + dependencies = [ 1701 + "openssl-probe", 1702 + "rustls-pki-types", 1703 + "schannel", 1704 + "security-framework", 1705 + ] 1706 + 1707 + [[package]] 1708 + name = "rustls-pemfile" 1709 + version = "2.2.0" 1710 + source = "registry+https://github.com/rust-lang/crates.io-index" 1711 + checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" 1712 + dependencies = [ 1713 + "rustls-pki-types", 1714 + ] 1715 + 1716 + [[package]] 1717 name = "rustls-pki-types" 1718 version = "1.12.0" 1719 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1724 1725 [[package]] 1726 name = "rustls-webpki" 1727 + version = "0.102.8" 1728 + source = "registry+https://github.com/rust-lang/crates.io-index" 1729 + checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" 1730 + dependencies = [ 1731 + "ring", 1732 + "rustls-pki-types", 1733 + "untrusted", 1734 + ] 1735 + 1736 + [[package]] 1737 + name = "rustls-webpki" 1738 version = "0.103.4" 1739 source = "registry+https://github.com/rust-lang/crates.io-index" 1740 checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc" 1741 dependencies = [ 1742 + "aws-lc-rs", 1743 "ring", 1744 "rustls-pki-types", 1745 "untrusted", ··· 1767 ] 1768 1769 [[package]] 1770 + name = "schannel" 1771 + version = "0.1.28" 1772 + source = "registry+https://github.com/rust-lang/crates.io-index" 1773 + checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" 1774 + dependencies = [ 1775 + "windows-sys 0.61.0", 1776 + ] 1777 + 1778 + [[package]] 1779 name = "scopeguard" 1780 version = "1.2.0" 1781 source = "registry+https://github.com/rust-lang/crates.io-index" 1782 checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 1783 1784 [[package]] 1785 + name = "security-framework" 1786 + version = "3.4.0" 1787 + source = "registry+https://github.com/rust-lang/crates.io-index" 1788 + checksum = "60b369d18893388b345804dc0007963c99b7d665ae71d275812d828c6f089640" 1789 + dependencies = [ 1790 + "bitflags 2.9.1", 1791 + "core-foundation", 1792 + "core-foundation-sys", 1793 + "libc", 1794 + "security-framework-sys", 1795 + ] 1796 + 1797 + [[package]] 1798 + name = "security-framework-sys" 1799 + version = "2.15.0" 1800 + source = "registry+https://github.com/rust-lang/crates.io-index" 1801 + checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" 1802 + dependencies = [ 1803 + "core-foundation-sys", 1804 + "libc", 1805 + ] 1806 + 1807 + [[package]] 1808 name = "serde" 1809 version = "1.0.219" 1810 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2350 ] 2351 2352 [[package]] 2353 + name = "tokio-rustls" 2354 + version = "0.26.2" 2355 + source = "registry+https://github.com/rust-lang/crates.io-index" 2356 + checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" 2357 + dependencies = [ 2358 + "rustls", 2359 + "tokio", 2360 + ] 2361 + 2362 + [[package]] 2363 name = "tokio-stream" 2364 version = "0.1.17" 2365 source = "registry+https://github.com/rust-lang/crates.io-index" 2366 checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" 2367 dependencies = [ 2368 "futures-core", 2369 + "pin-project-lite", 2370 + "tokio", 2371 + ] 2372 + 2373 + [[package]] 2374 + name = "tokio-util" 2375 + version = "0.7.16" 2376 + source = "registry+https://github.com/rust-lang/crates.io-index" 2377 + checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" 2378 + dependencies = [ 2379 + "bytes", 2380 + "futures-core", 2381 + "futures-sink", 2382 "pin-project-lite", 2383 "tokio", 2384 ] ··· 2545 checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" 2546 2547 [[package]] 2548 + name = "wasi" 2549 + version = "0.14.5+wasi-0.2.4" 2550 + source = "registry+https://github.com/rust-lang/crates.io-index" 2551 + checksum = "a4494f6290a82f5fe584817a676a34b9d6763e8d9d18204009fb31dceca98fd4" 2552 + dependencies = [ 2553 + "wasip2", 2554 + ] 2555 + 2556 + [[package]] 2557 + name = "wasip2" 2558 + version = "1.0.0+wasi-0.2.4" 2559 + source = "registry+https://github.com/rust-lang/crates.io-index" 2560 + checksum = "03fa2761397e5bd52002cd7e73110c71af2109aca4e521a9f40473fe685b0a24" 2561 + dependencies = [ 2562 + "wit-bindgen", 2563 + ] 2564 + 2565 + [[package]] 2566 name = "wasite" 2567 version = "0.1.0" 2568 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2693 dependencies = [ 2694 "windows-implement", 2695 "windows-interface", 2696 + "windows-link 0.1.3", 2697 "windows-result", 2698 "windows-strings", 2699 ] ··· 2727 checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" 2728 2729 [[package]] 2730 + name = "windows-link" 2731 + version = "0.2.0" 2732 + source = "registry+https://github.com/rust-lang/crates.io-index" 2733 + checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" 2734 + 2735 + [[package]] 2736 name = "windows-result" 2737 version = "0.3.4" 2738 source = "registry+https://github.com/rust-lang/crates.io-index" 2739 checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" 2740 dependencies = [ 2741 + "windows-link 0.1.3", 2742 ] 2743 2744 [[package]] ··· 2747 source = "registry+https://github.com/rust-lang/crates.io-index" 2748 checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" 2749 dependencies = [ 2750 + "windows-link 0.1.3", 2751 ] 2752 2753 [[package]] ··· 2775 checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 2776 dependencies = [ 2777 "windows-targets 0.52.6", 2778 + ] 2779 + 2780 + [[package]] 2781 + name = "windows-sys" 2782 + version = "0.61.0" 2783 + source = "registry+https://github.com/rust-lang/crates.io-index" 2784 + checksum = "e201184e40b2ede64bc2ea34968b28e33622acdbbf37104f0e4a33f7abe657aa" 2785 + dependencies = [ 2786 + "windows-link 0.2.0", 2787 ] 2788 2789 [[package]] ··· 2921 dependencies = [ 2922 "winapi", 2923 ] 2924 + 2925 + [[package]] 2926 + name = "wit-bindgen" 2927 + version = "0.45.1" 2928 + source = "registry+https://github.com/rust-lang/crates.io-index" 2929 + checksum = "5c573471f125075647d03df72e026074b7203790d41351cd6edc96f46bcccd36" 2930 2931 [[package]] 2932 name = "writeable"
+2
crates/firecracker-vm/Cargo.toml
··· 19 serde_json = "1.0.141" 20 rand = "0.8" 21 names = "0.14.0"
··· 19 serde_json = "1.0.141" 20 rand = "0.8" 21 names = "0.14.0" 22 + rumqttc = "0.25.0" 23 + tokio = { version = "1.47.1", features = ["full"] }
+55 -41
crates/firecracker-vm/src/coredns.rs
··· 1 - use std::process; 2 3 use anyhow::Error; 4 5 - use crate::{command::run_command, types::VmOptions}; 6 7 pub const COREDNS_CONFIG_PATH: &str = "/etc/coredns/Corefile"; 8 pub const COREDNS_SERVICE_TEMPLATE: &str = include_str!("./systemd/coredns.service"); 9 10 pub fn setup_coredns(config: &VmOptions) -> Result<(), Error> { 11 - println!("[+] Checking if CoreDNS is installed..."); 12 - if !coredns_is_installed()? { 13 - // TODO: install it automatically 14 - println!("[✗] CoreDNS is not installed. Please install it first to /usr/sbin."); 15 - process::exit(1); 16 - } 17 18 - let name = config 19 - .api_socket 20 - .split('/') 21 - .last() 22 - .ok_or_else(|| anyhow::anyhow!("Failed to extract VM name from API socket path"))? 23 - .replace("firecracker-", "") 24 - .replace(".sock", ""); 25 26 - let hosts = vec![format!("172.16.0.2 {}.firecracker", name)]; 27 28 - let hosts = hosts.join("\n "); 29 30 - let coredns_config: &str = &format!( 31 - r#" 32 firecracker:53 {{ 33 hosts {{ 34 172.16.0.1 br.firecracker ··· 63 health 64 }} 65 "#, 66 - hosts 67 - ); 68 69 - run_command( 70 - "sh", 71 - &[ 72 - "-c", 73 - &format!("echo '{}' > {}", coredns_config, COREDNS_CONFIG_PATH), 74 - ], 75 - true, 76 - )?; 77 78 - run_command( 79 - "sh", 80 - &[ 81 - "-c", 82 - &format!( 83 - "echo '{}' > /etc/systemd/system/coredns.service", 84 - COREDNS_SERVICE_TEMPLATE 85 - ), 86 - ], 87 - true, 88 - )?; 89 - restart_coredns()?; 90 91 Ok(()) 92 }
··· 1 + use std::{process, thread}; 2 3 use anyhow::Error; 4 5 + use crate::{command::run_command, mqttc, types::VmOptions}; 6 7 pub const COREDNS_CONFIG_PATH: &str = "/etc/coredns/Corefile"; 8 pub const COREDNS_SERVICE_TEMPLATE: &str = include_str!("./systemd/coredns.service"); 9 10 pub fn setup_coredns(config: &VmOptions) -> Result<(), Error> { 11 + let api_socket = config.api_socket.clone(); 12 + thread::spawn(move || { 13 + let runtime = tokio::runtime::Runtime::new().unwrap(); 14 + runtime.block_on(async { 15 + println!("[+] Checking if CoreDNS is installed..."); 16 + if !coredns_is_installed()? { 17 + // TODO: install it automatically 18 + println!("[✗] CoreDNS is not installed. Please install it first to /usr/sbin."); 19 + process::exit(1); 20 + } 21 22 + let message = mqttc::wait_for_mqtt_message("REQUEST").await?; 23 + let ip_addr = message 24 + .split_whitespace() 25 + .nth(2) 26 + .ok_or_else(|| anyhow::anyhow!("Failed to extract IP address from MQTT message"))?; 27 + 28 + let name = api_socket 29 + .split('/') 30 + .last() 31 + .ok_or_else(|| anyhow::anyhow!("Failed to extract VM name from API socket path"))? 32 + .replace("firecracker-", "") 33 + .replace(".sock", ""); 34 35 + let hosts = vec![format!("{} {}.firecracker", ip_addr, name)]; 36 37 + let hosts = hosts.join("\n "); 38 39 + let coredns_config: &str = &format!( 40 + r#" 41 firecracker:53 {{ 42 hosts {{ 43 172.16.0.1 br.firecracker ··· 72 health 73 }} 74 "#, 75 + hosts 76 + ); 77 78 + run_command( 79 + "sh", 80 + &[ 81 + "-c", 82 + &format!("echo '{}' > {}", coredns_config, COREDNS_CONFIG_PATH), 83 + ], 84 + true, 85 + )?; 86 87 + run_command( 88 + "sh", 89 + &[ 90 + "-c", 91 + &format!( 92 + "echo '{}' > /etc/systemd/system/coredns.service", 93 + COREDNS_SERVICE_TEMPLATE 94 + ), 95 + ], 96 + true, 97 + )?; 98 + restart_coredns()?; 99 + 100 + Ok::<(), Error>(()) 101 + })?; 102 + Ok::<(), Error>(()) 103 + }); 104 105 Ok(()) 106 }
+3
crates/firecracker-vm/src/lib.rs
··· 13 mod firecracker; 14 mod guest; 15 pub mod mac; 16 mod network; 17 mod nextdhcp; 18 pub mod types; ··· 95 let arch = command::run_command("uname", &["-m"], false)?.stdout; 96 let arch = String::from_utf8_lossy(&arch).trim().to_string(); 97 network::setup_network(options)?; 98 coredns::setup_coredns(options)?; 99 nextdhcp::setup_nextdhcp(options)?; 100
··· 13 mod firecracker; 14 mod guest; 15 pub mod mac; 16 + mod mosquitto; 17 + mod mqttc; 18 mod network; 19 mod nextdhcp; 20 pub mod types; ··· 97 let arch = command::run_command("uname", &["-m"], false)?.stdout; 98 let arch = String::from_utf8_lossy(&arch).trim().to_string(); 99 network::setup_network(options)?; 100 + mosquitto::setup_mosquitto(options)?; 101 coredns::setup_coredns(options)?; 102 nextdhcp::setup_nextdhcp(options)?; 103
+31
crates/firecracker-vm/src/mosquitto.rs
···
··· 1 + use anyhow::Error; 2 + 3 + use crate::{command::run_command, types::VmOptions}; 4 + 5 + pub fn setup_mosquitto(_config: &VmOptions) -> Result<(), Error> { 6 + println!("[+] Checking if Mosquitto is installed..."); 7 + if !mosquitto_is_installed()? { 8 + run_command( 9 + "apt-get", 10 + &["install", "-y", "mosquitto", "mosquitto-clients"], 11 + true, 12 + )?; 13 + } 14 + 15 + restart_mosquitto()?; 16 + println!("[✓] Mosquitto is set up successfully."); 17 + Ok(()) 18 + } 19 + 20 + pub fn restart_mosquitto() -> Result<(), Error> { 21 + println!("[+] Starting mosquitto..."); 22 + run_command("systemctl", &["enable", "mosquitto"], true)?; 23 + run_command("systemctl", &["restart", "mosquitto"], true)?; 24 + println!("[✓] Mosquitto started successfully."); 25 + Ok(()) 26 + } 27 + 28 + pub fn mosquitto_is_installed() -> Result<bool, Error> { 29 + let output = run_command("which", &["mosquitto"], false)?; 30 + Ok(output.status.success()) 31 + }
+25
crates/firecracker-vm/src/mqttc.rs
···
··· 1 + use std::time::Duration; 2 + 3 + use anyhow::Error; 4 + use rumqttc::{AsyncClient, MqttOptions, QoS}; 5 + 6 + pub async fn wait_for_mqtt_message(msgtype: &str) -> Result<String, Error> { 7 + println!("[+] Waiting for MQTT message..."); 8 + let mut mqttoptions = MqttOptions::new("fireup", "localhost", 1883); 9 + mqttoptions.set_keep_alive(Duration::from_secs(5)); 10 + 11 + let (client, mut eventloop) = AsyncClient::new(mqttoptions, 10); 12 + client.subscribe("/dhcp/#", QoS::AtMostOnce).await?; 13 + 14 + while let Ok(notification) = eventloop.poll().await { 15 + if let rumqttc::Event::Incoming(rumqttc::Packet::Publish(publish)) = notification { 16 + let payload_str = String::from_utf8_lossy(&publish.payload).to_string(); 17 + println!("[+] Received MQTT message: {}", payload_str); 18 + if payload_str.starts_with(msgtype) { 19 + return Ok(payload_str); 20 + } 21 + } 22 + } 23 + 24 + Err(Error::msg("Failed to receive MQTT message")) 25 + }
+16 -12
crates/firecracker-vm/src/nextdhcp.rs
··· 7 pub const NEXTDHCP_CONFIG_PATH: &str = "/etc/nextdhcp/Dhcpfile"; 8 pub const NEXTDHCP_SERVICE_TEMPLATE: &str = include_str!("./systemd/nextdhcp.service"); 9 10 - pub fn setup_nextdhcp(config: &VmOptions) -> Result<(), Error> { 11 println!("[+] Checking if NextDHCP is installed..."); 12 if !nextdhcp_is_installed()? { 13 // TODO: install it automatically ··· 15 process::exit(1); 16 } 17 18 - let nextdhcp_config: &str = &format!( 19 - r#" 20 - 172.16.0.1/24 {{ 21 lease 1h 22 23 - static {} 172.16.0.2 24 25 - range 172.16.0.2 172.16.0.150 26 27 - option {{ 28 router 172.16.0.1 29 nameserver 172.16.0.1 30 - }} 31 - }} 32 - "#, 33 - &config.mac_address 34 - ); 35 36 run_command( 37 "sh",
··· 7 pub const NEXTDHCP_CONFIG_PATH: &str = "/etc/nextdhcp/Dhcpfile"; 8 pub const NEXTDHCP_SERVICE_TEMPLATE: &str = include_str!("./systemd/nextdhcp.service"); 9 10 + pub fn setup_nextdhcp(_config: &VmOptions) -> Result<(), Error> { 11 println!("[+] Checking if NextDHCP is installed..."); 12 if !nextdhcp_is_installed()? { 13 // TODO: install it automatically ··· 15 process::exit(1); 16 } 17 18 + let nextdhcp_config: &str = r#" 19 + 172.16.0.1/24 { 20 lease 1h 21 22 + range 172.16.0.2 172.16.0.150 23 24 + mqtt { 25 + name default 26 + broker tcp://localhost:1883 27 28 + topic /dhcp/hwaddr/{hwaddr} 29 + payload "{msgtype} {hwaddr} {requestedip} {state}" 30 + qos 1 31 + } 32 + 33 + option { 34 router 172.16.0.1 35 nameserver 172.16.0.1 36 + } 37 + } 38 + "#; 39 40 run_command( 41 "sh",
+12 -11
crates/firecracker-vm/src/systemd/nextdhcp.service
··· 1 - [Unit] 2 - Description=NextDHCP Service 3 - After=network.target systemd-tmpfiles-setup.service 4 5 - [Service] 6 - ExecStart=/usr/sbin/nextdhcp -conf /etc/nextdhcp/Dhcpfile 7 - Restart=on-failure RestartSec=5 8 - LimitNOFILE=65535 9 - LimitNPROC=512 10 - ProtectSystem=strict 11 ReadWritePaths=/etc/nextdhcp 12 - NoNewPrivileges=true 13 AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE 14 WorkingDirectory=/etc/nextdhcp 15 16 - [Install] 17 WantedBy=multi-user.target
··· 1 + [Unit] 2 + Description=NextDHCP Service 3 + After=network.target systemd-tmpfiles-setup.service 4 5 + [Service] 6 + ExecStart=/usr/sbin/nextdhcp -conf /etc/nextdhcp/Dhcpfile 7 + Restart=on-failure 8 + RestartSec=5 9 + LimitNOFILE=65535 10 + LimitNPROC=512 11 + ProtectSystem=strict 12 ReadWritePaths=/etc/nextdhcp 13 + NoNewPrivileges=true 14 AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE 15 WorkingDirectory=/etc/nextdhcp 16 17 + [Install] 18 WantedBy=multi-user.target