Support config mechanism, service block feature.
This commit is contained in:
parent
c6ac334429
commit
54e6a11010
@ -152,6 +152,9 @@ func suitableRelay(activity *activitypub.Activity, actor *activitypub.Actor) boo
|
|||||||
if receivers != 0 {
|
if receivers != 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if relConfig.blockService && actor.Type == "Service" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
main.go
20
main.go
@ -25,6 +25,23 @@ var Actor activitypub.Actor
|
|||||||
// WebfingerResource : Relay's Webfinger resource
|
// WebfingerResource : Relay's Webfinger resource
|
||||||
var WebfingerResource activitypub.WebfingerResource
|
var WebfingerResource activitypub.WebfingerResource
|
||||||
|
|
||||||
|
type relayConfig struct {
|
||||||
|
blockService bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var relConfig relayConfig
|
||||||
|
|
||||||
|
func loadConfig() relayConfig {
|
||||||
|
blockService, err := RedClient.HGet("relay:config", "block_service").Result()
|
||||||
|
if err != nil {
|
||||||
|
RedClient.HSet("relay:config", "block_service", 0)
|
||||||
|
blockService = "0"
|
||||||
|
}
|
||||||
|
return relayConfig{
|
||||||
|
blockService: blockService == "1",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
pemPath := os.Getenv("ACTOR_PEM")
|
pemPath := os.Getenv("ACTOR_PEM")
|
||||||
if pemPath == "" {
|
if pemPath == "" {
|
||||||
@ -71,6 +88,9 @@ func main() {
|
|||||||
Actor = activitypub.GenerateActor(Hostname, &Hostkey.PublicKey)
|
Actor = activitypub.GenerateActor(Hostname, &Hostkey.PublicKey)
|
||||||
WebfingerResource = activitypub.GenerateWebfingerResource(Hostname, &Actor)
|
WebfingerResource = activitypub.GenerateWebfingerResource(Hostname, &Actor)
|
||||||
|
|
||||||
|
// Load Config
|
||||||
|
relConfig = loadConfig()
|
||||||
|
|
||||||
http.HandleFunc("/.well-known/webfinger", handleWebfinger)
|
http.HandleFunc("/.well-known/webfinger", handleWebfinger)
|
||||||
http.HandleFunc("/actor", handleActor)
|
http.HandleFunc("/actor", handleActor)
|
||||||
http.HandleFunc("/inbox", handleInbox)
|
http.HandleFunc("/inbox", handleInbox)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user