~mariusor/oni - Single user ActivityPub instance - sourcehut git

4 min read Original article ↗

Is a single user ActivityPub server compatible with Mastodon and the rest of the Fediverse.

It is part of the tools built for and with the help with of the GoActivityPub library.

ONI main page after fresh install

#Getting the source

$ git clone https://git.sr.ht/~mariusor/oni
$ cd oni

#Container images

Another option for running ONI is to use the pre-built images. More details about that can be found here.

#Features

Posting to an ONI instance is done using Client to Server ActivityPub. Currently, the client that supports most features is BOX.

The application supports text posts, image, audio and video uploads.

#Compiling

# We need to download the JavaScript dependencies, using yarn or npm:
# yarn install
# npm install
# Also, while we are in heavy development, we do have the 'go.sum' module checksum file in the repository,
# so we need to created it:
$ go mod tidy
# As a last step we need to bundle the static assets, for which we use go:generate with the 'esbuilder' API:
$ go generate assets.go
# We now can build the ONI binary:
$ go build -trimpath -a -ldflags '-s -w -extldflags "-static"' -o $(go env GOPATH)/bin/oni ./cmd/oni/main.go
# All of these steps have been grouped together with Make:
$ make all

#Run server

# --listen can be a tcp socket, a domain socket, or the magic string "systemd"
# The later should be used if running as a systemd service with socket activation
$ oni --listen 127.0.4.2:4567 --path ~/.cache/oni

#Running a server in a production environment

The development builds of ONI are not compatible with Mastodon, as the HTTP-Signatures generated are meant to be replayble from other contexts, which in production environments should be avoided.

Therefore, if you want to run an ONI instance as part of the wider fediverse you must make sure that it was built by passing either -tags prod or -tags qa to the build command.

#Add root actor

# Creates an actor for URL https://johndoe.example.com and adds an OAuth2 client application with name 'johndoe.example.com'
# with OAuth2 client password 'SuperSecretOAuth2ClientPassword'. 
# The --with-token boolean flag can make the application generate an Authorization header containing a Bearer token 
# usable directly in an ActivityPub client.
$ oni actor add --pw SuperSecretOAuth2ClientPassword https://johndoe.example.com
# with box

#Block remote instances

# Blocks all access to all johndoe.example.com pages for any access that has requests with Authorization 
# headers generated for actors hosted on naughty.social
$ oni block --client https://johndoe.example.com https://naughty.social

#Interacting with ONI instances using BOX cli helper

#Documentation

Further reading on how to use ONI can be found on the SourceHut wiki.

The wiki also contains more examples than the ones detailed here about how to use BOX for managing an ONI instance.

$ box authorize --as https://johndoe.example.com --secret SuperSecretOAuth2ClientPassword

#Post a Note

# Here --id, --name and --content are optional
# --id gets generated by the server if missing
# If --name and --content are empty $EDITOR is opened and they get extracted from the result
# if the content contains two empty lines, the --name is the text that precedes them, 
# and the --content the text after
$ box post --as https://johndoe.example.com --id https://johndoe.example.com/posts/first \
--name "First Post" --content "Hello Fediverse⁂!"

First post

#Upload an image

$ box upload --as https://johndoe.example.com --id https://johndoe.example.com/uploads/funny \
--name "Funny image" --summary "This is a short description." --path SOME/PATH/funny.jpg

#Blocking an Actor/Instance

$ box block --as https://johndoe.example.com --reason "Naughty, naughty!" https://naughty.social

#Contact and feedback

If you have problems, questions, ideas or suggestions, please contact us by posting to the discussions mailing list, or on GitHub. For quicker feedback the mailing list is preferred, as the GitHub issues are not checked very often.