{"id":473871,"date":"2025-09-04T03:00:10","date_gmt":"2025-09-04T03:00:10","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=473871"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=473871","title":{"rendered":"<span>librats: \u043d\u043e\u0432\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 P2P-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439<\/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>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u042f \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0438\u043a\u0430 <strong>rats-search<\/strong> \u043d\u0430 \u0431\u0430\u0437\u0435 DHT (<a href=\"https:\/\/github.com\/DEgITx\/rats-search\" rel=\"noopener noreferrer nofollow\">GitHub<\/a>). \u0415\u0433\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442: \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0438\u043a \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0442\u043e\u0440\u0440\u0435\u043d\u0442\u044b \u0443 \u0432\u0441\u0435\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0441\u0435\u0442\u0438 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0447\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e).<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0441\u0432\u043e\u0435\u0439 \u043d\u043e\u0432\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 (p2p), \u0433\u0434\u0435 \u0437\u043d\u0430\u043d\u0438\u0435 IP-\u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0430 \u043f\u043e\u0438\u0441\u043a \u0432\u0435\u0434\u0451\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b \u2014 DHT, mDNS, peer-exchange \u0438 \u0434\u0440\u0443\u0433\u0438\u0435. \u0414\u0443\u043c\u0430\u044e, \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0445 <strong>\u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0432\u043e\u043a\u0440\u0443\u0433, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c ;).<\/p>\n<h4>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u0438<\/h4>\n<p><strong>rats-search <\/strong>\u2014 \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u0440\u044b\u0439, \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0435\u0433\u043e \u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u043d\u0430 Electron. \u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c p2p-\u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0443\u044e \u043d\u0430 C++ \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0432\u044f\u0437\u0438 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0440\u0430\u0434\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432\u0441\u0451 \u043d\u0430 <strong>libp2p<\/strong> \u0438 \u0431\u044b\u043b \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0443\u0434\u0438\u0432\u043b\u0451\u043d \u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e. \u0411\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438 ~100 \u043f\u0438\u0440\u0430\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 (Ryzen 5700) \u0431\u044b\u043b \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u043d\u0430 100% \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0448\u0430\u0433\u043e\u0432 \u043f\u043e DHT \u0441\u0435\u0442\u0438, \u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u043b\u043e 500\u2013600 \u041c\u0411. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e libp2p \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0442\u0438\u043f\u043e it- \u0438 \u0442\u044f\u043d\u0435\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 300\u2013400 \u041c\u0411 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 <em>node_modules<\/em>, \u043d\u043e \u044d\u0442\u043e \u0436\u0435 \u043d\u0435 \u0434\u0435\u043b\u043e.<\/p>\n<p>\u0414\u0430, \u044d\u0442\u043e JS, \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441 C++ \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u043d\u043e \u0434\u0430\u0436\u0435 JS-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435 \u0434\u0430\u044e\u0442 \u0442\u0430\u043a\u0438\u0445 \u043f\u043b\u043e\u0445\u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, libp2p \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0435 \u0432\u0441\u0435 \u044f\u0437\u044b\u043a\u0438: \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0443\u0440\u0435\u0437\u0430\u043d\u044b, \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u043e\u0432\u0441\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u043b\u044f C++ \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <strong>mDNS<\/strong> \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d. \u0412 \u0438\u0442\u043e\u0433\u0435 \u044d\u0442\u0430\u043b\u043e\u043d\u043d\u044b\u043c\u0438 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f Go \u0438 JS, \u0438 \u043e\u043d\u0438 \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9b4\/6f9\/a57\/9b46f9a57320b7365d767cf4fc227acf.png\" alt=\"\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0443 libp2p \u044d\u0442\u043e \u043f\u043e\u043b\u043d\u044b\u0439 \u0440\u0430\u0437\u043d\u043e\u0431\u043e\u0439, \u043f\u043e\u0432\u0435\u0437\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e go \u0438 javascript\" title=\"\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0443 libp2p \u044d\u0442\u043e \u043f\u043e\u043b\u043d\u044b\u0439 \u0440\u0430\u0437\u043d\u043e\u0431\u043e\u0439, \u043f\u043e\u0432\u0435\u0437\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e go \u0438 javascript\" width=\"986\" height=\"494\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/9b4\/6f9\/a57\/9b46f9a57320b7365d767cf4fc227acf.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9b4\/6f9\/a57\/9b46f9a57320b7365d767cf4fc227acf.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0443 libp2p \u044d\u0442\u043e \u043f\u043e\u043b\u043d\u044b\u0439 \u0440\u0430\u0437\u043d\u043e\u0431\u043e\u0439, \u043f\u043e\u0432\u0435\u0437\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e go \u0438 javascript<\/figcaption><\/div>\n<\/figure>\n<h4>\u041f\u043e\u0447\u0435\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443<\/h4>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u044d\u0442\u043e\u0439 \u00ab\u043a\u043e\u043c\u0431\u0430\u0439\u043d-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\u00bb \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u044b \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u044f\u0437\u044b\u043a, \u0430 \u043a \u043d\u0435\u043c\u0443 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0443\u044e \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0435\u0434\u0438\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<p>\u0422\u0430\u043a \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c <strong>librats<\/strong> \u2014 \u043d\u043e\u0432\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0430 C++, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0430\u043d\u0435\u0442 \u0431\u0443\u0434\u0443\u0449\u0438\u043c \u044f\u0434\u0440\u043e\u043c Rats, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0438 \u0432 \u043b\u044e\u0431\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445.<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/librats.com\/\" rel=\"noopener noreferrer nofollow\">\u041e\u0444\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442<\/a> &#8212; <a href=\"https:\/\/librats.com\/\" rel=\"noopener noreferrer nofollow\">https:\/\/librats.com\/<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/DEgITx\/librats\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043d\u0430 github<\/a> &#8212; <a href=\"https:\/\/github.com\/DEgITx\/librats\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/DEgITx\/librats<\/a><\/p>\n<\/li>\n<\/ul>\n<h4>\u0427\u0442\u043e \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e<\/h4>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7ad\/d9e\/a1c\/7add9ea1c8182620cff77daff8c26ed1.png\" width=\"1292\" height=\"802\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/7ad\/d9e\/a1c\/7add9ea1c8182620cff77daff8c26ed1.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7ad\/d9e\/a1c\/7add9ea1c8182620cff77daff8c26ed1.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<ul>\n<li>\n<p>\u041f\u043e\u0438\u0441\u043a \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 <strong>DHT<\/strong><\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \/ \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \/ \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <strong>mDNS<\/strong> \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445<\/p>\n<\/li>\n<li>\n<p><strong>Historical peers<\/strong> \u2014 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <strong>gossipsub<\/strong> \u2014 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u043c\u0435\u043d \u043f\u0438\u0440\u0430\u043c\u0438 (peer exchange)<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 (\u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445) \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>ICE \/ STUN \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b<\/p>\n<\/li>\n<li>\n<p>\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 noise (Curve25519 + ChaCha20-Poly1305)<\/p>\n<\/li>\n<\/ul>\n<h4>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0438 \u044f\u0437\u044b\u043a\u0438<\/h4>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/071\/67e\/c8e\/07167ec8ee3e3a341610c09d30a3e1c4.png\" width=\"1263\" height=\"696\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/071\/67e\/c8e\/07167ec8ee3e3a341610c09d30a3e1c4.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/071\/67e\/c8e\/07167ec8ee3e3a341610c09d30a3e1c4.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<ul>\n<li>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 \u043f\u043e\u0434 <strong>Windows, macOS, Linux, Android<\/strong><\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b: <strong>GCC, Clang, MSVC<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435: \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 <strong>C++<\/strong>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432 <strong>C<\/strong> \u0438 <strong>Java<\/strong> \u0447\u0435\u0440\u0435\u0437 JNI; \u0432 Android \u2014 \u0447\u0435\u0440\u0435\u0437 NDK<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0d8\/e4b\/ff2\/0d8e4bff2ca8412e287751c26132e3ed.png\" width=\"1199\" height=\"911\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/0d8\/e4b\/ff2\/0d8e4bff2ca8412e287751c26132e3ed.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0d8\/e4b\/ff2\/0d8e4bff2ca8412e287751c26132e3ed.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<\/li>\n<\/ul>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/strong><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<h4>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/h4>\n<pre><code class=\"cpp\">#include \"librats.h\" #include &lt;iostream&gt; #include &lt;thread&gt; #include &lt;chrono&gt;  int main() {     \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 P2P \u043a\u043b\u0438\u0435\u043d\u0442     librats::RatsClient client(8080);          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043b\u0431\u044d\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438     client.set_connection_callback([](socket_t socket, const std::string&amp; peer_id) {         std::cout &lt;&lt; \"\u2705 \u041d\u043e\u0432\u044b\u0439 \u043f\u0438\u0440 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f: \" &lt;&lt; peer_id &lt;&lt; std::endl;     });          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043b\u0431\u044d\u043a\u0430 \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439     client.set_string_data_callback([](socket_t socket, const std::string&amp; peer_id, const std::string&amp; message) {         std::cout &lt;&lt; \"\ud83d\udcac \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 \" &lt;&lt; peer_id &lt;&lt; \": \" &lt;&lt; message &lt;&lt; std::endl;     });          \/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442     if (!client.start()) {         std::cerr &lt;&lt; \"\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\" &lt;&lt; std::endl;         return 1;     }          std::cout &lt;&lt; \"\ud83d\udc00 librats \u043a\u043b\u0438\u0435\u043d\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 8080\" &lt;&lt; std::endl;          \/\/ \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043f\u0438\u0440\u0443 (\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e)     \/\/ client.connect_to_peer(\"127.0.0.1\", 8081);          \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c \u043f\u0438\u0440\u0430\u043c     client.broadcast_string_to_peers(\"Hello from librats!\");          \/\/ \u041e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c     std::this_thread::sleep_for(std::chrono::minutes(1));          return 0; }<\/code><\/pre>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0435\u0436\u0438\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0442\u0440\u0451\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p>\u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445,<\/p>\n<\/li>\n<li>\n<p>\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445,<\/p>\n<\/li>\n<li>\n<p>JSON-\u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<h4>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430<\/h4>\n<p>\u041c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u0432\u0430\u0448\u0438\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c \u0438\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c.<\/p>\n<pre><code class=\"cpp\">#include \"librats.h\" #include &lt;iostream&gt;  int main() {     librats::RatsClient client(8080);          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f     client.set_protocol_name(\"my_app\");     client.set_protocol_version(\"1.0\");          std::cout &lt;&lt; \"Protocol: \" &lt;&lt; client.get_protocol_name()                &lt;&lt; \" v\" &lt;&lt; client.get_protocol_version() &lt;&lt; std::endl;     std::cout &lt;&lt; \"Discovery hash: \" &lt;&lt; client.get_discovery_hash() &lt;&lt; std::endl;          client.start();          \/\/ \u0417\u0430\u043f\u0443\u0441\u043a DHT-\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c     if (client.start_dht_discovery()) {         \/\/ \u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043e \u0441\u0432\u043e\u0451\u043c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438         client.announce_for_hash(client.get_discovery_hash());                  \/\/ \u041f\u043e\u0438\u0441\u043a \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0438\u0440\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u0442\u043e\u0442 \u0436\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b         client.find_peers_by_hash(client.get_discovery_hash(),              [](const std::vector&lt;std::string&gt;&amp; peers) {                 std::cout &lt;&lt; \"Found \" &lt;&lt; peers.size() &lt;&lt; \" peers\" &lt;&lt; std::endl;             });     }          return 0; }<\/code><\/pre>\n<h4>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0447\u0430\u0442\u0430<\/h4>\n<p>\u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0438\u043f\u0438\u0447\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0447\u0430\u0442\u0430. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0431\u0435\u0437 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f mesh-\u0441\u0435\u0442\u0438.<\/p>\n<pre><code class=\"cpp\">#include \"librats.h\" #include &lt;iostream&gt; #include &lt;string&gt;  int main() {     librats::RatsClient client(8080);          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e API     client.on(\"chat\", [](const std::string&amp; peer_id, const nlohmann::json&amp; data) {         std::cout &lt;&lt; \"[CHAT] \" &lt;&lt; peer_id &lt;&lt; \": \" &lt;&lt; data[\"message\"].get&lt;std::string&gt;() &lt;&lt; std::endl;     });          client.on(\"user_join\", [](const std::string&amp; peer_id, const nlohmann::json&amp; data) {         std::cout &lt;&lt; \"[JOIN] \" &lt;&lt; data[\"username\"].get&lt;std::string&gt;() &lt;&lt; \" \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043b\u0441\u044f\" &lt;&lt; std::endl;     });          \/\/ \u041a\u043e\u043b\u0431\u044d\u043a \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438     client.set_connection_callback([&amp;](socket_t socket, const std::string&amp; peer_id) {         std::cout &lt;&lt; \"\u2705 \u041f\u0438\u0440 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f: \" &lt;&lt; peer_id &lt;&lt; std::endl;                  \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435         nlohmann::json welcome;         welcome[\"username\"] = \"User_\" + client.get_our_peer_id().substr(0, 8);         client.send(\"user_join\", welcome);     });          client.start();          \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0447\u0430\u0442-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435     nlohmann::json chat_msg;     chat_msg[\"message\"] = \"Hello, P2P chat!\";     chat_msg[\"timestamp\"] = std::time(nullptr);     client.send(\"chat\", chat_msg);          return 0; }<\/code><\/pre>\n<h4>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 mesh-\u0441\u0435\u0442\u044f\u043c\u0438<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0443\u043f\u043d\u0443\u044e \u0441\u0435\u0442\u044c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0443\u0437\u043b\u043e\u0432), \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <strong>gossipsub<\/strong>.<\/p>\n<pre><code class=\"cpp\">#include \"librats.h\" #include &lt;iostream&gt;  int main() {     librats::RatsClient client(8080);          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0442\u043e\u043f\u0438\u043a\u043e\u0432     client.on_topic_message(\"news\", [](const std::string&amp; peer_id, const std::string&amp; topic, const std::string&amp; message) {         std::cout &lt;&lt; \"\ud83d\udcf0 [\" &lt;&lt; topic &lt;&lt; \"] \" &lt;&lt; peer_id &lt;&lt; \": \" &lt;&lt; message &lt;&lt; std::endl;     });          client.on_topic_json_message(\"events\", [](const std::string&amp; peer_id, const std::string&amp; topic, const nlohmann::json&amp; data) {         std::cout &lt;&lt; \"\ud83c\udf89 [\" &lt;&lt; topic &lt;&lt; \"] \u0421\u043e\u0431\u044b\u0442\u0438\u0435: \" &lt;&lt; data[\"type\"].get&lt;std::string&gt;() &lt;&lt; std::endl;     });          \/\/ \u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438\/\u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u0438\u0440\u043e\u0432     client.on_topic_peer_joined(\"news\", [](const std::string&amp; peer_id, const std::string&amp; topic) {         std::cout &lt;&lt; \"\u2795 \" &lt;&lt; peer_id &lt;&lt; \" \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043b\u0441\u044f \u043a \" &lt;&lt; topic &lt;&lt; std::endl;     });          client.start();     client.start_dht_discovery();          \/\/ \u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u0442\u043e\u043f\u0438\u043a\u0438     client.subscribe_to_topic(\"news\");     client.subscribe_to_topic(\"events\");          \/\/ \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439     client.publish_to_topic(\"news\", \"Breaking: librats is awesome!\");          nlohmann::json event;     event[\"type\"] = \"celebration\";     event[\"reason\"] = \"successful_connection\";     client.publish_json_to_topic(\"events\", event);          std::cout &lt;&lt; \"\ud83d\udcca \u041f\u0438\u0440\u043e\u0432 \u0432 'news': \" &lt;&lt; client.get_topic_peers(\"news\").size() &lt;&lt; std::endl;          return 0; }<\/code><\/pre>\n<h4>\u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/h4>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0444\u0430\u0439\u043b\u044b \u0438 \u0446\u0435\u043b\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/p>\n<pre><code class=\"cpp\">#include \"librats.h\" #include &lt;iostream&gt;  int main() {     librats::RatsClient client(8080);          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043b\u0431\u044d\u043a\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0444\u0430\u0439\u043b\u043e\u0432     client.on_file_transfer_progress([](const librats::FileTransferProgress&amp; progress) {         std::cout &lt;&lt; \"\ud83d\udcc1 \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \" &lt;&lt; progress.transfer_id.substr(0, 8)                    &lt;&lt; \": \" &lt;&lt; progress.get_completion_percentage() &lt;&lt; \"% \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e\"                   &lt;&lt; \" (\" &lt;&lt; (progress.transfer_rate_bps \/ 1024) &lt;&lt; \" KB\/s)\" &lt;&lt; std::endl;     });          client.on_file_transfer_completed([](const std::string&amp; transfer_id, bool success, const std::string&amp; error) {         if (success) {             std::cout &lt;&lt; \"\u2705 \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430: \" &lt;&lt; transfer_id.substr(0, 8) &lt;&lt; std::endl;         } else {             std::cout &lt;&lt; \"\u274c \u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438: \" &lt;&lt; error &lt;&lt; std::endl;         }     });          \/\/ \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u0434\u0430\u0447     client.on_file_transfer_request([](const std::string&amp; peer_id,                                        const librats::FileMetadata&amp; metadata,                                        const std::string&amp; transfer_id) {         std::cout &lt;&lt; \"\ud83d\udce5 \u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0444\u0430\u0439\u043b: \" &lt;&lt; metadata.filename                    &lt;&lt; \" (\" &lt;&lt; metadata.file_size &lt;&lt; \" \u0431\u0430\u0439\u0442) \u043e\u0442 \" &lt;&lt; peer_id.substr(0, 8) &lt;&lt; std::endl;         return true; \/\/ \u0410\u0432\u0442\u043e\u043f\u0440\u0438\u043d\u044f\u0442\u0438\u0435     });          \/\/ \u0420\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \"shared\"     client.on_file_request([](const std::string&amp; peer_id, const std::string&amp; file_path, const std::string&amp; transfer_id) {         std::cout &lt;&lt; \"\ud83d\udce4 \u0417\u0430\u043f\u0440\u043e\u0441: \" &lt;&lt; file_path &lt;&lt; \" \u043e\u0442 \" &lt;&lt; peer_id.substr(0, 8) &lt;&lt; std::endl;         return file_path.find(\"..\/\") == std::string::npos; \/\/ \u0417\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0432\u044b\u0445\u043e\u0434\u0430 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043f\u0443\u0442\u0438     });          client.start();          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438     librats::FileTransferConfig config;     config.chunk_size = 64 * 1024;       \/\/ \u0447\u0430\u043d\u043a\u0438 \u043f\u043e 64KB     config.max_concurrent_chunks = 4;    \/\/ 4 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0447\u0430\u043d\u043a\u0430     config.verify_checksums = true;      \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u0438     client.set_file_transfer_config(config);          \/\/ \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0447 (\u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \"peer_id\" \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 ID \u043f\u0438\u0440\u0430)     \/\/ std::string file_transfer = client.send_file(\"peer_id\", \"my_file.txt\");     \/\/ std::string dir_transfer = client.send_directory(\"peer_id\", \".\/my_folder\");     \/\/ std::string file_request = client.request_file(\"peer_id\", \"remote_file.txt\", \".\/downloaded_file.txt\");          std::cout &lt;&lt; \"\u0424\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0433\u043e\u0442\u043e\u0432\u0430. \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u043f\u0438\u0440\u043e\u0432 \u0438 \u043e\u0431\u043c\u0435\u043d\u0438\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u0444\u0430\u0439\u043b\u0430\u043c\u0438!\" &lt;&lt; std::endl;          return 0; }<\/code><\/pre>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/h4>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">#include \"librats.h\" #include &lt;iostream&gt;  int main() {     librats::RatsClient client(8080);          \/\/ \u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f     client.set_logging_enabled(true);     client.set_log_file_path(\"librats_app.log\");     client.set_log_level(\"INFO\");  \/\/ DEBUG, INFO, WARN, ERROR     client.set_log_colors_enabled(true);     client.set_log_timestamps_enabled(true);          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u043e\u0442\u0430\u0446\u0438\u0438 \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u043e\u0432     client.set_log_rotation_size(5 * 1024 * 1024);  \/\/ \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 5MB     client.set_log_retention_count(3);               \/\/ \u0445\u0440\u0430\u043d\u0438\u0442\u044c 3 \u0441\u0442\u0430\u0440\u044b\u0445 \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u0430          std::cout &lt;&lt; \"\ud83d\udcdd \u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432: \" &lt;&lt; client.get_log_file_path() &lt;&lt; std::endl;     std::cout &lt;&lt; \"\ud83d\udcca \u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f: \" &lt;&lt; static_cast&lt;int&gt;(client.get_log_level()) &lt;&lt; std::endl;     std::cout &lt;&lt; \"\ud83c\udfa8 \u0426\u0432\u0435\u0442\u043d\u043e\u0435 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435: \" &lt;&lt; (client.is_log_colors_enabled() ? \"\u0414\u0430\" : \"\u041d\u0435\u0442\") &lt;&lt; std::endl;          client.start();          \/\/ \u0412\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 librats \u0442\u0435\u043f\u0435\u0440\u044c \u0431\u0443\u0434\u0443\u0442 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f     client.broadcast_string_to_peers(\"\u042d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432 \u043b\u043e\u0433\u0430\u0445!\");          \/\/ \u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u0430 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 (\u0440\u0430\u0441\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f)     \/\/ client.clear_log_file();          return 0; }<\/code><\/pre>\n<p>\u0418 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"cpp\">#include \"librats.h\" #include &lt;iostream&gt;  int main() {     librats::RatsClient client(8080);          \/\/ Set custom data directory for config files     client.set_data_directory(\".\/my_app_data\");          \/\/ Load saved configuration (if exists)     if (client.load_configuration()) {         std::cout &lt;&lt; \"\ud83d\udcc4 Loaded existing configuration\" &lt;&lt; std::endl;     } else {         std::cout &lt;&lt; \"\ud83d\udcc4 Using default configuration\" &lt;&lt; std::endl;     }          \/\/ Get our persistent peer ID     std::cout &lt;&lt; \"\ud83c\udd94 Our peer ID: \" &lt;&lt; client.get_our_peer_id() &lt;&lt; std::endl;          client.start();          \/\/ Try to reconnect to previously connected peers     int reconnect_attempts = client.load_and_reconnect_peers();     std::cout &lt;&lt; \"\ud83d\udd04 Attempted to reconnect to \" &lt;&lt; reconnect_attempts &lt;&lt; \" previous peers\" &lt;&lt; std::endl;          \/\/ Configuration is automatically saved when client stops     \/\/ Files created: config.json, peers.rats, peers_ever.rats          \/\/ Manual save if needed     client.save_configuration();     client.save_historical_peers();          std::cout &lt;&lt; \"\ud83d\udcbe Configuration will be saved to: \" &lt;&lt; client.get_data_directory() &lt;&lt; std::endl;          return 0; }<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043d\u043e \u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432: \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e: \u00ab\u043f\u0442\u0438\u0446\u0430 \u0437\u0430\u043b\u0435\u0442\u0435\u043b\u0430\u00bb \u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043c\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0437\u0430\u043a\u043e\u043d\u043e\u043f\u043e\u0441\u043b\u0443\u0448\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0447\u0430\u0441\u0442\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0438\u043b\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0431\u0430\u0437\u044b \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u043f\u0438\u0440\u043e\u0432 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0435\u0442\u0438 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u043d\u043e\u0432\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u0441\u0435\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432.<\/p>\n<p>\u041d\u0443 \u0438 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a, \u0440\u0430\u0437 \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u044b \u0434\u0440\u0443\u0433\u0438\u0435 \u044f\u0437\u044b\u043a\u0438, \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 Java \u043d\u0430 Android. \u042f \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440 Activity \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0444\u043e\u043a\u0443\u0441\u0438\u0440\u0443\u0435\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 setupRatsClient():<\/p>\n<pre><code class=\"java\">public class MainActivity extends AppCompatActivity {     private static final String TAG = \"LibRatsExample\";     private static final int PERMISSION_REQUEST_CODE = 1;          private RatsClient ratsClient;     private TextView statusText;     private TextView messagesText;     private EditText hostInput;     private EditText portInput;     private EditText messageInput;     private Button startButton;     private Button connectButton;     private Button sendButton;          @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);                  initViews();         checkPermissions();         setupRatsClient();     }          private void initViews() {         statusText = findViewById(R.id.statusText);         messagesText = findViewById(R.id.messagesText);         hostInput = findViewById(R.id.hostInput);         portInput = findViewById(R.id.portInput);         messageInput = findViewById(R.id.messageInput);         startButton = findViewById(R.id.startButton);         connectButton = findViewById(R.id.connectButton);         sendButton = findViewById(R.id.sendButton);                  startButton.setOnClickListener(this::onStartClicked);         connectButton.setOnClickListener(this::onConnectClicked);         sendButton.setOnClickListener(this::onSendClicked);                  \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e         hostInput.setText(\"192.168.1.100\");         portInput.setText(\"8080\");         messageInput.setText(\"Hello from Android!\");                  updateUI();     }          private void checkPermissions() {         String[] permissions = {             Manifest.permission.INTERNET,             Manifest.permission.ACCESS_NETWORK_STATE,             Manifest.permission.ACCESS_WIFI_STATE,             Manifest.permission.CHANGE_WIFI_MULTICAST_STATE         };                  boolean allGranted = true;         for (String permission : permissions) {             if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) {                 allGranted = false;                 break;             }         }                  if (!allGranted) {             ActivityCompat.requestPermissions(this, permissions, PERMISSION_REQUEST_CODE);         }     }          private void setupRatsClient() {         try {             \/\/ \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435             RatsClient.setLoggingEnabled(true);             RatsClient.setLogLevel(\"INFO\");                          \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043b\u0438\u0435\u043d\u0442 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 8080             ratsClient = new RatsClient(8080);                          \/\/ \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043b\u0431\u044d\u043a\u0438             ratsClient.setConnectionCallback(new ConnectionCallback() {                 @Override                 public void onConnection(String peerId) {                     runOnUiThread(() -&gt; {                         appendMessage(\"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0438\u0441\u044c \u043a \u043f\u0438\u0440\u0443: \" + peerId);                         updateUI();                     });                 }             });                          ratsClient.setStringCallback(new StringMessageCallback() {                 @Override                 public void onStringMessage(String peerId, String message) {                     runOnUiThread(() -&gt; {                         appendMessage(\"\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 \" + peerId + \": \" + message);                     });                 }             });                          ratsClient.setDisconnectCallback(new DisconnectCallback() {                 @Override                 public void onDisconnect(String peerId) {                     runOnUiThread(() -&gt; {                         appendMessage(\"\u041e\u0442\u043a\u043b\u044e\u0447\u0438\u043b\u0438\u0441\u044c \u043e\u0442 \u043f\u0438\u0440\u0430: \" + peerId);                         updateUI();                     });                 }             });                          appendMessage(\"\u041a\u043b\u0438\u0435\u043d\u0442 LibRats \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\");             appendMessage(\"\u0412\u0435\u0440\u0441\u0438\u044f: \" + RatsClient.getVersionString());                      } catch (Exception e) {             Log.e(TAG, \"\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c RatsClient\", e);             appendMessage(\"\u041e\u0448\u0438\u0431\u043a\u0430: \" + e.getMessage());         }     }          private void onStartClicked(View view) {         if (ratsClient == null) return;                  try {             int result = ratsClient.start();             if (result == RatsClient.SUCCESS) {                 appendMessage(\"\u041a\u043b\u0438\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u043f\u0443\u0449\u0435\u043d\");                 appendMessage(\"\u041d\u0430\u0448 Peer ID: \" + ratsClient.getOurPeerId());                 updateUI();             } else {                 appendMessage(\"\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442: \" + result);             }         } catch (Exception e) {             Log.e(TAG, \"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\", e);             appendMessage(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430: \" + e.getMessage());         }     }          private void onConnectClicked(View view) {         if (ratsClient == null) return;                  String host = hostInput.getText().toString().trim();         String portStr = portInput.getText().toString().trim();                  if (host.isEmpty() || portStr.isEmpty()) {             Toast.makeText(this, \"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0445\u043e\u0441\u0442 \u0438 \u043f\u043e\u0440\u0442\", Toast.LENGTH_SHORT).show();             return;         }                  try {             int port = Integer.parseInt(portStr);             int result = ratsClient.connectWithStrategy(host, port, RatsClient.STRATEGY_AUTO_ADAPTIVE);                          if (result == RatsClient.SUCCESS) {                 appendMessage(\"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \" + host + \":\" + port);             } else {                 appendMessage(\"\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f: \" + result);             }         } catch (NumberFormatException e) {             Toast.makeText(this, \"\u041d\u0435\u0432\u0435\u0440\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0440\u0442\u0430\", Toast.LENGTH_SHORT).show();         } catch (Exception e) {             Log.e(TAG, \"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\", e);             appendMessage(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f: \" + e.getMessage());         }     }          private void onSendClicked(View view) {         if (ratsClient == null) return;                  String message = messageInput.getText().toString().trim();         if (message.isEmpty()) {             Toast.makeText(this, \"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\", Toast.LENGTH_SHORT).show();             return;         }                  try {             \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u0445 \u043f\u0438\u0440\u043e\u0432             String[] peerIds = ratsClient.getPeerIds();             if (peerIds.length == 0) {                 Toast.makeText(this, \"\u041d\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u0445 \u043f\u0438\u0440\u043e\u0432\", Toast.LENGTH_SHORT).show();                 return;             }                          \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u043e\u043c\u0443 \u043f\u0438\u0440\u0443             int result = ratsClient.sendString(peerIds[0], message);             if (result == RatsClient.SUCCESS) {                 appendMessage(\"\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e: \" + message);                 messageInput.setText(\"\");             } else {                 appendMessage(\"\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435: \" + result);             }         } catch (Exception e) {             Log.e(TAG, \"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\", e);             appendMessage(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f: \" + e.getMessage());         }     }          private void appendMessage(String message) {         Log.d(TAG, message);         messagesText.append(message + \"\\n\");                  \/\/ \u041f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0430 \u0432\u043d\u0438\u0437         messagesText.post(() -&gt; {             int scrollAmount = messagesText.getLayout().getLineTop(messagesText.getLineCount())                                - messagesText.getHeight();             if (scrollAmount &gt; 0) {                 messagesText.scrollTo(0, scrollAmount);             } else {                 messagesText.scrollTo(0, 0);             }         });     }          private void updateUI() {         if (ratsClient == null) {             statusText.setText(\"\u0421\u0442\u0430\u0442\u0443\u0441: \u041d\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\");             startButton.setEnabled(false);             connectButton.setEnabled(false);             sendButton.setEnabled(false);             return;         }                  try {             int peerCount = ratsClient.getPeerCount();             statusText.setText(\"\u0421\u0442\u0430\u0442\u0443\u0441: \" + peerCount + \" \u043f\u0438\u0440\u043e\u0432 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043e\");                          \/\/ \u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\/\u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u043d\u043e\u043f\u043e\u043a \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f             startButton.setEnabled(true);             connectButton.setEnabled(true);             sendButton.setEnabled(peerCount &gt; 0);                      } catch (Exception e) {             statusText.setText(\"\u0421\u0442\u0430\u0442\u0443\u0441: \u041e\u0448\u0438\u0431\u043a\u0430\");             Log.e(TAG, \"\u041e\u0448\u0438\u0431\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f UI\", e);         }     }          @Override     protected void onDestroy() {         super.onDestroy();         if (ratsClient != null) {             try {                 ratsClient.stop();                 ratsClient.destroy();             } catch (Exception e) {                 Log.e(TAG, \"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\", e);             }         }     }          @Override     public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {         super.onRequestPermissionsResult(requestCode, permissions, grantResults);         if (requestCode == PERMISSION_REQUEST_CODE) {             boolean allGranted = true;             for (int result : grantResults) {                 if (result != PackageManager.PERMISSION_GRANTED) {                     allGranted = false;                     break;                 }             }                          if (!allGranted) {                 Toast.makeText(this, \"\u0414\u043b\u044f LibRats \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f\", Toast.LENGTH_LONG).show();             }         }     } }<\/code><\/pre>\n<p><strong>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 C \u0432 \u0432\u0438\u0434\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/strong><\/p>\n<p>\u041d\u0430 C \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c:<\/p>\n<p><a href=\"https:\/\/github.com\/DEgITx\/librats\/blob\/master\/src\/librats_c.h\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/DEgITx\/librats\/blob\/master\/src\/librats_c.h<\/a> &#8212; \u0432\u0435\u0441\u044c \u0441\u043f\u0438\u0441\u043e\u043a, \u0430\u043d\u0430\u043b\u043e\u0433 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438\u0437 C++<\/p>\n<p>\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0433\u0434\u0430 \u043d\u0430 C:<\/p>\n<pre><code class=\"cpp\">#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;unistd.h&gt; #include &lt;signal.h&gt;  #include \"librats_c.h\"  \/\/ \u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 static rats_client_t client = NULL; static volatile int running = 1;  \/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u0438-\u043a\u043e\u043b\u0431\u044d\u043a\u0438 void on_peer_connected(void* user_data, const char* peer_id) {     printf(\"\u041f\u0438\u0440 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f: %s\\n\", peer_id); }  void on_peer_disconnected(void* user_data, const char* peer_id) {     printf(\"\u041f\u0438\u0440 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f: %s\\n\", peer_id); }  void on_string_message(void* user_data, const char* peer_id, const char* message) {     printf(\"\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 %s: %s\\n\", peer_id, message); }  void signal_handler(int sig) {     printf(\"\u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b...\\n\");     running = 0; }  int main(int argc, char* argv[]) {     printf(\"\u041f\u0440\u0438\u043c\u0435\u0440\\n\");     printf(\"========================\\n\\n\");          \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u0438\u0433\u043d\u0430\u043b\u0430     signal(SIGINT, signal_handler);          \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 8080     client = rats_create(8080);     if (!client) {         fprintf(stderr, \"\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0430!\\n\");         return 1;     }          \/\/ \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043b\u0431\u044d\u043a\u0438     rats_set_connection_callback(client, on_peer_connected, NULL);     rats_set_disconnect_callback(client, on_peer_disconnected, NULL);     rats_set_string_callback(client, on_string_message, NULL);          \/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0430     if (rats_start(client) != RATS_SUCCESS) {         fprintf(stderr, \"\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0430!\\n\");         rats_destroy(client);         return 1;     }          \/\/ \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043d\u0430\u0448 Peer ID     char* peer_id = rats_get_our_peer_id(client);     if (peer_id) {         printf(\"\u041d\u0430\u0448 Peer ID: %s\\n\", peer_id);         rats_string_free(peer_id);     }          printf(\"\u041a\u043b\u0438\u0435\u043d\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 8080\\n\");     printf(\"\u041d\u0430\u0436\u043c\u0438\u0442\u0435 Ctrl+C \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438\\n\\n\");          \/\/ \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u2014 \u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f     if (argc &gt;= 3) {         const char* host = argv[1];         int port = atoi(argv[2]);         printf(\"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a %s:%d...\\n\", host, port);         rats_connect(client, host, port);     }          \/\/ \u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u0446\u0438\u043a\u043b     int counter = 0;     while (running) {         sleep(1);         counter++;                  \/\/ \u041a\u0430\u0436\u0434\u044b\u0435 5 \u0441\u0435\u043a\u0443\u043d\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435         if (counter % 5 == 0) {             int peer_count = rats_get_peer_count(client);             if (peer_count &gt; 0) {                 char message[100];                 snprintf(message, sizeof(message), \"\u0417\u0434\u0430\u0440\u043e\u0432\u0430: %d\", counter \/ 5);                                  int sent = rats_broadcast_string(client, message);                 printf(\"\u0428\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 %d \u043f\u0438\u0440\u0430\u043c: %s\\n\", sent, message);             } else {                 printf(\"\u041d\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u0445 \u043f\u0438\u0440\u043e\u0432. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:\\n\");                 printf(\"  %s localhost 8080\\n\", argv[0]);             }         }     }          \/\/ \u041e\u0447\u0438\u0441\u0442\u043a\u0430     printf(\"\u041e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430...\\n\");     rats_stop(client);     rats_destroy(client);          printf(\"\u0411\u0430\u044e\u0448\u043a\u0438!\\n\");     return 0; }<\/code><\/pre>\n<p><strong>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/strong><\/p>\n<p>\u041d\u0443 \u0438 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u2014 \u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u043c\u043d\u0438\u0442\u0435 \u0442\u0435 500\u2013600 \u041c\u0411 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 p2p \u0447\u0435\u0440\u0435\u0437 libp2p? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441 <strong>librats<\/strong>:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/969\/97c\/7d8\/96997c7d8ca9bb5aa2d8a39fb79444c0.png\" width=\"760\" height=\"43\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/969\/97c\/7d8\/96997c7d8ca9bb5aa2d8a39fb79444c0.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/969\/97c\/7d8\/96997c7d8ca9bb5aa2d8a39fb79444c0.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u2026\u043d\u0435 \u043f\u0440\u0430\u0432\u0434\u0430 \u043b\u0438, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u044f\u0432\u043d\u043e \u043b\u0443\u0447\u0448\u0435?<\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435! \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044f \u0440\u0430\u0441\u0448\u0438\u0440\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u043e \u043c\u0435\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u043e\u0432 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u044f\u0437\u044b\u043a\u0438 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/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\/943652\/\"> https:\/\/habr.com\/ru\/articles\/943652\/<\/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>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u042f \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0438\u043a\u0430 <strong>rats-search<\/strong> \u043d\u0430 \u0431\u0430\u0437\u0435 DHT (<a href=\"https:\/\/github.com\/DEgITx\/rats-search\" rel=\"noopener noreferrer nofollow\">GitHub<\/a>). \u0415\u0433\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442: \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0438\u043a \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0442\u043e\u0440\u0440\u0435\u043d\u0442\u044b \u0443 \u0432\u0441\u0435\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0441\u0435\u0442\u0438 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0447\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e).<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0441\u0432\u043e\u0435\u0439 \u043d\u043e\u0432\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 (p2p), \u0433\u0434\u0435 \u0437\u043d\u0430\u043d\u0438\u0435 IP-\u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0430 \u043f\u043e\u0438\u0441\u043a \u0432\u0435\u0434\u0451\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b \u2014 DHT, mDNS, peer-exchange \u0438 \u0434\u0440\u0443\u0433\u0438\u0435. \u0414\u0443\u043c\u0430\u044e, \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0445 <strong>\u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0432\u043e\u043a\u0440\u0443\u0433, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c ;).<\/p>\n<h4>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u0438<\/h4>\n<p><strong>rats-search <\/strong>\u2014 \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u0440\u044b\u0439, \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0435\u0433\u043e \u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u043d\u0430 Electron. \u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c p2p-\u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0443\u044e \u043d\u0430 C++ \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0432\u044f\u0437\u0438 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0440\u0430\u0434\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432\u0441\u0451 \u043d\u0430 <strong>libp2p<\/strong> \u0438 \u0431\u044b\u043b \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0443\u0434\u0438\u0432\u043b\u0451\u043d \u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e. \u0411\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438 ~100 \u043f\u0438\u0440\u0430\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 (Ryzen 5700) \u0431\u044b\u043b \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u043d\u0430 100% \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0448\u0430\u0433\u043e\u0432 \u043f\u043e DHT \u0441\u0435\u0442\u0438, \u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u043b\u043e 500\u2013600 \u041c\u0411. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e libp2p \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0442\u0438\u043f\u043e it- \u0438 \u0442\u044f\u043d\u0435\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 300\u2013400 \u041c\u0411 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 <em>node_modules<\/em>, \u043d\u043e \u044d\u0442\u043e \u0436\u0435 \u043d\u0435 \u0434\u0435\u043b\u043e.<\/p>\n<p>\u0414\u0430, \u044d\u0442\u043e JS, \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441 C++ \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u043d\u043e \u0434\u0430\u0436\u0435 JS-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435 \u0434\u0430\u044e\u0442 \u0442\u0430\u043a\u0438\u0445 \u043f\u043b\u043e\u0445\u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, libp2p \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0435 \u0432\u0441\u0435 \u044f\u0437\u044b\u043a\u0438: \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0443\u0440\u0435\u0437\u0430\u043d\u044b, \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u043e\u0432\u0441\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u043b\u044f C++ \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <strong>mDNS<\/strong> \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d. \u0412 \u0438\u0442\u043e\u0433\u0435 \u044d\u0442\u0430\u043b\u043e\u043d\u043d\u044b\u043c\u0438 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f Go \u0438 JS, \u0438 \u043e\u043d\u0438 \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0443 libp2p \u044d\u0442\u043e \u043f\u043e\u043b\u043d\u044b\u0439 \u0440\u0430\u0437\u043d\u043e\u0431\u043e\u0439, \u043f\u043e\u0432\u0435\u0437\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e go \u0438 javascript<\/figcaption><\/div>\n<\/figure>\n<h4>\u041f\u043e\u0447\u0435\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443<\/h4>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u044d\u0442\u043e\u0439 \u00ab\u043a\u043e\u043c\u0431\u0430\u0439\u043d-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\u00bb \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u044b \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u044f\u0437\u044b\u043a, \u0430 \u043a \u043d\u0435\u043c\u0443 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0443\u044e \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0435\u0434\u0438\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<p>\u0422\u0430\u043a \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c <strong>librats<\/strong> \u2014 \u043d\u043e\u0432\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0430 C++, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0430\u043d\u0435\u0442 \u0431\u0443\u0434\u0443\u0449\u0438\u043c \u044f\u0434\u0440\u043e\u043c Rats, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0438 \u0432 \u043b\u044e\u0431\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445.<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/librats.com\/\" rel=\"noopener noreferrer nofollow\">\u041e\u0444\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442<\/a> &#8212; <a href=\"https:\/\/librats.com\/\" rel=\"noopener noreferrer nofollow\">https:\/\/librats.com\/<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/DEgITx\/librats\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043d\u0430 github<\/a> &#8212; <a href=\"https:\/\/github.com\/DEgITx\/librats\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/DEgITx\/librats<\/a><\/p>\n<\/li>\n<\/ul>\n<h4>\u0427\u0442\u043e \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e<\/h4>\n<figure class=\"full-width\"><\/figure>\n<ul>\n<li>\n<p>\u041f\u043e\u0438\u0441\u043a \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 <strong>DHT<\/strong><\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \/ \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \/ \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <strong>mDNS<\/strong> \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445<\/p>\n<\/li>\n<li>\n<p><strong>Historical peers<\/strong> \u2014 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <strong>gossipsub<\/strong> \u2014 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u043c\u0435\u043d \u043f\u0438\u0440\u0430\u043c\u0438 (peer exchange)<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 (\u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445) \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>ICE \/ STUN \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b<\/p>\n<\/li>\n<li>\n<p>\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 noise (Curve25519 + ChaCha20-Poly1305)<\/p>\n<\/li>\n<\/ul>\n<h4>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0438 \u044f\u0437\u044b\u043a\u0438<\/h4>\n<figure class=\"full-width\"><\/figure>\n<ul>\n<li>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 \u043f\u043e\u0434 <strong>Windows, macOS, Linux, Android<\/strong><\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b: <strong>GCC, Clang, MSVC<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435: \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 <strong>C++<\/strong>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432 <strong>C<\/strong> \u0438 <strong>Java<\/strong> \u0447\u0435\u0440\u0435\u0437 JNI; \u0432 Android \u2014 \u0447\u0435\u0440\u0435\u0437 NDK<\/p>\n<figure class=\"full-width\"><\/figure>\n<\/li>\n<\/ul>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/strong><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<h4>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/h4>\n<pre><code class=\"cpp\">#include \"librats.h\" #include &lt;iostream&gt; #include &lt;thread&gt; #include &lt;chrono&gt;  int main() {     \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 P2P \u043a\u043b\u0438\u0435\u043d\u0442     librats::RatsClient client(8080);          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043b\u0431\u044d\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438     client.set_connection_callback([](socket_t socket, const std::string&amp; peer_id) {         std::cout &lt;&lt; \"\u2705 \u041d\u043e\u0432\u044b\u0439 \u043f\u0438\u0440 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f: \" &lt;&lt; peer_id &lt;&lt; std::endl;     });          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043b\u0431\u044d\u043a\u0430 \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439     client.set_string_data_callback([](socket_t socket, const std::string&amp; peer_id, const std::string&amp; message) {         std::cout &lt;&lt; \"\ud83d\udcac \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 \" &lt;&lt; peer_id &lt;&lt; \": \" &lt;&lt; message &lt;&lt; std::endl;     });          \/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442     if (!client.start()) {         std::cerr &lt;&lt; \"\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\" &lt;&lt; std::endl;         return 1;     }          std::cout &lt;&lt; \"\ud83d\udc00 librats \u043a\u043b\u0438\u0435\u043d\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 8080\" &lt;&lt; std::endl;          \/\/ \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043f\u0438\u0440\u0443 (\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e)     \/\/ client.connect_to_peer(\"127.0.0.1\", 8081);          \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c \u043f\u0438\u0440\u0430\u043c     client.broadcast_string_to_peers(\"Hello from librats!\");          \/\/ \u041e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c     std::this_thread::sleep_for(std::chrono::minutes(1));          return 0; }<\/code><\/pre>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0435\u0436\u0438\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0442\u0440\u0451\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p>\u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445,<\/p>\n<\/li>\n<li>\n<p>\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445,<\/p>\n<\/li>\n<li>\n<p>JSON-\u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<h4>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430<\/h4>\n<p>\u041c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u0432\u0430\u0448\u0438\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c \u0438\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c.<\/p>\n<pre><code class=\"cpp\">#include \"librats.h\" #include &lt;iostream&gt;  int main() {     librats::RatsClient client(8080);          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f     client.set_protocol_name(\"my_app\");     client.set_protocol_version(\"1.0\");          std::cout &lt;&lt; \"Protocol: \" &lt;&lt; client.get_protocol_name()                &lt;&lt; \" v\" &lt;&lt; client.get_protocol_version() &lt;&lt; std::endl;     std::cout &lt;&lt; \"Discovery hash: \" &lt;&lt; client.get_discovery_hash() &lt;&lt; std::endl;          client.start();          \/\/ \u0417\u0430\u043f\u0443\u0441\u043a DHT-\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c     if (client.start_dht_discovery()) {         \/\/ \u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043e \u0441\u0432\u043e\u0451\u043c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438         client.announce_for_hash(client.get_discovery_hash());                  \/\/ \u041f\u043e\u0438\u0441\u043a \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0438\u0440\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u0442\u043e\u0442 \u0436\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b         client.find_peers_by_hash(client.get_discovery_hash(),              [](const std::vector&lt;std::string&gt;&amp; peers) {                 std::cout &lt;&lt; \"Found \" &lt;&lt; peers.size() &lt;&lt; \" peers\" &lt;&lt; std::endl;             });     }          return 0; }<\/code><\/pre>\n<h4>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0447\u0430\u0442\u0430<\/h4>\n<p>\u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0438\u043f\u0438\u0447\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0447\u0430\u0442\u0430. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0431\u0435\u0437 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f mesh-\u0441\u0435\u0442\u0438.<\/p>\n<pre><code class=\"cpp\">#include \"librats.h\" #include &lt;iostream&gt; #include &lt;string&gt;  int main() {     librats::RatsClient client(8080);          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e API     client.on(\"chat\", [](const std::string&amp; peer_id, const nlohmann::json&amp; data) {         std::cout &lt;&lt; \"[CHAT] \" &lt;&lt; peer_id &lt;&lt; \": \" &lt;&lt; data[\"message\"].get&lt;std::string&gt;() &lt;&lt; std::endl;     });          client.on(\"user_join\", [](const std::string&amp; peer_id, const nlohmann::json&amp; data) {         std::cout &lt;&lt; \"[JOIN] \" &lt;&lt; data[\"username\"].get&lt;std::string&gt;() &lt;&lt; \" \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043b\u0441\u044f\" &lt;&lt; std::endl;     });          \/\/ \u041a\u043e\u043b\u0431\u044d\u043a \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438     client.set_connection_callback([&amp;](socket_t socket, const std::string&amp; peer_id) {         std::cout &lt;&lt; \"\u2705 \u041f\u0438\u0440 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f: \" &lt;&lt; peer_id &lt;&lt; std::endl;                  \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435         nlohmann::json welcome;         welcome[\"username\"] = \"User_\" + client.get_our_peer_id().substr(0, 8);         client.send(\"user_join\", welcome);     });          client.start();          \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0447\u0430\u0442-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435     nlohmann::json chat_msg;     chat_msg[\"message\"] = \"Hello, P2P chat!\";     chat_msg[\"timestamp\"] = std::time(nullptr);     client.send(\"chat\", chat_msg);          return 0; }<\/code><\/pre>\n<h4>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 mesh-\u0441\u0435\u0442\u044f\u043c\u0438<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0443\u043f\u043d\u0443\u044e \u0441\u0435\u0442\u044c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0443\u0437\u043b\u043e\u0432), \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <strong>gossipsub<\/strong>.<\/p>\n<pre><code class=\"cpp\">#include \"librats.h\" #include &lt;iostream&gt;  int main() {     librats::RatsClient client(8080);          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0442\u043e\u043f\u0438\u043a\u043e\u0432     client.on_topic_message(\"news\", [](const std::string&amp; peer_id, const std::string&amp; topic, const std::string&amp; message) {         std::cout &lt;&lt; \"\ud83d\udcf0 [\" &lt;&lt; topic &lt;&lt; \"] \" &lt;&lt; peer_id &lt;&lt; \": \" &lt;&lt; message &lt;&lt; std::endl;     });          client.on_topic_json_message(\"events\", [](const std::string&amp; peer_id, const std::string&amp; topic, const nlohmann::json&amp; data) {         std::cout &lt;&lt; \"\ud83c\udf89 [\" &lt;&lt; topic &lt;&lt; \"] \u0421\u043e\u0431\u044b\u0442\u0438\u0435: \" &lt;&lt; data[\"type\"].get&lt;std::string&gt;() &lt;&lt; std::endl;     });          \/\/ \u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438\/\u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u0438\u0440\u043e\u0432     client.on_topic_peer_joined(\"news\", [](const std::string&amp; peer_id, const std::string&amp; topic) {         std::cout &lt;&lt; \"\u2795 \" &lt;&lt; peer_id &lt;&lt; \" \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043b\u0441\u044f \u043a \" &lt;&lt; topic &lt;&lt; std::endl;     });          client.start();     client.start_dht_discovery();          \/\/ \u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u0442\u043e\u043f\u0438\u043a\u0438     client.subscribe_to_topic(\"news\");     client.subscribe_to_topic(\"events\");          \/\/ \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439     client.publish_to_topic(\"news\", \"Breaking: librats is awesome!\");          nlohmann::json event;     event[\"type\"] = \"celebration\";     event[\"reason\"] = \"successful_connection\";     client.publish_json_to_topic(\"events\", event);          std::cout &lt;&lt; \"\ud83d\udcca \u041f\u0438\u0440\u043e\u0432 \u0432 'news': \" &lt;&lt; client.get_topic_peers(\"news\").size() &lt;&lt; std::endl;          return 0; }<\/code><\/pre>\n<h4>\u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/h4>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0444\u0430\u0439\u043b\u044b \u0438 \u0446\u0435\u043b\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/p>\n<pre><code class=\"cpp\">#include \"librats.h\" #include &lt;iostream&gt;  int main() {     librats::RatsClient client(8080);          \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043b\u0431\u044d\u043a\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0444\u0430\u0439\u043b\u043e\u0432     client.on_file_transfer_progress([](const librats::FileTransferProgress&amp; progress) {         std::cout &lt;&lt; \"\ud83d\udcc1 \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \" &lt;&lt; progress.transfer_id.substr(0, 8)                    &lt;&lt; \": \" &lt;&lt; progress.get_completion_percentage() &lt;&lt; \"% \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e\"                   &lt;&lt; \" (\" &lt;&lt; (progress.transfer_rate_bps \/ 1024) &lt;&lt; \" KB\/s)\" &lt;&lt; std::endl;     });          client.on_file_transfer_completed([](const std::string&amp; transfer_id, bool success, const std::string&amp; error) {         if (success) {             std::cout &lt;&lt; \"\u2705 \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430: \" &lt;&lt; transfer_id.substr(0, 8) &lt;&lt; std::endl;         } else {             std::cout &lt;&lt; \"\u274c \u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438: \" &lt;&lt; error &lt;&lt; std::endl;         }     });          \/\/ \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u0434\u0430\u0447     client.on_file_transfer_request([](const std::string&amp; peer_id,                                        const librats::FileMetadata&amp; metadata,                                        const std::string&amp; transfer_id) {         std::cout &lt;&lt; \"\ud83d\udce5 \u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0444\u0430\u0439\u043b: \" &lt;&lt; metadata.filename                    &lt;&lt; \" (\" &lt;&lt; metadata.file_size &lt;&lt; \" \u0431\u0430\u0439\u0442) \u043e\u0442 \" &lt;&lt; peer_id.substr(0, 8) &lt;&lt;<\/code><\/pre>\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-473871","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/473871","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=473871"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/473871\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=473871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=473871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=473871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}