{"_id":"@akiroz/mqtt-port-forward","_rev":"2-581ccc3fbf886aa4b89bdbf153627bdc","name":"@akiroz/mqtt-port-forward","dist-tags":{"latest":"0.0.9"},"versions":{"0.0.8":{"name":"@akiroz/mqtt-port-forward","version":"0.0.8","description":"Forward a socket over mqtt topics","main":"index.js","author":{"name":"Dean Netherton"},"license":"MIT","dependencies":{"bs58":"^4.0.1","core-js":"^3.6.4","debug":"^4.1.1","mqtt-extras":"^0.0.5","uuid":"^3.4.0"},"licenseText":"MIT License\n\nCopyright (c) 2019 Dean Netherton\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@akiroz/mqtt-port-forward@0.0.8","dist":{"shasum":"3ec2f4602a99a31ac072b6d7ba9be43786eb1c6b","integrity":"sha512-Z1f8zdrKBgZNRAxFSJsW+/zXpYvTVZNbqhtLCXHp7U9hGbapTsypr2RgrXg6qhYG5tDBaXEJtIKrIod2uNFncQ==","tarball":"https://registry.npmjs.org/@akiroz/mqtt-port-forward/-/mqtt-port-forward-0.0.8.tgz","fileCount":103,"unpackedSize":131293,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRPPuCRA9TVsSAnZWagAAkqkP/RP0pFPrpp1uT0lGbAmG\nJ4/k4w9QNsR7gYO9p1JBDYjm/z4Dzr9PPMfIvAf8puSjBLZXPH+8AhLwv2aI\n3TVwcZSDpfRRhBHRrk2nmkcE+pOLdipmNgrj1tMvEToAbb1ZvaCw4R5xhnXz\nfKl+UOCtpcGm2ni9IVTgUJ8BjS/CJQ9OPnwl6PcVOh2VXhmIK3v1LvdWcNPw\naAPpnawTQUG7LN7FG3FVP3gexCwPgDUJe4tDolqePKtukX4Do9PTTZrQTocx\nkpAUqFdJybHDYOwxZr1Nw9dHqKccUbUVYj1GmpD3VjXFDlDYaFos+NsIWVAH\nt6RIKj0INrSjmaflkuFAsdi89oL4xeOFYPWtMeHughdmav1CFEGyTTbFI4Gv\nT2IjgUWoTalaIfYlgS/2U8iW3zTMuNdqVk05V1qR9t30jSup7oHpzy0+aaMW\nZDuIiWDFU7pfdHfxsY0MrZHRR02MvYsma59lT3HhbLh7kZwRMJzIsdyQtOGd\nVyRlj9IF/wGwmIIzLfCGE+xauVOXhXA9+5vI89rwlqgjuFAwzFkPyubkzcN+\n5po3B8KhVIUwGY7jr+is618uSYCvMBxYkraUhSZ507MMCU3jXAoFrSh5W7fE\nq1P2X1pb8qRSdQnwccvrMlXTdp357eF8vAClb+t0XLO9MFKcskW9OZM8sFZO\nj+zk\r\n=q/4X\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGUx8m//olNPXofLmNZcUex6pEtepWgRpssMbhb0pv5FAiEAg7HNqE9E2rEtfTPg0KX0wYGQkDMsyQSQNlxGQSIMDTU="}]},"maintainers":[{"name":"akiroz","email":"akiroz.vectis@gmail.com"}],"_npmUser":{"name":"akiroz","email":"akiroz.vectis@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mqtt-port-forward_0.0.8_1581577198481_0.5936056724611574"},"_hasShrinkwrap":false},"0.0.9":{"name":"@akiroz/mqtt-port-forward","version":"0.0.9","description":"Forward a socket over mqtt topics","main":"index.js","author":{"name":"Dean Netherton"},"license":"MIT","dependencies":{"bs58":"^4.0.1","core-js":"^3.6.4","debug":"^4.1.1","mqtt-extras":"^0.0.5","uuid":"^3.4.0"},"licenseText":"MIT License\n\nCopyright (c) 2019 Dean Netherton\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@akiroz/mqtt-port-forward@0.0.9","dist":{"shasum":"5edffb7b9bd65702c20ee03f0f451770f210f2b0","integrity":"sha512-BlhZO2Ah46If8oEcVHUhX/h1h8cnTmkpHUZOLYOUxLNj4N5/HXQ24d1tq7oQgsirTXQzd6WR8SejONQhIm2AIA==","tarball":"https://registry.npmjs.org/@akiroz/mqtt-port-forward/-/mqtt-port-forward-0.0.9.tgz","fileCount":103,"unpackedSize":131164,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeViNuCRA9TVsSAnZWagAAkKEP/RDYD4czQpzUfH/JDYbB\nGqrrcR0WmxuBMWpVFyoc7wRIzW4lmQ+vjrqGMFOJr6h7x8uSXPiYog0giIge\np4GlFFpXJHkfL5g+vd4QCrfH3kpxRGH46WcN1KnCgNSEwciCvoKoky+VvZkn\nxfo6XdQ1+79H3h/G23WP+7Rg2uDdKlmW4WmMzicHO9iTkbP3ugxls0c3d8Rd\nGYBJ08cfDPFuG/MZ49t83fJo2So13SApOAvA1psXH2zfvjiWP4aZKQszKYPh\nDk61QS51poVWilwY1yp9ab3/l8oJrVf68VBFYsbAHdxdXLwkW+0qNX0kCT2A\nk+FUASFeYwpRVSeA9vWRDwCmFmKsWiPb4nbkLssRYgIvsJI3uo7bsZMPY56S\ne8Kyw3eh6hicFCiogL4Aew6FGS3326a321skURjqeXo3HJbshKhkeK5cwS+z\nqDZm6V/5TOucxZjSPl4b17mNAvZQKtORbJRvvuoiVWXQbefEouPfi1aAfT9s\n8DvvpfyDCRNT0LYlcHoqt6mXQaRK8EV+8ndnAyCEGhUWwz7B9N+xDLWz6bLF\nbbfGtnDX9uYbMlEweoOgtMRwVP+aBj3ILpaEtq4mY0sw7p5baxbA5h8HLO8e\np8ejvQRM3mbjZDkj1/nHPHCnnvpdp3rk/V42WLihxJJyzGQhqn0Rnru2isC/\nxhu+\r\n=B8UZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIASks4XGEzdHAWcpMUC/AApRe3YZQZcA8b3kh4vLx7rnAiEAyD6ouajielU9JAxsoVQQMgMbHUzqiNJV6rY3teP3AyE="}]},"maintainers":[{"name":"akiroz","email":"akiroz.vectis@gmail.com"}],"_npmUser":{"name":"akiroz","email":"akiroz.vectis@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mqtt-port-forward_0.0.9_1582703469581_0.36441726493993887"},"_hasShrinkwrap":false}},"time":{"created":"2020-02-13T06:59:58.448Z","0.0.8":"2020-02-13T06:59:58.654Z","modified":"2022-04-04T12:29:45.468Z","0.0.9":"2020-02-26T07:51:09.717Z"},"maintainers":[{"name":"akiroz","email":"akiroz.vectis@gmail.com"}],"description":"Forward a socket over mqtt topics","author":{"name":"Dean Netherton"},"license":"MIT","readme":"# MQTT Port Forwarding\n-----------\n\nThis modules provides a means to forward a tcp socket, over MQTT to another mqtt recipient\n\nIt can be integrated into your mqtt iot devices, to allow estabishing a secure ssh connection\nfrom your support laptop to a specific remote iot device.\n\n## Table of Contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [API Documentation](#api-documentation)\n- [Example](#example)\n- [License](#license)\n\n\n## Install\n\n```sh\n$ npm install mqtt-port-formward\n```\n\n## Usage\n\nThis package, exports 2 functions to establish the port forwarding.\n\n`forwardLocalPortToMqtt` - To listen on a specific port, and forward connection requests to a specific mqtt topic\n\n`forwardMqttToLocalPort` - To accept connection request over mqtt topic, and forward to a specific local port on 127.0.0.1\n\n## API Documentation\n\nThe package exports 2 functions\n\n* [forwardMqttToLocalPort()](#forwardmqtttolocalportmqttclient-portnumber-topic)\n* [forwardLocalPortToMqtt()](#forwardlocalporttomqttmqttclient-portnumber-topic)\n\n### forwardMqttToLocalPort(mqttClient, portNumber, topic, timeoutPeriod = 120000)\n\nSubscribes on the supplied `mqttClient` object, to the topic pattern `<topic>/tunnel/up/+`.\n\nWhen a new connection request is received on this topic, a socket connection is established\non `portNumber` to the localhost.  Assumes there is a service ready to accept this connection.\n\nOnce connection is establish, data received on topic `<topic>/tunnel/up/+` will be sent to\nthe socket, and data sent from the socket will be published to mqtt topic `<topic>/tunnel/down/+`\n\nIf the `mqttClient` object is closed, then any opened sockets will be closed.\n\nIf no traffic is received on the mqtt topic for `timeoutPeriod`, then all sockets will be closed.\n\n### forwardLocalPortToMqtt(mqttClient, portNumber, topic)\n\nEstablished a local socket listener on `portNumber`.  When connections are established,\nthe connection and data are forward to mqtt topic `<topic>/tunnel/down/+`\n\nIt also uses the supplied `mqttClient` object to subscribe and listen for messages\non topic `<topic>/tunnel/up/+` to return back to the local socket.\n\n\n## Example\n\nIf you have a device, you wish to be able to establish a ssh connection with,\nover mqtt, you first need to use `forwardMqttToLocalPort`.  This function will subscribe\nto a specific topic, and forward connections to a local ssh server running on your device.\n\nThis will need to be paried with the `forwardLocalPortToMqtt` running on another device.  This function\nwill establish a service for a specific port, and upon receiving connections/data, forward that to the appropriate device's topic\n\nOn your device, you first need a mqtt connection object - you can use the standard [mqtt library](https://github.com/mqttjs/MQTT.js)\nor if you are using AWS [aws-iot-device-sdk-js](https://github.com/aws/aws-iot-device-sdk-js)\n\nOnce you have created your mqttClient object, you can then invoke the `forwardMqttToLocalPort` function\n\n```\n  import {forwardMqttToLocalPort} from 'mqtt-port-forward'\n\n  // Forward requests received on mqtt topic 'mydevicessh/tunnel/down/+'\n  forwardMqttToLocalPort(mqttClient, 22, 'mydevice')\n\n```\n\nThen on the client device (eg: your laptop)\n\n```\n  import {forwardMqttToLocalPort} from 'mqtt-port-forward'\n\n  // Listen on localhost:2222 for connection requests and forward to 'mydevice/tunnel/down/+'\n  forwardLocalPortToMqtt(mqttClient, 2222, 'mydevicessh')\n```\n\nYou will need to ensure your 2 connections are authorised to send and received on\nthe topics `<topic>/tunnel/down/+` and `<topic/tunnel/up/+>`\n\n\n## License\n\n[MIT](LICENSE) © Dean Netherton\n","readmeFilename":"README.md"}