{"id":13455152,"url":"https://github.com/markelog/adit","last_synced_at":"2025-04-11T19:33:36.320Z","repository":{"id":66168910,"uuid":"43668735","full_name":"markelog/adit","owner":"markelog","description":"SSH tunnels – in any way you want it","archived":false,"fork":false,"pushed_at":"2017-03-05T21:13:21.000Z","size":131,"stargazers_count":55,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T15:32:30.685Z","etag":null,"topics":["adit","forwarding","reverse","ssh","ssh-tunnel","tunnel"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markelog.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-10-05T06:31:16.000Z","updated_at":"2024-10-07T07:55:38.000Z","dependencies_parsed_at":"2024-01-02T20:58:30.023Z","dependency_job_id":null,"html_url":"https://github.com/markelog/adit","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markelog%2Fadit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markelog%2Fadit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markelog%2Fadit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markelog%2Fadit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markelog","download_url":"https://codeload.github.com/markelog/adit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248467305,"owners_count":21108624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adit","forwarding","reverse","ssh","ssh-tunnel","tunnel"],"created_at":"2024-07-31T08:01:01.824Z","updated_at":"2025-04-11T19:33:36.240Z","avatar_url":"https://github.com/markelog.png","language":"JavaScript","readme":"# Adit [![Build Status](https://travis-ci.org/markelog/adit.svg?branch=master)](https://travis-ci.org/markelog/adit) [![Coverage Status](https://coveralls.io/repos/github/markelog/adit/badge.svg?branch=master\u0026t=CdowK8)](https://coveralls.io/github/markelog/adit?branch=master)\n\nForward all your stuff through ssh tunnel.\n\nThere is a lot of examples out there how this could be useful, for example, check out \"[SSH Tunnel - Local and Remote Port Forwarding Explained With Examples](http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html)\"\n\n## Usage\n\n### ssh and `Adit`\n```sh\n$ ssh -L 9000:imgur.com:80 example.com\n```\n\n```js\nnew Adit('9000:imgur.com:80 example.com'/*, password*/).forward().then(adit =\u003e {\n  console.log('success');\n\n  adit.close();\n});\n```\n\n`$ ssh -R 9000:localhost:3000 example.com`\n\n```js\nnew Adit('9000:localhost:3000 example.com'/*, password*/).reverse().then(adit =\u003e {\n  console.log('success');\n\n  adit.close();\n});\n```\n### Listen for events\n```js\nlet server = new Adit(...);\nserver.on('ready', ...);\nserver.on('tcp connection', ...)\nserver.on('error', ...);\nserver.on('data', ...);\n\nserver.forward(...).then(...);\n```\n\n### Thorough  \n\n```js\nimport Adit from 'adit';\n\nlet adit = new Adit({\n  \n  host: `example.com`\n\n  // Everything else is optional\n  // username: 'tester' // By default, `USER` environment variable will be used\n\n  // port: 22, // 22 By default\n  // Or port range - \n  // port: [22, 23], the first available port of the three will be used\n\n  // Also, see \"Authentification strategy\" below - \n  // \"agent\": \"path\",\n  // \"password\": \"pass\",\n  // \"key\": Buffer\n});\n\n// Or just\nlet adit = new Adit('example.com');\n\n// `3` - is how many times we want to try to connect, before bailing out */\nadit.open(3).then(connection =\u003e {\n  // At this point we established connection with remote server\n\n  // Forward all connections from **local** server to remote one\n  connection.out({\n    // from\n    host: 'example.com'\n    port: 80\n  }, {\n    // To\n    host: 'localhost'\n    port: 8080,\n    // Or port range - \n    // port: [25, 28], the first available port of the three will be used\n  }).then(() =\u003e {\n    // Forwarding is enabled\n  });\n\n  // Forward all connections from **remote** server to local one\n  connection.in({\n    // from\n    host: 'example.com'\n    port: 80,\n    // Or port range - \n    // port: [25, 28], the first available port of the three will be used\n  }, {\n    // To\n    host: 'localhost'\n    port: 8080\n  }).then(() =\u003e {\n    // Forwarding is enabled\n  });\n}, error =\u003e {\n  console.error(error);\n});\n\nadit.on('error', () =\u003e {\n  // Report error\n});\n\n// Then, after awhile you would want to close it\nadit.close();\n```\n\n## Authentification strategy\n* If `password` is defined - use it\n* If `agent` or `key` is defined explicitly - use one of them, prioritize the `agent`\n* If `agent` or `key` is not passed - use environment varibles (`SSH_AUTH_SOCK` for `agent`) \n\nNote: if `key` is used, assume it is added without passphrase, otherwise you should use `agent`\n\n","funding_links":[],"categories":["Packages","包","目录","\u003ca id=\"01e6651181d405ecdcd92a452989e7e0\"\u003e\u003c/a\u003e工具","Miscellaneous","Number"],"sub_categories":["Miscellaneous","其他","\u003ca id=\"9d6789f22a280f5bb6491d1353b02384\"\u003e\u003c/a\u003e隧道\u0026\u0026穿透","杂项"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkelog%2Fadit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkelog%2Fadit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkelog%2Fadit/lists"}