Skip to content

waus/ddm-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DDM Go

Go implementation of the DDM core service. The main entry point for embedded use is github.com/waus/ddm-go/pkg/service.

Contents

Use as a Library

Create a service with a local work directory, then use typed accounts and protocol addresses instead of passing raw strings through application code.

package main

import (
	"context"
	"time"

	"github.com/waus/ddm-go/pkg/proto"
	"github.com/waus/ddm-go/pkg/service"
)

func main() {
	ctx := context.Background()

	app, err := service.NewApp("./ddm-data")
	if err != nil {
		panic(err)
	}
	defer app.Close()

	alice, err := app.CreateAccount(ctx, "alice")
	if err != nil {
		panic(err)
	}

	recipient, err := proto.ParseAddress("recipient-ddm-address")
	if err != nil {
		panic(err)
	}

	if _, err := app.SendTextMessage(ctx, *alice, recipient, "hello", 24*time.Hour); err != nil {
		panic(err)
	}
}

Common service operations:

  • CreateAccount / CreateAccountWithPolicy create local identities.
  • ListAccounts returns local accounts.
  • SendTextMessage and SendMarkdownMessage enqueue outbound messages.
  • ListMailboxMessages reads inbox and outbox messages.
  • StartP2PDaemon starts the libp2p sync server.
  • StartHTTPDaemon starts the HTTP JSON sync API.
  • AddSource adds an upstream sync source: http(s) URL, file:// SQLite URL, or libp2p multiaddr.

TUI

DDM TUI

Run the terminal UI from this module:

go run ./cmd/tui

Useful startup flags:

  • -workdir <path>: directory for the local SQLite database, default ..
  • -log-file <path>: TUI log file, default ddm.log.
  • -http: start the HTTP JSON sync API server (metrics included).
  • -http-addr <host:port>: HTTP listen address used with -http, default 127.0.0.1:8080.
  • -p2p-addr <multiaddr>: libp2p listen multiaddr, default /ip4/0.0.0.0/tcp/23708.
  • -p2p-public-relay: enable the resource-limited public libp2p relay service.
  • -upstreams <list>: comma-separated upstream sync sources.

Example:

go run ./cmd/tui \
  -workdir ./ddm-data \
  -http \
  -http-addr 127.0.0.1:8080 \
  -p2p-addr /ip4/0.0.0.0/tcp/23708

Docker

Build the image from the Go module directory:

docker build -t ddm-go .

Run the daemon with p2p exposed on all host interfaces and HTTP published only on host localhost:

docker run --rm \
  -v ddm-go-data:/data \
  -p 23708:23708 \
  -p 23708:23708/udp \
  -p 127.0.0.1:8080:8080 \
  ddm-go

The image starts ddm-cli with:

ddm-cli -workdir /data -http -http-addr 0.0.0.0:8080 -p2p-addr /ip4/0.0.0.0/tcp/23708

Override or append CLI flags by passing a custom command to docker run.

About

TUI for DoomsDay messenger and automatisation library

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors