fmt and update readme
This commit is contained in:
parent
f2590fbe75
commit
ceaed5f3e7
22
README.md
22
README.md
@ -6,7 +6,27 @@ archives the fediverse
|
|||||||
|
|
||||||
[![CircleCI](https://circleci.com/gh/sneak/feta.svg?style=svg)](https://circleci.com/gh/sneak/feta)
|
[![CircleCI](https://circleci.com/gh/sneak/feta.svg?style=svg)](https://circleci.com/gh/sneak/feta)
|
||||||
|
|
||||||
# author
|
# ethics statement
|
||||||
|
|
||||||
|
It seems that some splinter groups are not well acquainted with the norms of
|
||||||
|
publishing data on the web.
|
||||||
|
|
||||||
|
Publishing your toots/messages on a server without marking them private or
|
||||||
|
requiring authentication and thus making them available to the web is an act
|
||||||
|
of affirmative consent to allowing others to download those toots/messages
|
||||||
|
(usually by viewing them in a browser on your profile page). If you don't
|
||||||
|
want your toots downloaded by remote/unauthenticated users on the web, do
|
||||||
|
not publish them to the web.
|
||||||
|
|
||||||
|
If you publish them to the whole web (and your home instance serves them to
|
||||||
|
all comers), do not be surprised or feel violated when people download (and
|
||||||
|
optionally save) them, as your home instance permits them to.
|
||||||
|
|
||||||
|
We do not have a right to be forgotten, as we do not have a right to delete
|
||||||
|
legitimately-obtained files from the hard drives of other people.
|
||||||
|
|
||||||
|
# Author
|
||||||
|
|
||||||
Jeffrey Paul <[sneak@sneak.berlin](mailto:sneak@sneak.berlin)>
|
Jeffrey Paul <[sneak@sneak.berlin](mailto:sneak@sneak.berlin)>
|
||||||
|
|
||||||
|
[@sneak@sneak.berlin](https://s.sneak.berlin/@sneak)
|
||||||
|
6
feta.go
6
feta.go
@ -4,7 +4,7 @@ import "os"
|
|||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
import "github.com/jinzhu/gorm"
|
import "github.com/jinzhu/gorm"
|
||||||
import _ "github.com/jinzhu/gorm/dialects/sqlite" // required for orm
|
import _ "github.com/jinzhu/gorm/dialects/sqlite" // required for orm
|
||||||
|
|
||||||
import "github.com/rs/zerolog"
|
import "github.com/rs/zerolog"
|
||||||
import "github.com/rs/zerolog/log"
|
import "github.com/rs/zerolog/log"
|
||||||
@ -33,7 +33,7 @@ type Process struct {
|
|||||||
builduser string
|
builduser string
|
||||||
locator *InstanceLocator
|
locator *InstanceLocator
|
||||||
manager *InstanceManager
|
manager *InstanceManager
|
||||||
ingester *tootIngester
|
ingester *tootIngester
|
||||||
api *fetaAPIServer
|
api *fetaAPIServer
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
startup time.Time
|
startup time.Time
|
||||||
@ -109,7 +109,7 @@ func (f *Process) runForever() int {
|
|||||||
f.locator.addInstanceNotificationChannel(newInstanceHostnameNotifications)
|
f.locator.addInstanceNotificationChannel(newInstanceHostnameNotifications)
|
||||||
f.manager.addInstanceNotificationChannel(newInstanceHostnameNotifications)
|
f.manager.addInstanceNotificationChannel(newInstanceHostnameNotifications)
|
||||||
|
|
||||||
f.manager.addTootDestination(f.ingester.getDeliveryChannel())
|
f.manager.addTootDestination(f.ingester.getDeliveryChannel())
|
||||||
|
|
||||||
// ingester goroutine:
|
// ingester goroutine:
|
||||||
go f.ingester.ingest()
|
go f.ingester.ingest()
|
||||||
|
24
ingester.go
24
ingester.go
@ -4,22 +4,30 @@ import "time"
|
|||||||
import "github.com/rs/zerolog/log"
|
import "github.com/rs/zerolog/log"
|
||||||
|
|
||||||
type tootIngester struct {
|
type tootIngester struct {
|
||||||
inbound chan *toot
|
inbound chan *toot
|
||||||
|
recentlySeen
|
||||||
|
}
|
||||||
|
|
||||||
|
type tootHash string
|
||||||
|
|
||||||
|
type seenTootMemo struct {
|
||||||
|
lastSeen time.Time
|
||||||
|
tootHash tootHash
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTootIngester() *tootIngester {
|
func newTootIngester() *tootIngester {
|
||||||
ti := new(tootIngester)
|
ti := new(tootIngester)
|
||||||
ti.inbound = make(chan *toot, 1)
|
ti.inbound = make(chan *toot, 1)
|
||||||
return ti
|
return ti
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ti *tootIngester) getDeliveryChannel() chan *toot {
|
func (ti *tootIngester) getDeliveryChannel() chan *toot {
|
||||||
return ti.inbound
|
return ti.inbound
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ti *tootIngester) ingest() {
|
func (ti *tootIngester) ingest() {
|
||||||
log.Info().Msg("tootIngester starting")
|
log.Info().Msg("tootIngester starting")
|
||||||
for {
|
for {
|
||||||
time.Sleep(1 * time.Second) // FIXME do something
|
time.Sleep(1 * time.Second) // FIXME do something
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,8 +170,8 @@ func (i *instance) nodeIdentified() bool {
|
|||||||
func (i *instance) detectNodeTypeIfNecessary() error {
|
func (i *instance) detectNodeTypeIfNecessary() error {
|
||||||
if !i.nodeIdentified() {
|
if !i.nodeIdentified() {
|
||||||
return i.fetchNodeInfo()
|
return i.fetchNodeInfo()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *instance) registerError() {
|
func (i *instance) registerError() {
|
||||||
|
10
locator.go
10
locator.go
@ -37,7 +37,7 @@ type InstanceLocator struct {
|
|||||||
pleromaIndexNextRefresh *time.Time
|
pleromaIndexNextRefresh *time.Time
|
||||||
mastodonIndexNextRefresh *time.Time
|
mastodonIndexNextRefresh *time.Time
|
||||||
reportInstanceVia chan InstanceHostname
|
reportInstanceVia chan InstanceHostname
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func newInstanceLocator() *InstanceLocator {
|
func newInstanceLocator() *InstanceLocator {
|
||||||
@ -49,11 +49,11 @@ func newInstanceLocator() *InstanceLocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (il *InstanceLocator) lock() {
|
func (il *InstanceLocator) lock() {
|
||||||
il.mu.Lock()
|
il.mu.Lock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (il *InstanceLocator) unlock() {
|
func (il *InstanceLocator) unlock() {
|
||||||
il.mu.Unlock()
|
il.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (il *InstanceLocator) addInstanceNotificationChannel(via chan InstanceHostname) {
|
func (il *InstanceLocator) addInstanceNotificationChannel(via chan InstanceHostname) {
|
||||||
@ -151,8 +151,8 @@ func (il *InstanceLocator) locateMastodon() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info().
|
log.Info().
|
||||||
Msg("fetched mastodon index")
|
Msg("fetched mastodon index")
|
||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
|
10
manager.go
10
manager.go
@ -19,7 +19,7 @@ type InstanceManager struct {
|
|||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
instances map[InstanceHostname]*instance
|
instances map[InstanceHostname]*instance
|
||||||
newInstanceNotifications chan InstanceHostname
|
newInstanceNotifications chan InstanceHostname
|
||||||
newToots chan *toot
|
newToots chan *toot
|
||||||
startup time.Time
|
startup time.Time
|
||||||
hostAdderSemaphore chan bool
|
hostAdderSemaphore chan bool
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ func newInstanceManager() *InstanceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (im *InstanceManager) addTootDestination(td chan *toot) {
|
func (im *InstanceManager) addTootDestination(td chan *toot) {
|
||||||
im.newToots = td
|
im.newToots = td
|
||||||
}
|
}
|
||||||
|
|
||||||
func (im *InstanceManager) logCaller(msg string) {
|
func (im *InstanceManager) logCaller(msg string) {
|
||||||
@ -99,7 +99,7 @@ func (im *InstanceManager) managerLoop() {
|
|||||||
}
|
}
|
||||||
im.unlock()
|
im.unlock()
|
||||||
|
|
||||||
// FIXME is this a bug outside of the mutex above?
|
// FIXME is this a bug outside of the mutex above?
|
||||||
for _, v := range il {
|
for _, v := range il {
|
||||||
go func(i *instance) {
|
go func(i *instance) {
|
||||||
i.Tick()
|
i.Tick()
|
||||||
@ -120,7 +120,7 @@ func (im *InstanceManager) hostnameExists(newhn InstanceHostname) bool {
|
|||||||
|
|
||||||
func (im *InstanceManager) addInstanceByHostname(newhn InstanceHostname) {
|
func (im *InstanceManager) addInstanceByHostname(newhn InstanceHostname) {
|
||||||
if im.hostnameExists(newhn) {
|
if im.hostnameExists(newhn) {
|
||||||
// ignore adding new if we already know about it
|
// ignore adding new if we already know about it
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ func (im *InstanceManager) receiveNewInstanceHostnames() {
|
|||||||
newhn = <-im.newInstanceNotifications
|
newhn = <-im.newInstanceNotifications
|
||||||
// receive them fast out of the channel, let the adding function lock to add
|
// receive them fast out of the channel, let the adding function lock to add
|
||||||
// them one at a time, using a bunch of blocked goroutines as our
|
// them one at a time, using a bunch of blocked goroutines as our
|
||||||
// modification queue
|
// modification queue
|
||||||
go im.addInstanceByHostname(newhn)
|
go im.addInstanceByHostname(newhn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user