{"id":21680867,"url":"https://github.com/brunobord/ncat-chat","last_synced_at":"2025-04-12T06:33:17.748Z","repository":{"id":66505740,"uuid":"350880236","full_name":"brunobord/ncat-chat","owner":"brunobord","description":"two dummy/minimalist bash scripts for client/server chatting using ncat/netcat","archived":false,"fork":false,"pushed_at":"2021-04-30T21:28:37.000Z","size":17,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-26T01:51:10.178Z","etag":null,"topics":["bash","chat","cli","client-server","ncat","netcat"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brunobord.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-23T22:56:32.000Z","updated_at":"2023-03-25T20:52:45.000Z","dependencies_parsed_at":"2023-02-24T00:46:01.271Z","dependency_job_id":null,"html_url":"https://github.com/brunobord/ncat-chat","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunobord%2Fncat-chat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunobord%2Fncat-chat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunobord%2Fncat-chat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunobord%2Fncat-chat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brunobord","download_url":"https://codeload.github.com/brunobord/ncat-chat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248529354,"owners_count":21119494,"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":["bash","chat","cli","client-server","ncat","netcat"],"created_at":"2024-11-25T15:21:50.488Z","updated_at":"2025-04-12T06:33:17.718Z","avatar_url":"https://github.com/brunobord.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# netcat-based chat\n\n[![GitHub release](https://img.shields.io/github/release/brunobord/ncat-chat.svg)](https://github.com/brunobord/ncat-chat/releases/)\n\nDid you know that you could run a chat service using only `netcat`/`ncat`?\n\n## BIG DISCLAIMER\n\n**This solution is by no mean production-safe. It's a toy.**\n\n* Anybody can usurp anybody's identity, there's no real control on the usernames.\n* `ncat` is a hell of a tool, but even if it has a quite large `--max-conns` argument (set to 100 on \\*Nix, 60 on Windows), there's no guarantee that it can handle the network traffic or the CPU load.\n\n## Requirements\n\n* `ncat` for servers \u0026 clients,\n* `awk`,\n* `mawk` (optional, only used in a \"bare-bones\" example below).\n* `rlwrap` (optional, to use arrow keys in the client).\n\n## License\n\nSince this client/server toolkit is basically stolen from here and there examples found on the Internet, that wouldn't be fair to assign a privative license to it.\n\nSo this piece of software is published under the terms of the WTFPL (v2).\n\nCopyright © 2021 Bruno Bord \u003cbruno@jehaisleprintemps.net\u003e\nThis work is free. You can redistribute it and/or modify it under the\nterms of the Do What The Fuck You Want To Public License, Version 2,\nas published by Sam Hocevar. See the COPYING file for more details.\n\n## Running the server\n\n### \"Bare bones\" servers\n\nA \"Bare bones\" server would run using:\n\n```sh\nncat --ssl --broker --listen -p \u003cport-number\u003e\n```\n\nYou may assign any (available) port number for your server.\n\nAnother way is to use the `--chat` parameter of `ncat`. But it prefixes every message with an arbitrary identifier. It makes you sure that nobody is usurpating your identity, but it might not be readable to have `\u003cuser1\u003e`, `\u003cuser2\u003e` or `\u003cuser3\u003e` talking to each other.\n\n### Our ncat server\n\nFor your convenience, we're providing a `.sh` script. The following will run a server on port `12345`.\n\n```sh\n./ncat-server.sh\n```\n\nIf you want to specify a dedicated port, you may use the following:\n\n```sh\nCHAT_PORT=\u003cport-number\u003e ./ncat-server.sh\n```\n\nYou can use the `Ctrl-C` key shortcut to stop the server.\n\n## Running a client\n\n### \"Bare bones\" clients\n\nRun a chat client using:\n\n```sh\nncat --ssl \u003cserver-address-or-hostname\u003e \u003cport-number\u003e\n```\n\n*Tip*: you can even test this on your own PC, in two separate shell sessions, where the server hostname would be: `localhost`.\n\nIf you want to make sure that your username/nickname is sent each time you're sending a message, you may try to use `mawk` along:\n\n```sh\nmawk -W interactive '$0=\"Alice: \"$0' | ncat --ssl \u003cserver-address-or-hostname\u003e \u003cport-number\u003e\n```\n\n#### About the SSL option\n\nBy default, the `ncat-client.sh` and `ncat-server.sh` scripts we're providing use SSL encryption.\n\nIt's a bit safer for your privacy, because it prevents intruders to sniff your messages over the network. Although, as long as someone knows both your hostname and port, they can access your messaging service, so… things are not as safe as they seem.\n\nPlease note that, if your server uses SSL, your client must use it also, otherwise you won't be able to send and receive messages through it.\n\nAnd, if you intend to *avoid* using SSL, the clients connected to it shouldn't use the `--ssl` option either, and you'll have to use the barebones clients \u0026 servers for that.\n\n### Our client\n\nFor your convenience, there's even a `.sh` script. If you want to connect to the default server on your PC, run:\n\n```sh\n./ncat-client.sh\n```\n\nYou'll then be connected to the server on `localhost` on port `12345`. But the discussion here will be limited, since you'll be the only person speaking. And if you open another shell and run the same command, and try to write messages, you'll see that all messages are prefixed by your `username@host` (extracted from the result of the `whoami` \u0026 `hostname` commands).\n\nSimilarly to the server port, you can also use environment variables to change your connection parameters. See the following example:\n\n```sh\nCHAT_HOST=alice-laptop CHAT_PORT=9999 CHAT_USER=Bob ./ncat-client.sh\n```\n\nYou can use the `Ctrl-D` key shortcut to disconnect.\n\n#### Colors\n\nYou may chose the color with which your messages will be received by the other users. By default, no specific colour will be sent along. If you want to change that, use the `CHAT_COLOR` environment variable, such as:\n\n```sh\nCHAT_COLOR=cyan ./ncat-client.sh\n```\n\nAvailable colors:\n\n* `red`\n* `green`\n* `yellow`\n* `blue`\n* `magenta`\n* `cyan`\n* `white`\n\nIf you're providing an unknown color, the \"no-color\" will be used.\n\n### User-friendly interface with `rlwrap`\n\nYou may notice that if you want to use arrows to move your cursor up/down or left/right, it inserts characters such as `^[[A^` or `[[D`. In order to enable arrow keys, you'd need to wrap launching the client script with the `rlwrap` tool, which wraps your program around GNU Readline.\n\nThen you can edit your message before sending it using right/left keys, and browse your input history using up/down arrow keys.\n\nExample usage:\n\n```sh\nrlwrap ./ncat-client.sh\n```\n\nOr, with environment variables:\n\n```sh\nCHAT_COLOR=blue CHAT_HOST=alice-laptop CHAT_PORT=9999 CHAT_USER=Bob rlwrap ./ncat-client.sh\n```\n\nPlease note that the call to `rlwrap` should appear *after* the environment variable definitions, not before.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunobord%2Fncat-chat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrunobord%2Fncat-chat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunobord%2Fncat-chat/lists"}