smsxmpp

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2022 License: MIT Imports: 15 Imported by: 3

README

SMS-over-XMPP

sms-over-xmpp is an XMPP component (XEP-0114) that acts as a gateway between an XMPP (aka Jabber) network and the SMS network. It allows you to send and receive SMS messages as if they were XMPP messages, using your favorite XMPP client.

You send an XMPP message and your friend receives an SMS. When they send you an SMS, you receive an XMPP message.

Supported SMS Providers

  • Twilio (recommended)
  • Nexmo/Vonage
  • Signalwire

Features

MMS

sms-over-xmpp can send and receive MMS messages containing images.

To send MMS, your XMPP client/server must support:

  • XEP-0363 (HTTP File Upload)
  • XEP-0066 (Out of Band Data)

To receive MMS, your XMPP client must support:

  • XEP-0066 (Out of Band Data)

If your client does not support XEP-0066, then incoming MMS will contain a URL to the media file.

CardDAV Roster Synchronization

sms-over-xmpp can optionally synchronize a CardDAV address book with your XMPP roster. Any contact in your address book with a mobile phone number is added to your XMPP roster with the necessary address to send them an SMS. When a contact is deleted, it is also deleted from your roster.

The synchronization is one-way: changes made to your XMPP roster aren't propagated to your address book, and may be reverted.

Your XMPP server must support XEP-0321. For Prosody, you can use mod_remote_roster. Note that as of April 22, 2022, the version of mod_remote_roster that ships with prosody-modules has a bug. A patch has been submitted upstream; in the meantime, use this version.

Installing

If you have the latest version of Go installed, you can run:

go install src.agwa.name/sms-over-xmpp/cmd/sms-over-xmpp@latest

Or, you can download a binary from the GitHub Releases Page.

sms-over-xmpp is a single statically-linked binary so using Docker or a similar technology is superfluous.

Configuring

See the Config Reference.

Tested Configurations

sms-over-xmpp has been tested with the following configuration:

  • Twilio for the SMS provider
  • Prosody for the XMPP server
  • Gajim for the desktop XMPP client
  • Monal for the mobile (iOS) XMPP client
  • Radicale for the CardDAV server (needed for address book synchronization)
  • mod_http_upload_s3 for HTTP file upload in Prosody (needed for sending MMS)
  • mod_remote_roster.lua for remote roster management in Prosody (needed for address book synchronization)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRosterNotIntialized = errors.New("the roster for this user has not been initialized yet")

Functions

func RegisterProviderType

func RegisterProviderType(name string, makeProvider MakeProviderFunc)

Types

type MakeProviderFunc

type MakeProviderFunc func(*Service, ProviderConfig) (Provider, error)

type Message

type Message struct {
	From      string // e.g. "+14155551212"
	To        string
	Cc        []string
	Body      string
	MediaURLs []string
}

type Provider

type Provider interface {
	Type() string
	Send(*Message) error
	HTTPHandler() http.Handler
}

func MakeProvider

func MakeProvider(typeName string, service *Service, config ProviderConfig) (Provider, error)

type ProviderConfig

type ProviderConfig map[string]string

type Roster

type Roster map[xmpp.Address]RosterItem

type RosterItem

type RosterItem struct {
	Name   string
	Groups []string
}

func (RosterItem) Equal

func (item RosterItem) Equal(other RosterItem) bool

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(config *config.Config) (*Service, error)

func (*Service) HTTPHandler

func (service *Service) HTTPHandler() http.Handler

func (*Service) Receive

func (service *Service) Receive(message *Message) error

func (*Service) RunAddressBookUpdater

func (service *Service) RunAddressBookUpdater(ctx context.Context) error

func (*Service) RunXMPPComponent

func (service *Service) RunXMPPComponent(ctx context.Context) error

func (*Service) SetRoster

func (service *Service) SetRoster(ctx context.Context, userJID xmpp.Address, newRoster Roster) error

Directories

Path Synopsis
cmd
providers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL