s83

package module
v0.0.0-...-d171176 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2022 License: MIT Imports: 17 Imported by: 0

README

s83

A sample Spring '83 client and server implementation according to the draft spec (29 JUN) in response to Robin’s Request For Friendly Critique and Comment (RRFFCC) and for fun.

Very much in flux, but sufficiently conformant to publish and get from the demo server!

Hosted server at may83.club.

Publishing at db8a22f49c7f98690106cc2aaac15201608db185b4ada99b5bf4f222883e1223.

Quick Start/Demo

1. Build client (s83)
$ go build -o bin/s83 ./cmd/client
$ cd bin
$ ./s83 --help
2. Generate a creator key ("secret").

This may take a few minutes to get lucky.

$ ./s83 new

Speed it up with (-j N) where N is the number of miners to run. Locally I get ~160k attempts per second.

3. Add your keys to a "profile"

Add the keys you just generated to the default client profile.

~/.config/s83/default

secret = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
server = https://may83.club

me
http://may83.club/db8a22f49c7f98690106cc2aaac15201608db185b4ada99b5bf4f222883e1223

You can have multiple profiles and switch between them with ./s38 -c PROFILE

Aside from the simple key = value lines this attempts to conform to the "Springfile" convention. You can add a list of the board URLs you would like to follow, optionally preceded by a handle for how you would like to track that board (me in the example above).

4. Verify you can reach the server by getting the ever-changing test board.
$ ./s83 get ab589f4dde9fce4180fcf42c7b05185b0a02a5d682e353fa39177995083e0583
5. Make a board and publish it.
$ echo "<h1>It's Alive</h1>" > board.html

$ ./s83 pub board.html
[info] Success
6. Get your board.

Assuming you added your key to your configuration you can check out your great work with a simple get. This will fetch all of your/followed boards, and render them to a local HTML file, The Daily Spring.

$ ./s83 get

You just distilled the distributed, ephemeral Springiverse into a single, fully encapsulated, immutable, cryptographically verified, personal periodical, The Daily Spring.

This is now just a local file. You can save it for later, open it right up in your browser of choice, email it to yourself or a friend, really anything.

There are some helpful options like -go, which immediately opens a browser for instant gratification, -new which will only show you boards you haven't seen, and -o to save the output to a specific path. For example:

$ ./s83 get -go -o the-daily-spring.html
7. Enjoy!

In addition to https://may83.club. Some other public servers you can publish/follow boards to/from are:

Current Limitations

While the core protocol functionality works, some features still need to be implemented. A non-exhaustive list of missing features follows.

  • server
    • missing gossip
    • potentially imprecise error messages
  • client
    • no "realms"
  • Tests
  • Linux only

Development continues. This list should shrink over time as the spec is refined and solidifies. The primary purpose at this point is to explore the corners of spec, provide friendly comment, and have a good time implementing something cool.

WIP: Deployment

work in progress

There is a Dockerfile provided for packaging up the server. Once things reach a level of stability/release this will get published, but for now you can build/test locally.

The Makefile provides some convenience functions` to spin up an ephemeral test instance.

make docker-build
make docker-serve

You can configure the server by setting enviornment variables:

$ ./s83d -h
Usage: s83d is designed to be configured using environment variables.

For example: `PORT=8383 ./s83d`

variable         default
--------         -------
HOST
PORT             8080
STORE            store
TTL              22
TITLE            s83d
ADMIN_BOARD
Local Quick Serve
make serve

Design Decisions

  • server
    • golang all standard library with minimal dependencies
    • flat/plaintext files for persistent storage
  • client
    • golang that spits out an html page and fires off a browser

Documentation

Index

Constants

View Source
const ClientCSS = template.CSS(`<style>
        :host { all: initial; display: block; box-sizing: border-box; padding: 2rem; }
        time { display: none; }
        p, h1, h2, h3, h4, h5 { margin: 0 0 2rem 0; }
        </style>`)

TODO: validate Preparing each board for display, the client should prepend this default CSS:

View Source
const InfernalKey = "d17eef211f510479ee6696495a2589f7e9fb055c2576749747d93444883e0123"
View Source
const KeyLen = 64
View Source
const MaxBoardLen = 2217
View Source
const MaxKey uint64 = math.MaxUint64 // 1<<64 - 1 =  (2**64 - 1)
View Source
const SigLen = 128
View Source
const SpringVersion = "83"

SpringVersion for use in http headers

View Source
const TestPrivate = "3371f8b011f51632fea33ed0a3688c26a45498205c6097c352bd4d079d224419"
View Source
const TestPublic = "ab589f4dde9fce4180fcf42c7b05185b0a02a5d682e353fa39177995083e0583"
View Source
const TimeFormat8601 = "2006-01-02T15:04:05Z" //"YYYY-MM-DDTHH:MM:SSZ"

Variables

This section is empty.

Functions

func ParseTimestamp

func ParseTimestamp(content []byte) (time.Time, error)

parse timestamp from HTML time element <time datetime="YYYY-MM-DDTHH:MM:SSZ">

Types

type Board

type Board struct {
	Publisher Publisher

	Content []byte
	// contains filtered or unexported fields
}

func BoardFromHTTP

func BoardFromHTTP(key string, auth string, body io.ReadCloser) (Board, error)

func NewBoard

func NewBoard(key string, sig Signature, content []byte) (Board, error)

func (Board) After

func (b Board) After(ts time.Time) bool

func (Board) AfterBoard

func (b Board) AfterBoard(other Board) bool

func (Board) Eq

func (b Board) Eq(other Board) bool

func (Board) Info

func (b Board) Info() string

func (Board) Key

func (b Board) Key() string

func (Board) Signature

func (b Board) Signature() string

func (Board) String

func (b Board) String() string

func (Board) Timestamp

func (b Board) Timestamp() string

func (Board) VerifySignature

func (b Board) VerifySignature() bool

type Creator

type Creator struct {
	PrivateKey ed25519.PrivateKey
	Publisher
}

func NewCreatorFromKey

func NewCreatorFromKey(privateKeyHex string) (Creator, error)

func (Creator) ExportPrivateKey

func (c Creator) ExportPrivateKey() string

func (Creator) NewBoard

func (c Creator) NewBoard(content []byte) (Board, error)

func (Creator) String

func (c Creator) String() string

func (Creator) Valid

func (c Creator) Valid() bool

type CreatorResult

type CreatorResult struct {
	Creator Creator
	Count   int
	Err     error
}

func NewCreator

func NewCreator(j int) CreatorResult

type Follow

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

func NewFollow

func NewFollow(key string, urlStr string, handle string) (Follow, error)

func ParseSpringfileFollows

func ParseSpringfileFollows(data []byte) []Follow

attempt to conform to the Springfile format of the demo client

func (Follow) GetBoard

func (f Follow) GetBoard(modTimeStr string) (Board, error)

func (Follow) Key

func (f Follow) Key() string

func (Follow) String

func (f Follow) String() string

type Publisher

type Publisher struct {
	PublicKey ed25519.PublicKey
}

func NewPublisherFromKey

func NewPublisherFromKey(publicKeyHex string) (Publisher, error)

func (Publisher) Key

func (p Publisher) Key() string

func (Publisher) String

func (p Publisher) String() string

type Signature

type Signature []byte

func (Signature) String

func (s Signature) String() string

Directories

Path Synopsis
cmd
Package store implements a simple flat file backed persistence mechanism for storing Spring '83 boards.
Package store implements a simple flat file backed persistence mechanism for storing Spring '83 boards.

Jump to

Keyboard shortcuts

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