murlog

package module
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

README

murlog

自分のドメインに、自分のホームを持つ。

murlog は一人用の ActivityPub サーバー。Go シングルバイナリ + SQLite で、レンタルサーバーの CGI から VPS まで、どこでも動く。

Features

  • ActivityPub 連合 — Mastodon / Misskey / GoToSocial と相互フォロー・投稿配信
  • CGI 対応 — 共用レンタルサーバー (さくら、Xserver 等) でも動作
  • ゼロ依存 — Go シングルバイナリ + SQLite、外部サービス不要
  • SPA + SSR — Preact SPA (マイページ) + Handlebars テーマ (公開ページ)
  • S3 互換ストレージ — メディアを Cloudflare R2 等に保存可能
  • 多言語対応 — 日本語 / 英語、Accept-Language で自動切替
  • PWA — モバイルでアプリライクに使える

Quick Start

# ビルド
make build

# 起動 (ポート 8080)
make serve

ブラウザで http://localhost:8080 にアクセスし、セットアップウィザードに従う。

Build from Source

Prerequisites
  • Go 1.22+
  • Node.js 20+ (フロントエンドビルド用)
git clone https://github.com/murlog-org/murlog.git
cd murlog

# フロントエンドビルド
make web-install
make web-build

# Go バイナリビルド
make build

# 開発モード (Go + Vite dev server 並走)
make dev

CGI デプロイ

レンタルサーバー向けのクロスコンパイル:

# Linux/FreeBSD 向けバイナリを一括ビルド
make cross

# dist/release/ にバイナリが生成される
ls dist/release/
# murlog-linux-amd64  murlog-freebsd-amd64  ...

詳細は docs/cgi.md を参照。

Documentation

ドキュメント 内容
docs/overview.md プロダクト概要・技術選定
docs/architecture.md サーバーアーキテクチャ
docs/domain.md ドメインモデル
docs/murlog-api.md API 仕様 (JSON-RPC 2.0)
docs/activitypub/ ActivityPub 実装・互換性
docs/frontend.md フロントエンド (SPA + テーマ)
docs/cgi.md CGI デプロイ
docs/security.md セキュリティ設計

License

AGPL-3.0 — Copyright (C) 2026 alarky

Documentation

Overview

Package murlog defines the domain types for the murlog ActivityPub server. murlog ActivityPub サーバーのドメイン型を定義するパッケージ。

Index

Constants

View Source
const (
	PasswordMinLen = 8
	PasswordMaxLen = 128
)

Password constraints. パスワードの制約。

View Source
const (
	UsernameMinLen = 1
	UsernameMaxLen = 30
)

Username constraints. ユーザー名の制約。

View Source
const (
	ContentTypeText = "text" // plain text (local posts) / プレーンテキスト (ローカル投稿)
	ContentTypeHTML = "html" // HTML (remote posts) / HTML (リモート投稿)
)

Post is a note/article (local or remote). 投稿(ローカルまたはリモート受信)。 ContentType represents the format of post content. 投稿コンテンツの形式。

View Source
const MaxJobAttempts = 5

MaxJobAttempts is the maximum number of attempts before a job is marked dead. ジョブが dead になるまでの最大試行回数。

Variables

View Source
var Commit = "unknown"

Commit is the git short hash, injected at build time via -ldflags. ビルド時に -ldflags で注入される git short hash。

View Source
var Version = "dev"

Version is the murlog version, injected at build time via -ldflags. ビルド時に -ldflags で注入される murlog バージョン。

Functions

func MustJSON

func MustJSON(v any) string

func ValidatePassword

func ValidatePassword(s string) error

ValidatePassword checks that a password meets minimum strength requirements. Requires 8-128 characters and at least 3 of 4 character types (lower, upper, digit, symbol). パスワードが最低限の強度要件を満たしているか検証する。 8〜128 文字かつ 4 種の文字種(小文字・大文字・数字・記号)のうち 3 種以上を要求。

func ValidateUsername

func ValidateUsername(s string) error

ValidateUsername checks that a username is valid for use in ActivityPub URIs. Returns nil if valid, or an error describing the problem. ActivityPub URI で使用可能なユーザー名かを検証する。

func VersionString

func VersionString() string

VersionString returns "version (commit)" for display. 表示用の "version (commit)" 文字列を返す。

Types

type APIToken

type APIToken struct {
	ID        id.ID
	Name      string    // human-readable label / 識別用ラベル
	TokenHash string    // SHA-256 hash / SHA-256 ハッシュ
	AppID     id.ID     // OAuth app ID (zero for direct issue) / OAuth アプリ ID (直接発行ならゼロ値)
	Scopes    string    // space-separated e.g. "read write" / スペース区切り
	ExpiresAt time.Time // zero value = never expires / ゼロ値 = 無期限
	CreatedAt time.Time
}

APIToken is a Bearer token for CLI/API access or OAuth 2.0. CLI/API アクセスまたは OAuth 2.0 用の Bearer トークン。

type Attachment

type Attachment struct {
	ID        id.ID
	PostID    id.ID  // zero until attached to a post / 投稿に紐づくまでゼロ値
	FilePath  string // relative path in media store, or remote URL / メディアストア内の相対パス、またはリモート URL
	MimeType  string
	Alt       string // alt text / 代替テキスト
	Width     int
	Height    int
	Size      int64
	CreatedAt time.Time
}

Attachment represents a media file attached to a post. 投稿に添付されたメディアファイル。

type Block

type Block struct {
	ID        id.ID
	ActorURI  string // blocked actor URI / ブロック対象の Actor URI
	CreatedAt time.Time
}

Block represents a blocked remote actor (instance-wide). ブロック済みリモート Actor (インスタンス全体)。

type CustomField

type CustomField struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

CustomField is a key-value pair displayed on the profile (PropertyValue). プロフィールに表示される key-value ペア (PropertyValue)。

type DomainBlock

type DomainBlock struct {
	ID        id.ID
	Domain    string // blocked domain / ブロック対象のドメイン
	CreatedAt time.Time
}

DomainBlock represents a blocked remote domain (instance-wide). ブロック済みリモートドメイン (インスタンス全体)。

type DomainFailure

type DomainFailure struct {
	Domain         string
	FailureCount   int
	LastError      string
	FirstFailureAt time.Time
	LastFailureAt  time.Time
}

DomainFailure tracks delivery failures per domain for circuit-breaker logic. サーキットブレーカー用のドメイン別配送失敗カウンター。

type Favourite

type Favourite struct {
	ID        id.ID
	PostID    id.ID  // favourited post / お気に入りされた投稿
	ActorURI  string // actor who favourited / お気に入りした Actor
	CreatedAt time.Time
}

Favourite represents a remote actor favouriting a local post. リモート Actor がローカル投稿をお気に入りした記録。

type Follow

type Follow struct {
	ID        id.ID
	PersonaID id.ID  // local persona / ローカルペルソナ
	TargetURI string // remote actor URI / リモート Actor の URI
	Accepted  bool   // true after receiving Accept / Accept 受信済みなら true
	CreatedAt time.Time
}

Follow represents a local persona following a remote actor. ローカルペルソナがリモート Actor をフォローしている関係。

type Follower

type Follower struct {
	ID        id.ID
	PersonaID id.ID  // local persona / ローカルペルソナ
	ActorURI  string // remote actor URI / リモート Actor の URI
	Approved  bool   // true after approval / 承認済みなら true
	CreatedAt time.Time
}

Follower represents a remote actor following a local persona. リモート Actor がローカルペルソナをフォローしている関係。

type InteractionCounts

type InteractionCounts struct {
	Favourites int
	Reblogs    int
}

InteractionCounts holds favourites/reblogs counts for a post. 投稿のいいね/リブログ数。

type JobStatus

type JobStatus int

JobStatus represents the state of a queue job. ジョブの実行状態。

const (
	JobPending JobStatus = iota // waiting to run / 実行待ち
	JobRunning                  // currently running / 実行中
	JobDone                     // completed successfully / 完了
	JobFailed                   // failed, may retry / 失敗、リトライ対象
	JobDead                     // max retries exhausted / リトライ上限到達
)

type JobType

type JobType int

JobType identifies the kind of background job. バックグラウンドジョブの種別。

const (
	JobAcceptFollow      JobType = iota + 1 // accept incoming follow / フォロー承認
	JobRejectFollow                         // reject incoming follow / フォロー拒否
	JobDeliverPost                          // fan-out new post to followers / 投稿をフォロワーに配信
	JobDeliverNote                          // deliver note to single actor / 1 Actor に Note 配送
	JobUpdatePost                           // fan-out post update / 投稿更新をファンアウト
	JobDeliverUpdateNote                    // deliver update note to single actor / 1 Actor に更新 Note 配送
	JobSendFollow                           // send follow request / フォローリクエスト送信
	JobUpdateActor                          // fan-out actor update / Actor 更新をファンアウト
	JobDeliverUpdate                        // deliver actor update to single actor / 1 Actor に更新配送
	JobDeliverDelete                        // fan-out post deletion / 投稿削除をファンアウト
	JobDeliverDeleteNote                    // deliver delete to single actor / 1 Actor に削除配送
	JobSendUndoFollow                       // send undo follow / フォロー解除送信
	JobSendLike                             // send like / いいね送信
	JobSendUndoLike                         // send undo like / いいね取消送信
	JobSendAnnounce                         // fan-out announce / リブログをファンアウト
	JobSendUndoAnnounce                     // fan-out undo announce / リブログ取消をファンアウト
	JobDeliverAnnounce                      // deliver announce to single actor / 1 Actor にリブログ配送
	JobSendBlock                            // send block / ブロック送信
	JobSendUndoBlock                        // send undo block / ブロック解除送信
	JobFetchRemoteActor                     // fetch and cache remote actor / リモート Actor フェッチ
)

func (JobType) String

func (t JobType) String() string

String returns the enum name of a JobType (e.g. "JobSendLike"). JobType の enum 名を返す(例: "JobSendLike")。

type Mention

type Mention struct {
	Acct string `json:"acct"` // "user@domain"
	Href string `json:"href"` // Actor URI
}

Mention is a resolved mention target in a post. 投稿内の解決済みメンション。

type Notification

type Notification struct {
	ID        id.ID
	PersonaID id.ID  // notification recipient / 通知の受信者
	Type      string // "follow", "mention", "reblog", "favourite"
	ActorURI  string // actor who triggered the notification / 通知を発生させた Actor
	PostID    id.ID  // related post (zero for follow) / 関連投稿 (follow の場合はゼロ値)
	Read      bool
	CreatedAt time.Time
}

Notification is a notification for a local persona. ローカルペルソナへの通知。

type OAuthApp

type OAuthApp struct {
	ID           id.ID
	ClientID     string // randomly generated / ランダム生成
	ClientSecret string // randomly generated / ランダム生成
	Name         string // app name / アプリ名
	RedirectURI  string
	Scopes       string // space-separated e.g. "read write" / スペース区切り
	CreatedAt    time.Time
}

OAuthApp is a registered OAuth 2.0 client application. 登録済み OAuth 2.0 クライアントアプリケーション。

type OAuthCode

type OAuthCode struct {
	ID            id.ID
	AppID         id.ID  // oauth_apps.id
	Code          string // randomly generated / ランダム生成
	RedirectURI   string
	Scopes        string
	CodeChallenge string // PKCE S256 challenge
	ExpiresAt     time.Time
	CreatedAt     time.Time
}

OAuthCode is a temporary authorization code for the OAuth 2.0 flow. OAuth 2.0 フローの一時的な認可コード。

type Persona

type Persona struct {
	ID             id.ID
	Username       string // unique, used in URIs / 一意、URIに使用
	DisplayName    string
	Summary        string // bio (HTML) / 自己紹介 (HTML)
	AvatarPath     string // relative path in media store / メディアストア内の相対パス
	HeaderPath     string // relative path in media store / メディアストア内の相対パス
	PublicKeyPEM   string
	PrivateKeyPEM  string
	Primary        bool   // true for the first persona / プライマリペルソナなら true
	Locked         bool   // true = manually approves followers / 手動フォロー承認
	ShowFollows    bool   // true = public follow/follower lists / フォロー・フォロワー一覧を公開
	Discoverable   bool   // true = appear in search results / 検索結果に表示される
	PinnedPostID   id.ID  // zero = no pinned post / ゼロ値 = ピン留めなし
	FieldsJSON     string // JSON array of custom fields / カスタムフィールドの JSON 配列
	PostCount      int    // cached count of local posts / ローカル投稿数キャッシュ
	FollowersCount int    // cached count of approved followers / 承認済みフォロワー数キャッシュ
	FollowingCount int    // cached count of follows / フォロー数キャッシュ
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

Persona is a local ActivityPub Actor. ローカルの ActivityPub Actor。

func (*Persona) Fields

func (p *Persona) Fields() []CustomField

Fields returns the parsed custom fields from FieldsJSON. FieldsJSON からパース済みカスタムフィールドを返す。

func (*Persona) SetFields

func (p *Persona) SetFields(fields []CustomField)

SetFields serializes custom fields to FieldsJSON. カスタムフィールドを FieldsJSON にシリアライズする。

type Post

type Post struct {
	ID             id.ID
	PersonaID      id.ID             // local: author, remote: receiving persona / ローカル:投稿者, リモート:受信先ペルソナ
	Content        string            // source content (text or HTML depending on ContentType) / ソースコンテンツ
	ContentType    string            // "text" or "html" / コンテンツ形式
	ContentMap     map[string]string // lang -> content for multilingual / 言語別コンテンツ
	Visibility     Visibility
	Origin         string // "local", "remote", "system"
	URI            string // ActivityPub URI (remote only) / AP URI (リモートのみ)
	ActorURI       string // remote actor URI (remote only) / リモート投稿者の Actor URI
	InReplyToURI   string // AP URI of parent post (reply target) / リプライ先投稿の AP URI
	MentionsJSON   string // JSON array of resolved mentions / 解決済みメンションの JSON 配列
	HashtagsJSON   string // JSON array of hashtag strings / ハッシュタグの JSON 配列
	RebloggedByURI string // Actor URI of who reblogged this post / この投稿をリブログした Actor の URI
	ReblogOfPostID id.ID  // original post ID for local reblog wrapper / ローカルリブログ wrapper の元投稿 ID
	Summary        string // CW text (Content Warning) / CW テキスト
	Sensitive      bool   // sensitive media flag / センシティブメディアフラグ
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

func (*Post) Hashtags

func (p *Post) Hashtags() []string

Hashtags returns the parsed hashtags from HashtagsJSON. HashtagsJSON からパース済みハッシュタグを返す。

func (*Post) Mentions

func (p *Post) Mentions() []Mention

Mentions returns the parsed mentions from MentionsJSON. MentionsJSON からパース済みメンションを返す。

func (*Post) SetHashtags

func (p *Post) SetHashtags(tags []string)

SetHashtags serializes hashtags to HashtagsJSON. ハッシュタグを HashtagsJSON にシリアライズする。

func (*Post) SetMentions

func (p *Post) SetMentions(mentions []Mention)

SetMentions serializes mentions to MentionsJSON. メンションを MentionsJSON にシリアライズする。

type QueueJob

type QueueJob struct {
	ID          id.ID
	Type        JobType // job kind / ジョブ種別
	Payload     string  // JSON
	Status      JobStatus
	Attempts    int
	LastError   string // last error message / 最終エラーメッセージ
	NextRunAt   time.Time
	CreatedAt   time.Time
	CompletedAt time.Time // zero if not completed / 未完了ならゼロ値
}

QueueJob is a background job in the queue. ジョブキューにおけるバックグラウンドジョブ。

func NewJob

func NewJob(jobType JobType, payload any) *QueueJob

MustJSON marshals v to a JSON string. Errors are silently ignored. v を JSON 文字列にマーシャルする。エラーは無視する。 NewJob creates a pending QueueJob with the given type and payload. 指定された型とペイロードで保留中の QueueJob を生成する。

type Reblog

type Reblog struct {
	ID        id.ID
	PostID    id.ID  // reblogged post / リブログされた投稿
	ActorURI  string // actor who reblogged / リブログした Actor
	CreatedAt time.Time
}

Reblog represents a remote actor reblogging (Announce) a local post. リモート Actor がローカル投稿をリブログ (Announce) した記録。

type RemoteActor

type RemoteActor struct {
	URI         string // primary key (actor URI) / 主キー (Actor URI)
	Username    string
	DisplayName string
	Summary     string
	Inbox       string
	AvatarURL   string
	HeaderURL   string
	FeaturedURL string    // Featured (pinned) collection URL / ピン留めコレクション URL
	FieldsJSON  string    // JSON array of custom fields / カスタムフィールドの JSON 配列
	Acct        string    // "user@domain" for mention resolution / メンション解決用の acct
	FetchedAt   time.Time // cache freshness / キャッシュ鮮度
}

RemoteActor is a cached representation of a remote ActivityPub actor. リモート ActivityPub Actor のキャッシュ。

func (*RemoteActor) Fields

func (a *RemoteActor) Fields() []CustomField

Fields returns the parsed custom fields from FieldsJSON. FieldsJSON からパース済みカスタムフィールドを返す。

type Session

type Session struct {
	ID        id.ID
	TokenHash string // SHA-256 hash of the session token / セッショントークンの SHA-256 ハッシュ
	ExpiresAt time.Time
	CreatedAt time.Time
}

Session is a login session for the admin UI. 管理画面のログインセッション。

type Setting

type Setting struct {
	Key   string
	Value string
}

Setting is a key-value pair for application settings stored in DB. DB に保存されるアプリケーション設定の KV ペア。

type Visibility

type Visibility int

Visibility controls who can see a post. 投稿の公開範囲。

const (
	VisibilityPublic    Visibility = iota // public timeline + federation / 公開タイムライン + 連合
	VisibilityUnlisted                    // federation but not public timeline / 連合のみ、公開タイムラインには載せない
	VisibilityFollowers                   // followers only / フォロワー限定
	VisibilityDirect                      // direct message / ダイレクトメッセージ
)

Directories

Path Synopsis
Package activitypub provides minimal ActivityPub vocabulary types and protocol logic.
Package activitypub provides minimal ActivityPub vocabulary types and protocol logic.
Package app assembles dependencies and provides the application entry point.
Package app assembles dependencies and provides the application entry point.
cmd
murlog command
Package config handles loading murlog.ini.
Package config handles loading murlog.ini.
Package handler — JSON API helpers.
Package handler — JSON API helpers.
Package hashtag provides hashtag parsing and HTML conversion for ActivityPub posts.
Package hashtag provides hashtag parsing and HTML conversion for ActivityPub posts.
Package i18n provides internationalization support using external JSON locale files.
Package i18n provides internationalization support using external JSON locale files.
Package id provides UUIDv7 generation and handling.
Package id provides UUIDv7 generation and handling.
internal
mediautil
Package mediautil provides shared media helpers used by handler and worker.
Package mediautil provides shared media helpers used by handler and worker.
sqlutil
Package sqlutil provides shared SQL helpers used by store/sqlite and queue/sqlqueue.
Package sqlutil provides shared SQL helpers used by store/sqlite and queue/sqlqueue.
Package media defines the interface for media file storage.
Package media defines the interface for media file storage.
fs
Package fs implements media.Store using the local filesystem.
Package fs implements media.Store using the local filesystem.
imageproc
Package imageproc provides image processing utilities for media uploads.
Package imageproc provides image processing utilities for media uploads.
s3
Package s3 implements media.Store using S3-compatible object storage.
Package s3 implements media.Store using S3-compatible object storage.
Package mention provides mention parsing and HTML conversion for ActivityPub posts.
Package mention provides mention parsing and HTML conversion for ActivityPub posts.
Package queue defines the background job queue interface for murlog.
Package queue defines the background job queue interface for murlog.
sqlqueue
Package sqlqueue implements queue.Queue using database/sql (SQLite-compatible).
Package sqlqueue implements queue.Queue using database/sql (SQLite-compatible).
seeddb generates a SQLite DB with large dataset for performance testing.
seeddb generates a SQLite DB with large dataset for performance testing.
Package store defines the data access interface and driver registry for murlog.
Package store defines the data access interface and driver registry for murlog.
sqlite
Package sqlite implements store.Store using SQLite (modernc.org/sqlite).
Package sqlite implements store.Store using SQLite (modernc.org/sqlite).
Package totp implements TOTP (RFC 6238) for two-factor authentication.
Package totp implements TOTP (RFC 6238) for two-factor authentication.
Package worker processes background jobs from the queue.
Package worker processes background jobs from the queue.

Jump to

Keyboard shortcuts

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