GithubHelp home page GithubHelp logo

xmpp-echo-bot's Introduction

XMPP Echo Bot

Do you know that situation, you really really need an XMPP echo bot, but you don’t have access to high-level tools like Python to write one? All you have is openssl, bash, dig, stdbuf and sed? Then this tool is for you.

This is an XMPP echo bot written in (mostly) sed. Bash is used to do the pre-authentication setup (look up DNS records, establish TLS via openssl s_client). sed processes the XML stream and handles all interaction with the server on the XMPP level. Yes, this kinda parses XML in sed.

Tested to work against Prosody 0.9.

Usage

./echoz.sh user@domain password

Supported Features

Testimonials

  • This is crazy, I haven't crashed it yet!Matthew Wild
  • I'm frightened. It's only two steps away from gaining consciousness.Georg Lukas
  • I am simultaneously appalled and in awe. wowLance
  • With Echoz.sed, we were able to reduce our XMPP Echo server costs by 90% compared to our previous TeX-based solution. — Leon
  • While simple and limited, sed is sufficiently powerful for a large number of purposes.Wikipedia
  • oh my god this actually worksTest

Implementation Details

  • We use tr to convert > to \n -- since sed is line (or NUL) based, there’s not really another way to parse XMPP XML (which generally never contains newlines) with sed.
  • TLS is handled outside of sed for similar reasons. And to keep my sanity (some people might question whether I still have any bit of sanity left).
  • Likewise, SRV lookup and composition of the authentication data is entirely handled in bash. This also means that only PLAIN SASL authentication is supported -- SCRAM requires a level of interactivity which would be extremely hard to achieve in sed (not impossible though; we would "just" have to implement base64 and sha1-hmac in sed).
  • Since XMPP is a protocol where the client speaks first, we need to hand sed some initial input to allow it to generate a "line" of output (the stream header). We do that with bash, and use that opportunity to pass some configuration to the sed program (namely JID and authentication string).

Design Considerations

  • We considered using xml2 to convert the XML stream into events; however, it turns out that 2xm[ doesn’t like stream resets. Also, using the tr approach also allows us to detect the end of elements, which is useful for various purposes.

xmpp-echo-bot's People

Contributors

horazont avatar

Watchers

Holger Weiß avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.