{"id":376928,"date":"2024-05-24T09:00:08","date_gmt":"2024-05-24T09:00:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=376928"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=376928","title":{"rendered":"<span>\u0412\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0447\u0435\u0440\u0435\u0437 Wake-on-Lan<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Wake-on-Lan (WoL) \u2014 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f (\u043a\u0430\u043a \u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f) \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 \u043d\u0430 \u0430\u0434\u0440\u0435\u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0433\u043e \u0445\u043e\u0441\u0442\u0430. \u041d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 WoL \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0435\u0449\u0451 \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440? <\/p>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438 \u0432\u0435\u0441\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u0442\u0435\u043a\u0441\u0442\u00a0\u2014 \u044d\u0442\u043e \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 <a href=\"https:\/\/img-fotki.yandex.ru\/get\/6700\/35340376.f9\/0_facfe_46f0772c_orig.jpg\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0431\u0443\u0445\u0430\u043d\u043a\u0443 \u0445\u043b\u0435\u0431\u0430 \u0432\u00a0\u0442\u0440\u043e\u043b\u043b\u0435\u0439\u0431\u0443\u0441<\/a>. \u041d\u043e\u00a0\u0435\u0441\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0442\u043e\u00a0\u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u0442?<\/p>\n<h2>\u0412 \u0447\u0451\u043c \u0441\u0443\u0442\u044c?<\/h2>\n<p>\u042f \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e WoL \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u0447\u0435\u0440\u0435\u0437 \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443 \u043d\u0430 \u043a\u043e\u0440\u043f\u0443\u0441\u0435 \u041f\u041a. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 WoL-\u043f\u0430\u043a\u0435\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u043b\u0435\u0437\u043b\u043e \u0432 Play Market&#8217;\u0435, \u043a\u043e\u0433\u0434\u0430 \u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u0440\u0435\u0448\u0438\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u0442\u0435\u044e. \u0418 \u0447\u0442\u043e \u043c\u043d\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 \u043d\u0451\u043c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0443 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f &#8212; \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u043a\u0435\u0442 \u043d\u0430 \u041f\u041a. \u0412\u0441\u0451. <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043c\u0438\u043d\u0443\u0442\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043e\u0434\u043d\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438\u0437 \u043b\u044e\u0431\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438. \u0410 \u0435\u0441\u043b\u0438 \u0432\u043d\u0435\u0441\u0442\u0438 \u043f\u0430\u0440\u0443 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433 \u0440\u043e\u0443\u0442\u0435\u0440\u0430, \u0442\u043e \u0438 \u0438\u0437 \u043b\u044e\u0431\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043c\u0438\u0440\u0430, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442.<\/p>\n<p>\u041d\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0442\u0430\u043a \u0436\u0435 \u043b\u0435\u0433\u043a\u043e \u043f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043e\u0434\u043d\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440. \u0411\u0435\u0433\u043b\u044b\u0439 \u0433\u0443\u0433\u043b\u0451\u0436 \u0432 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c \u0438 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430\u0445 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u0434\u043b\u044f \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0430\u0433\u0435\u043d\u0442 (\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043c\u043d\u043e\u0433\u043e) \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d \u0438 \u0434\u0430\u043b\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u041f\u041a, \u0445\u043e\u0442\u044c \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c, \u0445\u043e\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0430\u0439\u043b\u0430\u043c \u0438 \u043c\u043d\u043e\u0433\u043e \u0432\u0441\u0435\u0433\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0438\u0437 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0430 \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u044f \u043f\u0440\u0438\u0432\u044b\u043a \u0438 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0430\u0433\u0435\u043d\u0442\u044b \u043d\u0430 \u041f\u041a \u043c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c, \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0430 \u043d\u0435\u043b\u044c\u0437\u044f \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b WoL \u0434\u043b\u044f \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f?<\/p>\n<h2>\u041f\u043e\u0438\u0441\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u043f\u043e\u0441\u043b\u0435 \u0435\u0449\u0451 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0433\u0443\u0433\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f WoL \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u043d\u0430 \u044d\u0442\u043e\u043c \u0435\u0433\u043e \u043f\u043e\u043b\u043d\u043e\u043c\u043e\u0447\u0438\u044f \u0432\u0441\u0451. \u0410 \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0447\u0442\u043e-\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b, \u043d\u0443 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438 \u0442\u0443\u0442 \u043c\u0435\u043b\u044c\u043a\u043d\u0443\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u043a\u0430\u043a \u0442\u043e\u043f\u043e\u0440, \u043c\u044b\u0441\u043b\u044c: &#171;\u0410 \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 WoL-\u043f\u0430\u043a\u0435\u0442, \u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u043a, \u0447\u0442\u043e \u0435\u043c\u0443 \u043f\u043e\u0440\u0430 \u0431\u044b \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f?&#187;.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 Python, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c IDE \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043c\u044b\u0441\u043b WoL \u043d\u0430 \u043f\u0440\u044f\u043c\u043e \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b\u0439.<\/p>\n<h2>\u041f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c<\/h2>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 WoL-\u043f\u0430\u043a\u0435\u0442 \u0438 \u0438\u0437 \u0447\u0435\u0433\u043e \u043e\u043d \u0441\u0434\u0435\u043b\u0430\u043d. <\/p>\n<p>WoL-\u043f\u0430\u043a\u0435\u0442 \u0438\u043b\u0438 \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443 magic packet \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c UDP \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430 7 \u0438\u043b\u0438 9 \u043f\u043e\u0440\u0442, \u00ab\u0432\u0435\u0441\u0438\u0442\u00bb 102 \u0431\u0430\u0439\u0442\u0430 \u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439:<\/p>\n<ol>\n<li>\n<p>\u0421\u0438\u043c\u0432\u043e\u043b 0xFF, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0439\u0441\u044f 6 \u0440\u0430\u0437. \u0418\u0442\u043e\u0433\u043e 6 \u0431\u0430\u0439\u0442;<\/p>\n<\/li>\n<li>\n<p>MAC-\u0430\u0434\u0440\u0435\u0441 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0439\u0441\u044f 16 \u0440\u0430\u0437. \u0420\u0430\u0437\u043c\u0435\u0440 MAC-\u0430\u0434\u0440\u0435\u0441\u0430 6 \u0431\u0430\u0439\u0442, \u0438\u0442\u043e\u0433\u043e 96 \u0431\u0430\u0439\u0442.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0437\u043d\u0430\u044f \u044d\u0442\u043e, \u043f\u043b\u0430\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<ol>\n<li>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c WoL-\u043f\u0430\u043a\u0435\u0442\u044b \u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0440\u0442\u0430. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c, \u0442.\u043a. \u043d\u0430 \u041f\u041a \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0430\u0434\u0440\u0435\u0441\u043e\u043c;<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c IP \u0438 MAC-\u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 WoL-\u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u0435 UDP-\u043f\u043e\u0440\u0442\u0430, \u043a\u0443\u0434\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c WoL-\u043f\u0430\u043a\u0435\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0437\u0430\u0442\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0438\u0445 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432 \u043f. 3 \u0438 \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, \u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>Profit!<\/p>\n<\/li>\n<\/ol>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0421 \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0443\u043d\u043a\u0442\u043e\u043c \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e. \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0433\u0434\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u044d\u0442\u043e Ethernet 4. \u041d\u043e\u043c\u0435\u0440 \u043f\u043e\u0440\u0442\u0430 \u0434\u043b\u044f WoL-\u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435, \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e 7 \u0438 9. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 9.<\/p>\n<pre><code class=\"python\">WOL_PORT = 9 INTERFACE_NAME = 'Ethernet 4'<\/code><\/pre>\n<p>\u041f\u0443\u043d\u043a\u0442 \u0432\u0442\u043e\u0440\u043e\u0439. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f IP \u0438 MAC-\u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <strong>psutil<\/strong> (\u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c).<\/p>\n<p><code>pip install psutil<\/code><\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0430\u0434\u0440\u0435\u0441\u043e\u0432:<\/p>\n<pre><code class=\"python\">import psutil  def get_ip_mac_address(interface_name: str) -> tuple:     ip_addr = mac_addr = None      for item in psutil.net_if_addrs()[interface_name]:         addr = item.address          # \u0412 IPv4-\u0430\u0434\u0440\u0435\u0441\u0430\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 - \u0442\u043e\u0447\u043a\u0438         if '.' in addr:             ip_addr = addr         # \u0412 MAC-\u0430\u0434\u0440\u0435\u0441\u0430\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u043b\u0438\u0431\u043e \u0442\u0438\u0440\u0435, \u043b\u0438\u0431\u043e \u043e\u0434\u0438\u043d\u0430\u0440\u043d\u043e\u0435 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435.         # \u0414\u0432\u043e\u0439\u043d\u043e\u0435 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435 - \u044d\u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u0434\u043b\u044f \u0430\u0434\u0440\u0435\u0441\u043e\u0432 IPv6         elif ('-' in addr or ':' in item) and '::' not in addr:             # \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u043c MAC-\u0430\u0434\u0440\u0435\u0441 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443. \u0424\u043e\u0440\u043c\u0430\u0442 \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u041e\u0421             mac_addr = addr.replace(':', '-').upper()      if not ip_addr or not mac_addr or ip_addr == '127.0.0.1':         raise '\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c IP \u0438\u043b\u0438 MAC-\u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430'      return ip_addr, mac_addr<\/code><\/pre>\n<p>\u041c\u0435\u043b\u043a\u0438\u0435 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043e\u0434\u0443 \u0435\u0441\u0442\u044c \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u0434\u0435, \u043d\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0430 6.<br \/>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>psutil.net_if_addrs()[interface_name]<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u041f\u043e\u0440\u044f\u0434\u043e\u043a \u044d\u0442\u0438\u0445 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 \u0440\u0430\u0437\u043d\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u041e\u0421 (\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0430 Windows 10 \u0438 Ubuntu 20.04), \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u043e\u0438\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0446\u0438\u043a\u043b \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u043f\u0430\u0440\u043e\u0439 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043a\u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0442\u043e.<\/p>\n<p>(\u0423\u0436\u0435 \u043f\u043e\u0441\u0442\u0444\u0430\u043a\u0442\u0443\u043c \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <abbr class=\"habraabbr\" title=\"\u041e\u0434\u043d\u043e \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043e\u0440\u0442\u0435\u0436\u0430, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0430\u0434\u0440\u0435\u0441\u0430\" data-title=\"&lt;p>\u041e\u0434\u043d\u043e \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043e\u0440\u0442\u0435\u0436\u0430, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0430\u0434\u0440\u0435\u0441\u0430&lt;\/p>&lt;p>&lt;\/p>&#187; data-abbr=&#187;family&#187;>family<\/abbr>, \u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0431\u044b\u043b\u043e \u043b\u0435\u043d\u044c).<\/p>\n<p>\u0421\u043e \u0432\u0442\u043e\u0440\u044b\u043c \u043f\u0443\u043d\u043a\u0442\u043e\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0443\u043d\u043a\u0442 \u0442\u0440\u0438. \u0422\u0443\u0442 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u043e\u0447\u0442\u0438 \u043a\u0430\u043a \u0432 \u043f\u0435\u0440\u0432\u043e\u043c.<br \/>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 MAC-\u0430\u0434\u0440\u0435\u0441 \u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u043a\u0435\u0442:<\/p>\n<pre><code class=\"python\">def assemble_wol_packet(mac_address: str) -> str:     return f'{\"FF-\" * 6}{(mac_address + \"-\") * 16}'<\/code><\/pre>\n<p>\u0427\u0435\u0442\u0432\u0451\u0440\u0442\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445.<br \/>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u0430 \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c IP-\u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<br \/>\u041d\u0430 \u0441\u0442\u0440\u043e\u043a\u0435 4 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437 \u043f\u0443\u043d\u043a\u0442\u0430 2, \u0430 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0435 9 \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437 \u043f\u0443\u043d\u043a\u0442\u0430 3<\/p>\n<pre><code class=\"python\">import socket  def run_udp_port_listener(port: int, interface_name: str):     ip_addr, mac_addr = get_ip_mac_address(interface_name)      server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)     server_socket.bind((ip_addr, port))      assembled_wol_packet = assemble_wol_packet(mac_addr)      while True:         data, _ = server_socket.recvfrom(1024)<\/code><\/pre>\n<p>\u0418 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0438\u0439 \u043f\u0443\u043d\u043a\u0442 &#8212; \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e.<br \/>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"python\">decoded_packet_data = '-'.join(f'{byte:02x}' for byte in raw_bytes).upper() + '-'<\/code><\/pre>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439: \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u2014 \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0431\u0430\u0439\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>byte:02x<\/code> . \u0414\u0430\u043b\u0435\u0435 \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0437\u043d\u0430\u043a &#171;-&#187; \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u043a \u0432\u0435\u0440\u0445\u043d\u0435\u043c\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443.<br \/>\u041f\u043e \u0438\u0434\u0435\u0435 \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u0430 \u0442\u0438\u0440\u0435, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c, \u0447\u0442\u043e \u0432 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u043f\u0443\u043d\u043a\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c, \u043d\u043e \u0441 \u043d\u0438\u043c \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u043a\u0443, \u0435\u0441\u043b\u0438 \u0432\u0434\u0440\u0443\u0433 \u0447\u0442\u043e-\u0442\u043e \u0438\u0434\u0451\u0442 \u043d\u0435 \u0442\u0430\u043a.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u041f\u041a. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043b\u0443\u0447\u0448\u0435 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"python\">def check_is_wol_packet(raw_bytes: bytes, assembled_wol_packet: str) -> int:     decoded_packet_data = '-'.join(f'{byte:02x}' for byte in raw_bytes).upper() + '-'      if decoded_packet_data == assembled_wol_packet:         return 1      return 0<\/code><\/pre>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u043c shutdown:<\/p>\n<pre><code class=\"python\">import os  # ... \u0417\u0434\u0435\u0441\u044c \u043a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0440\u0442\u0430 ...  while True:     data, _ = server_socket.recvfrom(1024)      is_wol_packet = check_is_wol_packet(data, assembled_wol_packet)      if is_wol_packet == 1:         if os.name == 'posix':             os.system('sudo shutdown -h now')         elif os.name == 'nt':             os.system('shutdown -s -t 0 -f')<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0435\u0440\u0451\u043c \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0432\u043c\u0435\u0441\u0442\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import socket import os import logging import psutil  WOL_PORT = 9 INTERFACE_NAME = 'Ethernet 4'  logging.basicConfig(format='%(levelname)s: %(asctime)s %(message)s', level=logging.INFO) logger = logging.getLogger(__name__)   def get_ip_mac_address(interface_name: str) -> tuple:     ip_addr = mac_addr = None      for item in psutil.net_if_addrs()[interface_name]:         addr = item.address          # \u0412 IPv4-\u0430\u0434\u0440\u0435\u0441\u0430\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 - \u0442\u043e\u0447\u043a\u0438         if '.' in addr:             ip_addr = addr         # \u0412 MAC-\u0430\u0434\u0440\u0435\u0441\u0430\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u043b\u0438\u0431\u043e \u0442\u0438\u0440\u0435, \u043b\u0438\u0431\u043e \u043e\u0434\u0438\u043d\u0430\u0440\u043d\u043e\u0435 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435.         # \u0414\u0432\u043e\u0439\u043d\u043e\u0435 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435 - \u044d\u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u0434\u043b\u044f \u0430\u0434\u0440\u0435\u0441\u043e\u0432 IPv6         elif ('-' in addr or ':' in item) and '::' not in addr:             # \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u043c MAC-\u0430\u0434\u0440\u0435\u0441 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443. \u0424\u043e\u0440\u043c\u0430\u0442 \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u041e\u0421             mac_addr = addr.replace(':', '-').upper()      if not ip_addr or not mac_addr or ip_addr == '127.0.0.1':         raise '\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c IP \u0438\u043b\u0438 MAC-\u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430'      return ip_addr, mac_addr   def assemble_wol_packet(mac_address: str) -> str:     return f'{\"FF-\" * 6}{(mac_address + \"-\") * 16}'   def check_is_wol_packet(raw_bytes: bytes, assembled_wol_packet: str) -> int:     decoded_packet_data = '-'.join(f'{byte:02x}' for byte in raw_bytes).upper() + '-'      if decoded_packet_data == assembled_wol_packet:         return 1      return 0   def run_udp_port_listener(port: int, interface_name: str):     ip_addr, mac_addr = get_ip_mac_address(interface_name)      server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)     server_socket.bind((ip_addr, port))     logger.info(f'Listening on {ip_addr}:{port}')      assembled_wol_packet = assemble_wol_packet(mac_addr)      while True:         data, _ = server_socket.recvfrom(1024)          is_wol_packet = check_is_wol_packet(data, assembled_wol_packet)          if is_wol_packet == 1:             if os.name == 'posix':                 os.system('sudo shutdown -h now')             elif os.name == 'nt':                 os.system('shutdown -s -t 0 -f')   run_udp_port_listener(WOL_PORT, INTERFACE_NAME) <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0435\u0441\u043b\u0438 \u0432\u0441\u0451 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432\u0435\u0440\u043d\u043e, \u0442\u043e \u043f\u0440\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 WoL-\u043f\u0430\u043a\u0435\u0442\u0430 \u043d\u0430 IP-\u0430\u0434\u0440\u0435\u0441 \u041f\u041a \u043e\u043d \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043a\u043e\u043b\u0434\u043e\u0432\u0430\u0442\u044c \u0441 \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u043c, \u0442\u043e \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 \u0430\u0432\u0442\u043e\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043b\u0443\u0436\u0431\u0443, \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0439 \u041e\u0421, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0447\u0435\u0433\u043e.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u043e<\/h2>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u0435\u043d. \u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u043b\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0435\u0449\u0435\u0439, \u043d\u043e \u043b\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435\u043d\u0443\u0436\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0435. \u0422\u043e \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u043d\u0443\u0436\u043d\u043e \u043c\u043d\u0435 \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0438 \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/816765\/\"> https:\/\/habr.com\/ru\/articles\/816765\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Wake-on-Lan (WoL) \u2014 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f (\u043a\u0430\u043a \u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f) \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 \u043d\u0430 \u0430\u0434\u0440\u0435\u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0433\u043e \u0445\u043e\u0441\u0442\u0430. \u041d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 WoL \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0435\u0449\u0451 \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440? <\/p>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438 \u0432\u0435\u0441\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u0442\u0435\u043a\u0441\u0442\u00a0\u2014 \u044d\u0442\u043e \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 <a href=\"https:\/\/img-fotki.yandex.ru\/get\/6700\/35340376.f9\/0_facfe_46f0772c_orig.jpg\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0431\u0443\u0445\u0430\u043d\u043a\u0443 \u0445\u043b\u0435\u0431\u0430 \u0432\u00a0\u0442\u0440\u043e\u043b\u043b\u0435\u0439\u0431\u0443\u0441<\/a>. \u041d\u043e\u00a0\u0435\u0441\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0442\u043e\u00a0\u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u0442?<\/p>\n<h2>\u0412 \u0447\u0451\u043c \u0441\u0443\u0442\u044c?<\/h2>\n<p>\u042f \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e WoL \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u0447\u0435\u0440\u0435\u0437 \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443 \u043d\u0430 \u043a\u043e\u0440\u043f\u0443\u0441\u0435 \u041f\u041a. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 WoL-\u043f\u0430\u043a\u0435\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u043b\u0435\u0437\u043b\u043e \u0432 Play Market&#8217;\u0435, \u043a\u043e\u0433\u0434\u0430 \u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u0440\u0435\u0448\u0438\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u0442\u0435\u044e. \u0418 \u0447\u0442\u043e \u043c\u043d\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 \u043d\u0451\u043c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0443 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f &#8212; \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u043a\u0435\u0442 \u043d\u0430 \u041f\u041a. \u0412\u0441\u0451. <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043c\u0438\u043d\u0443\u0442\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043e\u0434\u043d\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438\u0437 \u043b\u044e\u0431\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438. \u0410 \u0435\u0441\u043b\u0438 \u0432\u043d\u0435\u0441\u0442\u0438 \u043f\u0430\u0440\u0443 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433 \u0440\u043e\u0443\u0442\u0435\u0440\u0430, \u0442\u043e \u0438 \u0438\u0437 \u043b\u044e\u0431\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043c\u0438\u0440\u0430, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442.<\/p>\n<p>\u041d\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0442\u0430\u043a \u0436\u0435 \u043b\u0435\u0433\u043a\u043e \u043f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043e\u0434\u043d\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440. \u0411\u0435\u0433\u043b\u044b\u0439 \u0433\u0443\u0433\u043b\u0451\u0436 \u0432 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c \u0438 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430\u0445 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u0434\u043b\u044f \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0430\u0433\u0435\u043d\u0442 (\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043c\u043d\u043e\u0433\u043e) \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d \u0438 \u0434\u0430\u043b\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u041f\u041a, \u0445\u043e\u0442\u044c \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c, \u0445\u043e\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0430\u0439\u043b\u0430\u043c \u0438 \u043c\u043d\u043e\u0433\u043e \u0432\u0441\u0435\u0433\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0438\u0437 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0430 \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u044f \u043f\u0440\u0438\u0432\u044b\u043a \u0438 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0430\u0433\u0435\u043d\u0442\u044b \u043d\u0430 \u041f\u041a \u043c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c, \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0430 \u043d\u0435\u043b\u044c\u0437\u044f \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b WoL \u0434\u043b\u044f \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f?<\/p>\n<h2>\u041f\u043e\u0438\u0441\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u043f\u043e\u0441\u043b\u0435 \u0435\u0449\u0451 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0433\u0443\u0433\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f WoL \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u043d\u0430 \u044d\u0442\u043e\u043c \u0435\u0433\u043e \u043f\u043e\u043b\u043d\u043e\u043c\u043e\u0447\u0438\u044f \u0432\u0441\u0451. \u0410 \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0447\u0442\u043e-\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b, \u043d\u0443 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438 \u0442\u0443\u0442 \u043c\u0435\u043b\u044c\u043a\u043d\u0443\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u043a\u0430\u043a \u0442\u043e\u043f\u043e\u0440, \u043c\u044b\u0441\u043b\u044c: &#171;\u0410 \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 WoL-\u043f\u0430\u043a\u0435\u0442, \u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u043a, \u0447\u0442\u043e \u0435\u043c\u0443 \u043f\u043e\u0440\u0430 \u0431\u044b \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f?&#187;.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 Python, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c IDE \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043c\u044b\u0441\u043b WoL \u043d\u0430 \u043f\u0440\u044f\u043c\u043e \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b\u0439.<\/p>\n<h2>\u041f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c<\/h2>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 WoL-\u043f\u0430\u043a\u0435\u0442 \u0438 \u0438\u0437 \u0447\u0435\u0433\u043e \u043e\u043d \u0441\u0434\u0435\u043b\u0430\u043d. <\/p>\n<p>WoL-\u043f\u0430\u043a\u0435\u0442 \u0438\u043b\u0438 \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443 magic packet \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c UDP \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430 7 \u0438\u043b\u0438 9 \u043f\u043e\u0440\u0442, \u00ab\u0432\u0435\u0441\u0438\u0442\u00bb 102 \u0431\u0430\u0439\u0442\u0430 \u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439:<\/p>\n<ol>\n<li>\n<p>\u0421\u0438\u043c\u0432\u043e\u043b 0xFF, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0439\u0441\u044f 6 \u0440\u0430\u0437. \u0418\u0442\u043e\u0433\u043e 6 \u0431\u0430\u0439\u0442;<\/p>\n<\/li>\n<li>\n<p>MAC-\u0430\u0434\u0440\u0435\u0441 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0439\u0441\u044f 16 \u0440\u0430\u0437. \u0420\u0430\u0437\u043c\u0435\u0440 MAC-\u0430\u0434\u0440\u0435\u0441\u0430 6 \u0431\u0430\u0439\u0442, \u0438\u0442\u043e\u0433\u043e 96 \u0431\u0430\u0439\u0442.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0437\u043d\u0430\u044f \u044d\u0442\u043e, \u043f\u043b\u0430\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<ol>\n<li>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c WoL-\u043f\u0430\u043a\u0435\u0442\u044b \u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0440\u0442\u0430. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c, \u0442.\u043a. \u043d\u0430 \u041f\u041a \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0430\u0434\u0440\u0435\u0441\u043e\u043c;<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c IP \u0438 MAC-\u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 WoL-\u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u0435 UDP-\u043f\u043e\u0440\u0442\u0430, \u043a\u0443\u0434\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c WoL-\u043f\u0430\u043a\u0435\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0437\u0430\u0442\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0438\u0445 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432 \u043f. 3 \u0438 \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, \u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>Profit!<\/p>\n<\/li>\n<\/ol>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0421 \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0443\u043d\u043a\u0442\u043e\u043c \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e. \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0433\u0434\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u044d\u0442\u043e Ethernet 4. \u041d\u043e\u043c\u0435\u0440 \u043f\u043e\u0440\u0442\u0430 \u0434\u043b\u044f WoL-\u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435, \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e 7 \u0438 9. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 9.<\/p>\n<pre><code class=\"python\">WOL_PORT = 9 INTERFACE_NAME = 'Ethernet 4'<\/code><\/pre>\n<p>\u041f\u0443\u043d\u043a\u0442 \u0432\u0442\u043e\u0440\u043e\u0439. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f IP \u0438 MAC-\u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <strong>psutil<\/strong> (\u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c).<\/p>\n<p><code>pip install psutil<\/code><\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0430\u0434\u0440\u0435\u0441\u043e\u0432:<\/p>\n<pre><code class=\"python\">import psutil  def get_ip_mac_address(interface_name: str) -> tuple:     ip_addr = mac_addr = None      for item in psutil.net_if_addrs()[interface_name]:         addr = item.address          # \u0412 IPv4-\u0430\u0434\u0440\u0435\u0441\u0430\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 - \u0442\u043e\u0447\u043a\u0438         if '.' in addr:             ip_addr = addr         # \u0412 MAC-\u0430\u0434\u0440\u0435\u0441\u0430\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u043b\u0438\u0431\u043e \u0442\u0438\u0440\u0435, \u043b\u0438\u0431\u043e \u043e\u0434\u0438\u043d\u0430\u0440\u043d\u043e\u0435 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435.         # \u0414\u0432\u043e\u0439\u043d\u043e\u0435 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435 - \u044d\u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u0434\u043b\u044f \u0430\u0434\u0440\u0435\u0441\u043e\u0432 IPv6         elif ('-' in addr or ':' in item) and '::' not in addr:             # \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u043c MAC-\u0430\u0434\u0440\u0435\u0441 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443. \u0424\u043e\u0440\u043c\u0430\u0442 \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u041e\u0421             mac_addr = addr.replace(':', '-').upper()      if not ip_addr or not mac_addr or ip_addr == '127.0.0.1':         raise '\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c IP \u0438\u043b\u0438 MAC-\u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430'      return ip_addr, mac_addr<\/code><\/pre>\n<p>\u041c\u0435\u043b\u043a\u0438\u0435 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043e\u0434\u0443 \u0435\u0441\u0442\u044c \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u0434\u0435, \u043d\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0430 6.<br \/>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>psutil.net_if_addrs()[interface_name]<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u041f\u043e\u0440\u044f\u0434\u043e\u043a \u044d\u0442\u0438\u0445 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 \u0440\u0430\u0437\u043d\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u041e\u0421 (\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0430 Windows 10 \u0438 Ubuntu 20.04), \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u043e\u0438\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0446\u0438\u043a\u043b \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u043f\u0430\u0440\u043e\u0439 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043a\u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0442\u043e.<\/p>\n<p>(\u0423\u0436\u0435 \u043f\u043e\u0441\u0442\u0444\u0430\u043a\u0442\u0443\u043c \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <abbr class=\"habraabbr\" title=\"\u041e\u0434\u043d\u043e \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043e\u0440\u0442\u0435\u0436\u0430, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0430\u0434\u0440\u0435\u0441\u0430\" data-title=\"&lt;p>\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0430\u0434\u0440\u0435\u0441\u0430&#187; data-title=&lt;p>\u041e\u0434\u043d\u043e \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043e\u0440\u0442\u0435\u0436\u0430, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0430\u0434\u0440\u0435\u0441\u0430&lt;\/p>&lt;p>&lt;\/p>&#187; data-abbr=&#187;family&#187;>family<\/abbr>, \u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0431\u044b\u043b\u043e \u043b\u0435\u043d\u044c).<\/p>\n<p>\u0421\u043e \u0432\u0442\u043e\u0440\u044b\u043c \u043f\u0443\u043d\u043a\u0442\u043e\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0443\u043d\u043a\u0442 \u0442\u0440\u0438. \u0422\u0443\u0442 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u043e\u0447\u0442\u0438 \u043a\u0430\u043a \u0432 \u043f\u0435\u0440\u0432\u043e\u043c.<br \/>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 MAC-\u0430\u0434\u0440\u0435\u0441 \u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u043a\u0435\u0442:<\/p>\n<pre><code class=\"python\">def assemble_wol_packet(mac_address: str) -> str:     return f'{\"FF-\" * 6}{(mac_address + \"-\") * 16}'<\/code><\/pre>\n<p>\u0427\u0435\u0442\u0432\u0451\u0440\u0442\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445.<br \/>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u0430 \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c IP-\u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<br \/>\u041d\u0430 \u0441\u0442\u0440\u043e\u043a\u0435 4 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437 \u043f\u0443\u043d\u043a\u0442\u0430 2, \u0430 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0435 9 \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437 \u043f\u0443\u043d\u043a\u0442\u0430 3<\/p>\n<pre><code class=\"python\">import socket  def run_udp_port_listener(port: int, interface_name: str):     ip_addr, mac_addr = get_ip_mac_address(interface_name)      server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)     server_socket.bind((ip_addr, port))      assembled_wol_packet = assemble_wol_packet(mac_addr)      while True:         data, _ = server_socket.recvfrom(1024)<\/code><\/pre>\n<p>\u0418 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0438\u0439 \u043f\u0443\u043d\u043a\u0442 &#8212; \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e.<br \/>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"python\">decoded_packet_data = '-'.join(f'{byte:02x}' for byte in raw_bytes).upper() + '-'<\/code><\/pre>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439: \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u2014 \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0431\u0430\u0439\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>byte:02x<\/code> . \u0414\u0430\u043b\u0435\u0435 \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0437\u043d\u0430\u043a &#171;-&#187; \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u043a \u0432\u0435\u0440\u0445\u043d\u0435\u043c\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443.<br \/>\u041f\u043e \u0438\u0434\u0435\u0435 \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u0430 \u0442\u0438\u0440\u0435, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c, \u0447\u0442\u043e \u0432 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u043f\u0443\u043d\u043a\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c, \u043d\u043e \u0441 \u043d\u0438\u043c \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u043a\u0443, \u0435\u0441\u043b\u0438 \u0432\u0434\u0440\u0443\u0433 \u0447\u0442\u043e-\u0442\u043e \u0438\u0434\u0451\u0442 \u043d\u0435 \u0442\u0430\u043a.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u041f\u041a. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043b\u0443\u0447\u0448\u0435 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"python\">def check_is_wol_packet(raw_bytes: bytes, assembled_wol_packet: str) -> int:     decoded_packet_data = '-'.join(f'{byte:02x}' for byte in raw_bytes).upper() + '-'      if decoded_packet_data == assembled_wol_packet:         return 1      return 0<\/code><\/pre>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u043c shutdown:<\/p>\n<pre><code class=\"python\">import os  # ... \u0417\u0434\u0435\u0441\u044c \u043a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0440\u0442\u0430 ...  while True:     data, _ = server_socket.recvfrom(1024)      is_wol_packet = check_is_wol_packet(data, assembled_wol_packet)      if is_wol_packet == 1:         if os.name == 'posix':             os.system('sudo shutdown -h now')         elif os.name == 'nt':             os.system('shutdown -s -t 0 -f')<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0435\u0440\u0451\u043c \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0432\u043c\u0435\u0441\u0442\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import socket import os import logging import psutil  WOL_PORT = 9 INTERFACE_NAME = 'Ethernet 4'  logging.basicConfig(format='%(levelname)s: %(asctime)s %(message)s', level=logging.INFO) logger = logging.getLogger(__name__)   def get_ip_mac_address(interface_name: str) -> tuple:     ip_addr = mac_addr = None      for item in psutil.net_if_addrs()[interface_name]:         addr = item.address          # \u0412 IPv4-\u0430\u0434\u0440\u0435\u0441\u0430\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 - \u0442\u043e\u0447\u043a\u0438         if '.' in addr:             ip_addr = addr         # \u0412 MAC-\u0430\u0434\u0440\u0435\u0441\u0430\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u043b\u0438\u0431\u043e \u0442\u0438\u0440\u0435, \u043b\u0438\u0431\u043e \u043e\u0434\u0438\u043d\u0430\u0440\u043d\u043e\u0435 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435.         # \u0414\u0432\u043e\u0439\u043d\u043e\u0435 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435 - \u044d\u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u0434\u043b\u044f \u0430\u0434\u0440\u0435\u0441\u043e\u0432 IPv6         elif ('-' in addr or ':' in item) and '::' not in addr:             # \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u043c MAC-\u0430\u0434\u0440\u0435\u0441 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443. \u0424\u043e\u0440\u043c\u0430\u0442 \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u041e\u0421             mac_addr = addr.replace(':', '-').upper()      if not ip_addr or not mac_addr or ip_addr == '127.0.0.1':         raise '\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c IP \u0438\u043b\u0438 MAC-\u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430'      return ip_addr, mac_addr   def assemble_wol_packet(mac_address: str) -> str:     return f'{\"FF-\" * 6}{(mac_address + \"-\") * 16}'   def check_is_wol_packet(raw_bytes: bytes, assembled_wol_packet: str) -> int:     decoded_packet_data = '-'.join(f'{byte:02x}' for byte in raw_bytes).upper() + '-'      if decoded_packet_data == assembled_wol_packet:         return 1      return 0   def run_udp_port_listener(port: int, interface_name: str):     ip_addr, mac_addr = get_ip_mac_address(interface_name)      server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)     server_socket.bind((ip_addr, port))     logger.info(f'Listening on {ip_addr}:{port}')      assembled_wol_packet = assemble_wol_packet(mac_addr)      while True:         data, _ = server_socket.recvfrom(1024)          is_wol_packet = check_is_wol_packet(data, assembled_wol_packet)          if is_wol_packet == 1:             if os.name == 'posix':                 os.system('sudo shutdown -h now')             elif os.name == 'nt':                 os.system('shutdown -s -t 0 -f')   run_udp_port_listener(WOL_PORT, INTERFACE_NAME) <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0435\u0441\u043b\u0438 \u0432\u0441\u0451 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432\u0435\u0440\u043d\u043e, \u0442\u043e \u043f\u0440\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 WoL-\u043f\u0430\u043a\u0435\u0442\u0430 \u043d\u0430 IP-\u0430\u0434\u0440\u0435\u0441 \u041f\u041a \u043e\u043d \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043a\u043e\u043b\u0434\u043e\u0432\u0430\u0442\u044c \u0441 \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u043c, \u0442\u043e \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 \u0430\u0432\u0442\u043e\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043b\u0443\u0436\u0431\u0443, \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0439 \u041e\u0421, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0447\u0435\u0433\u043e.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u043e<\/h2>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u0435\u043d. \u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u043b\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-376928","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/376928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=376928"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/376928\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=376928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=376928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=376928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}