{"id":18151293,"url":"https://github.com/msantos/xmppipe","last_synced_at":"2026-03-08T07:31:57.002Z","repository":{"id":31875949,"uuid":"35444287","full_name":"msantos/xmppipe","owner":"msantos","description":"stdio over XMPP","archived":false,"fork":false,"pushed_at":"2025-04-22T11:45:58.000Z","size":295,"stargazers_count":25,"open_issues_count":2,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-28T18:03:05.553Z","etag":null,"topics":["capsicum","chatbot","pledge","seccomp","xmpp"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msantos.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-05-11T19:10:42.000Z","updated_at":"2025-04-22T11:46:02.000Z","dependencies_parsed_at":"2025-04-28T17:49:51.627Z","dependency_job_id":null,"html_url":"https://github.com/msantos/xmppipe","commit_stats":{"total_commits":249,"total_committers":2,"mean_commits":124.5,"dds":0.008032128514056214,"last_synced_commit":"1b9986edcc7d5d33cf728ade15159337963ae12b"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/msantos/xmppipe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Fxmppipe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Fxmppipe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Fxmppipe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Fxmppipe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msantos","download_url":"https://codeload.github.com/msantos/xmppipe/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Fxmppipe/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30248874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T05:41:50.788Z","status":"ssl_error","status_checked_at":"2026-03-08T05:41:39.075Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["capsicum","chatbot","pledge","seccomp","xmpp"],"created_at":"2024-11-02T01:07:15.984Z","updated_at":"2026-03-08T07:31:56.996Z","avatar_url":"https://github.com/msantos.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SYNOPSIS\n\nxmppipe [*options*] [*jid*]\n\n# DESCRIPTION\n\nxmppipe - stdio over XMPP\n\nxmppipe redirects stdin/stdout in a shell pipeline to an XMPP MUC\n(XEP-0045) or a one to one chat:\n\n* supports flow control using stream management (XEP-0198)\n* optionally deals with overload by acting as a circuit breaker or by\n  discarding messages\n* works with line oriented tools like grep, sed and\n  awk by outputting each message as a newline terminated,\n  [percent-encoded](https://en.wikipedia.org/wiki/Percent-encoding) string\n\nxmppipe can be used in shell scripts to quickly write interactive bots\nfor monitoring systems or for sending alerts.\n\n# USAGE\n\n```bash\nxmppipe [*options*]\n\nXMPPIPE_USERNAME=me@example.com\nXMPPIPE_PASSWORD=\"password\"\n\n# default name: stdout-*hostname*-*uid*\nxmpipe\nxmppipe muc\nxmppipe muc@example.com\n```\n\n# REQUIREMENTS\n\n* [libstrophe](https://github.com/strophe/libstrophe)\n\n  libstrophe 0.9.2 or later is required for [TLS certificate\n  verification](https://github.com/strophe/libstrophe/issues/100).\n\n# BUILD\n\n```bash\n$ make\n```\n\n## Tests\n\n```bash\n# Install bats:\n# apt-get install bats\nmake test\n```\n\n# PROCESS RESTRICTIONS\n\nxmppipe restricts process operations at 2 points:\n\n* a permissive \"init\" sandbox allowing network connections to the\n  XMPP server\n\n* once the connection is established, a stricter \"stdio\" sandbox\n  limits the process to I/O operations\n\nThe effectiveness of the process restrictions depend on which mechanism\nis used. By default:\n\n* Linux:\n\n  * init: seccomp(2)\n  * stdio: seccomp(2)\n\n* OpenBSD:\n\n  * init: pledge(2)\n  * stdio: pledge(2)\n\n* FreeBSD:\n\n  * init: setrlimit(2)\n  * stdio: setrlimit(2)/capsicum(4)\n\n* other: setrlimit(2)\n\n  * init: setrlimit(2)\n  * stdio: setrlimit(2)\n\nSelecting which process restrictions are enforced is done at compile\ntime. For example, to use the \"rlimit\" process restrictions:\n\n```bash\nRESTRICT_PROCESS=rlimit make\n```\n\nIf the process restrictions are interfering with normal operation, please\nopen an issue. To disable all process restrictions, compile using the\n\"null\" sandbox:\n\n```bash\nRESTRICT_PROCESS=null make\n```\n\n# OPTIONS\n\n-u, --username *JID*\n: XMPP username: takes precedence over environment variable\n\n-p, --password *password*\n: XMPP password: takes precedence over environment variable\n\n-r, --resource *resource*\n: XMPP resource, used as the nickname in the MUC\n\n-S, --subject *subject*\n: XMPP MUC subject\n\n-a, --address *address[:port]*\n: Specify the IP address and port of the XMPP server\n\n-F, --format *text|csv*\n: stdin is text (default) or colon separated values\n\n-d, --discard\n: Discard stdin when MUC is empty\n\n-D, --discard-to-stdout\n: Discard stdin and print to local stdout\n\n-e, --ignore-eof\n: Ignore stdin EOF\n\n-s, --exit-when-empty\n: Exit when MUC is empty\n\n-x, --base64\n: Base64 encode/decode data\n\n-b, --buffer-size *size*\n: Size of read buffer\n\n-I, --interval *interval*\n: Request stream management status every interval messages\n\n-k, --keepalive *seconds*\n: Periodically send a keepalive\n\n-K, --keepalive-failures *count*\n: Number of keepalive failures before exiting\n\n-P, --poll-delay *ms*\n: Poll delay\n\n-v, --verbose\n: Increase verbosity\n\n-V, --version\n: Display version\n\n--chat\n: Use one to one chat\n\n--no-tls-verify\n: Disable TLS certificate verification\n\n# ENVIRONMENT VARIABLES\n\nXMPPIPE_USERNAME\n: XMPP jid\n\nXMPPIPE_PASSWORD\n: XMPP password\n\n# DECODING PERCENT-ENCODED STRINGS\n\nUsing bash:\n\n```bash\ndecode() {\n  printf '%b' \"${1//%/\\\\x}\"\n}\n```\n\n# EXAMPLES\n\n## Shell Bot\n\nAn interactive XMPP bot written in the shell:\n\n```bash\n#!/bin/bash\n\nset -o errexit\nset -o nounset\nset -o pipefail\n\ndecode() {\n  printf '%b' \"${1//%/\\\\x}\"\n}\n\nbot() {\n  while IFS=: read -r stanza type from to body; do\n    case \"$stanza\" in\n      m) ;;\n\n      p)\n        decode \"$stanza:$type:$from:$to\" 1\u003e\u00262\n        echo 1\u003e\u00262\n        continue\n        ;;\n\n      *) continue ;;\n    esac\n\n    USER=\"$(decode \"${from#*/}\")\"\n    MSG=\"$(decode \"${body}\")\"\n\n    case $MSG in\n      *\"has set the subject to:\"*) ;;\n      \"sudo make me a sandwich\")\n        echo \"$USER: you're a sandwich\"\n        ;;\n      sudo*)\n        echo \"I'm sorry, $USER. I'm afraid I can't do that.\"\n        ;;\n      uptime)\n        uptime\n        ;;\n      exit)\n        echo \"exiting ...\"\n        exit 0\n        ;;\n      *)\n        echo \"$MSG\"\n        ;;\n    esac\n  done\n}\n\ncoproc bot\nxmppipe \"$@\" \u003c\u0026\"${COPROC[0]}\" \u003e\u0026\"${COPROC[1]}\"\n```\n\n## Sending Notifications/Alerts\n\nStart `xmppipe` attached to a pipe:\n\n```bash\nmkfifo /tmp/xmpp\n\nxmppipe -o groupchat \u003c\u003e/tmp/xmpp\n```\n\nAny data written to the pipe will be sent to the groupchat:\n\n```bash\necho \"test\" \u003e/tmp/xmpp\n\ndf -h \u003e/tmp/xmpp\n\ngit diff \u003e/tmp/xmpp\n```\n\n## SSH over XMPP\n\nSee [examples/ssh-over-xmpp](https://github.com/msantos/xmppipe/blob/master/examples/ssh-over-xmpp):\n\n```bash\n# Server: has access to the destination SSH server\n# ssh-over-xmpp server \u003cconference\u003e \u003cIP address\u003e \u003cport\u003e\nssh-over-xmpp server sshxmpp 1.2.3.4 22\n\n## Client: has access to the XMPP server\nssh -o ProxyCommand=\"ssh-over-xmpp client sshxmpp\" 127.0.0.1\n```\n\n## Stream Events from Riemann\n\nThis example will stream events from a query to an XMPP MUC using\n[Riemann's](https://github.com/riemann/riemann) SSE interface. The events\nare written to a named pipe to avoid buffering.\n\n```bash\ncoproc curl -s --get --data subscribe=true \\\n  --data-urlencode 'query=(service ~= \"^example\")' \\\n  http://example.com:80/index \u003c/dev/null\nxmppipe --verbose --verbose \\\n  --discard --subject \"riemann events\" muc \u003c\u0026\"${COPROC[0]}\"\n```\n\n### Desktop Notifications\n\n```bash\n#!/bin/bash\n\nset -o errexit\nset -o nounset\nset -o pipefail\n\ndecode() {\n  printf '%b' \"${1//%/\\\\x}\"\n}\n\nMUC=\"\"\n\nwhile getopts \":o:\" opt; do\n  case $opt in\n    o) MUC=\"$OPTARG\" ;;\n    *) ;;\n  esac\ndone\n\nxmppipe \"$@\" | while IFS=: read -r stanza _ _ _ body; do\n  case \"$stanza\" in\n    m) notify-send \"$MUC\" \"$(decode \"$body\")\" ;;\n    *) continue ;;\n  esac\ndone\n```\n\n### Mirror a terminal session using script(1)\n\n* user\n\n```bash\n#!/bin/bash\n\nMUC=console\n\nTMPDIR=$(mktemp -d)\nFIFO=$TMPDIR/console\nmkfifo \"$FIFO\"\n\nstty cols 80 rows 24\nxmppipe --resource user -x $MUC \u003c \"$FIFO\" \u003e/dev/null 2\u003e\"$TMPDIR/stderr\" \u0026\nscript -q -f \"$FIFO\"\n```\n\n* viewers\n\n```bash\n#!/bin/bash\n\ndecode() {\n  printf '%b' \"${1//%/\\\\x}\"\n}\n\nstty cols 80 rows 24\nxmppipe --resource viewer --base64 console |\n  while IFS=: read -r _ _ _ _ m; do\n    [ \"$m\" = \"m\" ] \u0026\u0026 decode \"$m\"\n  done\n```\n\n## Image Upload\n\nUpload an image using HTTP Upload (XEP-0363) then display it inline.\n\nSee [examples/image-upload](https://github.com/msantos/xmppipe/blob/master/examples/image-upload):\n\n```bash\nimage-upload -o groupchat\n```\n\n```\n# file must be in the same working directory as image-upload\necho \"upload::::example.png\" \u003e/tmp/image_upload/stdin\n```\n\n# FORMAT\n\nEach message is terminated by a new line. Message fields are separated by\n\":\" and percent encoded.\n\nColon separated values are accepted as input if the input format type\nis set to csv (`--format=csv`).\n\n## Presence\n\n```\np:\u003cavailable|unavailable\u003e:\u003cto jid\u003e:\u003cfrom jid\u003e\n```\n\n### Input/Output\n\nBoth\n\n### Example\n\n```\np:available:test@muc.example.com/xmppipe:occupant@example.com/1234\n```\n\n## Message\n\n```\nm:\u003cchat|groupchat|normal|headline\u003e:\u003cfrom jid\u003e:\u003cto jid\u003e:\u003cmessage body\u003e\n```\n\n### Input/Output\n\nBoth\n\n### Example\n\n```\nm:groupchat:test@muc.example.com/mobile:user1@example.com/1234:Hello\nm:chat:user1@example.com/mobile:user2@example.com:Message%20goes%20here\n```\n\n## Inline Image\n\nInline images will add a hint so clients (notably\n[Conversations](https://github.com/iNPUTmice/Conversations)) will display\nthe image instead of a URL.\n\n* type, from and to are optional\n* message body: the percent escaped URL\n\n```\nI:\u003cchat|groupchat|normal|headline\u003e:\u003cfrom jid\u003e:\u003cto jid\u003e:\u003curl\u003e\n```\n\n### Input/Output\n\nInput only\n\n### Example\n\n```\nI::::https%3A%2F%2Fhttpstatusdogs.com%2Fimg%2F500.jpg\n```\n\n## XEP-0363: HTTP Upload\n\nHTTP uploads create an upload slot. The XMPP server will respond with\n`get` and `put` URLs. The `put` URL can be used to upload the file using,\ne.g., `curl`. The `get` URL is used by clients for downloading the file.\n\nNote: xmppipe creates the upload slot. Another utility, such as curl,\ncan be used to upload the file.\n\nThe input format is:\n\n* type, from and to are optional\n* message body: percent escaped, pipe separated value\n  * filename\n  * size\n  * optional: MIME type\n\n```\nu:\u003cchat|groupchat|normal|headline\u003e:\u003cfrom jid\u003e:\u003cto jid\u003e:\u003cfilename\u003e|\u003csize (bytes)\u003e[|\u003ccontent-type\u003e]\n```\n\nThe output format is:\n\n* type, from and to are optional\n* message body: percent escaped, pipe separated value\n  * get URL\n  * put URL\n\n```\nU:\u003cchat|groupchat|normal|headline\u003e:\u003cfrom jid\u003e:\u003cto jid\u003e:\u003cget URL\u003e|\u003cput URL\u003e\n```\n\n### Example\n\n```\n# $ stat --format=\"%s\" example.png\n# 16698\nu::::example.png%7C16698\n\n# also specify content type\nu::::example.png%7C16698%7Cimage%2Fpng\n\n# server response: slot created\nU:groupchat:upload.example.com:user@example.com/123:https%3A//example.com/upload/0b9da82fea20a78778cbeddeab0472286cc35ed1/xyEaWFVZv3sv5ay9AGH5qBU02gglZRyUeGbjQg3k/example.png%7chttps%3A//example.com/upload/0b9da82fea20a78778cbeddeab0472286cc35ed1/xyEaWFVZv3sv5ay9AGH5qBU02gglZRyUeGbjQg3k/example.png\n\n# to upload the file\ncurl https://example.com/upload/0b9da82fea20a78778cbeddeab0472286cc35ed1/xyEaWFVZv3sv5ay9AGH5qBU02gglZRyUeGbjQg3k/example.png --upload-file example.png\n```\n\n# COMPATIBILITY\n\nTesting is done with ejabberd.\n\nAlso confirmed to work with:\n\n* ejabberd ([creep.im](https://compliance.conversations.im/server/creep.im/))\n* prosody ([dismail.de](https://compliance.conversations.im/server/dismail.de/))\n* openfire ([jab.im](https://compliance.conversations.im/server/jab.im/))\n* tigase ([tigase.im](https://compliance.conversations.im/server/tigase.im/))\n* mongooseim\n\n# LICENSE\n\nCopyright (c) 2015-2025, Michael Santos michael.santos@gmail.com\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\nWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\nANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\nOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\n# TODO\n\n* support [XEP-0384: OMEMO Encryption](https://xmpp.org/extensions/xep-0384.html)\n\n* support alternative input modes\n  * \"raw\" mode: XML input/output\n\n* HTTP Upload\n  * support PUT header elements\n  * handle error conditions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsantos%2Fxmppipe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsantos%2Fxmppipe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsantos%2Fxmppipe/lists"}