Copyright (c) 2012, Ivan Vucica, http://ivan.vucica.net/
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This is a small XMPP bot that makes use of TUN/TAP virtual network capability of the operating system to add a virtual network card, and then sends all network traffic over XMPP to the target party via message stanzas.
This was primarily a proof-of-concept hack to allow communication with a certain emulator running in a browser. (Network traffic is sent from the emulator into browser-based XMPP client, and the client then sends it to the XMPP server which can forward the traffic onwards). If it were to be done properly, at the very least it'd have to use the InBand Bytestreams as defined in XEP-0047.
If it were to be done even better, it'd use Jingle to negotiate the channel with some of the candidates being in-band, and some actually determined via ICE and the data being transmitted peer-to-peer.
However, that was not the goal; the goal was to allow exchange of traffic with the sandboxed emulator, and to do so in the easiest way possible.
This uses xmpppy library.
More specifically, xmpppy-0.5.0rc1 was used. Unpack
and place the
xmpp/ subfolder directly into xmpptuntap's folder.
Add Linux support. Currently, a static TAP device is opened, in the way TUN/TAP support works under Mac OS X.
Switch to Jingle negotiation. Even if true p2p support is not added, it'd still be nice to make things compatible with someone's theoretical future client. (XEP-0166)
Switch to in-band bytestreams. This would tolerate incoming data coming out of order. (XEP-0047, XEP-0261)