2021-06-06 12:39:42 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/rsa"
|
2023-12-27 10:37:58 +00:00
|
|
|
"log/slog"
|
2021-06-06 12:39:42 +00:00
|
|
|
"net/http"
|
|
|
|
"sync"
|
|
|
|
|
2021-06-17 14:34:57 +00:00
|
|
|
shutdowner "git.jlel.se/jlelse/go-shutdowner"
|
2021-06-06 12:39:42 +00:00
|
|
|
ts "git.jlel.se/jlelse/template-strings"
|
2022-04-17 05:27:17 +00:00
|
|
|
"github.com/dgraph-io/ristretto"
|
2021-06-19 06:37:16 +00:00
|
|
|
ct "github.com/elnormous/contenttype"
|
2022-12-10 11:47:36 +00:00
|
|
|
apc "github.com/go-ap/client"
|
2021-06-06 12:39:42 +00:00
|
|
|
"github.com/go-fed/httpsig"
|
|
|
|
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
|
|
|
"github.com/yuin/goldmark"
|
2021-06-28 20:17:18 +00:00
|
|
|
"go.goblog.app/app/pkgs/minify"
|
2022-08-09 15:25:22 +00:00
|
|
|
"go.goblog.app/app/pkgs/plugins"
|
2023-11-11 18:00:04 +00:00
|
|
|
"go.hacdias.com/indielib/indieauth"
|
2022-04-12 06:48:09 +00:00
|
|
|
"golang.org/x/crypto/acme/autocert"
|
2021-06-06 12:39:42 +00:00
|
|
|
"golang.org/x/sync/singleflight"
|
|
|
|
)
|
|
|
|
|
|
|
|
type goBlog struct {
|
|
|
|
// ActivityPub
|
|
|
|
apPrivateKey *rsa.PrivateKey
|
2022-04-21 16:18:39 +00:00
|
|
|
apPubKeyBytes []byte
|
2022-12-10 11:47:36 +00:00
|
|
|
apSigner httpsig.Signer
|
|
|
|
apSignMutex sync.Mutex
|
|
|
|
apHttpClients map[string]*apc.C
|
2021-06-06 12:39:42 +00:00
|
|
|
webfingerResources map[string]*configBlog
|
|
|
|
webfingerAccts map[string]string
|
2021-06-19 06:37:16 +00:00
|
|
|
// ActivityStreams
|
|
|
|
asCheckMediaTypes []ct.MediaType
|
2021-06-06 12:39:42 +00:00
|
|
|
// Assets
|
|
|
|
assetFileNames map[string]string
|
|
|
|
assetFiles map[string]*assetFile
|
2022-04-12 06:48:09 +00:00
|
|
|
// Autocert
|
|
|
|
autocertManager *autocert.Manager
|
|
|
|
autocertInit sync.Once
|
2021-06-06 12:39:42 +00:00
|
|
|
// Blogroll
|
|
|
|
blogrollCacheGroup singleflight.Group
|
2021-06-18 12:32:03 +00:00
|
|
|
// Blogstats
|
|
|
|
blogStatsCacheGroup singleflight.Group
|
2021-06-06 12:39:42 +00:00
|
|
|
// Cache
|
|
|
|
cache *cache
|
|
|
|
// Config
|
|
|
|
cfg *config
|
|
|
|
// Database
|
|
|
|
db *database
|
2021-06-19 06:37:16 +00:00
|
|
|
// Errors
|
|
|
|
errorCheckMediaTypes []ct.MediaType
|
2022-02-22 18:47:12 +00:00
|
|
|
// Geo
|
|
|
|
photonMutex sync.Mutex
|
2021-06-06 12:39:42 +00:00
|
|
|
// Hooks
|
2022-01-03 12:55:44 +00:00
|
|
|
pPostHooks []postHookFunc
|
|
|
|
pUpdateHooks []postHookFunc
|
|
|
|
pDeleteHooks []postHookFunc
|
|
|
|
pUndeleteHooks []postHookFunc
|
|
|
|
hourlyHooks []hourlyHookFunc
|
2021-06-19 06:37:16 +00:00
|
|
|
// HTTP Client
|
2021-12-07 17:23:57 +00:00
|
|
|
httpClient *http.Client
|
2021-06-14 19:34:29 +00:00
|
|
|
// HTTP Routers
|
2021-07-17 07:33:44 +00:00
|
|
|
d http.Handler
|
2022-01-24 08:43:06 +00:00
|
|
|
// IndexNow
|
2022-02-25 15:29:42 +00:00
|
|
|
inKey []byte
|
|
|
|
inLoad sync.Once
|
2021-11-23 14:23:01 +00:00
|
|
|
// IndieAuth
|
|
|
|
ias *indieauth.Server
|
2023-12-27 10:37:58 +00:00
|
|
|
// Logs (HTTP)
|
2021-06-06 12:39:42 +00:00
|
|
|
logf *rotatelogs.RotateLogs
|
2023-12-27 10:37:58 +00:00
|
|
|
// Logs (Program)
|
|
|
|
logger *slog.Logger
|
|
|
|
logLevel *slog.LevelVar
|
2021-06-06 12:39:42 +00:00
|
|
|
// Markdown
|
2021-08-04 21:26:38 +00:00
|
|
|
md, absoluteMd, titleMd goldmark.Markdown
|
2021-06-20 13:18:02 +00:00
|
|
|
// Media
|
2021-06-23 12:28:51 +00:00
|
|
|
compressorsInit sync.Once
|
|
|
|
compressors []mediaCompression
|
|
|
|
mediaStorageInit sync.Once
|
|
|
|
mediaStorage mediaStorage
|
2022-12-14 13:56:27 +00:00
|
|
|
// Microformats
|
|
|
|
mfInit sync.Once
|
|
|
|
mfCache *ristretto.Cache
|
2023-12-19 11:15:30 +00:00
|
|
|
// Micropub
|
|
|
|
mpImpl *micropubImplementation
|
2021-06-18 12:32:03 +00:00
|
|
|
// Minify
|
|
|
|
min minify.Minifier
|
2022-08-09 15:25:22 +00:00
|
|
|
// Plugins
|
|
|
|
pluginHost *plugins.PluginHost
|
2022-11-27 14:06:43 +00:00
|
|
|
// Profile image
|
2022-12-13 19:13:57 +00:00
|
|
|
profileImageHashString string
|
|
|
|
profileImageHashGroup singleflight.Group
|
2022-04-17 05:27:17 +00:00
|
|
|
// Reactions
|
|
|
|
reactionsInit sync.Once
|
|
|
|
reactionsCache *ristretto.Cache
|
|
|
|
reactionsSfg singleflight.Group
|
2021-06-06 12:39:42 +00:00
|
|
|
// Regex Redirects
|
|
|
|
regexRedirects []*regexRedirect
|
|
|
|
// Sessions
|
|
|
|
loginSessions, captchaSessions *dbSessionStore
|
2021-06-17 14:34:57 +00:00
|
|
|
// Shutdown
|
|
|
|
shutdown shutdowner.Shutdowner
|
2021-06-06 12:39:42 +00:00
|
|
|
// Template strings
|
|
|
|
ts *ts.TemplateStrings
|
|
|
|
// Tor
|
2021-08-02 18:43:24 +00:00
|
|
|
torAddress string
|
|
|
|
torHostname string
|
2021-06-06 12:39:42 +00:00
|
|
|
}
|