initial commit, working examples of echo services for XMPP (data/toxmpp.py) and Tox (data/textecho.py); toxmpp docker image contains tmux and tmuxinator, and a helper session, to be removed from release version
commit
79c43b01f5
|
@ -0,0 +1,20 @@
|
|||
http://spectrum.im/
|
||||
http://spectrum.im/documentation/tutorials/gateway_mode.html
|
||||
https://github.com/hanzz/libtransport/blob/master/plugin/python/NetworkPlugin.py
|
||||
|
||||
http://delx.net.au/projects/pymsnt/devel.html
|
||||
|
||||
http://xmpppy.sourceforge.net/
|
||||
https://github.com/normanr/irc-transport/blob/master/irc.py
|
||||
https://github.com/normanr/irc-transport/blob/master/IRC-Transport-Howtouse.html
|
||||
http://xmpppy.sourceforge.net/apidocs/index.html
|
||||
|
||||
https://www.ejabberd.im/node/5134
|
||||
http://xmpp.org/extensions/xep-0114.html
|
||||
http://sleekxmpp.com/getting_started/component.html
|
||||
https://twistedmatrix.com/trac/wiki/XMPPServerArchitecture
|
||||
|
||||
https://github.com/aitjcize/tox-irc-sync/blob/master/tox-irc-sync.py
|
||||
|
||||
https://wiki.tox.im/Nodes
|
||||
https://blog.tox.im/running-a-bootstrap-node/
|
|
@ -0,0 +1,14 @@
|
|||
FROM debian:jessie
|
||||
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get upgrade -y
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends prosody lua-event lua-zlib lua-sec
|
||||
|
||||
# expose ports
|
||||
EXPOSE 5222 5269 5280 5347
|
||||
|
||||
# add config dir
|
||||
ADD prosody.cfg.lua /etc/prosody/prosody.cfg.lua
|
||||
RUN mkdir -p /var/run/prosody/ && mkdir -p /var/lib/prosody/ && chown -R prosody:prosody /etc/prosody/prosody.cfg.lua /var/run/prosody/ /var/lib/prosody/
|
||||
|
||||
USER prosody
|
||||
CMD prosody
|
|
@ -0,0 +1,190 @@
|
|||
-- Prosody Example Configuration File
|
||||
--
|
||||
-- Information on configuring Prosody can be found on our
|
||||
-- website at http://prosody.im/doc/configure
|
||||
--
|
||||
-- Tip: You can check that the syntax of this file is correct
|
||||
-- when you have finished by running: luac -p prosody.cfg.lua
|
||||
-- If there are any errors, it will let you know what and where
|
||||
-- they are, otherwise it will keep quiet.
|
||||
--
|
||||
-- The only thing left to do is rename this file to remove the .dist ending, and fill in the
|
||||
-- blanks. Good luck, and happy Jabbering!
|
||||
|
||||
|
||||
---------- Server-wide settings ----------
|
||||
-- Settings in this section apply to the whole server and are the default settings
|
||||
-- for any virtual hosts
|
||||
|
||||
-- This is a (by default, empty) list of accounts that are admins
|
||||
-- for the server. Note that you must create the accounts separately
|
||||
-- (see http://prosody.im/doc/creating_accounts for info)
|
||||
-- Example: admins = { "user1@example.com", "user2@example.net" }
|
||||
admins = { }
|
||||
|
||||
-- Enable use of libevent for better performance under high load
|
||||
-- For more information see: http://prosody.im/doc/libevent
|
||||
--use_libevent = true;
|
||||
|
||||
-- This is the list of modules Prosody will load on startup.
|
||||
-- It looks for mod_modulename.lua in the plugins folder, so make sure that exists too.
|
||||
-- Documentation on modules can be found at: http://prosody.im/doc/modules
|
||||
modules_enabled = {
|
||||
|
||||
-- Generally required
|
||||
"roster"; -- Allow users to have a roster. Recommended ;)
|
||||
"saslauth"; -- Authentication for clients and servers. Recommended if you want to log in.
|
||||
"tls"; -- Add support for secure TLS on c2s/s2s connections
|
||||
"dialback"; -- s2s dialback support
|
||||
"disco"; -- Service discovery
|
||||
|
||||
-- Not essential, but recommended
|
||||
-- "private"; -- Private XML storage (for room bookmarks, etc.)
|
||||
-- "vcard"; -- Allow users to set vCards
|
||||
|
||||
-- These are commented by default as they have a performance impact
|
||||
--"privacy"; -- Support privacy lists
|
||||
--"compression"; -- Stream compression (Debian: requires lua-zlib module to work)
|
||||
|
||||
-- Nice to have
|
||||
"version"; -- Replies to server version requests
|
||||
"uptime"; -- Report how long server has been running
|
||||
"time"; -- Let others know the time here on this server
|
||||
--"ping"; -- Replies to XMPP pings with pongs
|
||||
--"pep"; -- Enables users to publish their mood, activity, playing music and more
|
||||
"register"; -- Allow users to register on this server using a client and change passwords
|
||||
|
||||
-- Admin interfaces
|
||||
--"admin_adhoc"; -- Allows administration via an XMPP client that supports ad-hoc commands
|
||||
--"admin_telnet"; -- Opens telnet console interface on localhost port 5582
|
||||
|
||||
-- HTTP modules
|
||||
--"bosh"; -- Enable BOSH clients, aka "Jabber over HTTP"
|
||||
--"http_files"; -- Serve static files from a directory over HTTP
|
||||
|
||||
-- Other specific functionality
|
||||
"posix"; -- POSIX functionality, sends server to background, enables syslog, etc.
|
||||
--"groups"; -- Shared roster support
|
||||
--"announce"; -- Send announcement to all online users
|
||||
--"welcome"; -- Welcome users who register accounts
|
||||
--"watchregistrations"; -- Alert admins of registrations
|
||||
--"motd"; -- Send a message to users when they log in
|
||||
--"legacyauth"; -- Legacy authentication. Only used by some old clients and bots.
|
||||
--"http";
|
||||
};
|
||||
|
||||
-- These modules are auto-loaded, but should you want
|
||||
-- to disable them then uncomment them here:
|
||||
modules_disabled = {
|
||||
-- "offline"; -- Store offline messages
|
||||
-- "c2s"; -- Handle client connections
|
||||
-- "s2s"; -- Handle server-to-server connections
|
||||
};
|
||||
|
||||
-- default host
|
||||
--http_default_host = "localhost"
|
||||
|
||||
-- for testing!
|
||||
component_interface = "*"
|
||||
|
||||
-- Disable account creation by default, for security
|
||||
-- For more information see http://prosody.im/doc/creating_accounts
|
||||
allow_registration = true;
|
||||
|
||||
-- Debian:
|
||||
-- send the server to background.
|
||||
--
|
||||
daemonize = false;
|
||||
|
||||
-- Debian:
|
||||
-- Please, don't change this option since /var/run/prosody/
|
||||
-- is one of the few directories Prosody is allowed to write to
|
||||
--
|
||||
pidfile = "/var/run/prosody/prosody.pid";
|
||||
|
||||
-- These are the SSL/TLS-related settings. If you don't want
|
||||
-- to use SSL/TLS, you may comment or remove this
|
||||
ssl = {
|
||||
key = "/etc/ssl/private/ssl-cert-snakeoil.key";
|
||||
certificate = "/etc/ssl/certs/ssl-cert-snakeoil.pem";
|
||||
}
|
||||
|
||||
-- Force clients to use encrypted connections? This option will
|
||||
-- prevent clients from authenticating unless they are using encryption.
|
||||
|
||||
c2s_require_encryption = false
|
||||
|
||||
-- Force certificate authentication for server-to-server connections?
|
||||
-- This provides ideal security, but requires servers you communicate
|
||||
-- with to support encryption AND present valid, trusted certificates.
|
||||
-- NOTE: Your version of LuaSec must support certificate verification!
|
||||
-- For more information see http://prosody.im/doc/s2s#security
|
||||
|
||||
s2s_secure_auth = false
|
||||
|
||||
-- Many servers don't support encryption or have invalid or self-signed
|
||||
-- certificates. You can list domains here that will not be required to
|
||||
-- authenticate using certificates. They will be authenticated using DNS.
|
||||
|
||||
--s2s_insecure_domains = { "gmail.com" }
|
||||
|
||||
-- Even if you leave s2s_secure_auth disabled, you can still require valid
|
||||
-- certificates for some domains by specifying a list here.
|
||||
|
||||
--s2s_secure_domains = { "jabber.org" }
|
||||
|
||||
-- Select the authentication backend to use. The 'internal' providers
|
||||
-- use Prosody's configured data storage to store the authentication data.
|
||||
-- To allow Prosody to offer secure authentication mechanisms to clients, the
|
||||
-- default provider stores passwords in plaintext. If you do not trust your
|
||||
-- server please see http://prosody.im/doc/modules/mod_auth_internal_hashed
|
||||
-- for information about using the hashed backend.
|
||||
|
||||
authentication = "internal_plain"
|
||||
|
||||
-- Select the storage backend to use. By default Prosody uses flat files
|
||||
-- in its configured data directory, but it also supports more backends
|
||||
-- through modules. An "sql" backend is included by default, but requires
|
||||
-- additional dependencies. See http://prosody.im/doc/storage for more info.
|
||||
|
||||
--storage = "sql" -- Default is "internal" (Debian: "sql" requires one of the
|
||||
-- lua-dbi-sqlite3, lua-dbi-mysql or lua-dbi-postgresql packages to work)
|
||||
|
||||
-- For the "sql" backend, you can uncomment *one* of the below to configure:
|
||||
--sql = { driver = "SQLite3", database = "prosody.sqlite" } -- Default. 'database' is the filename.
|
||||
--sql = { driver = "MySQL", database = "prosody", username = "prosody", password = "secret", host = "localhost" }
|
||||
--sql = { driver = "PostgreSQL", database = "prosody", username = "prosody", password = "secret", host = "localhost" }
|
||||
|
||||
-- Logging configuration
|
||||
-- For advanced logging see http://prosody.im/doc/logging
|
||||
--
|
||||
-- Debian:
|
||||
-- Logs info and higher to /var/log
|
||||
-- Logs errors to syslog also
|
||||
log = {
|
||||
-- Log files (change 'info' to 'debug' for debug logs):
|
||||
debug = "/var/log/prosody/prosody.log";
|
||||
error = "/var/log/prosody/prosody.err";
|
||||
-- Syslog:
|
||||
-- { levels = { "error" }; to = "syslog"; };
|
||||
}
|
||||
|
||||
----------- Virtual hosts -----------
|
||||
-- You need to add a VirtualHost entry for each domain you wish Prosody to serve.
|
||||
-- Settings under each VirtualHost entry apply *only* to that host.
|
||||
|
||||
VirtualHost "tox-prosody"
|
||||
|
||||
------ Components ------
|
||||
-- You can specify components to add hosts that provide special services,
|
||||
-- like multi-user conferences, and transports.
|
||||
-- For more information on components, see http://prosody.im/doc/components
|
||||
|
||||
---Set up an external component (default component port is 5347)
|
||||
--
|
||||
-- External components allow adding various services, such as gateways/
|
||||
-- transports to other networks like ICQ, MSN and Yahoo. For more info
|
||||
-- see: http://prosody.im/doc/components#adding_an_external_component
|
||||
--
|
||||
Component "tox.tox-prosody"
|
||||
component_secret = "changeme"
|
|
@ -0,0 +1,114 @@
|
|||
[('CHAT_CHANGE_PEER_ADD', 0L),
|
||||
('CHAT_CHANGE_PEER_DEL', 1L),
|
||||
('CHAT_CHANGE_PEER_NAME', 2L),
|
||||
('FAERR_ALREADYSENT', -4L),
|
||||
('FAERR_BADCHECKSUM', -6L),
|
||||
('FAERR_NOMEM', -8L),
|
||||
('FAERR_NOMESSAGE', -2L),
|
||||
('FAERR_OWNKEY', -3L),
|
||||
('FAERR_SETNEWNOSPAM', -7L),
|
||||
('FAERR_TOOLONG', -1L),
|
||||
('FAERR_UNKNOWN', -5L),
|
||||
('FILECONTROL_ACCEPT', 0L),
|
||||
('FILECONTROL_FINISHED', 3L),
|
||||
('FILECONTROL_KILL', 2L),
|
||||
('FILECONTROL_PAUSE', 1L),
|
||||
('FILECONTROL_RESUME_BROKEN', 4L),
|
||||
('GROUPCHAT_TYPE_AV', 1L),
|
||||
('GROUPCHAT_TYPE_TEXT', 0L),
|
||||
('USERSTATUS_AWAY', 1L),
|
||||
('USERSTATUS_BUSY', 2L),
|
||||
('USERSTATUS_INVALID', 3L),
|
||||
('USERSTATUS_NONE', 0L),
|
||||
('__class__', <type 'type'>),
|
||||
('__delattr__', <slot wrapper '__delattr__' of 'object' objects>),
|
||||
('__doc__', 'ToxCore object'),
|
||||
('__format__', <method '__format__' of 'object' objects>),
|
||||
('__getattribute__', <slot wrapper '__getattribute__' of 'object' objects>),
|
||||
('__hash__', <slot wrapper '__hash__' of 'object' objects>),
|
||||
('__init__', <slot wrapper '__init__' of 'Tox' objects>),
|
||||
('__new__', <built-in method __new__ of type object at 0x7f57772b1400>),
|
||||
('__reduce__', <method '__reduce__' of 'object' objects>),
|
||||
('__reduce_ex__', <method '__reduce_ex__' of 'object' objects>),
|
||||
('__repr__', <slot wrapper '__repr__' of 'object' objects>),
|
||||
('__setattr__', <slot wrapper '__setattr__' of 'object' objects>),
|
||||
('__sizeof__', <method '__sizeof__' of 'object' objects>),
|
||||
('__str__', <slot wrapper '__str__' of 'object' objects>),
|
||||
('__subclasshook__', <built-in method __subclasshook__ of type object at 0x7f57772b1400>),
|
||||
('add_friend', <method 'add_friend' of 'Tox' objects>),
|
||||
('add_friend_norequest', <method 'add_friend_norequest' of 'Tox' objects>),
|
||||
('add_groupchat', <method 'add_groupchat' of 'Tox' objects>),
|
||||
('bootstrap_from_address', <method 'bootstrap_from_address' of 'Tox' objects>),
|
||||
('count_chatlist', <method 'count_chatlist' of 'Tox' objects>),
|
||||
('count_friendlist', <method 'count_friendlist' of 'Tox' objects>),
|
||||
('del_friend', <method 'del_friend' of 'Tox' objects>),
|
||||
('del_groupchat', <method 'del_groupchat' of 'Tox' objects>),
|
||||
('do', <method 'do' of 'Tox' objects>),
|
||||
('do_interval', <method 'do_interval' of 'Tox' objects>),
|
||||
('file_data_remaining', <method 'file_data_remaining' of 'Tox' objects>),
|
||||
('file_data_size', <method 'file_data_size' of 'Tox' objects>),
|
||||
('file_send_control', <method 'file_send_control' of 'Tox' objects>),
|
||||
('file_send_data', <method 'file_send_data' of 'Tox' objects>),
|
||||
('friend_exists', <method 'friend_exists' of 'Tox' objects>),
|
||||
('get_address', <method 'get_address' of 'Tox' objects>),
|
||||
('get_chatlist', <method 'get_chatlist' of 'Tox' objects>),
|
||||
('get_client_id', <method 'get_client_id' of 'Tox' objects>),
|
||||
('get_friend_connection_status', <method 'get_friend_connection_status' of 'Tox' objects>),
|
||||
('get_friend_id', <method 'get_friend_id' of 'Tox' objects>),
|
||||
('get_friendlist', <method 'get_friendlist' of 'Tox' objects>),
|
||||
('get_is_typing', <method 'get_is_typing' of 'Tox' objects>),
|
||||
('get_keys', <method 'get_keys' of 'Tox' objects>),
|
||||
('get_last_online', <method 'get_last_online' of 'Tox' objects>),
|
||||
('get_name', <method 'get_name' of 'Tox' objects>),
|
||||
('get_name_size', <method 'get_name_size' of 'Tox' objects>),
|
||||
('get_nospam', <method 'get_nospam' of 'Tox' objects>),
|
||||
('get_num_online_friends', <method 'get_num_online_friends' of 'Tox' objects>),
|
||||
('get_self_name', <method 'get_self_name' of 'Tox' objects>),
|
||||
('get_self_name_size', <method 'get_self_name_size' of 'Tox' objects>),
|
||||
('get_self_status_message', <method 'get_self_status_message' of 'Tox' objects>),
|
||||
('get_self_status_message_size', <method 'get_self_status_message_size' of 'Tox' objects>),
|
||||
('get_self_user_status', <method 'get_self_user_status' of 'Tox' objects>),
|
||||
('get_status_message', <method 'get_status_message' of 'Tox' objects>),
|
||||
('get_status_message_size', <method 'get_status_message_size' of 'Tox' objects>),
|
||||
('get_user_status', <method 'get_user_status' of 'Tox' objects>),
|
||||
('group_action_send', <method 'group_action_send' of 'Tox' objects>),
|
||||
('group_get_names', <method 'group_get_names' of 'Tox' objects>),
|
||||
('group_get_title', <method 'group_get_title' of 'Tox' objects>),
|
||||
('group_get_type', <method 'group_get_type' of 'Tox' objects>),
|
||||
('group_message_send', <method 'group_message_send' of 'Tox' objects>),
|
||||
('group_number_peers', <method 'group_number_peers' of 'Tox' objects>),
|
||||
('group_peername', <method 'group_peername' of 'Tox' objects>),
|
||||
('group_set_title', <method 'group_set_title' of 'Tox' objects>),
|
||||
('invite_friend', <method 'invite_friend' of 'Tox' objects>),
|
||||
('isconnected', <method 'isconnected' of 'Tox' objects>),
|
||||
('join_groupchat', <method 'join_groupchat' of 'Tox' objects>),
|
||||
('kill', <method 'kill' of 'Tox' objects>),
|
||||
('load', <method 'load' of 'Tox' objects>),
|
||||
('load_from_file', <method 'load_from_file' of 'Tox' objects>),
|
||||
('new_file_sender', <method 'new_file_sender' of 'Tox' objects>),
|
||||
('on_connection_status', <method 'on_connection_status' of 'Tox' objects>),
|
||||
('on_file_control', <method 'on_file_control' of 'Tox' objects>),
|
||||
('on_file_data', <method 'on_file_data' of 'Tox' objects>),
|
||||
('on_file_send_request', <method 'on_file_send_request' of 'Tox' objects>),
|
||||
('on_friend_action', <method 'on_friend_action' of 'Tox' objects>),
|
||||
('on_friend_message', <method 'on_friend_message' of 'Tox' objects>),
|
||||
('on_friend_request', <method 'on_friend_request' of 'Tox' objects>),
|
||||
('on_group_action', <method 'on_group_action' of 'Tox' objects>),
|
||||
('on_group_invite', <method 'on_group_invite' of 'Tox' objects>),
|
||||
('on_group_message', <method 'on_group_message' of 'Tox' objects>),
|
||||
('on_group_namelist_change', <method 'on_group_namelist_change' of 'Tox' objects>),
|
||||
('on_name_change', <method 'on_name_change' of 'Tox' objects>),
|
||||
('on_read_receipt', <method 'on_read_receipt' of 'Tox' objects>),
|
||||
('on_status_message', <method 'on_status_message' of 'Tox' objects>),
|
||||
('on_typing_change', <method 'on_typing_change' of 'Tox' objects>),
|
||||
('on_user_status', <method 'on_user_status' of 'Tox' objects>),
|
||||
('save', <method 'save' of 'Tox' objects>),
|
||||
('save_to_file', <method 'save_to_file' of 'Tox' objects>),
|
||||
('send_action', <method 'send_action' of 'Tox' objects>),
|
||||
('send_message', <method 'send_message' of 'Tox' objects>),
|
||||
('set_name', <method 'set_name' of 'Tox' objects>),
|
||||
('set_nospam', <method 'set_nospam' of 'Tox' objects>),
|
||||
('set_status_message', <method 'set_status_message' of 'Tox' objects>),
|
||||
('set_user_is_typing', <method 'set_user_is_typing' of 'Tox' objects>),
|
||||
('set_user_status', <method 'set_user_status' of 'Tox' objects>),
|
||||
('size', <method 'size' of 'Tox' objects>)]
|
|
@ -0,0 +1,81 @@
|
|||
FROM debian:jessie
|
||||
|
||||
# based on Dockerfile from PyTox:
|
||||
# https://github.com/aitjcize/PyTox/blob/master/Dockerfile
|
||||
# by aitjcize
|
||||
# https://github.com/aitjcize
|
||||
# distributed under GNU GPLv3
|
||||
# https://github.com/aitjcize/PyTox/blob/master/COPYING
|
||||
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get upgrade -y
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y git wget make libtool automake pkg-config python3-pip python3-yaml
|
||||
|
||||
# test requirements
|
||||
RUN pip3 install tox
|
||||
|
||||
# we don't want everthing to be run in /, do we
|
||||
WORKDIR /opt/
|
||||
|
||||
#####################################################################
|
||||
# PyTox #
|
||||
#####################################################################
|
||||
|
||||
## python interpreters
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-common python-software-properties
|
||||
#RUN add-apt-repository -y ppa:fkrull/deadsnakes
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-dev
|
||||
|
||||
# installing libsodium, needed for Core
|
||||
RUN git clone https://github.com/jedisct1/libsodium.git
|
||||
RUN cd libsodium && git checkout tags/0.7.0 && ./autogen.sh && ./configure --prefix=/usr && make && make install
|
||||
|
||||
# installing libopus, needed for audio encoding/decoding -- no need, no audio-video functionality for the time being
|
||||
#RUN wget http://downloads.xiph.org/releases/opus/opus-1.0.3.tar.gz
|
||||
#RUN tar xzf opus-1.0.3.tar.gz
|
||||
#RUN cd opus-1.0.3 && ./configure && make && make install
|
||||
|
||||
# installing vpx -- no need, no audio-video functionality for the time being
|
||||
#RUN apt-get install -y yasm
|
||||
#RUN git clone http://git.chromium.org/webm/libvpx.git
|
||||
#RUN cd libvpx && ./configure --enable-shared && make && make install
|
||||
|
||||
# creating libraries' links and updating cache
|
||||
RUN ldconfig
|
||||
RUN git clone https://github.com/irungentoo/ProjectTox-Core.git toxcore
|
||||
RUN cd toxcore && autoreconf -i
|
||||
RUN cd toxcore && ./configure --prefix=/usr --disable-tests --disable-ntox
|
||||
RUN cd toxcore && make
|
||||
RUN cd toxcore && make install
|
||||
|
||||
# PyTox
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python-dev
|
||||
#RUN git clone https://github.com/aitjcize/PyTox.git PyTox
|
||||
ADD PyTox /opt/PyTox
|
||||
#ADD PyTox/pytox PyTox/pytox
|
||||
#ADD PyTox/setup.py PyTox/setup.py
|
||||
#ADD PyTox/examples PyTox/examples
|
||||
#ADD PyTox/tests PyTox/tests
|
||||
#ADD PyTox/MANIFEST.in PyTox/MANIFEST.in
|
||||
#ADD PyTox/tox.ini PyTox/tox.ini
|
||||
RUN cd PyTox && python3 setup.py install
|
||||
|
||||
|
||||
#####################################################################
|
||||
# SleekXMPP #
|
||||
#####################################################################
|
||||
|
||||
ADD SleekXMPP /opt/SleekXMPP
|
||||
RUN cd /opt/SleekXMPP && python3 setup.py install
|
||||
|
||||
#####################################################################
|
||||
# Utils #
|
||||
#####################################################################
|
||||
|
||||
# to be removed from the release version
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tmux ruby vim
|
||||
RUN gem install tmuxinator
|
||||
ENV EDITOR vim
|
||||
ENV SHELL /bin/bash
|
||||
RUN mkdir /root/.tmuxinator/
|
||||
ADD data/tmoxmpp.yml /.tmuxinator/
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
id="svg3039"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.4 r9939"
|
||||
width="473.84644"
|
||||
height="473.84644"
|
||||
sodipodi:docname="tox.svg"
|
||||
inkscape:export-filename="/home/rysiek/Projekty/toxmpp/toxmpp/tox.png"
|
||||
inkscape:export-xdpi="18.23"
|
||||
inkscape:export-ydpi="18.23">
|
||||
<metadata
|
||||
id="metadata3045">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs3043" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1366"
|
||||
inkscape:window-height="713"
|
||||
id="namedview3041"
|
||||
showgrid="false"
|
||||
units="mm"
|
||||
fit-margin-top="3"
|
||||
fit-margin-left="3"
|
||||
fit-margin-right="3"
|
||||
fit-margin-bottom="3"
|
||||
inkscape:zoom="0.91899853"
|
||||
inkscape:cx="229.62313"
|
||||
inkscape:cy="228.55522"
|
||||
inkscape:window-x="-4"
|
||||
inkscape:window-y="-3"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg3039" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3051"
|
||||
d="m 65.513316,462.26542 c -4.30439,-1.2902 -8.9701,-4.822 -11.7014,-8.8576 l -2.44708,-3.6157 -0.29798,-123.5 c -0.20733,-85.9256 0.029,-124.6273 0.77663,-127.205 1.3952,-4.8101 5.30375,-9.3883 10.10731,-11.8389 3.54515,-1.8086 6.02481,-1.9561 32.87421,-1.9561 l 29.039844,0 0,-33.7763 c 0,-18.5769 0.4662,-37.5894 1.036,-42.25 9.32419,-76.265196 90.3739,-120.677996 159.6842,-87.502096 11.66322,5.5827 19.54356,10.9335 28.52109,19.3659 17.17552,16.1327 28.95355,38.0599 33.38998,62.162396 1.20235,6.5323 1.61588,16.9498 1.78629,45.0001 l 0.22174,36.5 30.43035,0.5 c 32.73504,0.5378 33.48736,0.6579 38.63262,6.1686 5.56339,5.9584 5.2996,-0.6691 5.27577,132.5492 -0.0209,116.5998 -0.11366,122.984 -1.84302,126.7907 -2.2903,5.0415 -7.94198,10.0662 -12.85769,11.4313 -4.65128,1.2917 -338.322484,1.3243 -342.628864,0.034 z M 270.7649,406.22892 c 10.42264,-2.4027 14.09995,-8.2631 14.09995,-22.4707 0,-16.2502 -5.83498,-29.631 -17.61694,-40.399 -3.00365,-2.7452 -8.1866,-6.2993 -11.51765,-7.8981 l -6.05647,-2.9068 3.10322,-1.0818 c 4.73458,-1.6505 13.40767,-10.4695 16.63492,-16.9148 2.56415,-5.121 2.89062,-6.8278 2.91993,-15.2656 0.0286,-8.2317 -0.31752,-10.2343 -2.5924,-15 -7.13964,-14.9571 -22.13519,-23.1227 -38.40789,-20.9144 -12.26867,1.6649 -24.1457,11.0949 -28.44432,22.584 -2.1743,5.8114 -2.85321,16.0585 -1.44966,21.8807 1.96137,8.1363 8.19031,16.8057 15.39781,21.4308 l 4.9646,3.1857 -6.88623,3.4451 c -12.71674,6.3619 -22.2538,19.4174 -25.5498,34.9756 -4.21636,19.9027 0.37608,32.437 13.00088,35.4837 4.67828,1.1291 63.42004,1.0136 68.40005,-0.1344 z m -17.11933,-186.8585 c 20.40475,-16.414 40.92807,-41.4937 50.24087,-61.3949 13.26585,-28.3488 11.32598,-56.2882 -5.44479,-78.419696 -19.10588,-25.2131 -54.62435,-35.8297 -86.27646,-25.7883 -22.58708,7.1655 -41.80877,25.7593 -48.50238,46.917996 -2.84217,8.9842 -3.51628,26.2802 -1.39575,35.8116 5.77389,25.9525 26.03209,46.1325 54.09779,53.8889 8.57693,2.3703 22.55748,3.0691 32.3031,1.6146 l 5.30309,-0.7915 -0.67053,3.7915 c -1.158,6.5479 -4.42565,15.4722 -9.01076,24.6093 -2.4337,4.8499 -4.4249,9.0282 -4.4249,9.2852 0,1.0433 4.56895,-2.1145 13.78072,-9.5247 z"
|
||||
style="fill:#313636"
|
||||
sodipodi:nodetypes="sscscsscsssssscsssssssssscsssssssscsssssssssssscssss" />
|
||||
</svg>
|
After Width: | Height: | Size: 4.0 KiB |
|
@ -0,0 +1,98 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# @file echo-no-av.py
|
||||
# @author Michał "rysiek" Woźniak <rysiek@hackerspace.pl>
|
||||
# @author Wei-Ning Huang (AZ) <aitjcize@gmail.com>
|
||||
#
|
||||
# Copyright (C) 2015 Michał "rysiek" Woźniak <rysiek@hackerspace.pl>
|
||||
# Copyright (C) 2013 - 2014 Wei-Ning Huang (AZ) <aitjcize@gmail.com>
|
||||
# All Rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
from pytox import Tox
|
||||
|
||||
from time import sleep
|
||||
from os.path import exists
|
||||
|
||||
SERVER = [
|
||||
"172.17.42.1",
|
||||
33445,
|
||||
"3FA2E5273F0C368576FE120B374664E3B41E2CDF21639AFED3DC301490FFB01FAAA47B78D5F4"
|
||||
# "80.232.246.79",
|
||||
# 33445,
|
||||
# "0B8DCEAA7BDDC44BB11173F987CAE3566A2D7057D8DD3CC642BD472B9391002A"
|
||||
]
|
||||
|
||||
DATA = 'echo.data'
|
||||
|
||||
|
||||
class EchoBot(Tox):
|
||||
def __init__(self):
|
||||
if exists(DATA):
|
||||
self.load_from_file(DATA)
|
||||
|
||||
self.set_name("EchoBot")
|
||||
print('ID: %s' % self.get_address())
|
||||
|
||||
self.connect()
|
||||
#self.av = AV(self, 1)
|
||||
|
||||
def connect(self):
|
||||
print('connecting...')
|
||||
self.bootstrap_from_address(SERVER[0], SERVER[1], SERVER[2])
|
||||
|
||||
def loop(self):
|
||||
checked = False
|
||||
|
||||
try:
|
||||
while True:
|
||||
status = self.isconnected()
|
||||
|
||||
if not checked and status:
|
||||
print('Connected to DHT.')
|
||||
checked = True
|
||||
|
||||
if checked and not status:
|
||||
print('Disconnected from DHT.')
|
||||
self.connect()
|
||||
checked = False
|
||||
|
||||
self.do()
|
||||
sleep(0.01)
|
||||
except KeyboardInterrupt:
|
||||
self.save_to_file(DATA)
|
||||
|
||||
def on_friend_request(self, pk, message):
|
||||
print('Friend request from %s: %s' % (pk, message))
|
||||
self.add_friend_norequest(pk)
|
||||
print('Accepted.')
|
||||
|
||||
def on_friend_message(self, friendId, message):
|
||||
name = self.get_name(friendId)
|
||||
print('%s: %s' % (name, message))
|
||||
print('EchoBot: %s' % message)
|
||||
self.send_message(friendId, message)
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
DATA = sys.argv[1]
|
||||
|
||||
t = EchoBot()
|
||||
t.loop()
|
|
@ -0,0 +1,9 @@
|
|||
name: tmoxmpp
|
||||
root: /opt/data
|
||||
|
||||
windows:
|
||||
- editor:
|
||||
layout: even-horizontal
|
||||
panes:
|
||||
- python3 textecho.py
|
||||
- python3 toxmpp.py -j tox.tox-prosody -p changeme -s tox-prosody -P 5347 -d
|
|
@ -0,0 +1,187 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
SleekXMPP: The Sleek XMPP Library
|
||||
Copyright (C) 2010 Nathanael C. Fritz
|
||||
This file is part of SleekXMPP.
|
||||
|
||||
See the file LICENSE for copying permission.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import logging
|
||||
import getpass
|
||||
from optparse import OptionParser
|
||||
|
||||
import sleekxmpp
|
||||
from sleekxmpp.componentxmpp import ComponentXMPP
|
||||
|
||||
# Python versions before 3.0 do not use UTF-8 encoding
|
||||
# by default. To ensure that Unicode is handled properly
|
||||
# throughout SleekXMPP, we will set the default encoding
|
||||
# ourselves to UTF-8.
|
||||
if sys.version_info < (3, 0):
|
||||
from sleekxmpp.util.misc_ops import setdefaultencoding
|
||||
setdefaultencoding('utf8')
|
||||
else:
|
||||
raw_input = input
|
||||
|
||||
|
||||
def tdbg(txt):
|
||||
print ("TOXMPP :: %s" % txt)
|
||||
|
||||
class EchoComponent(ComponentXMPP):
|
||||
|
||||
"""
|
||||
A simple SleekXMPP component that echoes messages.
|
||||
"""
|
||||
|
||||
def __init__(self, jid, secret, server, port):
|
||||
ComponentXMPP.__init__(self, jid, secret, server, port)
|
||||
|
||||
# You don't need a session_start handler, but that is
|
||||
# where you would broadcast initial presence.
|
||||
|
||||
# The message event is triggered whenever a message
|
||||
# stanza is received. Be aware that that includes
|
||||
# MUC messages and error messages.
|
||||
self.add_event_handler("message", self.message)
|
||||
|
||||
#self.add_event_handler("presence_subscribe", self.presence_subscribe)
|
||||
# auto-managing subscriptions, for the time being
|
||||
#self.auto_authorize = True
|
||||
tdbg('setting event handlers: presence_probe, got_online, got_offline')
|
||||
self.add_event_handler('presence_probe', self.handle_probe)
|
||||
self.add_event_handler('got_online', self.got_online)
|
||||
self.add_event_handler('got_offline', self.got_offline)
|
||||
|
||||
|
||||
def message(self, msg):
|
||||
"""
|
||||
Process incoming message stanzas. Be aware that this also
|
||||
includes MUC messages and error messages. It is usually
|
||||
a good idea to check the messages's type before processing
|
||||
or sending replies.
|
||||
|
||||
Since a component may send messages from any number of JIDs,
|
||||
it is best to always include a from JID.
|
||||
|
||||
Arguments:
|
||||
msg -- The received message stanza. See the documentation
|
||||
for stanza objects and the Message stanza to see
|
||||
how it may be used.
|
||||
"""
|
||||
# The reply method will use the messages 'to' JID as the
|
||||
# outgoing reply's 'from' JID.
|
||||
msg.reply("Thanks for sending\n%(body)s" % msg).send()
|
||||
|
||||
# DEBUG
|
||||
def got_online(self, presence):
|
||||
tdbg('got online: %s for %s' % (presence['from'], presence['to']))
|
||||
|
||||
# DEBUG
|
||||
def got_offline(self, presence):
|
||||
tdbg('got offline: %s for %s' % (presence['from'], presence['to']))
|
||||
|
||||
# Why doesn't this work?
|
||||
def handle_probe(self, presence):
|
||||
sender = presence['from']
|
||||
tdbg('a presence probe from %s; replying...' % sender)
|
||||
# Populate the presence reply with the agent's current status.
|
||||
self.sendPresence(pto=sender, pstatus="Busy studying XMPP", pshow="chat")
|
||||
|
||||
# Where self is a SleekXMPP object, and self.backend is some arbitrary
|
||||
# object that you create depending on the needs of your application.
|
||||
|
||||
# self.add_event_handler('presence_subscribe', self.subscribe)
|
||||
# self.add_event_handler('presence_subscribed', self.subscribed)
|
||||
# The unsubscribe and unsubscribed handlers will be similar.
|
||||
|
||||
# If a component is being used, be sure to set the pfrom parameter
|
||||
# when sending presences if you are using multiple JIDs for the component,
|
||||
# such as user1@component.example.com and user2@component.example.com.
|
||||
|
||||
def subscribe(self, presence):
|
||||
# If the subscription request is rejected.
|
||||
if not self.backend.allow_subscription(presence['from']):
|
||||
self.sendPresence(pto=presence['from'],
|
||||
ptype='unsubscribed')
|
||||
return
|
||||
|
||||
# If the subscription request is accepted.
|
||||
self.sendPresence(pto=presence['from'],
|
||||
ptype='subscribed')
|
||||
|
||||
# Save the fact that a subscription has been accepted, somehow. Here
|
||||
# we use a backend object that has a roster.
|
||||
self.backend.roster.subscribe(presence['from'])
|
||||
|
||||
# If a bi-directional subscription does not exist, create one.
|
||||
if not self.backend.roster.sub_from(presence['from']):
|
||||
self.sendPresence(pto=presence['from'],
|
||||
ptype='subscribe')
|
||||
|
||||
def subscribed(self, presence):
|
||||
# Store the new subscription state, somehow. Here we use a backend object.
|
||||
self.backend.roster.subscribed(presence['from'])
|
||||
|
||||
# Send a new presence update to the subscriber.
|
||||
self.sendPresence(pto=presence['from'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Setup the command line arguments.
|
||||
optp = OptionParser()
|
||||
|
||||
# Output verbosity options.
|
||||
optp.add_option('-q', '--quiet', help='set logging to ERROR',
|
||||
action='store_const', dest='loglevel',
|
||||
const=logging.ERROR, default=logging.INFO)
|
||||
optp.add_option('-d', '--debug', help='set logging to DEBUG',
|
||||
action='store_const', dest='loglevel',
|
||||
const=logging.DEBUG, default=logging.INFO)
|
||||
optp.add_option('-v', '--verbose', help='set logging to COMM',
|
||||
action='store_const', dest='loglevel',
|
||||
const=5, default=logging.INFO)
|
||||
|
||||
# JID and password options.
|
||||
optp.add_option("-j", "--jid", dest="jid",
|
||||
help="JID to use")
|
||||
optp.add_option("-p", "--password", dest="password",
|
||||
help="password to use")
|
||||
optp.add_option("-s", "--server", dest="server",
|
||||
help="server to connect to")
|
||||
optp.add_option("-P", "--port", dest="port",
|
||||
help="port to connect to")
|
||||
|
||||
opts, args = optp.parse_args()
|
||||
|
||||
if opts.jid is None:
|
||||
opts.jid = raw_input("Component JID: ")
|
||||
if opts.password is None:
|
||||
opts.password = getpass.getpass("Password: ")
|
||||
if opts.server is None:
|
||||
opts.server = raw_input("Server: ")
|
||||
if opts.port is None:
|
||||
opts.port = int(raw_input("Port: "))
|
||||
|
||||
# Setup logging.
|
||||
logging.basicConfig(level=opts.loglevel,
|
||||
format='%(levelname)-8s %(message)s')
|
||||
|
||||
# Setup the EchoComponent and register plugins. Note that while plugins
|
||||
# may have interdependencies, the order in which you register them does
|
||||
# not matter.
|
||||
xmpp = EchoComponent(opts.jid, opts.password, opts.server, opts.port)
|
||||
xmpp.registerPlugin('xep_0030') # Service Discovery
|
||||
xmpp.registerPlugin('xep_0004') # Data Forms
|
||||
xmpp.registerPlugin('xep_0060') # PubSub
|
||||
xmpp.registerPlugin('xep_0199') # XMPP Ping
|
||||
|
||||
# Connect to the XMPP server and start processing XMPP stanzas.
|
||||
if xmpp.connect():
|
||||
xmpp.process(block=True)
|
||||
print("Done")
|
||||
else:
|
||||
print("Unable to connect.")
|
Loading…
Reference in New Issue