few path changes and added fix from master
This commit is contained in:
81
app/api/api.go
Normal file
81
app/api/api.go
Normal file
@ -0,0 +1,81 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/RichardKnop/machinery/v1"
|
||||
cache "github.com/patrickmn/go-cache"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
var (
|
||||
version string
|
||||
globalConfig *models.RelayConfig
|
||||
|
||||
// Actor : Relay's Actor
|
||||
Actor models.Actor
|
||||
|
||||
// WebfingerResource : Relay's Webfinger resource
|
||||
WebfingerResource models.WebfingerResource
|
||||
|
||||
// Nodeinfo : Relay's Nodeinfo
|
||||
Nodeinfo models.NodeinfoResources
|
||||
|
||||
relayState models.RelayState
|
||||
machineryServer *machinery.Server
|
||||
actorCache *cache.Cache
|
||||
)
|
||||
|
||||
func Entrypoint(g *models.RelayConfig, v string) error {
|
||||
var err error
|
||||
globalConfig = g
|
||||
version = v
|
||||
|
||||
err = initialize(globalConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
registResourceHandlers()
|
||||
|
||||
logrus.Info("Staring API Server at ", globalConfig.ServerBind())
|
||||
err = http.ListenAndServe(globalConfig.ServerBind(), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func initialize(globalConfig *models.RelayConfig) error {
|
||||
var err error
|
||||
|
||||
redisClient := globalConfig.RedisClient()
|
||||
relayState = models.NewState(redisClient, true)
|
||||
relayState.ListenNotify(nil)
|
||||
|
||||
machineryServer, err = models.NewMachineryServer(globalConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Actor = models.NewActivityPubActorFromSelfKey(globalConfig)
|
||||
actorCache = cache.New(5*time.Minute, 10*time.Minute)
|
||||
|
||||
WebfingerResource.GenerateFromActor(globalConfig.ServerHostname(), &Actor)
|
||||
Nodeinfo.GenerateFromActor(globalConfig.ServerHostname(), &Actor, version)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func registResourceHandlers() {
|
||||
http.HandleFunc("/.well-known/nodeinfo", handleNodeinfoLink)
|
||||
http.HandleFunc("/.well-known/webfinger", handleWebfinger)
|
||||
http.HandleFunc("/nodeinfo/2.1", handleNodeinfo)
|
||||
http.HandleFunc("/actor", handleActor)
|
||||
http.HandleFunc("/inbox", func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, decodeActivity)
|
||||
})
|
||||
}
|
39
app/api/api_test.go
Normal file
39
app/api/api_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
var err error
|
||||
|
||||
testConfigPath := "../misc/test/config.yml"
|
||||
file, _ := os.Open(testConfigPath)
|
||||
defer file.Close()
|
||||
|
||||
viper.SetConfigType("yaml")
|
||||
viper.ReadConfig(file)
|
||||
viper.Set("ACTOR_PEM", "../misc/test/testKey.pem")
|
||||
viper.BindEnv("REDIS_URL")
|
||||
|
||||
globalConfig, err = models.NewRelayConfig()
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = initialize(globalConfig)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
relayState = models.NewState(relayState.RedisClient, false)
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
code := m.Run()
|
||||
os.Exit(code)
|
||||
}
|
70
app/api/decode.go
Normal file
70
app/api/decode.go
Normal file
@ -0,0 +1,70 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-fed/httpsig"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
func decodeActivity(request *http.Request) (*models.Activity, *models.Actor, []byte, error) {
|
||||
request.Header.Set("Host", request.Host)
|
||||
dataLen, _ := strconv.Atoi(request.Header.Get("Content-Length"))
|
||||
body := make([]byte, dataLen)
|
||||
request.Body.Read(body)
|
||||
|
||||
// Verify HTTPSignature
|
||||
verifier, err := httpsig.NewVerifier(request)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
KeyID := verifier.KeyId()
|
||||
keyOwnerActor := new(models.Actor)
|
||||
err = keyOwnerActor.RetrieveRemoteActor(KeyID, fmt.Sprintf("%s (golang net/http; Activity-Relay %s; %s)", globalConfig.ServerServiceName(), version, globalConfig.ServerHostname().Host), actorCache)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
PubKey, err := models.ReadPublicKeyRSAFromString(keyOwnerActor.PublicKey.PublicKeyPem)
|
||||
if PubKey == nil {
|
||||
return nil, nil, nil, errors.New("Failed parse PublicKey from string")
|
||||
}
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
err = verifier.Verify(PubKey, httpsig.RSA_SHA256)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
// Verify Digest
|
||||
givenDigest := request.Header.Get("Digest")
|
||||
hash := sha256.New()
|
||||
hash.Write(body)
|
||||
b := hash.Sum(nil)
|
||||
calculatedDigest := "SHA-256=" + base64.StdEncoding.EncodeToString(b)
|
||||
|
||||
if givenDigest != calculatedDigest {
|
||||
return nil, nil, nil, errors.New("Digest header is mismatch")
|
||||
}
|
||||
|
||||
// Parse Activity
|
||||
var activity models.Activity
|
||||
err = json.Unmarshal(body, &activity)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
var remoteActor models.Actor
|
||||
err = remoteActor.RetrieveRemoteActor(activity.Actor, fmt.Sprintf("%s (golang net/http; Activity-Relay %s; %s)", globalConfig.ServerServiceName(), version, globalConfig.ServerHostname().Host), actorCache)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
return &activity, &remoteActor, body, nil
|
||||
}
|
117
app/api/decode_test.go
Normal file
117
app/api/decode_test.go
Normal file
@ -0,0 +1,117 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
func TestDecodeActivity(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: "innocent.yukimochi.io",
|
||||
InboxURL: "https://innocent.yukimochi.io/inbox",
|
||||
})
|
||||
|
||||
file, _ := os.Open("../misc/test/create.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
length := strconv.Itoa(len(body))
|
||||
req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body))
|
||||
req.Host = "relay.01.cloudgarage.yukimochi.io"
|
||||
req.Header.Add("content-length", length)
|
||||
req.Header.Add("content-type", "application/activity+json")
|
||||
req.Header.Add("date", "Sun, 23 Dec 2018 07:39:37 GMT")
|
||||
req.Header.Add("digest", "SHA-256=mxgIzbPwBuNYxmjhQeH0vWeEedQGqR1R7zMwR/XTfX8=")
|
||||
req.Header.Add("signature", `keyId="https://innocent.yukimochi.io/users/YUKIMOCHI#main-key",algorithm="rsa-sha256",headers="(request-target) host date digest content-type",signature="MhxXhL21RVp8VmALER2U/oJlWldJAB2COiU2QmwGopLD2pw1c32gQvg0PaBRHfMBBOsidZuRRnj43Kn488zW2xV3n3DYWcGscSh527/hhRzcpLVX2kBqbf/WeQzJmfJVuOX4SzivVhnnUB8PvlPj5LRHpw4n/ctMTq37strKDl9iZg9rej1op1YFJagDxm3iPzAhnv8lzO4RI9dstt2i/sN5EfjXai97oS7EgI//Kj1wJCRk9Pw1iTsGfPTkbk/aVZwDt7QGGvGDdO0JJjsCqtIyjojoyD9hFY9GzMqvTwVIYJrh54AUHq2i80veybaOBbCFcEaK0RpKoLs101r5Uw=="`)
|
||||
|
||||
activity, actor, _, err := decodeActivity(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
|
||||
if activity.Actor != actor.ID {
|
||||
fmt.Println(actor.ID)
|
||||
t.Fatalf("Failed - retrieved actor is invalid")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeActivityWithNoSignature(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: "innocent.yukimochi.io",
|
||||
InboxURL: "https://innocent.yukimochi.io/inbox",
|
||||
})
|
||||
|
||||
file, _ := os.Open("../misc/test/create.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
length := strconv.Itoa(len(body))
|
||||
req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body))
|
||||
req.Host = "relay.01.cloudgarage.yukimochi.io"
|
||||
req.Header.Add("content-length", length)
|
||||
req.Header.Add("content-type", "application/activity+json")
|
||||
req.Header.Add("date", "Sun, 23 Dec 2018 07:39:37 GMT")
|
||||
req.Header.Add("digest", "SHA-256=mxgIzbPwBuNYxmjhQeH0vWeEedQGqR1R7zMwR/XTfX8=")
|
||||
|
||||
_, _, _, err := decodeActivity(req)
|
||||
if err.Error() != "neither \"Signature\" nor \"Authorization\" have signature parameters" {
|
||||
t.Fatalf("Failed - Accept request without signature")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeActivityWithNotFoundKeyId(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: "innocent.yukimochi.io",
|
||||
InboxURL: "https://innocent.yukimochi.io/inbox",
|
||||
})
|
||||
|
||||
file, _ := os.Open("../misc/test/create.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
length := strconv.Itoa(len(body))
|
||||
req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body))
|
||||
req.Host = "relay.01.cloudgarage.yukimochi.io"
|
||||
req.Header.Add("content-length", length)
|
||||
req.Header.Add("content-type", "application/activity+json")
|
||||
req.Header.Add("date", "Sun, 23 Dec 2018 07:39:37 GMT")
|
||||
req.Header.Add("digest", "SHA-256=mxgIzbPwBuNYxmjhQeH0vWeEedQGqR1R7zMwR/XTfX8=")
|
||||
req.Header.Add("signature", `keyId="https://innocent.yukimochi.io/users/admin#main-key",algorithm="rsa-sha256",headers="(request-target) host date digest content-type",signature="MhxXhL21RVp8VmALER2U/oJlWldJAB2COiU2QmwGopLD2pw1c32gQvg0PaBRHfMBBOsidZuRRnj43Kn488zW2xV3n3DYWcGscSh527/hhRzcpLVX2kBqbf/WeQzJmfJVuOX4SzivVhnnUB8PvlPj5LRHpw4n/ctMTq37strKDl9iZg9rej1op1YFJagDxm3iPzAhnv8lzO4RI9dstt2i/sN5EfjXai97oS7EgI//Kj1wJCRk9Pw1iTsGfPTkbk/aVZwDt7QGGvGDdO0JJjsCqtIyjojoyD9hFY9GzMqvTwVIYJrh54AUHq2i80veybaOBbCFcEaK0RpKoLs101r5Uw=="`)
|
||||
|
||||
_, _, _, err := decodeActivity(req)
|
||||
if err.Error() != "404 Not Found" {
|
||||
t.Fatalf("Failed - Accept notfound KeyId")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeActivityWithInvalidDigest(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: "innocent.yukimochi.io",
|
||||
InboxURL: "https://innocent.yukimochi.io/inbox",
|
||||
})
|
||||
|
||||
file, _ := os.Open("../misc/test/create.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
length := strconv.Itoa(len(body))
|
||||
req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body))
|
||||
req.Host = "relay.01.cloudgarage.yukimochi.io"
|
||||
req.Header.Add("content-length", length)
|
||||
req.Header.Add("content-type", "application/activity+json")
|
||||
req.Header.Add("date", "Sun, 23 Dec 2018 07:39:37 GMT")
|
||||
req.Header.Add("digest", "SHA-256=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
|
||||
req.Header.Add("signature", `keyId="https://innocent.yukimochi.io/users/YUKIMOCHI#main-key",algorithm="rsa-sha256",headers="(request-target) host date digest content-type",signature="MhxXhL21RVp8VmALER2U/oJlWldJAB2COiU2QmwGopLD2pw1c32gQvg0PaBRHfMBBOsidZuRRnj43Kn488zW2xV3n3DYWcGscSh527/hhRzcpLVX2kBqbf/WeQzJmfJVuOX4SzivVhnnUB8PvlPj5LRHpw4n/ctMTq37strKDl9iZg9rej1op1YFJagDxm3iPzAhnv8lzO4RI9dstt2i/sN5EfjXai97oS7EgI//Kj1wJCRk9Pw1iTsGfPTkbk/aVZwDt7QGGvGDdO0JJjsCqtIyjojoyD9hFY9GzMqvTwVIYJrh54AUHq2i80veybaOBbCFcEaK0RpKoLs101r5Uw=="`)
|
||||
|
||||
_, _, _, err := decodeActivity(req)
|
||||
if err.Error() != "crypto/rsa: verification error" {
|
||||
t.Fatalf("Failed - Accept unvalid digest")
|
||||
}
|
||||
}
|
323
app/api/handle.go
Normal file
323
app/api/handle.go
Normal file
@ -0,0 +1,323 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/RichardKnop/machinery/v1/tasks"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
func handleWebfinger(writer http.ResponseWriter, request *http.Request) {
|
||||
resource := request.URL.Query()["resource"]
|
||||
if request.Method != "GET" || len(resource) == 0 {
|
||||
writer.WriteHeader(400)
|
||||
writer.Write(nil)
|
||||
} else {
|
||||
request := resource[0]
|
||||
if request == WebfingerResource.Subject {
|
||||
webfingerResource, err := json.Marshal(&WebfingerResource)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
writer.Header().Add("Content-Type", "application/json")
|
||||
writer.WriteHeader(200)
|
||||
writer.Write(webfingerResource)
|
||||
} else {
|
||||
writer.WriteHeader(404)
|
||||
writer.Write(nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func handleNodeinfoLink(writer http.ResponseWriter, request *http.Request) {
|
||||
if request.Method != "GET" {
|
||||
writer.WriteHeader(400)
|
||||
writer.Write(nil)
|
||||
} else {
|
||||
linksResource, err := json.Marshal(&Nodeinfo.NodeinfoLinks)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
writer.Header().Add("Content-Type", "application/json")
|
||||
writer.WriteHeader(200)
|
||||
writer.Write(linksResource)
|
||||
}
|
||||
}
|
||||
|
||||
func handleNodeinfo(writer http.ResponseWriter, request *http.Request) {
|
||||
if request.Method != "GET" {
|
||||
writer.WriteHeader(400)
|
||||
writer.Write(nil)
|
||||
} else {
|
||||
userCount := len(relayState.Subscriptions)
|
||||
Nodeinfo.Nodeinfo.Usage.Users.Total = userCount
|
||||
Nodeinfo.Nodeinfo.Usage.Users.ActiveMonth = userCount
|
||||
Nodeinfo.Nodeinfo.Usage.Users.ActiveHalfyear = userCount
|
||||
linksResource, err := json.Marshal(&Nodeinfo.Nodeinfo)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
writer.Header().Add("Content-Type", "application/json")
|
||||
writer.WriteHeader(200)
|
||||
writer.Write(linksResource)
|
||||
}
|
||||
}
|
||||
|
||||
func handleActor(writer http.ResponseWriter, request *http.Request) {
|
||||
if request.Method == "GET" {
|
||||
actor, err := json.Marshal(&Actor)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
writer.Header().Add("Content-Type", "application/activity+json")
|
||||
writer.WriteHeader(200)
|
||||
writer.Write(actor)
|
||||
} else {
|
||||
writer.WriteHeader(400)
|
||||
writer.Write(nil)
|
||||
}
|
||||
}
|
||||
|
||||
func contains(entries interface{}, finder string) bool {
|
||||
switch entry := entries.(type) {
|
||||
case string:
|
||||
return entry == finder
|
||||
case []string:
|
||||
for i := 0; i < len(entry); i++ {
|
||||
if entry[i] == finder {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
case []models.Subscription:
|
||||
for i := 0; i < len(entry); i++ {
|
||||
if entry[i].Domain == finder {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func pushRelayJob(sourceInbox string, body []byte) {
|
||||
for _, domain := range relayState.Subscriptions {
|
||||
if sourceInbox != domain.Domain {
|
||||
job := &tasks.Signature{
|
||||
Name: "relay",
|
||||
RetryCount: 0,
|
||||
Args: []tasks.Arg{
|
||||
{
|
||||
Name: "inboxURL",
|
||||
Type: "string",
|
||||
Value: domain.InboxURL,
|
||||
},
|
||||
{
|
||||
Name: "body",
|
||||
Type: "string",
|
||||
Value: string(body),
|
||||
},
|
||||
},
|
||||
}
|
||||
_, err := machineryServer.SendTask(job)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func pushRegisterJob(inboxURL string, body []byte) {
|
||||
job := &tasks.Signature{
|
||||
Name: "register",
|
||||
RetryCount: 2,
|
||||
Args: []tasks.Arg{
|
||||
{
|
||||
Name: "inboxURL",
|
||||
Type: "string",
|
||||
Value: inboxURL,
|
||||
},
|
||||
{
|
||||
Name: "body",
|
||||
Type: "string",
|
||||
Value: string(body),
|
||||
},
|
||||
},
|
||||
}
|
||||
_, err := machineryServer.SendTask(job)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func followAcceptable(activity *models.Activity, actor *models.Actor) error {
|
||||
if contains(activity.Object, "https://www.w3.org/ns/activitystreams#Public") {
|
||||
return nil
|
||||
} else {
|
||||
return errors.New("Follow only allowed for https://www.w3.org/ns/activitystreams#Public")
|
||||
}
|
||||
}
|
||||
|
||||
func unFollowAcceptable(activity *models.Activity, actor *models.Actor) error {
|
||||
if contains(activity.Object, "https://www.w3.org/ns/activitystreams#Public") {
|
||||
return nil
|
||||
} else {
|
||||
return errors.New("Unfollow only allowed for https://www.w3.org/ns/activitystreams#Public")
|
||||
}
|
||||
}
|
||||
|
||||
func suitableFollow(activity *models.Activity, actor *models.Actor) bool {
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
if contains(relayState.BlockedDomains, domain.Host) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func relayAcceptable(activity *models.Activity, actor *models.Actor) error {
|
||||
if !contains(activity.To, "https://www.w3.org/ns/activitystreams#Public") && !contains(activity.Cc, "https://www.w3.org/ns/activitystreams#Public") {
|
||||
return errors.New("activity should contain https://www.w3.org/ns/activitystreams#Public as receiver")
|
||||
}
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
if contains(relayState.Subscriptions, domain.Host) {
|
||||
return nil
|
||||
}
|
||||
return errors.New("to use the relay service, Subscribe me in advance")
|
||||
}
|
||||
|
||||
func suitableRelay(activity *models.Activity, actor *models.Actor) bool {
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
if contains(relayState.LimitedDomains, domain.Host) {
|
||||
return false
|
||||
}
|
||||
if relayState.RelayConfig.BlockService && actor.Type != "Person" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func handleInbox(writer http.ResponseWriter, request *http.Request, activityDecoder func(*http.Request) (*models.Activity, *models.Actor, []byte, error)) {
|
||||
switch request.Method {
|
||||
case "POST":
|
||||
activity, actor, body, err := activityDecoder(request)
|
||||
if err != nil {
|
||||
writer.WriteHeader(400)
|
||||
writer.Write(nil)
|
||||
} else {
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
switch activity.Type {
|
||||
case "Follow":
|
||||
err = followAcceptable(activity, actor)
|
||||
if err != nil {
|
||||
resp := activity.GenerateResponse(globalConfig.ServerHostname(), "Reject")
|
||||
jsonData, _ := json.Marshal(&resp)
|
||||
go pushRegisterJob(actor.Inbox, jsonData)
|
||||
logrus.Error("Reject Follow Request : ", err.Error(), activity.Actor)
|
||||
|
||||
writer.WriteHeader(202)
|
||||
writer.Write(nil)
|
||||
} else {
|
||||
if suitableFollow(activity, actor) {
|
||||
if relayState.RelayConfig.ManuallyAccept {
|
||||
relayState.RedisClient.HMSet("relay:pending:"+domain.Host, map[string]interface{}{
|
||||
"inbox_url": actor.Endpoints.SharedInbox,
|
||||
"activity_id": activity.ID,
|
||||
"type": "Follow",
|
||||
"actor": actor.ID,
|
||||
"object": activity.Object.(string),
|
||||
})
|
||||
logrus.Info("Pending Follow Request : ", activity.Actor)
|
||||
} else {
|
||||
resp := activity.GenerateResponse(globalConfig.ServerHostname(), "Accept")
|
||||
jsonData, _ := json.Marshal(&resp)
|
||||
go pushRegisterJob(actor.Inbox, jsonData)
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: domain.Host,
|
||||
InboxURL: actor.Endpoints.SharedInbox,
|
||||
ActivityID: activity.ID,
|
||||
ActorID: actor.ID,
|
||||
})
|
||||
logrus.Info("Accept Follow Request : ", activity.Actor)
|
||||
}
|
||||
} else {
|
||||
resp := activity.GenerateResponse(globalConfig.ServerHostname(), "Reject")
|
||||
jsonData, _ := json.Marshal(&resp)
|
||||
go pushRegisterJob(actor.Inbox, jsonData)
|
||||
logrus.Info("Reject Follow Request : ", activity.Actor)
|
||||
}
|
||||
|
||||
writer.WriteHeader(202)
|
||||
writer.Write(nil)
|
||||
}
|
||||
case "Undo":
|
||||
nestedActivity, _ := activity.NestedActivity()
|
||||
if nestedActivity.Type == "Follow" && nestedActivity.Actor == activity.Actor {
|
||||
err = unFollowAcceptable(nestedActivity, actor)
|
||||
if err != nil {
|
||||
logrus.Error("Reject Unfollow Request : ", err.Error())
|
||||
writer.WriteHeader(400)
|
||||
writer.Write([]byte(err.Error()))
|
||||
} else {
|
||||
relayState.DelSubscription(domain.Host)
|
||||
logrus.Info("Accept Unfollow Request : ", activity.Actor)
|
||||
|
||||
writer.WriteHeader(202)
|
||||
writer.Write(nil)
|
||||
}
|
||||
} else {
|
||||
err = relayAcceptable(activity, actor)
|
||||
if err != nil {
|
||||
writer.WriteHeader(400)
|
||||
writer.Write([]byte(err.Error()))
|
||||
} else {
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
go pushRelayJob(domain.Host, body)
|
||||
logrus.Debug("Accept Relay Status : ", activity.Actor)
|
||||
|
||||
writer.WriteHeader(202)
|
||||
writer.Write(nil)
|
||||
}
|
||||
}
|
||||
case "Create", "Update", "Delete", "Announce", "Move":
|
||||
err = relayAcceptable(activity, actor)
|
||||
if err != nil {
|
||||
writer.WriteHeader(400)
|
||||
writer.Write([]byte(err.Error()))
|
||||
} else {
|
||||
if suitableRelay(activity, actor) {
|
||||
if relayState.RelayConfig.CreateAsAnnounce && activity.Type == "Create" {
|
||||
nestedObject, err := activity.NestedActivity()
|
||||
if err != nil {
|
||||
logrus.Error("Fail Decode Activity : ", err.Error())
|
||||
}
|
||||
switch nestedObject.Type {
|
||||
case "Note":
|
||||
resp := nestedObject.GenerateAnnounce(globalConfig.ServerHostname())
|
||||
jsonData, _ := json.Marshal(&resp)
|
||||
go pushRelayJob(domain.Host, jsonData)
|
||||
logrus.Debug("Accept Announce Note : ", activity.Actor)
|
||||
default:
|
||||
logrus.Debug("Skipping Announce", nestedObject.Type, ": ", activity.Actor)
|
||||
}
|
||||
} else {
|
||||
go pushRelayJob(domain.Host, body)
|
||||
logrus.Debug("Accept Relay Status : ", activity.Actor)
|
||||
}
|
||||
} else {
|
||||
logrus.Debug("Skipping Relay Status : ", activity.Actor)
|
||||
}
|
||||
|
||||
writer.WriteHeader(202)
|
||||
writer.Write(nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
writer.WriteHeader(404)
|
||||
writer.Write(nil)
|
||||
}
|
||||
}
|
786
app/api/handle_test.go
Normal file
786
app/api/handle_test.go
Normal file
@ -0,0 +1,786 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
const (
|
||||
BlockService models.Config = iota
|
||||
ManuallyAccept
|
||||
CreateAsAnnounce
|
||||
)
|
||||
|
||||
func TestHandleWebfingerGet(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(handleWebfinger))
|
||||
defer s.Close()
|
||||
|
||||
req, _ := http.NewRequest("GET", s.URL, nil)
|
||||
q := req.URL.Query()
|
||||
q.Add("resource", "acct:relay@"+globalConfig.ServerHostname().Host)
|
||||
req.URL.RawQuery = q.Encode()
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.Header.Get("Content-Type") != "application/json" {
|
||||
t.Fatalf("Failed - Content-Type not match.")
|
||||
}
|
||||
if r.StatusCode != 200 {
|
||||
t.Fatalf("Failed - StatusCode is not 200.")
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
data, _ := ioutil.ReadAll(r.Body)
|
||||
var webfingerResource models.WebfingerResource
|
||||
err = json.Unmarshal(data, &webfingerResource)
|
||||
if err != nil {
|
||||
t.Fatalf("WebfingerResource response is not valid.")
|
||||
}
|
||||
|
||||
domain, _ := url.Parse(webfingerResource.Links[0].Href)
|
||||
if domain.Host != globalConfig.ServerHostname().Host {
|
||||
t.Fatalf("WebfingerResource's Host not valid.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleWebfingerGetBadResource(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(handleWebfinger))
|
||||
defer s.Close()
|
||||
|
||||
req, _ := http.NewRequest("GET", s.URL, nil)
|
||||
q := req.URL.Query()
|
||||
q.Add("resource", "acct:yukimochi@"+os.Getenv("RELAY_DOMAIN"))
|
||||
req.URL.RawQuery = q.Encode()
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 404 {
|
||||
t.Fatalf("Failed - StatusCode is not 404.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleNodeinfoLinkGet(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(handleNodeinfoLink))
|
||||
defer s.Close()
|
||||
|
||||
req, _ := http.NewRequest("GET", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.Header.Get("Content-Type") != "application/json" {
|
||||
t.Fatalf("Failed - Content-Type not match.")
|
||||
}
|
||||
if r.StatusCode != 200 {
|
||||
t.Fatalf("Failed - StatusCode is not 200.")
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
data, _ := ioutil.ReadAll(r.Body)
|
||||
var nodeinfoLinks models.NodeinfoLinks
|
||||
err = json.Unmarshal(data, &nodeinfoLinks)
|
||||
if err != nil {
|
||||
t.Fatalf("NodeinfoLinks response is not valid.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleNodeinfoLinkInvalidMethod(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(handleNodeinfoLink))
|
||||
defer s.Close()
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 400 {
|
||||
t.Fatalf("Failed - StatusCode is not 400.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleNodeinfoGet(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(handleNodeinfo))
|
||||
defer s.Close()
|
||||
|
||||
req, _ := http.NewRequest("GET", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.Header.Get("Content-Type") != "application/json" {
|
||||
t.Fatalf("Failed - Content-Type not match.")
|
||||
}
|
||||
if r.StatusCode != 200 {
|
||||
t.Fatalf("Failed - StatusCode is not 200.")
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
data, _ := ioutil.ReadAll(r.Body)
|
||||
var nodeinfo models.Nodeinfo
|
||||
err = json.Unmarshal(data, &nodeinfo)
|
||||
if err != nil {
|
||||
t.Fatalf("Nodeinfo response is not valid.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleNodeinfoInvalidMethod(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(handleNodeinfo))
|
||||
defer s.Close()
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 400 {
|
||||
t.Fatalf("Failed - StatusCode is not 400.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleWebfingerInvalidMethod(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(handleWebfinger))
|
||||
defer s.Close()
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 400 {
|
||||
t.Fatalf("Failed - StatusCode is not 400.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleActorGet(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(handleActor))
|
||||
defer s.Close()
|
||||
|
||||
r, err := http.Get(s.URL)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.Header.Get("Content-Type") != "application/activity+json" {
|
||||
t.Fatalf("Failed - Content-Type not match.")
|
||||
}
|
||||
if r.StatusCode != 200 {
|
||||
t.Fatalf("Failed - StatusCode is not 200.")
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
data, _ := ioutil.ReadAll(r.Body)
|
||||
var actor models.Actor
|
||||
err = json.Unmarshal(data, &actor)
|
||||
if err != nil {
|
||||
t.Fatalf("Actor response is not valid.")
|
||||
}
|
||||
|
||||
domain, _ := url.Parse(actor.ID)
|
||||
if domain.Host != globalConfig.ServerHostname().Host {
|
||||
t.Fatalf("Actor's Host not valid.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleActorInvalidMethod(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(handleActor))
|
||||
defer s.Close()
|
||||
|
||||
r, err := http.Post(s.URL, "text/plain", nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 400 {
|
||||
t.Fatalf("Failed - StatusCode is not 400.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestContains(t *testing.T) {
|
||||
data := "nil"
|
||||
sData := []string{
|
||||
"no",
|
||||
"nil",
|
||||
}
|
||||
badData := 0
|
||||
result := contains(data, "true")
|
||||
if result != false {
|
||||
t.Fatalf("Failed - no contain but true.")
|
||||
}
|
||||
result = contains(data, "nil")
|
||||
if result != true {
|
||||
t.Fatalf("Failed - contain but false.")
|
||||
}
|
||||
result = contains(sData, "true")
|
||||
if result != false {
|
||||
t.Fatalf("Failed - no contain but true. (slice)")
|
||||
}
|
||||
result = contains(sData, "nil")
|
||||
if result != true {
|
||||
t.Fatalf("Failed - contain but false. (slice)")
|
||||
}
|
||||
result = contains(badData, "hoge")
|
||||
if result != false {
|
||||
t.Fatalf("Failed - input bad data but true. (slice)")
|
||||
}
|
||||
}
|
||||
|
||||
func mockActivityDecoderProvider(activity *models.Activity, actor *models.Actor) func(r *http.Request) (*models.Activity, *models.Actor, []byte, error) {
|
||||
return func(r *http.Request) (*models.Activity, *models.Actor, []byte, error) {
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return activity, actor, body, nil
|
||||
}
|
||||
}
|
||||
|
||||
func mockActivity(req string) models.Activity {
|
||||
switch req {
|
||||
case "Follow":
|
||||
file, _ := os.Open("../misc/test/follow.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
var activity models.Activity
|
||||
json.Unmarshal(body, &activity)
|
||||
return activity
|
||||
case "Invalid-Follow":
|
||||
file, _ := os.Open("../misc/test/followAsActor.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
var activity models.Activity
|
||||
json.Unmarshal(body, &activity)
|
||||
return activity
|
||||
case "Unfollow":
|
||||
file, _ := os.Open("../misc/test/unfollow.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
var activity models.Activity
|
||||
json.Unmarshal(body, &activity)
|
||||
return activity
|
||||
case "Invalid-Unfollow":
|
||||
body := "{\"@context\":\"https://www.w3.org/ns/activitystreams\",\"id\":\"https://mastodon.test.yukimochi.io/c125e836-e622-478e-a22d-2d9fbf2f496f\",\"type\":\"Undo\",\"actor\":\"https://mastodon.test.yukimochi.io/users/yukimochi\",\"object\":{\"@context\":\"https://www.w3.org/ns/activitystreams\",\"id\":\"https://hacked.test.yukimochi.io/c125e836-e622-478e-a22d-2d9fbf2f496f\",\"type\":\"Follow\",\"actor\":\"https://hacked.test.yukimochi.io/users/yukimochi\",\"object\":\"https://www.w3.org/ns/activitystreams#Public\"}}"
|
||||
var activity models.Activity
|
||||
json.Unmarshal([]byte(body), &activity)
|
||||
return activity
|
||||
case "UnfollowAsActor":
|
||||
body := "{\"@context\":\"https://www.w3.org/ns/activitystreams\",\"id\":\"https://mastodon.test.yukimochi.io/c125e836-e622-478e-a22d-2d9fbf2f496f\",\"type\":\"Undo\",\"actor\":\"https://mastodon.test.yukimochi.io/users/yukimochi\",\"object\":{\"@context\":\"https://www.w3.org/ns/activitystreams\",\"id\":\"https://hacked.test.yukimochi.io/c125e836-e622-478e-a22d-2d9fbf2f496f\",\"type\":\"Follow\",\"actor\":\"https://mastodon.test.yukimochi.io/users/yukimochi\",\"object\":\"https://relay.yukimochi.example.org/actor\"}}"
|
||||
var activity models.Activity
|
||||
json.Unmarshal([]byte(body), &activity)
|
||||
return activity
|
||||
case "Create":
|
||||
file, _ := os.Open("../misc/test/create.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
var activity models.Activity
|
||||
json.Unmarshal(body, &activity)
|
||||
return activity
|
||||
case "Create-Article":
|
||||
body := "{\"@context\":[\"https://www.w3.org/ns/activitystreams\",\"https://w3id.org/security/v1\",{\"manuallyApprovesFollowers\":\"as:manuallyApprovesFollowers\",\"sensitive\":\"as:sensitive\",\"movedTo\":{\"@id\":\"as:movedTo\",\"@type\":\"@id\"},\"Hashtag\":\"as:Hashtag\",\"ostatus\":\"http://ostatus.org#\",\"atomUri\":\"ostatus:atomUri\",\"inReplyToAtomUri\":\"ostatus:inReplyToAtomUri\",\"conversation\":\"ostatus:conversation\",\"toot\":\"http://joinmastodon.org/ns#\",\"Emoji\":\"toot:Emoji\",\"focalPoint\":{\"@container\":\"@list\",\"@id\":\"toot:focalPoint\"},\"featured\":{\"@id\":\"toot:featured\",\"@type\":\"@id\"},\"schema\":\"http://schema.org#\",\"PropertyValue\":\"schema:PropertyValue\",\"value\":\"schema:value\"}],\"id\":\"https://mastodon.test.yukimochi.io/users/yukimochi/statuses/101075045564444857/activity\",\"type\":\"Create\",\"actor\":\"https://mastodon.test.yukimochi.io/users/yukimochi\",\"published\":\"2018-11-15T11:07:26Z\",\"to\":[\"https://www.w3.org/ns/activitystreams#Public\"],\"cc\":[\"https://mastodon.test.yukimochi.io/users/yukimochi/followers\"],\"object\":{\"id\":\"https://mastodon.test.yukimochi.io/users/yukimochi/statuses/101075045564444857\",\"type\":\"Article\",\"summary\":null,\"inReplyTo\":null,\"published\":\"2018-11-15T11:07:26Z\",\"url\":\"https://mastodon.test.yukimochi.io/@yukimochi/101075045564444857\",\"attributedTo\":\"https://mastodon.test.yukimochi.io/users/yukimochi\",\"to\":[\"https://www.w3.org/ns/activitystreams#Public\"],\"cc\":[\"https://mastodon.test.yukimochi.io/users/yukimochi/followers\"],\"sensitive\":false,\"atomUri\":\"https://mastodon.test.yukimochi.io/users/yukimochi/statuses/101075045564444857\",\"inReplyToAtomUri\":null,\"conversation\":\"tag:mastodon.test.yukimochi.io,2018-11-15:objectId=68:objectType=Conversation\",\"content\":\"<p>Actvity-Relay</p>\",\"contentMap\":{\"en\":\"<p>Actvity-Relay</p>\"},\"attachment\":[],\"tag\":[]},\"signature\":{\"type\":\"RsaSignature2017\",\"creator\":\"https://mastodon.test.yukimochi.io/users/yukimochi#main-key\",\"created\":\"2018-11-15T11:07:26Z\",\"signatureValue\":\"mMgl2GgVPgb1Kw6a2iDIZc7r0j3ob+Cl9y+QkCxIe6KmnUzb15e60UuhkE5j3rJnoTwRKqOFy1PMkSxlYW6fPG/5DBxW9I4kX+8sw8iH/zpwKKUOnXUJEqfwRrNH2ix33xcs/GkKPdedY6iAPV9vGZ10MSMOdypfYgU9r+UI0sTaaC2iMXH0WPnHQuYAI+Q1JDHIbDX5FH1WlDL6+8fKAicf3spBMxDwPHGPK8W2jmDLWdN2Vz4ffsCtWs5BCuqOKZrtTW0Rdd4HWzo40MnRXvBjv7yNlnnKzokANBqiOLWT7kNfK0+Vtnt6c/bNX64KBro53KR7wL3ZBvPVuv5rdQ==\"}}"
|
||||
var activity models.Activity
|
||||
json.Unmarshal([]byte(body), &activity)
|
||||
return activity
|
||||
case "Announce":
|
||||
file, _ := os.Open("../misc/test/announce.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
var activity models.Activity
|
||||
json.Unmarshal(body, &activity)
|
||||
return activity
|
||||
case "Undo":
|
||||
file, _ := os.Open("../misc/test/undo.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
var activity models.Activity
|
||||
json.Unmarshal(body, &activity)
|
||||
return activity
|
||||
default:
|
||||
panic("No assigned request.")
|
||||
}
|
||||
}
|
||||
|
||||
func mockActor(req string) models.Actor {
|
||||
switch req {
|
||||
case "Person":
|
||||
file, _ := os.Open("../misc/test/person.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
var actor models.Actor
|
||||
json.Unmarshal(body, &actor)
|
||||
return actor
|
||||
case "Service":
|
||||
file, _ := os.Open("../misc/test/service.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
var actor models.Actor
|
||||
json.Unmarshal(body, &actor)
|
||||
return actor
|
||||
case "Application":
|
||||
file, _ := os.Open("../misc/test/application.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
var actor models.Actor
|
||||
json.Unmarshal(body, &actor)
|
||||
return actor
|
||||
default:
|
||||
panic("No assigned request.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuitableRelayNoBlockService(t *testing.T) {
|
||||
activity := mockActivity("Create")
|
||||
personActor := mockActor("Person")
|
||||
serviceActor := mockActor("Service")
|
||||
applicationActor := mockActor("Application")
|
||||
|
||||
relayState.SetConfig(BlockService, false)
|
||||
|
||||
if suitableRelay(&activity, &personActor) != true {
|
||||
t.Fatalf("Failed - Person status not relay")
|
||||
}
|
||||
if suitableRelay(&activity, &serviceActor) != true {
|
||||
t.Fatalf("Failed - Service status not relay")
|
||||
}
|
||||
if suitableRelay(&activity, &applicationActor) != true {
|
||||
t.Fatalf("Failed - Service status not relay")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuitableRelayBlockService(t *testing.T) {
|
||||
activity := mockActivity("Create")
|
||||
personActor := mockActor("Person")
|
||||
serviceActor := mockActor("Service")
|
||||
applicationActor := mockActor("Application")
|
||||
|
||||
relayState.SetConfig(BlockService, true)
|
||||
|
||||
if suitableRelay(&activity, &personActor) != true {
|
||||
t.Fatalf("Failed - Person status not relay")
|
||||
}
|
||||
if suitableRelay(&activity, &serviceActor) != false {
|
||||
t.Fatalf("Failed - Service status may relay when blocking mode")
|
||||
}
|
||||
if suitableRelay(&activity, &applicationActor) != false {
|
||||
t.Fatalf("Failed - Application status may relay when blocking mode")
|
||||
}
|
||||
relayState.SetConfig(BlockService, false)
|
||||
}
|
||||
|
||||
func TestHandleInboxNoSignature(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, decodeActivity)
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 400 {
|
||||
t.Fatalf("Failed - StatusCode is not 400")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleInboxInvalidMethod(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, decodeActivity)
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
req, _ := http.NewRequest("GET", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 404 {
|
||||
t.Fatalf("Failed - StatusCode is not 404")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleInboxValidFollow(t *testing.T) {
|
||||
activity := mockActivity("Follow")
|
||||
actor := mockActor("Person")
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, mockActivityDecoderProvider(&activity, &actor))
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 202 {
|
||||
t.Fatalf("Failed - StatusCode is not 202 - " + strconv.Itoa(r.StatusCode))
|
||||
}
|
||||
res, _ := relayState.RedisClient.Exists("relay:subscription:" + domain.Host).Result()
|
||||
if res != 1 {
|
||||
t.Fatalf("Failed - Subscription not works.")
|
||||
}
|
||||
relayState.DelSubscription(domain.Host)
|
||||
}
|
||||
|
||||
func TestHandleInboxValidManuallyFollow(t *testing.T) {
|
||||
activity := mockActivity("Follow")
|
||||
actor := mockActor("Person")
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, mockActivityDecoderProvider(&activity, &actor))
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
// Switch Manually
|
||||
relayState.SetConfig(ManuallyAccept, true)
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 202 {
|
||||
t.Fatalf("Failed - StatusCode is not 202 - " + strconv.Itoa(r.StatusCode))
|
||||
}
|
||||
res, _ := relayState.RedisClient.Exists("relay:pending:" + domain.Host).Result()
|
||||
if res != 1 {
|
||||
t.Fatalf("Failed - Pending not works.")
|
||||
}
|
||||
res, _ = relayState.RedisClient.Exists("relay:subscription:" + domain.Host).Result()
|
||||
if res != 0 {
|
||||
t.Fatalf("Failed - Pending was skipped.")
|
||||
}
|
||||
relayState.DelSubscription(domain.Host)
|
||||
relayState.SetConfig(ManuallyAccept, false)
|
||||
}
|
||||
|
||||
func TestHandleInboxInvalidFollow(t *testing.T) {
|
||||
activity := mockActivity("Invalid-Follow")
|
||||
actor := mockActor("Person")
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, mockActivityDecoderProvider(&activity, &actor))
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
relayState.SetConfig(ManuallyAccept, false)
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 202 {
|
||||
t.Fatalf("Failed - StatusCode is not 202 - " + strconv.Itoa(r.StatusCode))
|
||||
}
|
||||
res, _ := relayState.RedisClient.Exists("relay:subscription:" + domain.Host).Result()
|
||||
if res != 0 {
|
||||
t.Fatalf("Failed - Subscription not blocked.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleInboxValidFollowBlocked(t *testing.T) {
|
||||
activity := mockActivity("Follow")
|
||||
actor := mockActor("Person")
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, mockActivityDecoderProvider(&activity, &actor))
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
relayState.SetBlockedDomain(domain.Host, true)
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 202 {
|
||||
t.Fatalf("Failed - StatusCode is not 202 - " + strconv.Itoa(r.StatusCode))
|
||||
}
|
||||
res, _ := relayState.RedisClient.Exists("relay:subscription:" + domain.Host).Result()
|
||||
if res != 0 {
|
||||
t.Fatalf("Failed - Subscription not blocked.")
|
||||
}
|
||||
relayState.DelSubscription(domain.Host)
|
||||
relayState.SetBlockedDomain(domain.Host, false)
|
||||
}
|
||||
|
||||
func TestHandleInboxValidUnfollow(t *testing.T) {
|
||||
activity := mockActivity("Unfollow")
|
||||
actor := mockActor("Person")
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, mockActivityDecoderProvider(&activity, &actor))
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: domain.Host,
|
||||
InboxURL: "https://mastodon.test.yukimochi.io/inbox",
|
||||
})
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 202 {
|
||||
t.Fatalf("Failed - StatusCode is not 202 - " + strconv.Itoa(r.StatusCode))
|
||||
}
|
||||
res, _ := relayState.RedisClient.Exists("relay:subscription:" + domain.Host).Result()
|
||||
if res != 0 {
|
||||
t.Fatalf("Failed - Subscription not succeed.")
|
||||
}
|
||||
relayState.DelSubscription(domain.Host)
|
||||
}
|
||||
|
||||
func TestHandleInboxInvalidUnfollow(t *testing.T) {
|
||||
activity := mockActivity("Invalid-Unfollow")
|
||||
actor := mockActor("Person")
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, mockActivityDecoderProvider(&activity, &actor))
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: domain.Host,
|
||||
InboxURL: "https://mastodon.test.yukimochi.io/inbox",
|
||||
})
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 400 {
|
||||
t.Fatalf("Failed - StatusCode is not 400")
|
||||
}
|
||||
res, _ := relayState.RedisClient.Exists("relay:subscription:" + domain.Host).Result()
|
||||
if res != 1 {
|
||||
t.Fatalf("Failed - Block hacked unfollow not succeed.")
|
||||
}
|
||||
relayState.DelSubscription(domain.Host)
|
||||
}
|
||||
|
||||
func TestHandleInboxUnfollowAsActor(t *testing.T) {
|
||||
activity := mockActivity("UnfollowAsActor")
|
||||
actor := mockActor("Person")
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, mockActivityDecoderProvider(&activity, &actor))
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: domain.Host,
|
||||
InboxURL: "https://mastodon.test.yukimochi.io/inbox",
|
||||
})
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 400 {
|
||||
t.Fatalf("Failed - StatusCode is not 400")
|
||||
}
|
||||
res, _ := relayState.RedisClient.Exists("relay:subscription:" + domain.Host).Result()
|
||||
if res != 1 {
|
||||
t.Fatalf("Failed - Block actor unfollow not succeed.")
|
||||
}
|
||||
relayState.DelSubscription(domain.Host)
|
||||
}
|
||||
|
||||
func TestHandleInboxValidCreate(t *testing.T) {
|
||||
activity := mockActivity("Create")
|
||||
actor := mockActor("Person")
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, mockActivityDecoderProvider(&activity, &actor))
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: domain.Host,
|
||||
InboxURL: "https://mastodon.test.yukimochi.io/inbox",
|
||||
})
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: "example.org",
|
||||
InboxURL: "https://example.org/inbox",
|
||||
})
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 202 {
|
||||
t.Fatalf("Failed - StatusCode is not 202 - " + strconv.Itoa(r.StatusCode))
|
||||
}
|
||||
relayState.DelSubscription(domain.Host)
|
||||
relayState.DelSubscription("example.org")
|
||||
relayState.RedisClient.Del("relay:subscription:" + domain.Host).Result()
|
||||
relayState.RedisClient.Del("relay:subscription:example.org").Result()
|
||||
}
|
||||
|
||||
func TestHandleInboxLimitedCreate(t *testing.T) {
|
||||
activity := mockActivity("Create")
|
||||
actor := mockActor("Person")
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, mockActivityDecoderProvider(&activity, &actor))
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: domain.Host,
|
||||
InboxURL: "https://mastodon.test.yukimochi.io/inbox",
|
||||
})
|
||||
relayState.SetLimitedDomain(domain.Host, true)
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 202 {
|
||||
t.Fatalf("Failed - StatusCode is not 202 - " + strconv.Itoa(r.StatusCode))
|
||||
}
|
||||
relayState.DelSubscription(domain.Host)
|
||||
relayState.SetLimitedDomain(domain.Host, false)
|
||||
}
|
||||
|
||||
func TestHandleInboxValidCreateAsAnnounceNote(t *testing.T) {
|
||||
activity := mockActivity("Create")
|
||||
actor := mockActor("Person")
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, mockActivityDecoderProvider(&activity, &actor))
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: domain.Host,
|
||||
InboxURL: "https://mastodon.test.yukimochi.io/inbox",
|
||||
})
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: "example.org",
|
||||
InboxURL: "https://example.org/inbox",
|
||||
})
|
||||
relayState.SetConfig(CreateAsAnnounce, true)
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 202 {
|
||||
t.Fatalf("Failed - StatusCode is not 202 - " + strconv.Itoa(r.StatusCode))
|
||||
}
|
||||
relayState.DelSubscription(domain.Host)
|
||||
relayState.DelSubscription("example.org")
|
||||
relayState.SetConfig(CreateAsAnnounce, false)
|
||||
}
|
||||
|
||||
func TestHandleInboxValidCreateAsAnnounceNoNote(t *testing.T) {
|
||||
activity := mockActivity("Create-Article")
|
||||
actor := mockActor("Person")
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, mockActivityDecoderProvider(&activity, &actor))
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: domain.Host,
|
||||
InboxURL: "https://mastodon.test.yukimochi.io/inbox",
|
||||
})
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: "example.org",
|
||||
InboxURL: "https://example.org/inbox",
|
||||
})
|
||||
relayState.SetConfig(CreateAsAnnounce, true)
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 202 {
|
||||
t.Fatalf("Failed - StatusCode is not 202 - " + strconv.Itoa(r.StatusCode))
|
||||
}
|
||||
relayState.DelSubscription(domain.Host)
|
||||
relayState.DelSubscription("example.org")
|
||||
relayState.SetConfig(CreateAsAnnounce, false)
|
||||
}
|
||||
|
||||
func TestHandleInboxUnsubscriptionCreate(t *testing.T) {
|
||||
activity := mockActivity("Create")
|
||||
actor := mockActor("Person")
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, mockActivityDecoderProvider(&activity, &actor))
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 400 {
|
||||
t.Fatalf("Failed - StatusCode is not 400")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleInboxUndo(t *testing.T) {
|
||||
activity := mockActivity("Undo")
|
||||
actor := mockActor("Person")
|
||||
domain, _ := url.Parse(activity.Actor)
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handleInbox(w, r, mockActivityDecoderProvider(&activity, &actor))
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: domain.Host,
|
||||
InboxURL: "https://mastodon.test.yukimochi.io/inbox",
|
||||
})
|
||||
|
||||
req, _ := http.NewRequest("POST", s.URL, nil)
|
||||
client := new(http.Client)
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
if r.StatusCode != 202 {
|
||||
t.Fatalf("Failed - StatusCode is not 202 - " + strconv.Itoa(r.StatusCode))
|
||||
}
|
||||
res, _ := relayState.RedisClient.Exists("relay:subscription:" + domain.Host).Result()
|
||||
if res != 1 {
|
||||
t.Fatalf("Failed - Missing unsubscribed.")
|
||||
}
|
||||
relayState.DelSubscription(domain.Host)
|
||||
}
|
173
app/control/config.go
Normal file
173
app/control/config.go
Normal file
@ -0,0 +1,173 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
const (
|
||||
BlockService models.Config = iota
|
||||
ManuallyAccept
|
||||
CreateAsAnnounce
|
||||
)
|
||||
|
||||
func configCmdInit() *cobra.Command {
|
||||
var config = &cobra.Command{
|
||||
Use: "config",
|
||||
Short: "Manage configuration for relay",
|
||||
Long: "Enable/disable relay customize and import/export relay database.",
|
||||
}
|
||||
|
||||
var configList = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List all relay configuration",
|
||||
Long: "List all relay configuration.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
initProxy(listConfig, cmd, args)
|
||||
},
|
||||
}
|
||||
config.AddCommand(configList)
|
||||
|
||||
var configExport = &cobra.Command{
|
||||
Use: "export",
|
||||
Short: "Export all relay information",
|
||||
Long: "Export all relay information by JSON format.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
initProxy(exportConfig, cmd, args)
|
||||
},
|
||||
}
|
||||
config.AddCommand(configExport)
|
||||
|
||||
var configImport = &cobra.Command{
|
||||
Use: "import [flags]",
|
||||
Short: "Import all relay information",
|
||||
Long: "Import all relay information from JSON file.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
initProxy(importConfig, cmd, args)
|
||||
},
|
||||
}
|
||||
configImport.Flags().String("json", "", "JSON file-path")
|
||||
configImport.MarkFlagRequired("json")
|
||||
config.AddCommand(configImport)
|
||||
|
||||
var configEnable = &cobra.Command{
|
||||
Use: "enable",
|
||||
Short: "Enable/disable relay configuration",
|
||||
Long: `Enable or disable relay configuration.
|
||||
- service-block
|
||||
Blocking feature for service-type actor.
|
||||
- manually-accept
|
||||
Enable manually accept follow request.
|
||||
- create-as-announce
|
||||
Enable announce activity instead of relay create activity (not recommend)`,
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return initProxyE(configEnable, cmd, args)
|
||||
},
|
||||
}
|
||||
configEnable.Flags().BoolP("disable", "d", false, "Disable configuration instead of Enable")
|
||||
config.AddCommand(configEnable)
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
func configEnable(cmd *cobra.Command, args []string) error {
|
||||
disable := cmd.Flag("disable").Value.String() == "true"
|
||||
for _, config := range args {
|
||||
switch config {
|
||||
case "service-block":
|
||||
if disable {
|
||||
relayState.SetConfig(BlockService, false)
|
||||
cmd.Println("Blocking for service-type actor is Disabled.")
|
||||
} else {
|
||||
relayState.SetConfig(BlockService, true)
|
||||
cmd.Println("Blocking for service-type actor is Enabled.")
|
||||
}
|
||||
case "manually-accept":
|
||||
if disable {
|
||||
relayState.SetConfig(ManuallyAccept, false)
|
||||
cmd.Println("Manually accept follow-request is Disabled.")
|
||||
} else {
|
||||
relayState.SetConfig(ManuallyAccept, true)
|
||||
cmd.Println("Manually accept follow-request is Enabled.")
|
||||
}
|
||||
case "create-as-announce":
|
||||
if disable {
|
||||
relayState.SetConfig(CreateAsAnnounce, false)
|
||||
cmd.Println("Announce activity instead of relay create activity is Disabled.")
|
||||
} else {
|
||||
relayState.SetConfig(CreateAsAnnounce, true)
|
||||
cmd.Println("Announce activity instead of relay create activity is Enabled.")
|
||||
}
|
||||
default:
|
||||
cmd.Println("Invalid config given")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func listConfig(cmd *cobra.Command, args []string) {
|
||||
cmd.Println("Blocking for service-type actor : ", relayState.RelayConfig.BlockService)
|
||||
cmd.Println("Manually accept follow-request : ", relayState.RelayConfig.ManuallyAccept)
|
||||
cmd.Println("Announce activity instead of relay create activity : ", relayState.RelayConfig.CreateAsAnnounce)
|
||||
}
|
||||
|
||||
func exportConfig(cmd *cobra.Command, args []string) {
|
||||
jsonData, _ := json.Marshal(&relayState)
|
||||
cmd.Println(string(jsonData))
|
||||
}
|
||||
|
||||
func importConfig(cmd *cobra.Command, args []string) {
|
||||
file, err := os.Open(cmd.Flag("json").Value.String())
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return
|
||||
}
|
||||
jsonData, err := ioutil.ReadAll(file)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return
|
||||
}
|
||||
var data models.RelayState
|
||||
err = json.Unmarshal(jsonData, &data)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
if data.RelayConfig.BlockService {
|
||||
relayState.SetConfig(BlockService, true)
|
||||
cmd.Println("Blocking for service-type actor is Enabled.")
|
||||
}
|
||||
if data.RelayConfig.ManuallyAccept {
|
||||
relayState.SetConfig(ManuallyAccept, true)
|
||||
cmd.Println("Manually accept follow-request is Enabled.")
|
||||
}
|
||||
if data.RelayConfig.CreateAsAnnounce {
|
||||
relayState.SetConfig(CreateAsAnnounce, true)
|
||||
cmd.Println("Announce activity instead of relay create activity is Enabled.")
|
||||
}
|
||||
for _, LimitedDomain := range data.LimitedDomains {
|
||||
relayState.SetLimitedDomain(LimitedDomain, true)
|
||||
cmd.Println("Set [" + LimitedDomain + "] as limited domain")
|
||||
}
|
||||
for _, BlockedDomain := range data.BlockedDomains {
|
||||
relayState.SetBlockedDomain(BlockedDomain, true)
|
||||
cmd.Println("Set [" + BlockedDomain + "] as blocked domain")
|
||||
}
|
||||
for _, Subscription := range data.Subscriptions {
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: Subscription.Domain,
|
||||
InboxURL: Subscription.InboxURL,
|
||||
ActivityID: Subscription.ActivityID,
|
||||
ActorID: Subscription.ActorID,
|
||||
})
|
||||
cmd.Println("Register [" + Subscription.Domain + "] as subscriber")
|
||||
}
|
||||
}
|
161
app/control/config_test.go
Normal file
161
app/control/config_test.go
Normal file
@ -0,0 +1,161 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestServiceBlock(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
|
||||
app.SetArgs([]string{"enable", "service-block"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
if !relayState.RelayConfig.BlockService {
|
||||
t.Fatalf("Not Enabled Blocking feature for service-type actor")
|
||||
}
|
||||
|
||||
app.SetArgs([]string{"enable", "-d", "service-block"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
if relayState.RelayConfig.BlockService {
|
||||
t.Fatalf("Not Disabled Blocking feature for service-type actor")
|
||||
}
|
||||
}
|
||||
|
||||
func TestManuallyAccept(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
|
||||
app.SetArgs([]string{"enable", "manually-accept"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
if !relayState.RelayConfig.ManuallyAccept {
|
||||
t.Fatalf("Not Enabled Manually accept follow-request feature")
|
||||
}
|
||||
|
||||
app.SetArgs([]string{"enable", "-d", "manually-accept"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
if relayState.RelayConfig.ManuallyAccept {
|
||||
t.Fatalf("Not Disabled Manually accept follow-request feature")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateAsAnnounce(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
|
||||
app.SetArgs([]string{"enable", "create-as-announce"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
if !relayState.RelayConfig.CreateAsAnnounce {
|
||||
t.Fatalf("Enable announce activity instead of relay create activity")
|
||||
}
|
||||
|
||||
app.SetArgs([]string{"enable", "-d", "create-as-announce"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
if relayState.RelayConfig.CreateAsAnnounce {
|
||||
t.Fatalf("Enable announce activity instead of relay create activity")
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidConfig(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
buffer := new(bytes.Buffer)
|
||||
app.SetOut(buffer)
|
||||
|
||||
app.SetArgs([]string{"enable", "hoge"})
|
||||
app.Execute()
|
||||
|
||||
output := buffer.String()
|
||||
if strings.Split(output, "\n")[0] != "Invalid config given" {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestListConfig(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
buffer := new(bytes.Buffer)
|
||||
app.SetOut(buffer)
|
||||
|
||||
app.SetArgs([]string{"list"})
|
||||
app.Execute()
|
||||
|
||||
output := buffer.String()
|
||||
for _, row := range strings.Split(output, "\n") {
|
||||
switch strings.Split(row, ":")[0] {
|
||||
case "Blocking for service-type actor ":
|
||||
if strings.Split(row, ":")[1] == " true" {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
case "Manually accept follow-request ":
|
||||
if strings.Split(row, ":")[1] == " true" {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
case "Announce activity instead of relay create activity ":
|
||||
if strings.Split(row, ":")[1] == " true" {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestExportConfig(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
buffer := new(bytes.Buffer)
|
||||
app.SetOut(buffer)
|
||||
|
||||
app.SetArgs([]string{"export"})
|
||||
app.Execute()
|
||||
|
||||
file, err := os.Open("../misc/test/blankConfig.json")
|
||||
if err != nil {
|
||||
t.Fatalf("Test resource fetch error.")
|
||||
}
|
||||
jsonData, _ := ioutil.ReadAll(file)
|
||||
output := buffer.String()
|
||||
if strings.Split(output, "\n")[0] != string(jsonData) {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestImportConfig(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
|
||||
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
app.SetOut(buffer)
|
||||
|
||||
app.SetArgs([]string{"export"})
|
||||
app.Execute()
|
||||
|
||||
file, err := os.Open("../misc/test/exampleConfig.json")
|
||||
if err != nil {
|
||||
t.Fatalf("Test resource fetch error.")
|
||||
}
|
||||
jsonData, _ := ioutil.ReadAll(file)
|
||||
output := buffer.String()
|
||||
if strings.Split(output, "\n")[0] != string(jsonData) {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
}
|
91
app/control/control.go
Normal file
91
app/control/control.go
Normal file
@ -0,0 +1,91 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/RichardKnop/machinery/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
var (
|
||||
globalConfig *models.RelayConfig
|
||||
|
||||
initProxy = initializeProxy
|
||||
initProxyE = initializeProxyE
|
||||
|
||||
// Actor : Relay's Actor
|
||||
Actor models.Actor
|
||||
|
||||
relayState models.RelayState
|
||||
machineryServer *machinery.Server
|
||||
)
|
||||
|
||||
func BuildCommand(command *cobra.Command) {
|
||||
command.AddCommand(configCmdInit())
|
||||
command.AddCommand(domainCmdInit())
|
||||
command.AddCommand(followCmdInit())
|
||||
}
|
||||
|
||||
func initializeProxy(function func(cmd *cobra.Command, args []string), cmd *cobra.Command, args []string) {
|
||||
initConfig(cmd)
|
||||
function(cmd, args)
|
||||
}
|
||||
|
||||
func initializeProxyE(function func(cmd *cobra.Command, args []string) error, cmd *cobra.Command, args []string) error {
|
||||
initConfig(cmd)
|
||||
return function(cmd, args)
|
||||
}
|
||||
|
||||
func initConfig(cmd *cobra.Command) error {
|
||||
var err error
|
||||
|
||||
configPath := cmd.Flag("config").Value.String()
|
||||
file, err := os.Open(configPath)
|
||||
defer file.Close()
|
||||
|
||||
if err == nil {
|
||||
viper.SetConfigType("yaml")
|
||||
viper.ReadConfig(file)
|
||||
} else {
|
||||
logrus.Warn("Config file not exist. Use environment variables.")
|
||||
|
||||
viper.BindEnv("ACTOR_PEM")
|
||||
viper.BindEnv("REDIS_URL")
|
||||
viper.BindEnv("RELAY_BIND")
|
||||
viper.BindEnv("RELAY_DOMAIN")
|
||||
viper.BindEnv("RELAY_SERVICENAME")
|
||||
viper.BindEnv("JOB_CONCURRENCY")
|
||||
viper.BindEnv("RELAY_SUMMARY")
|
||||
viper.BindEnv("RELAY_ICON")
|
||||
viper.BindEnv("RELAY_IMAGE")
|
||||
}
|
||||
|
||||
globalConfig, err = models.NewRelayConfig()
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
initialize(globalConfig)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func initialize(globalconfig *models.RelayConfig) error {
|
||||
var err error
|
||||
|
||||
redisClient := globalConfig.RedisClient()
|
||||
relayState = models.NewState(redisClient, true)
|
||||
relayState.ListenNotify(nil)
|
||||
|
||||
machineryServer, err = models.NewMachineryServer(globalConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Actor = models.NewActivityPubActorFromSelfKey(globalConfig)
|
||||
|
||||
return nil
|
||||
}
|
52
app/control/control_test.go
Normal file
52
app/control/control_test.go
Normal file
@ -0,0 +1,52 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
var err error
|
||||
|
||||
testConfigPath := "../misc/test/config.yml"
|
||||
file, _ := os.Open(testConfigPath)
|
||||
defer file.Close()
|
||||
|
||||
viper.SetConfigType("yaml")
|
||||
viper.ReadConfig(file)
|
||||
viper.Set("ACTOR_PEM", "../misc/test/testKey.pem")
|
||||
viper.BindEnv("REDIS_URL")
|
||||
|
||||
globalConfig, err = models.NewRelayConfig()
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = initialize(globalConfig)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
relayState = models.NewState(globalConfig.RedisClient(), false)
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
initProxy = emptyProxy
|
||||
initProxyE = emptyProxyE
|
||||
|
||||
code := m.Run()
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
func emptyProxy(function func(cmd *cobra.Command, args []string), cmd *cobra.Command, args []string) {
|
||||
function(cmd, args)
|
||||
}
|
||||
|
||||
func emptyProxyE(function func(cmd *cobra.Command, args []string) error, cmd *cobra.Command, args []string) error {
|
||||
return function(cmd, args)
|
||||
}
|
139
app/control/domain.go
Normal file
139
app/control/domain.go
Normal file
@ -0,0 +1,139 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
func domainCmdInit() *cobra.Command {
|
||||
var domain = &cobra.Command{
|
||||
Use: "domain",
|
||||
Short: "Manage subscriber domain",
|
||||
Long: "List all subscriber, set/unset domain as limited or blocked and undo subscribe domain.",
|
||||
}
|
||||
|
||||
var domainList = &cobra.Command{
|
||||
Use: "list [flags]",
|
||||
Short: "List domain",
|
||||
Long: "List domain which filtered given type.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return initProxyE(listDomains, cmd, args)
|
||||
},
|
||||
}
|
||||
domainList.Flags().StringP("type", "t", "subscriber", "domain type [subscriber,limited,blocked]")
|
||||
domain.AddCommand(domainList)
|
||||
|
||||
var domainSet = &cobra.Command{
|
||||
Use: "set [flags]",
|
||||
Short: "Set or unset domain as limited or blocked",
|
||||
Long: "Set or unset domain as limited or blocked.",
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return initProxyE(setDomainType, cmd, args)
|
||||
},
|
||||
}
|
||||
domainSet.Flags().StringP("type", "t", "", "Apply domain type [limited,blocked]")
|
||||
domainSet.MarkFlagRequired("type")
|
||||
domainSet.Flags().BoolP("undo", "u", false, "Unset domain as limited or blocked")
|
||||
domain.AddCommand(domainSet)
|
||||
|
||||
var domainUnfollow = &cobra.Command{
|
||||
Use: "unfollow [flags]",
|
||||
Short: "Send Unfollow request for given domains",
|
||||
Long: "Send unfollow request for given domains.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return initProxyE(unfollowDomains, cmd, args)
|
||||
},
|
||||
}
|
||||
domain.AddCommand(domainUnfollow)
|
||||
|
||||
return domain
|
||||
}
|
||||
|
||||
func createUnfollowRequestResponse(subscription models.Subscription) error {
|
||||
activity := models.Activity{
|
||||
Context: []string{"https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"},
|
||||
ID: subscription.ActivityID,
|
||||
Actor: subscription.ActorID,
|
||||
Type: "Follow",
|
||||
Object: "https://www.w3.org/ns/activitystreams#Public",
|
||||
}
|
||||
|
||||
resp := activity.GenerateResponse(globalConfig.ServerHostname(), "Reject")
|
||||
jsonData, _ := json.Marshal(&resp)
|
||||
pushRegisterJob(subscription.InboxURL, jsonData)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func listDomains(cmd *cobra.Command, args []string) error {
|
||||
var domains []string
|
||||
switch cmd.Flag("type").Value.String() {
|
||||
case "limited":
|
||||
cmd.Println(" - Limited domain :")
|
||||
domains = relayState.LimitedDomains
|
||||
case "blocked":
|
||||
cmd.Println(" - Blocked domain :")
|
||||
domains = relayState.BlockedDomains
|
||||
default:
|
||||
cmd.Println(" - Subscriber domain :")
|
||||
temp := relayState.Subscriptions
|
||||
for _, domain := range temp {
|
||||
domains = append(domains, domain.Domain)
|
||||
}
|
||||
}
|
||||
for _, domain := range domains {
|
||||
cmd.Println(domain)
|
||||
}
|
||||
cmd.Println(fmt.Sprintf("Total : %d", len(domains)))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func setDomainType(cmd *cobra.Command, args []string) error {
|
||||
undo := cmd.Flag("undo").Value.String() == "true"
|
||||
switch cmd.Flag("type").Value.String() {
|
||||
case "limited":
|
||||
for _, domain := range args {
|
||||
relayState.SetLimitedDomain(domain, !undo)
|
||||
if undo {
|
||||
cmd.Println("Unset [" + domain + "] as limited domain")
|
||||
} else {
|
||||
cmd.Println("Set [" + domain + "] as limited domain")
|
||||
}
|
||||
}
|
||||
case "blocked":
|
||||
for _, domain := range args {
|
||||
relayState.SetBlockedDomain(domain, !undo)
|
||||
if undo {
|
||||
cmd.Println("Unset [" + domain + "] as blocked domain")
|
||||
} else {
|
||||
cmd.Println("Set [" + domain + "] as blocked domain")
|
||||
}
|
||||
}
|
||||
default:
|
||||
cmd.Println("Invalid type given")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func unfollowDomains(cmd *cobra.Command, args []string) error {
|
||||
subscriptions := relayState.Subscriptions
|
||||
for _, domain := range args {
|
||||
if contains(subscriptions, domain) {
|
||||
subscription := *relayState.SelectSubscription(domain)
|
||||
createUnfollowRequestResponse(subscription)
|
||||
relayState.DelSubscription(subscription.Domain)
|
||||
cmd.Println("Unfollow [" + subscription.Domain + "]")
|
||||
break
|
||||
} else {
|
||||
cmd.Println("Invalid domain [" + domain + "] given")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
245
app/control/domain_test.go
Normal file
245
app/control/domain_test.go
Normal file
@ -0,0 +1,245 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestListDomainSubscriber(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
|
||||
app = domainCmdInit()
|
||||
app.SetOut(buffer)
|
||||
app.SetArgs([]string{"list"})
|
||||
app.Execute()
|
||||
|
||||
output := buffer.String()
|
||||
valid := ` - Subscriber domain :
|
||||
subscription.example.jp
|
||||
Total : 1
|
||||
`
|
||||
if output != valid {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestListDomainLimited(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
|
||||
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
|
||||
app = domainCmdInit()
|
||||
app.SetOut(buffer)
|
||||
app.SetArgs([]string{"list", "-t", "limited"})
|
||||
app.Execute()
|
||||
|
||||
output := buffer.String()
|
||||
valid := ` - Limited domain :
|
||||
limitedDomain.example.jp
|
||||
Total : 1
|
||||
`
|
||||
if output != valid {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestListDomainBlocked(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
|
||||
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
|
||||
app = domainCmdInit()
|
||||
app.SetOut(buffer)
|
||||
app.SetArgs([]string{"list", "-t", "blocked"})
|
||||
app.Execute()
|
||||
|
||||
output := buffer.String()
|
||||
valid := ` - Blocked domain :
|
||||
blockedDomain.example.jp
|
||||
Total : 1
|
||||
`
|
||||
if output != valid {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDomainBlocked(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := domainCmdInit()
|
||||
|
||||
app.SetArgs([]string{"set", "-t", "blocked", "testdomain.example.jp"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
|
||||
valid := false
|
||||
for _, domain := range relayState.BlockedDomains {
|
||||
if domain == "testdomain.example.jp" {
|
||||
valid = true
|
||||
}
|
||||
}
|
||||
|
||||
if !valid {
|
||||
t.Fatalf("Not set blocked domain")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDomainLimited(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := domainCmdInit()
|
||||
|
||||
app.SetArgs([]string{"set", "-t", "limited", "testdomain.example.jp"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
|
||||
valid := false
|
||||
for _, domain := range relayState.LimitedDomains {
|
||||
if domain == "testdomain.example.jp" {
|
||||
valid = true
|
||||
}
|
||||
}
|
||||
|
||||
if !valid {
|
||||
t.Fatalf("Not set limited domain")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnsetDomainBlocked(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
|
||||
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||
app.Execute()
|
||||
|
||||
app = domainCmdInit()
|
||||
app.SetArgs([]string{"set", "-t", "blocked", "-u", "blockedDomain.example.jp"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
|
||||
valid := true
|
||||
for _, domain := range relayState.BlockedDomains {
|
||||
if domain == "blockedDomain.example.jp" {
|
||||
valid = false
|
||||
}
|
||||
}
|
||||
|
||||
if !valid {
|
||||
t.Fatalf("Not unset blocked domain")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnsetDomainLimited(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
|
||||
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||
app.Execute()
|
||||
|
||||
app = domainCmdInit()
|
||||
app.SetArgs([]string{"set", "-t", "limited", "-u", "limitedDomain.example.jp"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
|
||||
valid := true
|
||||
for _, domain := range relayState.LimitedDomains {
|
||||
if domain == "limitedDomain.example.jp" {
|
||||
valid = false
|
||||
}
|
||||
}
|
||||
|
||||
if !valid {
|
||||
t.Fatalf("Not unset blocked domain")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDomainInvalid(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
|
||||
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
|
||||
app = domainCmdInit()
|
||||
app.SetOut(buffer)
|
||||
app.SetArgs([]string{"set", "-t", "hoge", "hoge.example.jp"})
|
||||
app.Execute()
|
||||
|
||||
output := buffer.String()
|
||||
if strings.Split(output, "\n")[0] != "Invalid type given" {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnfollowDomain(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
|
||||
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||
app.Execute()
|
||||
|
||||
app = domainCmdInit()
|
||||
app.SetArgs([]string{"unfollow", "subscription.example.jp"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
|
||||
valid := true
|
||||
for _, domain := range relayState.Subscriptions {
|
||||
if domain.Domain == "subscription.example.jp" {
|
||||
valid = false
|
||||
}
|
||||
}
|
||||
|
||||
if !valid {
|
||||
t.Fatalf("Not unfollowed domain")
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidUnfollowDomain(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := configCmdInit()
|
||||
|
||||
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||
app.Execute()
|
||||
relayState.Load()
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
|
||||
app = domainCmdInit()
|
||||
app.SetOut(buffer)
|
||||
app.SetArgs([]string{"unfollow", "unknown.tld"})
|
||||
app.Execute()
|
||||
|
||||
output := buffer.String()
|
||||
if strings.Split(output, "\n")[0] != "Invalid domain [unknown.tld] given" {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
}
|
215
app/control/follow.go
Normal file
215
app/control/follow.go
Normal file
@ -0,0 +1,215 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/RichardKnop/machinery/v1/tasks"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
func followCmdInit() *cobra.Command {
|
||||
var follow = &cobra.Command{
|
||||
Use: "follow",
|
||||
Short: "Manage follow request for relay",
|
||||
Long: "List all follow request and accept/reject follow requests.",
|
||||
}
|
||||
|
||||
var followList = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List follow request",
|
||||
Long: "List follow request.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return initProxyE(listFollows, cmd, args)
|
||||
},
|
||||
}
|
||||
follow.AddCommand(followList)
|
||||
|
||||
var followAccept = &cobra.Command{
|
||||
Use: "accept",
|
||||
Short: "Accept follow request",
|
||||
Long: "Accept follow request by domain.",
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return initProxyE(acceptFollow, cmd, args)
|
||||
},
|
||||
}
|
||||
follow.AddCommand(followAccept)
|
||||
|
||||
var followReject = &cobra.Command{
|
||||
Use: "reject",
|
||||
Short: "Reject follow request",
|
||||
Long: "Reject follow request by domain.",
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return initProxyE(rejectFollow, cmd, args)
|
||||
},
|
||||
}
|
||||
follow.AddCommand(followReject)
|
||||
|
||||
var updateActor = &cobra.Command{
|
||||
Use: "update",
|
||||
Short: "Update actor object",
|
||||
Long: "Update actor object for whole subscribers.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return initProxyE(updateActor, cmd, args)
|
||||
},
|
||||
}
|
||||
follow.AddCommand(updateActor)
|
||||
|
||||
return follow
|
||||
}
|
||||
|
||||
func pushRegisterJob(inboxURL string, body []byte) {
|
||||
job := &tasks.Signature{
|
||||
Name: "register",
|
||||
RetryCount: 25,
|
||||
Args: []tasks.Arg{
|
||||
{
|
||||
Name: "inboxURL",
|
||||
Type: "string",
|
||||
Value: inboxURL,
|
||||
},
|
||||
{
|
||||
Name: "body",
|
||||
Type: "string",
|
||||
Value: string(body),
|
||||
},
|
||||
},
|
||||
}
|
||||
_, err := machineryServer.SendTask(job)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func createFollowRequestResponse(domain string, response string) error {
|
||||
data, err := relayState.RedisClient.HGetAll("relay:pending:" + domain).Result()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
activity := models.Activity{
|
||||
Context: []string{"https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"},
|
||||
ID: data["activity_id"],
|
||||
Actor: data["actor"],
|
||||
Type: data["type"],
|
||||
Object: data["object"],
|
||||
}
|
||||
|
||||
resp := activity.GenerateResponse(globalConfig.ServerHostname(), response)
|
||||
jsonData, err := json.Marshal(&resp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pushRegisterJob(data["inbox_url"], jsonData)
|
||||
relayState.RedisClient.Del("relay:pending:" + domain)
|
||||
if response == "Accept" {
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: domain,
|
||||
InboxURL: data["inbox_url"],
|
||||
ActivityID: data["activity_id"],
|
||||
ActorID: data["actor"],
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func createUpdateActorActivity(subscription models.Subscription) error {
|
||||
activity := models.Activity{
|
||||
Context: []string{"https://www.w3.org/ns/activitystreams"},
|
||||
ID: globalConfig.ServerHostname().String() + "/activities/" + uuid.NewV4().String(),
|
||||
Actor: globalConfig.ServerHostname().String() + "/actor",
|
||||
Type: "Update",
|
||||
To: []string{"https://www.w3.org/ns/activitystreams#Public"},
|
||||
Object: Actor,
|
||||
}
|
||||
|
||||
jsonData, err := json.Marshal(&activity)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pushRegisterJob(subscription.InboxURL, jsonData)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func listFollows(cmd *cobra.Command, args []string) error {
|
||||
var domains []string
|
||||
cmd.Println(" - Follow request :")
|
||||
follows, err := relayState.RedisClient.Keys("relay:pending:*").Result()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, follow := range follows {
|
||||
domains = append(domains, strings.Replace(follow, "relay:pending:", "", 1))
|
||||
}
|
||||
for _, domain := range domains {
|
||||
cmd.Println(domain)
|
||||
}
|
||||
cmd.Println(fmt.Sprintf("Total : %d", len(domains)))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func acceptFollow(cmd *cobra.Command, args []string) error {
|
||||
var err error
|
||||
var domains []string
|
||||
follows, err := relayState.RedisClient.Keys("relay:pending:*").Result()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, follow := range follows {
|
||||
domains = append(domains, strings.Replace(follow, "relay:pending:", "", 1))
|
||||
}
|
||||
|
||||
for _, domain := range args {
|
||||
if contains(domains, domain) {
|
||||
cmd.Println("Accept [" + domain + "] follow request")
|
||||
createFollowRequestResponse(domain, "Accept")
|
||||
} else {
|
||||
cmd.Println("Invalid domain [" + domain + "] given")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func rejectFollow(cmd *cobra.Command, args []string) error {
|
||||
var err error
|
||||
var domains []string
|
||||
follows, err := relayState.RedisClient.Keys("relay:pending:*").Result()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, follow := range follows {
|
||||
domains = append(domains, strings.Replace(follow, "relay:pending:", "", 1))
|
||||
}
|
||||
|
||||
for _, domain := range args {
|
||||
for _, request := range domains {
|
||||
if domain == request {
|
||||
cmd.Println("Reject [" + domain + "] follow request")
|
||||
createFollowRequestResponse(domain, "Reject")
|
||||
break
|
||||
}
|
||||
}
|
||||
cmd.Println("Invalid domain [" + domain + "] given")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateActor(cmd *cobra.Command, args []string) error {
|
||||
for _, subscription := range relayState.Subscriptions {
|
||||
err := createUpdateActorActivity(subscription)
|
||||
if err != nil {
|
||||
cmd.Println("Failed Update Actor for " + subscription.Domain)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
136
app/control/follow_test.go
Normal file
136
app/control/follow_test.go
Normal file
@ -0,0 +1,136 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestListFollows(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := followCmdInit()
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
app.SetOut(buffer)
|
||||
|
||||
relayState.RedisClient.HMSet("relay:pending:example.com", map[string]interface{}{
|
||||
"inbox_url": "https://example.com/inbox",
|
||||
"activity_id": "https://example.com/UUID",
|
||||
"type": "Follow",
|
||||
"actor": "https://example.com/user/example",
|
||||
"object": "https://" + globalConfig.ServerHostname().Host + "/actor",
|
||||
})
|
||||
|
||||
app.SetArgs([]string{"list"})
|
||||
app.Execute()
|
||||
|
||||
output := buffer.String()
|
||||
valid := ` - Follow request :
|
||||
example.com
|
||||
Total : 1
|
||||
`
|
||||
if output != valid {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAcceptFollow(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := followCmdInit()
|
||||
|
||||
relayState.RedisClient.HMSet("relay:pending:example.com", map[string]interface{}{
|
||||
"inbox_url": "https://example.com/inbox",
|
||||
"activity_id": "https://example.com/UUID",
|
||||
"type": "Follow",
|
||||
"actor": "https://example.com/user/example",
|
||||
"object": "https://" + globalConfig.ServerHostname().Host + "/actor",
|
||||
})
|
||||
|
||||
app.SetArgs([]string{"accept", "example.com"})
|
||||
app.Execute()
|
||||
|
||||
valid, _ := relayState.RedisClient.Exists("relay:pending:example.com").Result()
|
||||
if valid != 0 {
|
||||
t.Fatalf("Not removed follow request.")
|
||||
}
|
||||
|
||||
valid, _ = relayState.RedisClient.Exists("relay:subscription:example.com").Result()
|
||||
if valid != 1 {
|
||||
t.Fatalf("Not created subscription.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRejectFollow(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := followCmdInit()
|
||||
|
||||
relayState.RedisClient.HMSet("relay:pending:example.com", map[string]interface{}{
|
||||
"inbox_url": "https://example.com/inbox",
|
||||
"activity_id": "https://example.com/UUID",
|
||||
"type": "Follow",
|
||||
"actor": "https://example.com/user/example",
|
||||
"object": "https://" + globalConfig.ServerHostname().Host + "/actor",
|
||||
})
|
||||
|
||||
app.SetArgs([]string{"reject", "example.com"})
|
||||
app.Execute()
|
||||
|
||||
valid, _ := relayState.RedisClient.Exists("relay:pending:example.com").Result()
|
||||
if valid != 0 {
|
||||
t.Fatalf("No response follow request.")
|
||||
}
|
||||
|
||||
valid, _ = relayState.RedisClient.Exists("relay:subscription:example.com").Result()
|
||||
if valid != 0 {
|
||||
t.Fatalf("Created subscription.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidFollow(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := followCmdInit()
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
app.SetOut(buffer)
|
||||
|
||||
app.SetArgs([]string{"accept", "unknown.tld"})
|
||||
app.Execute()
|
||||
|
||||
output := buffer.String()
|
||||
if strings.Split(output, "\n")[0] != "Invalid domain [unknown.tld] given" {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidRejectFollow(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
app := followCmdInit()
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
app.SetOut(buffer)
|
||||
|
||||
app.SetArgs([]string{"reject", "unknown.tld"})
|
||||
app.Execute()
|
||||
|
||||
output := buffer.String()
|
||||
if strings.Split(output, "\n")[0] != "Invalid domain [unknown.tld] given" {
|
||||
t.Fatalf("Invalid Response.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateUpdateActorActivity(t *testing.T) {
|
||||
app := configCmdInit()
|
||||
|
||||
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||
app.Execute()
|
||||
|
||||
app = followCmdInit()
|
||||
|
||||
app.SetArgs([]string{"update"})
|
||||
app.Execute()
|
||||
}
|
24
app/control/utils.go
Normal file
24
app/control/utils.go
Normal file
@ -0,0 +1,24 @@
|
||||
package control
|
||||
|
||||
import "github.com/yukimochi/Activity-Relay/models"
|
||||
|
||||
func contains(entries interface{}, finder string) bool {
|
||||
switch entry := entries.(type) {
|
||||
case string:
|
||||
return entry == finder
|
||||
case []string:
|
||||
for i := 0; i < len(entry); i++ {
|
||||
if entry[i] == finder {
|
||||
return true
|
||||
}
|
||||
}
|
||||
case []models.Subscription:
|
||||
for i := 0; i < len(entry); i++ {
|
||||
if entry[i].Domain == finder {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
32
app/control/utils_test.go
Normal file
32
app/control/utils_test.go
Normal file
@ -0,0 +1,32 @@
|
||||
package control
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestContains(t *testing.T) {
|
||||
data := "nil"
|
||||
sData := []string{
|
||||
"no",
|
||||
"nil",
|
||||
}
|
||||
badData := 0
|
||||
result := contains(data, "true")
|
||||
if result != false {
|
||||
t.Fatalf("Failed - no contain but true.")
|
||||
}
|
||||
result = contains(data, "nil")
|
||||
if result != true {
|
||||
t.Fatalf("Failed - contain but false.")
|
||||
}
|
||||
result = contains(sData, "true")
|
||||
if result != false {
|
||||
t.Fatalf("Failed - no contain but true. (slice)")
|
||||
}
|
||||
result = contains(sData, "nil")
|
||||
if result != true {
|
||||
t.Fatalf("Failed - contain but false. (slice)")
|
||||
}
|
||||
result = contains(badData, "hoge")
|
||||
if result != false {
|
||||
t.Fatalf("Failed - input bad data but true. (slice)")
|
||||
}
|
||||
}
|
92
app/deliver/deliver.go
Normal file
92
app/deliver/deliver.go
Normal file
@ -0,0 +1,92 @@
|
||||
package deliver
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/RichardKnop/machinery/v1"
|
||||
"github.com/RichardKnop/machinery/v1/log"
|
||||
"github.com/go-redis/redis"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
var (
|
||||
version string
|
||||
globalConfig *models.RelayConfig
|
||||
|
||||
// Actor : Relay's Actor
|
||||
Actor models.Actor
|
||||
|
||||
redisClient *redis.Client
|
||||
machineryServer *machinery.Server
|
||||
httpClient *http.Client
|
||||
)
|
||||
|
||||
func relayActivity(args ...string) error {
|
||||
inboxURL := args[0]
|
||||
body := args[1]
|
||||
err := sendActivity(inboxURL, Actor.ID, []byte(body), globalConfig.ActorKey())
|
||||
if err != nil {
|
||||
domain, _ := url.Parse(inboxURL)
|
||||
evalScript := "local change = redis.call('HSETNX',KEYS[1], 'last_error', ARGV[1]); if change == 1 then redis.call('EXPIRE', KEYS[1], ARGV[2]) end;"
|
||||
redisClient.Eval(evalScript, []string{"relay:statistics:" + domain.Host}, err.Error(), 60).Result()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func registerActivity(args ...string) error {
|
||||
inboxURL := args[0]
|
||||
body := args[1]
|
||||
err := sendActivity(inboxURL, Actor.ID, []byte(body), globalConfig.ActorKey())
|
||||
return err
|
||||
}
|
||||
|
||||
func Entrypoint(g *models.RelayConfig, v string) error {
|
||||
var err error
|
||||
globalConfig = g
|
||||
version = v
|
||||
|
||||
err = initialize(globalConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = machineryServer.RegisterTask("register", registerActivity)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = machineryServer.RegisterTask("relay", relayActivity)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
workerID := uuid.NewV4()
|
||||
worker := machineryServer.NewWorker(workerID.String(), globalConfig.JobConcurrency())
|
||||
err = worker.Launch()
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func initialize(globalConfig *models.RelayConfig) error {
|
||||
var err error
|
||||
|
||||
redisClient = globalConfig.RedisClient()
|
||||
|
||||
machineryServer, err = models.NewMachineryServer(globalConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
httpClient = &http.Client{Timeout: time.Duration(5) * time.Second}
|
||||
|
||||
Actor = models.NewActivityPubActorFromSelfKey(globalConfig)
|
||||
newNullLogger := NewNullLogger()
|
||||
log.DEBUG = newNullLogger
|
||||
|
||||
return nil
|
||||
}
|
140
app/deliver/deliver_test.go
Normal file
140
app/deliver/deliver_test.go
Normal file
@ -0,0 +1,140 @@
|
||||
package deliver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
var err error
|
||||
|
||||
testConfigPath := "../misc/test/config.yml"
|
||||
file, _ := os.Open(testConfigPath)
|
||||
defer file.Close()
|
||||
|
||||
viper.SetConfigType("yaml")
|
||||
viper.ReadConfig(file)
|
||||
viper.Set("ACTOR_PEM", "../misc/test/testKey.pem")
|
||||
viper.BindEnv("REDIS_URL")
|
||||
|
||||
globalConfig, err = models.NewRelayConfig()
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = initialize(globalConfig)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
redisClient.FlushAll().Result()
|
||||
code := m.Run()
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
func TestRelayActivity(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
data, _ := ioutil.ReadAll(r.Body)
|
||||
if string(data) != "data" || r.Header.Get("Content-Type") != "application/activity+json" {
|
||||
w.WriteHeader(500)
|
||||
w.Write(nil)
|
||||
} else {
|
||||
w.WriteHeader(202)
|
||||
w.Write(nil)
|
||||
}
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
err := relayActivity(s.URL, "data")
|
||||
if err != nil {
|
||||
t.Fatal("Failed - Data transfer not collect")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRelayActivityNoHost(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
err := relayActivity("http://nohost.example.jp", "data")
|
||||
if err == nil {
|
||||
t.Fatal("Failed - Error not reported.")
|
||||
}
|
||||
domain, _ := url.Parse("http://nohost.example.jp")
|
||||
data, _ := redisClient.HGet("relay:statistics:"+domain.Host, "last_error").Result()
|
||||
if data == "" {
|
||||
t.Fatal("Failed - Error not cached.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRelayActivityResp500(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(500)
|
||||
w.Write(nil)
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
err := relayActivity(s.URL, "data")
|
||||
if err == nil {
|
||||
t.Fatal("Failed - Error not reported.")
|
||||
}
|
||||
domain, _ := url.Parse(s.URL)
|
||||
data, _ := redisClient.HGet("relay:statistics:"+domain.Host, "last_error").Result()
|
||||
if data == "" {
|
||||
t.Fatal("Failed - Error not cached.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterActivity(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
data, _ := ioutil.ReadAll(r.Body)
|
||||
if string(data) != "data" || r.Header.Get("Content-Type") != "application/activity+json" {
|
||||
w.WriteHeader(500)
|
||||
w.Write(nil)
|
||||
} else {
|
||||
w.WriteHeader(202)
|
||||
w.Write(nil)
|
||||
}
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
err := registerActivity(s.URL, "data")
|
||||
if err != nil {
|
||||
t.Fatal("Failed - Data transfer not collect")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterActivityNoHost(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
err := registerActivity("http://nohost.example.jp", "data")
|
||||
if err == nil {
|
||||
t.Fatal("Failed - Error not reported.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterActivityResp500(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(500)
|
||||
w.Write(nil)
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
err := registerActivity(s.URL, "data")
|
||||
if err == nil {
|
||||
t.Fatal("Failed - Error not reported.")
|
||||
}
|
||||
}
|
30
app/deliver/logger.go
Normal file
30
app/deliver/logger.go
Normal file
@ -0,0 +1,30 @@
|
||||
package deliver
|
||||
|
||||
// NullLogger : Null logger for debug output
|
||||
type NullLogger struct {
|
||||
}
|
||||
|
||||
// NewNullLogger : Create NullLogger
|
||||
func NewNullLogger() *NullLogger {
|
||||
var newNullLogger NullLogger
|
||||
return &newNullLogger
|
||||
}
|
||||
|
||||
func (l *NullLogger) Print(v ...interface{}) {
|
||||
}
|
||||
func (l *NullLogger) Printf(format string, v ...interface{}) {
|
||||
}
|
||||
func (l *NullLogger) Println(v ...interface{}) {
|
||||
}
|
||||
func (l *NullLogger) Fatal(v ...interface{}) {
|
||||
}
|
||||
func (l *NullLogger) Fatalf(format string, v ...interface{}) {
|
||||
}
|
||||
func (l *NullLogger) Fatalln(v ...interface{}) {
|
||||
}
|
||||
func (l *NullLogger) Panic(v ...interface{}) {
|
||||
}
|
||||
func (l *NullLogger) Panicf(format string, v ...interface{}) {
|
||||
}
|
||||
func (l *NullLogger) Panicln(v ...interface{}) {
|
||||
}
|
53
app/deliver/sender.go
Normal file
53
app/deliver/sender.go
Normal file
@ -0,0 +1,53 @@
|
||||
package deliver
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rsa"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
"strings"
|
||||
|
||||
httpdate "github.com/Songmu/go-httpdate"
|
||||
"github.com/go-fed/httpsig"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// See https://github.com/mastodon/mastodon/pull/14556
|
||||
const ONEHOUR = 60 * 60
|
||||
|
||||
func appendSignature(request *http.Request, body *[]byte, KeyID string, privateKey *rsa.PrivateKey) error {
|
||||
request.Header.Set("Host", request.Host)
|
||||
request.Header.Set("(request-target)", fmt.Sprintf("%s %s", strings.ToLower(request.Method), request.URL.Path))
|
||||
|
||||
signer, _, err := httpsig.NewSigner([]httpsig.Algorithm{httpsig.RSA_SHA256}, httpsig.DigestSha256, []string{httpsig.RequestTarget, "Host", "Date", "Digest", "Content-Type"}, httpsig.Signature, ONEHOUR)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = signer.SignRequest(privateKey, KeyID, request, *body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func sendActivity(inboxURL string, KeyID string, body []byte, privateKey *rsa.PrivateKey) error {
|
||||
req, _ := http.NewRequest("POST", inboxURL, bytes.NewBuffer(body))
|
||||
req.Header.Set("Content-Type", "application/activity+json")
|
||||
req.Header.Set("User-Agent", fmt.Sprintf("%s (golang net/http; Activity-Relay %s; %s)", globalConfig.ServerServiceName(), version, globalConfig.ServerHostname().Host))
|
||||
req.Header.Set("Date", httpdate.Time2Str(time.Now()))
|
||||
appendSignature(req, &body, KeyID, privateKey)
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
logrus.Debug(inboxURL, " ", resp.StatusCode)
|
||||
if resp.StatusCode/100 != 2 {
|
||||
return errors.New("Post " + inboxURL + ": " + resp.Status)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
58
app/deliver/sender_test.go
Normal file
58
app/deliver/sender_test.go
Normal file
@ -0,0 +1,58 @@
|
||||
package deliver
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rsa"
|
||||
"crypto/sha256"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"encoding/pem"
|
||||
"github.com/Songmu/go-httpdate"
|
||||
"github.com/go-fed/httpsig"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func generatePublicKeyPEMString(publicKey *rsa.PublicKey) string {
|
||||
publicKeyByte := x509.MarshalPKCS1PublicKey(publicKey)
|
||||
publicKeyPem := pem.EncodeToMemory(
|
||||
&pem.Block{
|
||||
Type: "RSA PUBLIC KEY",
|
||||
Bytes: publicKeyByte,
|
||||
},
|
||||
)
|
||||
return string(publicKeyPem)
|
||||
}
|
||||
|
||||
func TestAppendSignature(t *testing.T) {
|
||||
file, _ := os.Open("../misc/test/create.json")
|
||||
body, _ := ioutil.ReadAll(file)
|
||||
req, _ := http.NewRequest("POST", "https://localhost", bytes.NewBuffer(body))
|
||||
req.Header.Set("Content-Type", "application/activity+json")
|
||||
req.Header.Set("Date", httpdate.Time2Str(time.Now()))
|
||||
appendSignature(req, &body, "https://innocent.yukimochi.io/users/YUKIMOCHI#main-key", globalConfig.ActorKey())
|
||||
|
||||
// Verify HTTPSignature
|
||||
verifier, err := httpsig.NewVerifier(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
err = verifier.Verify(globalConfig.ActorKey().Public(), httpsig.RSA_SHA256)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
|
||||
// Verify Digest
|
||||
givenDigest := req.Header.Get("Digest")
|
||||
hash := sha256.New()
|
||||
hash.Write(body)
|
||||
b := hash.Sum(nil)
|
||||
calculatedDigest := "SHA-256=" + base64.StdEncoding.EncodeToString(b)
|
||||
|
||||
if givenDigest != calculatedDigest {
|
||||
t.Fatalf("Failed - " + err.Error())
|
||||
}
|
||||
}
|
80
app/go.mod
Normal file
80
app/go.mod
Normal file
@ -0,0 +1,80 @@
|
||||
module github.com/lilfade/Activity-Relay/app
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/RichardKnop/machinery v1.10.0
|
||||
github.com/Songmu/go-httpdate v1.0.0
|
||||
github.com/go-fed/httpsig v1.1.0
|
||||
github.com/go-redis/redis v6.15.9+incompatible
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/satori/go.uuid v1.2.0
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/spf13/cobra v1.6.1
|
||||
github.com/spf13/viper v1.13.0
|
||||
github.com/lilfade/Activity-Relay v1.1.1
|
||||
)
|
||||
|
||||
require (
|
||||
cloud.google.com/go v0.105.0 // indirect
|
||||
cloud.google.com/go/compute v1.12.1 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.2.1 // indirect
|
||||
cloud.google.com/go/iam v0.7.0 // indirect
|
||||
cloud.google.com/go/pubsub v1.8.3 // indirect
|
||||
github.com/RichardKnop/logging v0.0.0-20190827224416-1a693bdd4fae // indirect
|
||||
github.com/aws/aws-sdk-go v1.35.35 // indirect
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
||||
github.com/go-redis/redis/v8 v8.4.0 // indirect
|
||||
github.com/go-redsync/redsync/v4 v4.0.4 // indirect
|
||||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/golang/snappy v0.0.3 // indirect
|
||||
github.com/gomodule/redigo v2.0.0+incompatible // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
|
||||
github.com/googleapis/gax-go/v2 v2.6.0 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.0 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.1 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/kelseyhightower/envconfig v1.4.0 // indirect
|
||||
github.com/klauspost/compress v1.11.3 // indirect
|
||||
github.com/magiconair/properties v1.8.6 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||
github.com/spf13/afero v1.8.2 // indirect
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/streadway/amqp v1.0.0 // indirect
|
||||
github.com/subosito/gotenv v1.4.1 // indirect
|
||||
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
|
||||
github.com/xdg/stringprep v1.0.0 // indirect
|
||||
go.mongodb.org/mongo-driver v1.4.3 // indirect
|
||||
go.opencensus.io v0.23.0 // indirect
|
||||
go.opentelemetry.io/otel v0.14.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
|
||||
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
|
||||
golang.org/x/text v0.4.0 // indirect
|
||||
google.golang.org/api v0.102.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c // indirect
|
||||
google.golang.org/grpc v1.50.1 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
728
app/go.sum
Normal file
728
app/go.sum
Normal file
@ -0,0 +1,728 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
||||
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||
cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
||||
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
||||
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
|
||||
cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
|
||||
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
|
||||
cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
|
||||
cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
|
||||
cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
|
||||
cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
|
||||
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
|
||||
cloud.google.com/go v0.71.0/go.mod h1:qZfY4Y7AEIQwG/fQYD3xrxLNkQZ0Xzf3HGeqCkA6LVM=
|
||||
cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI=
|
||||
cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk=
|
||||
cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY=
|
||||
cloud.google.com/go v0.105.0 h1:DNtEKRBAAzeS4KyIory52wWHuClNaXJ5x1F7xa4q+5Y=
|
||||
cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM=
|
||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
|
||||
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
|
||||
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
|
||||
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
|
||||
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
|
||||
cloud.google.com/go/compute v1.12.1 h1:gKVJMEyqV5c/UnpzjjQbo3Rjvvqpr9B1DFSbJC4OXr0=
|
||||
cloud.google.com/go/compute v1.12.1/go.mod h1:e8yNOBcBONZU1vJKCvCoDw/4JQsA0dpM4x/6PIIOocU=
|
||||
cloud.google.com/go/compute/metadata v0.2.1 h1:efOwf5ymceDhK6PKMnnrTHP4pppY5L22mle96M1yP48=
|
||||
cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM=
|
||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
|
||||
cloud.google.com/go/iam v0.7.0 h1:k4MuwOsS7zGJJ+QfZ5vBK8SgHBAvYN/23BWsiihJ1vs=
|
||||
cloud.google.com/go/iam v0.7.0/go.mod h1:H5Br8wRaDGNc8XP3keLc4unfUUZeyH3Sfl9XpQEYOeg=
|
||||
cloud.google.com/go/kms v1.6.0 h1:OWRZzrPmOZUzurjI2FBGtgY2mB1WaJkqhw6oIwSj0Yg=
|
||||
cloud.google.com/go/longrunning v0.1.1 h1:y50CXG4j0+qvEukslYFBCrzaXX0qpFbBzc3PchSu/LE=
|
||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
|
||||
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
|
||||
cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
|
||||
cloud.google.com/go/pubsub v1.8.3 h1:kl5QdIn98mYhX+G7OzdQ9W3SQ0XXdhHlTw0GHa723pI=
|
||||
cloud.google.com/go/pubsub v1.8.3/go.mod h1:m8NMRz5lt0YjbQQ40RjocDVRjgYyzyYpP6ix3dxwRno=
|
||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
|
||||
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
|
||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/RichardKnop/logging v0.0.0-20190827224416-1a693bdd4fae h1:DcFpTQBYQ9Ct2d6sC7ol0/ynxc2pO1cpGUM+f4t5adg=
|
||||
github.com/RichardKnop/logging v0.0.0-20190827224416-1a693bdd4fae/go.mod h1:rJJ84PyA/Wlmw1hO+xTzV2wsSUon6J5ktg0g8BF2PuU=
|
||||
github.com/RichardKnop/machinery v1.10.0 h1:fw2qkFY145N55pkoCFk27aJYBgIB97KVp9SLII7ykwk=
|
||||
github.com/RichardKnop/machinery v1.10.0/go.mod h1:BU4Cgsp2OpTy00OqVBkVjUJUlhchpUV8M83VHH6lCZY=
|
||||
github.com/Songmu/go-httpdate v1.0.0 h1:39S00oyg9q+kMso2ahhK4pvD4EXk4zQWzt/AMqGlH3o=
|
||||
github.com/Songmu/go-httpdate v1.0.0/go.mod h1:QPvdlIAR7M8UtklJx5CMOOCIq7hbx2QdxyEPvTF5QVs=
|
||||
github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48=
|
||||
github.com/aws/aws-sdk-go v1.35.35 h1:o/EbgEcIPWga7GWhJhb3tiaxqk4/goTdo5YEMdnVxgE=
|
||||
github.com/aws/aws-sdk-go v1.35.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b h1:L/QXpzIa3pOvUGt1D1lA5KjYhPBAN/3iWdP7xeFS9F0=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
|
||||
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
|
||||
github.com/go-fed/httpsig v1.1.0 h1:9M+hb0jkEICD8/cAiNqEB66R87tTINszBRTjwjQzWcI=
|
||||
github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg=
|
||||
github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||
github.com/go-redis/redis/v7 v7.4.0 h1:7obg6wUoj05T0EpY0o8B59S9w5yeMWql7sw2kwNW1x4=
|
||||
github.com/go-redis/redis/v7 v7.4.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg=
|
||||
github.com/go-redis/redis/v8 v8.1.1/go.mod h1:ysgGY09J/QeDYbu3HikWEIPCwaeOkuNoTgKayTEaEOw=
|
||||
github.com/go-redis/redis/v8 v8.4.0 h1:J5NCReIgh3QgUJu398hUncxDExN4gMOHI11NVbVicGQ=
|
||||
github.com/go-redis/redis/v8 v8.4.0/go.mod h1:A1tbYoHSa1fXwN+//ljcCYYJeLmVrwL9hbQN45Jdy0M=
|
||||
github.com/go-redsync/redsync/v4 v4.0.4 h1:ru0qG+VCefaZSx3a5ADmlKZXkNdgeeYWIuymDu/tzV8=
|
||||
github.com/go-redsync/redsync/v4 v4.0.4/go.mod h1:QBOJAs1k8O6Eyrre4a++pxQgHe5eQ+HF56KuTVv+8Bs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0=
|
||||
github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY=
|
||||
github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg=
|
||||
github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
|
||||
github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
|
||||
github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs=
|
||||
github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI=
|
||||
github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI=
|
||||
github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk=
|
||||
github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28=
|
||||
github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo=
|
||||
github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk=
|
||||
github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw=
|
||||
github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360=
|
||||
github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg=
|
||||
github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE=
|
||||
github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8=
|
||||
github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc=
|
||||
github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc=
|
||||
github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
|
||||
github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
|
||||
github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ=
|
||||
github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0=
|
||||
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/gomodule/redigo v1.8.2/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
|
||||
github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
|
||||
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.2.0 h1:y8Yozv7SZtlU//QXbezB6QkpuE6jMD2/gfzk4AftXjs=
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/googleapis/gax-go/v2 v2.6.0 h1:SXk3ABtQYDT/OH8jAyvEOQ58mgawq5C4o/4/89qN2ZU=
|
||||
github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY=
|
||||
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
|
||||
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI=
|
||||
github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
|
||||
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
|
||||
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
|
||||
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
|
||||
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.11.3 h1:dB4Bn0tN3wdCzQxnS8r06kV74qN/TAfaIS0bVE8h3jc=
|
||||
github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
|
||||
github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
|
||||
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.14.1/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M=
|
||||
github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA=
|
||||
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
|
||||
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
|
||||
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||
github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
|
||||
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
|
||||
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
||||
github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg=
|
||||
github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
|
||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo=
|
||||
github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo=
|
||||
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
|
||||
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
|
||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
|
||||
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
|
||||
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
|
||||
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.13.0 h1:BWSJ/M+f+3nmdz9bxB+bWX28kkALN2ok11D0rSo8EJU=
|
||||
github.com/spf13/viper v1.13.0/go.mod h1:Icm2xNL3/8uyh/wFuB1jI7TiTNKp8632Nwegu+zgdYw=
|
||||
github.com/streadway/amqp v1.0.0 h1:kuuDrUJFZL1QYL9hUNuCxNObNzB0bV/ZG5jV3RWAQgo=
|
||||
github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203 h1:QVqDTf3h2WHt08YuiTGPZLls0Wq99X9bWd0Q5ZSBesM=
|
||||
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203/go.mod h1:oqN97ltKNihBbwlX8dLpwxCl3+HnXKV/R0e+sRLd9C8=
|
||||
github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs=
|
||||
github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
|
||||
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c h1:u40Z8hqBAAQyv+vATcGgV0YCnDjqSL7/q/JyPhhJSPk=
|
||||
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
|
||||
github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
|
||||
github.com/xdg/stringprep v1.0.0 h1:d9X0esnoa3dFsV0FG35rAT0RIhYFlPq7MiP+DW89La0=
|
||||
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yukimochi/Activity-Relay v1.1.1 h1:veyqMC5OtDArnq0xdSWi2+XGngw+UCb2fqNjeqnN1FI=
|
||||
github.com/yukimochi/Activity-Relay v1.1.1/go.mod h1:7V4Oxkkv/eXgHDeC5B5SH98eKvgNcBqPrH5dv90IwB8=
|
||||
go.mongodb.org/mongo-driver v1.4.3 h1:moga+uhicpVshTyaqY9L23E6QqwcHRUv1sqyOsoyOO8=
|
||||
go.mongodb.org/mongo-driver v1.4.3/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
|
||||
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
|
||||
go.opentelemetry.io/otel v0.11.0/go.mod h1:G8UCk+KooF2HLkgo8RHX9epABH/aRGYET7gQOqBVdB0=
|
||||
go.opentelemetry.io/otel v0.14.0 h1:YFBEfjCk9MTjaytCNSUkp9Q8lF7QJezA06T71FbQxLQ=
|
||||
go.opentelemetry.io/otel v0.14.0/go.mod h1:vH5xEuwy7Rts0GNtsCW3HYQoZDY+OmBJ6t1bFGGlxgw=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
||||
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
||||
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
||||
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201026091529-146b70c837a4/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b h1:tvrvnPFcdzp294diPnrdZZZ8XUt2Tyj7svb7X52iDuU=
|
||||
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 h1:nt+Q6cXKz4MosCSpnbMtqiQ8Oz0pxTef2B4Vca2lvfk=
|
||||
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 h1:WIoqL4EROvwiPdUtaip4VcDdpZ4kha7wBWZrbVKCIZg=
|
||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
||||
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE=
|
||||
golang.org/x/tools v0.0.0-20201030143252-cf7a54d06671/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201125231158-b5590deeca9b/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
|
||||
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
|
||||
google.golang.org/api v0.34.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg=
|
||||
google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg=
|
||||
google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE=
|
||||
google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8=
|
||||
google.golang.org/api v0.102.0 h1:JxJl2qQ85fRMPNvlZY/enexbxpCjLwGhZUtgfGeQ51I=
|
||||
google.golang.org/api v0.102.0/go.mod h1:3VFl6/fzoA+qNuS1N1/VfXY4LjoXN/wzeIp7TweWwGo=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
|
||||
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201030142918-24207fddd1c3/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c h1:QgY/XxIAIeccR+Ca/rDdKubLIU9rcJ3xfy1DC/Wd2Oo=
|
||||
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c/go.mod h1:CGI5F/G+E5bKwmfYo09AXuVN4dD894kIKUFmVbP2/Fo=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8=
|
||||
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY=
|
||||
google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
115
app/main.go
Normal file
115
app/main.go
Normal file
@ -0,0 +1,115 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/lilfade/Activity-Relay/app/api"
|
||||
"github.com/lilfade/Activity-Relay/app/control"
|
||||
"github.com/lilfade/Activity-Relay/app/deliver"
|
||||
"github.com/lilfade/Activity-Relay/app/models"
|
||||
)
|
||||
|
||||
var (
|
||||
version string
|
||||
verbose bool
|
||||
|
||||
globalConfig *models.RelayConfig
|
||||
)
|
||||
|
||||
func main() {
|
||||
logrus.SetFormatter(&logrus.TextFormatter{
|
||||
ForceColors: true,
|
||||
})
|
||||
|
||||
var app = buildCommand()
|
||||
app.PersistentFlags().StringP("config", "c", "config.yml", "Path of config file.")
|
||||
app.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Show debug log in stdout.")
|
||||
|
||||
app.Execute()
|
||||
}
|
||||
|
||||
func buildCommand() *cobra.Command {
|
||||
var server = &cobra.Command{
|
||||
Use: "server",
|
||||
Short: "Activity-Relay API Server",
|
||||
Long: "Activity-Relay API Server is providing WebFinger API, ActivityPub inbox",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
initConfig(cmd)
|
||||
fmt.Println(globalConfig.DumpWelcomeMessage("API Server", version))
|
||||
err := api.Entrypoint(globalConfig, version)
|
||||
if err != nil {
|
||||
logrus.Fatal(err.Error())
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var worker = &cobra.Command{
|
||||
Use: "worker",
|
||||
Short: "Activity-Relay Job Worker",
|
||||
Long: "Activity-Relay Job Worker is providing ActivityPub Activity deliverer",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
initConfig(cmd)
|
||||
fmt.Println(globalConfig.DumpWelcomeMessage("Job Worker", version))
|
||||
err := deliver.Entrypoint(globalConfig, version)
|
||||
if err != nil {
|
||||
logrus.Fatal(err.Error())
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var command = &cobra.Command{
|
||||
Use: "control",
|
||||
Short: "Activity-Relay CLI",
|
||||
Long: "Activity-Relay CLI Management Utility",
|
||||
}
|
||||
control.BuildCommand(command)
|
||||
|
||||
var app = &cobra.Command{
|
||||
Short: "YUKIMOCHI Activity-Relay",
|
||||
Long: "YUKIMOCHI Activity-Relay - ActivityPub Relay Server",
|
||||
}
|
||||
app.AddCommand(server)
|
||||
app.AddCommand(worker)
|
||||
app.AddCommand(command)
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
func initConfig(cmd *cobra.Command) {
|
||||
if verbose {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
fmt.Println("DEBUG VIEW")
|
||||
}
|
||||
|
||||
configPath := cmd.Flag("config").Value.String()
|
||||
file, err := os.Open(configPath)
|
||||
defer file.Close()
|
||||
|
||||
if err == nil {
|
||||
viper.SetConfigType("yaml")
|
||||
viper.ReadConfig(file)
|
||||
} else {
|
||||
logrus.Warn("Config file not exist. Use environment variables.")
|
||||
|
||||
viper.BindEnv("ACTOR_PEM")
|
||||
viper.BindEnv("REDIS_URL")
|
||||
viper.BindEnv("RELAY_BIND")
|
||||
viper.BindEnv("RELAY_DOMAIN")
|
||||
viper.BindEnv("RELAY_SERVICENAME")
|
||||
viper.BindEnv("JOB_CONCURRENCY")
|
||||
viper.BindEnv("RELAY_SUMMARY")
|
||||
viper.BindEnv("RELAY_ICON")
|
||||
viper.BindEnv("RELAY_IMAGE")
|
||||
}
|
||||
|
||||
globalConfig, err = models.NewRelayConfig()
|
||||
if err != nil {
|
||||
logrus.Fatal(err.Error())
|
||||
}
|
||||
}
|
26
app/misc/dist/init/relay-api.service
vendored
Normal file
26
app/misc/dist/init/relay-api.service
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
# relay-api.service
|
||||
#
|
||||
# For using YUKIMOCHI Activity-Relay.
|
||||
#
|
||||
# See https://github.com/yukimochi/Activity-Relay/wiki for instructions.
|
||||
|
||||
[Unit]
|
||||
Description=YUKIMOCHI Activity-Relay API Server
|
||||
Documentation=https://github.com/yukimochi/Activity-Relay/wiki
|
||||
After=network.target network-online.target
|
||||
Requires=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=relay
|
||||
Group=relay
|
||||
ExecStart=/usr/bin/relay --config /var/lib/relay/config.yml server
|
||||
TimeoutStopSec=5s
|
||||
LimitNOFILE=1048576
|
||||
LimitNPROC=512
|
||||
PrivateTmp=true
|
||||
ProtectSystem=full
|
||||
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
25
app/misc/dist/init/relay-worker.service
vendored
Normal file
25
app/misc/dist/init/relay-worker.service
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# relay-worker.service
|
||||
#
|
||||
# For using YUKIMOCHI Activity-Relay.
|
||||
#
|
||||
# See https://github.com/yukimochi/Activity-Relay/wiki for instructions.
|
||||
|
||||
[Unit]
|
||||
Description=YUKIMOCHI Activity-Relay Job Worker
|
||||
Documentation=https://github.com/yukimochi/Activity-Relay/wiki
|
||||
After=network.target network-online.target
|
||||
Requires=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=relay
|
||||
Group=relay
|
||||
ExecStart=/usr/bin/relay --config /var/lib/relay/config.yml worker
|
||||
TimeoutStopSec=5s
|
||||
LimitNOFILE=1048576
|
||||
LimitNPROC=512
|
||||
PrivateTmp=true
|
||||
ProtectSystem=full
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
1
app/misc/test/announce.json
Normal file
1
app/misc/test/announce.json
Normal file
@ -0,0 +1 @@
|
||||
{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":{"@id":"as:movedTo","@type":"@id"},"Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":{"@id":"toot:featured","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://innocent.yukimochi.io/users/YUKIMOCHI/statuses/101289250732181320/activity","type":"Announce","actor":"https://innocent.yukimochi.io/users/YUKIMOCHI","published":"2018-12-23T07:48:31Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://innocent.yukimochi.io/users/YUKIMOCHI","https://innocent.yukimochi.io/users/YUKIMOCHI/followers"],"object":"https://innocent.yukimochi.io/users/YUKIMOCHI/statuses/101289215743686309","atomUri":"https://innocent.yukimochi.io/users/YUKIMOCHI/statuses/101289250732181320/activity","signature":{"type":"RsaSignature2017","creator":"https://innocent.yukimochi.io/users/YUKIMOCHI#main-key","created":"2018-12-23T07:48:31Z","signatureValue":"BV9zw6w0fESP03/DAY185Qk74FIOGDkuX5o1ASRK/OjAEdH2gm7wXQVZ5vYzjJo1AG6CJyNE/XFVdqCqakJCpzJ6QJcTmm+//hq7J9VFlkpIgIGUBUtOOaVe5lWTi+z+pN23jQ0dGnYyBMxihIVMbrSYh0IelgcyhMkRwwhLHWB8/AmOhnyK+VvFD+g99f3e92f72mD86lE2xZjoxXG/ErS56U75pKqp7OUSRo5yu8uG6vCPFoOqu6lrNSm4jAGUwHY82j4IpCElwdahDu3TM+frw+AnZUjlj7EJMbZQyYJ/C6nE5HsoMT13Ph5AJtJif03At5XYgVDv5Eesh10n1w=="}}
|
1
app/misc/test/application.json
Normal file
1
app/misc/test/application.json
Normal file
@ -0,0 +1 @@
|
||||
{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":{"@id":"as:movedTo","@type":"@id"},"Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":{"@id":"toot:featured","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://innocent.yukimochi.io/users/YUKIMOCHI","type":"Application","following":"https://innocent.yukimochi.io/users/YUKIMOCHI/following","followers":"https://innocent.yukimochi.io/users/YUKIMOCHI/followers","inbox":"https://innocent.yukimochi.io/users/YUKIMOCHI/inbox","outbox":"https://innocent.yukimochi.io/users/YUKIMOCHI/outbox","featured":"https://innocent.yukimochi.io/users/YUKIMOCHI/collections/featured","preferredUsername":"YUKIMOCHI","name":"雪餅🌟","summary":"\u003cp\u003e実験鯖です。連合して痛い目に合っても自己責任です・・・?(COM3D2の無垢ちゃん、かわいいかわいい!!)\u003c/p\u003e","url":"https://innocent.yukimochi.io/@YUKIMOCHI","manuallyApprovesFollowers":false,"publicKey":{"id":"https://innocent.yukimochi.io/users/YUKIMOCHI#main-key","owner":"https://innocent.yukimochi.io/users/YUKIMOCHI","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzNxXtpYOLYtpTUCxJDTq\nokV++p35C8lV+UlA8XIj8i1t64fWCqT1ULmlDEyiL1gWHEOVlV45z9PsCtJ2b2lV\nRFVBdQ1AeNKmaaTuX7CYM3wtli2cQQUlGEwWh1sgAv/LeoKRP90sA6O9M8M9H6T4\nF2cVHAaEnDFwjBQKtk/Bt70+esSkbe1qsc7vmrkaONAZrNVy6JY70r2Tg2uv7I3K\ndBpau6Igt1g87odVTPIhIVec8vnBzJvrHM1zorzRK+kPGjjAQ5XvZhkZzvjSfkkg\nqN5jDQrjfoW53vCfIJlbinEdWkJtGrDAnN1PjYIvH1bkOVJLDGUAtRtkTuCqJHPf\nMQIDAQAB\n-----END PUBLIC KEY-----\n"},"tag":[],"attachment":[],"endpoints":{"sharedInbox":"https://innocent.yukimochi.io/inbox"},"icon":{"type":"Image","mediaType":"image/png","url":"https://media.innocent.yukimochi.io/innocent/accounts/avatars/000/000/001/original/9f015d132fa2ef58.png"},"image":{"type":"Image","mediaType":"image/png","url":"https://media.innocent.yukimochi.io/innocent/accounts/headers/000/000/001/original/81300f90185e4d38.png"}}
|
1
app/misc/test/blankConfig.json
Normal file
1
app/misc/test/blankConfig.json
Normal file
@ -0,0 +1 @@
|
||||
{"RedisClient":{},"relayConfig":{}}
|
10
app/misc/test/config.yml
Normal file
10
app/misc/test/config.yml
Normal file
@ -0,0 +1,10 @@
|
||||
# ACTOR_PEM: FILL_WITH_EACH_TEST
|
||||
# REDIS_URL: FILL_WITH_EACH_TEST
|
||||
|
||||
RELAY_BIND: 0.0.0.0:8080
|
||||
RELAY_DOMAIN: relay.toot.yukimochi.jp
|
||||
RELAY_SERVICENAME: YUKIMOCHI Toot Relay Service
|
||||
JOB_CONCURRENCY: 50
|
||||
RELAY_SUMMARY: YUKIMOCHI Toot Relay Service is Running by Activity-Relay
|
||||
RELAY_ICON: https://example.com/example_icon.png
|
||||
RELAY_IMAGE: https://example.com/example_image.png
|
1
app/misc/test/create.json
Normal file
1
app/misc/test/create.json
Normal file
@ -0,0 +1 @@
|
||||
{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":{"@id":"as:movedTo","@type":"@id"},"Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":{"@id":"toot:featured","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://innocent.yukimochi.io/users/YUKIMOCHI/statuses/101289215743686309/activity","type":"Create","actor":"https://innocent.yukimochi.io/users/YUKIMOCHI","published":"2018-12-23T07:39:37Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://innocent.yukimochi.io/users/YUKIMOCHI/followers"],"object":{"id":"https://innocent.yukimochi.io/users/YUKIMOCHI/statuses/101289215743686309","type":"Note","summary":null,"inReplyTo":null,"published":"2018-12-23T07:39:37Z","url":"https://innocent.yukimochi.io/@YUKIMOCHI/101289215743686309","attributedTo":"https://innocent.yukimochi.io/users/YUKIMOCHI","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://innocent.yukimochi.io/users/YUKIMOCHI/followers"],"sensitive":false,"atomUri":"https://innocent.yukimochi.io/users/YUKIMOCHI/statuses/101289215743686309","inReplyToAtomUri":null,"conversation":"tag:innocent.yukimochi.io,2018-12-23:objectId=113387:objectType=Conversation","content":"\u003cp\u003eてすてす\u003c/p\u003e","contentMap":{"ja":"\u003cp\u003eてすてす\u003c/p\u003e"},"attachment":[],"tag":[]},"signature":{"type":"RsaSignature2017","creator":"https://innocent.yukimochi.io/users/YUKIMOCHI#main-key","created":"2018-12-23T07:39:37Z","signatureValue":"TvpvX96xZpAXorHCkoUdBRVq53geGvJjZtFt0971PO2AvqeHouHOVKKL9Q/WCH2raZdFnC8bsBPeWHZ+XVRxS/6poXyZ5sx+LrOEugng9+J0HwuI97GJFpcfltzXPvEKGyeScpGxQoVzbMwH5WO8jddEXA6Qxmr5LNleSEEamwB+ZQRab7Xm2KVkGkdPW/gA0n9sVdpPTjcayrDSIF7HZrUr7lMVfUsWJctpVs45YkIkn2GOdmkYmbbQ5Mg0B4bYKI06p9e7EQ0WiCmO+zHvCh6QSWWx1qZNWm3j10ia1gP/FKpEBLhZkBoC7TJxNe/6pW5L03yT7F72rf8Ztxb76A=="}}
|
1
app/misc/test/exampleConfig.json
Normal file
1
app/misc/test/exampleConfig.json
Normal file
@ -0,0 +1 @@
|
||||
{"RedisClient":{},"relayConfig":{"blockService":true,"manuallyAccept":true,"createAsAnnounce":true},"limitedDomains":["limitedDomain.example.jp"],"blockedDomains":["blockedDomain.example.jp"],"subscriptions":[{"domain":"subscription.example.jp","inbox_url":"https://subscription.example.jp/inbox","activity_id":"https://subscription.example.jp/UUID","actor_id":"https://subscription.example.jp/users/example"}]}
|
1
app/misc/test/follow.json
Normal file
1
app/misc/test/follow.json
Normal file
@ -0,0 +1 @@
|
||||
{"@context":"https://www.w3.org/ns/activitystreams","id":"https://innocent.yukimochi.io/be0802b1-8648-4598-b794-2ed19532100d","type":"Follow","actor":"https://innocent.yukimochi.io/users/mayaeh","object":"https://www.w3.org/ns/activitystreams#Public"}
|
1
app/misc/test/followAsActor.json
Normal file
1
app/misc/test/followAsActor.json
Normal file
@ -0,0 +1 @@
|
||||
{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":{"@id":"as:movedTo","@type":"@id"},"Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":{"@id":"toot:featured","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://innocent.yukimochi.io/5cfe3380-6cf0-4a1a-a4dd-283b96999a9e","type":"Follow","actor":"https://innocent.yukimochi.io/users/YUKIMOCHI","object":"https://relay.01.cloudgarage.yukimochi.io/actor","signature":{"type":"RsaSignature2017","creator":"https://innocent.yukimochi.io/users/YUKIMOCHI#main-key","created":"2018-12-23T07:57:33Z","signatureValue":"t61d9Y2FispoIXDIxJH1eOs0/GAkIkCnESQv9ganfTVvDqaS9+jgW7o2/P1jeITIfOapqJlYuko3XtcxaGPbR/V4pL19xM8qaSLP1HO9COwnqy+CuWD7PKZ/E0y6Dnm/PETrn72yxxLRh95lsY0iwsD+ClFyLr9PoIRsVAV98ng1G23sQvAA7unapUjJMIgCVtNa3nylWHopcvdGLG5kqXVoXIfYN4H8HwiNoMzU4336bNSc1UIclnGcAjbfZtXvS3rEuSHIwBHGxnXHr3bKmclm5cwYmDHzfuwkCIJduehRfdLnSP1JGQig1GM2qX+/UIC4uEiD1tTWBIV6vR1i8g=="}}
|
1
app/misc/test/person.json
Normal file
1
app/misc/test/person.json
Normal file
@ -0,0 +1 @@
|
||||
{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":{"@id":"as:movedTo","@type":"@id"},"Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":{"@id":"toot:featured","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://innocent.yukimochi.io/users/YUKIMOCHI","type":"Person","following":"https://innocent.yukimochi.io/users/YUKIMOCHI/following","followers":"https://innocent.yukimochi.io/users/YUKIMOCHI/followers","inbox":"https://innocent.yukimochi.io/users/YUKIMOCHI/inbox","outbox":"https://innocent.yukimochi.io/users/YUKIMOCHI/outbox","featured":"https://innocent.yukimochi.io/users/YUKIMOCHI/collections/featured","preferredUsername":"YUKIMOCHI","name":"雪餅🌟","summary":"\u003cp\u003e実験鯖です。連合して痛い目に合っても自己責任です・・・?(COM3D2の無垢ちゃん、かわいいかわいい!!)\u003c/p\u003e","url":"https://innocent.yukimochi.io/@YUKIMOCHI","manuallyApprovesFollowers":false,"publicKey":{"id":"https://innocent.yukimochi.io/users/YUKIMOCHI#main-key","owner":"https://innocent.yukimochi.io/users/YUKIMOCHI","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzNxXtpYOLYtpTUCxJDTq\nokV++p35C8lV+UlA8XIj8i1t64fWCqT1ULmlDEyiL1gWHEOVlV45z9PsCtJ2b2lV\nRFVBdQ1AeNKmaaTuX7CYM3wtli2cQQUlGEwWh1sgAv/LeoKRP90sA6O9M8M9H6T4\nF2cVHAaEnDFwjBQKtk/Bt70+esSkbe1qsc7vmrkaONAZrNVy6JY70r2Tg2uv7I3K\ndBpau6Igt1g87odVTPIhIVec8vnBzJvrHM1zorzRK+kPGjjAQ5XvZhkZzvjSfkkg\nqN5jDQrjfoW53vCfIJlbinEdWkJtGrDAnN1PjYIvH1bkOVJLDGUAtRtkTuCqJHPf\nMQIDAQAB\n-----END PUBLIC KEY-----\n"},"tag":[],"attachment":[],"endpoints":{"sharedInbox":"https://innocent.yukimochi.io/inbox"},"icon":{"type":"Image","mediaType":"image/png","url":"https://media.innocent.yukimochi.io/innocent/accounts/avatars/000/000/001/original/9f015d132fa2ef58.png"},"image":{"type":"Image","mediaType":"image/png","url":"https://media.innocent.yukimochi.io/innocent/accounts/headers/000/000/001/original/81300f90185e4d38.png"}}
|
1
app/misc/test/service.json
Normal file
1
app/misc/test/service.json
Normal file
@ -0,0 +1 @@
|
||||
{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":{"@id":"as:movedTo","@type":"@id"},"Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":{"@id":"toot:featured","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://innocent.yukimochi.io/users/YUKIMOCHI","type":"Service","following":"https://innocent.yukimochi.io/users/YUKIMOCHI/following","followers":"https://innocent.yukimochi.io/users/YUKIMOCHI/followers","inbox":"https://innocent.yukimochi.io/users/YUKIMOCHI/inbox","outbox":"https://innocent.yukimochi.io/users/YUKIMOCHI/outbox","featured":"https://innocent.yukimochi.io/users/YUKIMOCHI/collections/featured","preferredUsername":"YUKIMOCHI","name":"雪餅🌟","summary":"\u003cp\u003e実験鯖です。連合して痛い目に合っても自己責任です・・・?(COM3D2の無垢ちゃん、かわいいかわいい!!)\u003c/p\u003e","url":"https://innocent.yukimochi.io/@YUKIMOCHI","manuallyApprovesFollowers":false,"publicKey":{"id":"https://innocent.yukimochi.io/users/YUKIMOCHI#main-key","owner":"https://innocent.yukimochi.io/users/YUKIMOCHI","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzNxXtpYOLYtpTUCxJDTq\nokV++p35C8lV+UlA8XIj8i1t64fWCqT1ULmlDEyiL1gWHEOVlV45z9PsCtJ2b2lV\nRFVBdQ1AeNKmaaTuX7CYM3wtli2cQQUlGEwWh1sgAv/LeoKRP90sA6O9M8M9H6T4\nF2cVHAaEnDFwjBQKtk/Bt70+esSkbe1qsc7vmrkaONAZrNVy6JY70r2Tg2uv7I3K\ndBpau6Igt1g87odVTPIhIVec8vnBzJvrHM1zorzRK+kPGjjAQ5XvZhkZzvjSfkkg\nqN5jDQrjfoW53vCfIJlbinEdWkJtGrDAnN1PjYIvH1bkOVJLDGUAtRtkTuCqJHPf\nMQIDAQAB\n-----END PUBLIC KEY-----\n"},"tag":[],"attachment":[],"endpoints":{"sharedInbox":"https://innocent.yukimochi.io/inbox"},"icon":{"type":"Image","mediaType":"image/png","url":"https://media.innocent.yukimochi.io/innocent/accounts/avatars/000/000/001/original/9f015d132fa2ef58.png"},"image":{"type":"Image","mediaType":"image/png","url":"https://media.innocent.yukimochi.io/innocent/accounts/headers/000/000/001/original/81300f90185e4d38.png"}}
|
27
app/misc/test/testKey.pem
Normal file
27
app/misc/test/testKey.pem
Normal file
@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpQIBAAKCAQEAtl1oFS/LyBBlygdHp7bepNFgFvVLehdU31ReuFwt1WYDNEIQ
|
||||
a60tH3CyjpnFw2Hq8z5tRtTIJgMTROBI2CU7wgpC4IEO1jFpl4vRqJ7bcCQBib+6
|
||||
QI+9TCCI2qLgnCObfU8i6HWj4Z5fDMhKrMLMbdjLDVNGy7PRlVGR/b/Ootur4PXF
|
||||
2Xnxp+otum477/vT5SVNcJy6ZbFn//M6wo1ienKTnBOPjvMmz5JR8I6YczGJfmdr
|
||||
IPFdfjz24JT3fyIYRP6jUEo6mAyMIJReBN66LrehOa+tETyMPCHnponrhbrpq49t
|
||||
/0dQmtIorQeD5Yxi3BTbk3mJrd0sxvz5cPwsdQIDAQABAoIBAG8RhrHYsWmBKy2X
|
||||
r3mjNAj4CGkTLswGZ8e5UBNC+RtOjUcHsY6TI7dRYT7ewwcTnRBXBiEsuVYFa3f4
|
||||
jgUu8C1nKIIpuEqWP7RwENp9HjM3isRFxH9LzEQQUKmwp9IREcOJLj6cX5qrZUKY
|
||||
vnpoDjAc6NaN0MGCHHSwAJWme4jN7/0CRIAOhOEesaiUnkTEifIQBzGU83bDKi1Z
|
||||
6WRnq+RS1MyMRVg/yo80UtywSLOIVuyb/trMcEXKNK5pBpJHxEMj1UBJ8j/vEyY6
|
||||
LBs5NtH4miALVE5B5h5x/tP2onlA0uyEI+Pr5kW7UMJrn0Uvl8qGLYYCm9v78Og9
|
||||
AckPmKUCgYEA6MnaJxxhjJI3Og3I28nAse551Ag134jb+V9tl+Pj5WNNUtLKtM/6
|
||||
FIlKsXMLENk6I3Xj55dXSj7tJvNtvi91IdyBLDFtvLaFp2rvvbtyZ6JNVpeZ9dke
|
||||
azPL7JLN86fyGiFVsHw+IcPgFO/4ahtXdDe6tUCwbrKoVUGEwkoRmv8CgYEAyIxx
|
||||
jzcxAR4q8iPIpslc5VaMHcqoW2Zm61Y07B4oFdmqjz+IP1pumJAovQsu+fA5GMtU
|
||||
Bjq2W9xndMwuwOtGRt/Icc2JA8+manUZxNeKajhSypf+Ry6jFMYe7kuEW/iSfhdR
|
||||
jS2os5W6YmjnP5l1KI5q8LXtNWOIIumUmh0m/IsCgYEAiNZ+whbQ0MzyYdHQjEIg
|
||||
X3eLbbQV1vygMgqCZZK0WBbzUQhP19GZc5Dwszao/pJytn2KJoyz5xTuWsMlc3J6
|
||||
LBluZQf5NcEk97DIlIMnUPv68jfTbMzgMKwV5060edHzYqDNuhyOeVKm2iflopnH
|
||||
4q0Pt5P7Ilcq1FLbM0pO5wkCgYEAtEzPq5pLDF467gcN1iUix2zP+9i/E600yk9u
|
||||
tPlHwJ04oiDUNWDwHWk9tvfe/AXkz0299PvEB0JYIMGRJxBe1klKxEWs8Sg2zW8K
|
||||
A9ZkMqsAg/OyP/zF0V9tX3+1N5p62bHNN8fc69epAeCeRqeIlTW1H0PwRxd8xSaK
|
||||
2yNqcZECgYEAgPXPwXxT2qzdSfVp7TrT53kOYEPlkZXkzRZ0h9eRFbUNKRCt5h53
|
||||
qCq1DBOVAtQpKzGR0YGaA/JOMEYm8co2xAJH0Rkf+8GtsEi38Bqf8pzrdLAxQBi8
|
||||
oKk/pmB/LnNw6gDkL7Pi05kBHxa1kSCGmBxTe/5fCbaowTI+p0xkiNU=
|
||||
-----END RSA PRIVATE KEY-----
|
1
app/misc/test/undo.json
Normal file
1
app/misc/test/undo.json
Normal file
@ -0,0 +1 @@
|
||||
{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":{"@id":"as:movedTo","@type":"@id"},"Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":{"@id":"toot:featured","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://innocent.yukimochi.io/users/YUKIMOCHI#announces/101289250732181320/undo","type":"Undo","actor":"https://innocent.yukimochi.io/users/YUKIMOCHI","to":["https://www.w3.org/ns/activitystreams#Public"],"object":{"id":"https://innocent.yukimochi.io/users/YUKIMOCHI/statuses/101289250732181320/activity","type":"Announce","actor":"https://innocent.yukimochi.io/users/YUKIMOCHI","published":"2018-12-23T07:48:31Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://innocent.yukimochi.io/users/YUKIMOCHI","https://innocent.yukimochi.io/users/YUKIMOCHI/followers"],"object":"https://innocent.yukimochi.io/users/YUKIMOCHI/statuses/101289215743686309","atomUri":"https://innocent.yukimochi.io/users/YUKIMOCHI/statuses/101289250732181320/activity"},"signature":{"type":"RsaSignature2017","creator":"https://innocent.yukimochi.io/users/YUKIMOCHI#main-key","created":"2018-12-23T07:50:53Z","signatureValue":"mPq1BaRWwJGnoAKssfolfhRB/MTFhnZTbxi5IHFast+EvoYqjir/ZDgGJwVo07Zkrok6yLSESALolXzGOoteV+BC+Idmb1c8iWX52kZSKaPqFTOwDWI0tumtTACWnluK0WdGxgmFQxmhfkyO7iz9yka6FA0Gbn3dLfaMWmOCJUJwrDRdS7tlsXe2W3cGqQGpXrabKUol5jZv0BojUVEWiVzlrfVtVmE/38+mttydcMpPYw9WBNtomm3kHBDwU7FbszRigUAO3MOI1ABGb3Zi67mihDfC1RoWgxwn4ke2/z6bzxvy6g8Biy0cSjUbDSf3xHypKJGSU62Es+DdKCPpSQ=="}}
|
1
app/misc/test/unfollow.json
Normal file
1
app/misc/test/unfollow.json
Normal file
@ -0,0 +1 @@
|
||||
{"@context":"https://www.w3.org/ns/activitystreams","id":"https://innocent.yukimochi.io/d4028c5c-a794-4dcf-b2a8-0eaa41a086a1","type":"Undo","actor":"https://innocent.yukimochi.io/users/mayaeh","object":{"id":"https://innocent.yukimochi.io/102e3bf7-8a15-42d1-9e99-590e8e436f8e","type":"Follow","actor":"https://innocent.yukimochi.io/users/mayaeh","object":"https://www.w3.org/ns/activitystreams#Public"}}
|
140
app/models/config.go
Normal file
140
app/models/config.go
Normal file
@ -0,0 +1,140 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"crypto/rsa"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/RichardKnop/machinery/v1"
|
||||
"github.com/RichardKnop/machinery/v1/config"
|
||||
"github.com/go-redis/redis"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// RelayConfig contains valid configuration.
|
||||
type RelayConfig struct {
|
||||
actorKey *rsa.PrivateKey
|
||||
domain *url.URL
|
||||
redisClient *redis.Client
|
||||
redisURL string
|
||||
serverBind string
|
||||
serviceName string
|
||||
serviceSummary string
|
||||
serviceIconURL *url.URL
|
||||
serviceImageURL *url.URL
|
||||
jobConcurrency int
|
||||
}
|
||||
|
||||
// NewRelayConfig create valid RelayConfig from viper configuration. If invalid configuration detected, return error.
|
||||
func NewRelayConfig() (*RelayConfig, error) {
|
||||
domain, err := url.ParseRequestURI("https://" + viper.GetString("RELAY_DOMAIN"))
|
||||
if err != nil {
|
||||
return nil, errors.New("RELAY_DOMAIN: " + err.Error())
|
||||
}
|
||||
|
||||
iconURL, err := url.ParseRequestURI(viper.GetString("RELAY_ICON"))
|
||||
if err != nil {
|
||||
logrus.Warn("RELAY_ICON: INVALID OR EMPTY. THIS COLUMN IS DISABLED.")
|
||||
iconURL = nil
|
||||
}
|
||||
|
||||
imageURL, err := url.ParseRequestURI(viper.GetString("RELAY_IMAGE"))
|
||||
if err != nil {
|
||||
logrus.Warn("RELAY_IMAGE: INVALID OR EMPTY. THIS COLUMN IS DISABLED.")
|
||||
imageURL = nil
|
||||
}
|
||||
|
||||
jobConcurrency := viper.GetInt("JOB_CONCURRENCY")
|
||||
if jobConcurrency < 1 {
|
||||
return nil, errors.New("JOB_CONCURRENCY IS 0 OR EMPTY. SHOULD BE MORE THAN 1")
|
||||
}
|
||||
|
||||
privateKey, err := readPrivateKeyRSA(viper.GetString("ACTOR_PEM"))
|
||||
if err != nil {
|
||||
return nil, errors.New("ACTOR_PEM: " + err.Error())
|
||||
}
|
||||
|
||||
redisURL := viper.GetString("REDIS_URL")
|
||||
redisOption, err := redis.ParseURL(redisURL)
|
||||
if err != nil {
|
||||
return nil, errors.New("REDIS_URL: " + err.Error())
|
||||
}
|
||||
redisClient := redis.NewClient(redisOption)
|
||||
err = redisClient.Ping().Err()
|
||||
if err != nil {
|
||||
return nil, errors.New("Redis Connection Test: " + err.Error())
|
||||
}
|
||||
|
||||
serverBind := viper.GetString("RELAY_BIND")
|
||||
|
||||
return &RelayConfig{
|
||||
actorKey: privateKey,
|
||||
domain: domain,
|
||||
redisClient: redisClient,
|
||||
redisURL: redisURL,
|
||||
serverBind: serverBind,
|
||||
serviceName: viper.GetString("RELAY_SERVICENAME"),
|
||||
serviceSummary: viper.GetString("RELAY_SUMMARY"),
|
||||
serviceIconURL: iconURL,
|
||||
serviceImageURL: imageURL,
|
||||
jobConcurrency: jobConcurrency,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ServerBind is API Server's bind interface definition.
|
||||
func (relayConfig *RelayConfig) ServerBind() string {
|
||||
return relayConfig.serverBind
|
||||
}
|
||||
|
||||
// ServerHostname is API Server's hostname definition.
|
||||
func (relayConfig *RelayConfig) ServerHostname() *url.URL {
|
||||
return relayConfig.domain
|
||||
}
|
||||
|
||||
// ServerServiceName is API Server's servername definition.
|
||||
func (relayConfig *RelayConfig) ServerServiceName() string {
|
||||
return relayConfig.serviceName
|
||||
}
|
||||
|
||||
// JobConcurrency is API Worker's jobConcurrency definition.
|
||||
func (relayConfig *RelayConfig) JobConcurrency() int {
|
||||
return relayConfig.jobConcurrency
|
||||
}
|
||||
|
||||
// ActorKey is API Worker's HTTPSignature private key.
|
||||
func (relayConfig *RelayConfig) ActorKey() *rsa.PrivateKey {
|
||||
return relayConfig.actorKey
|
||||
}
|
||||
|
||||
// RedisClient is return redis client from RelayConfig.
|
||||
func (relayConfig *RelayConfig) RedisClient() *redis.Client {
|
||||
return relayConfig.redisClient
|
||||
}
|
||||
|
||||
// DumpWelcomeMessage provide build and config information string.
|
||||
func (relayConfig *RelayConfig) DumpWelcomeMessage(moduleName string, version string) string {
|
||||
return fmt.Sprintf(`Welcome to YUKIMOCHI Activity-Relay %s - %s
|
||||
- Configuration
|
||||
RELAY NAME : %s
|
||||
RELAY DOMAIN : %s
|
||||
REDIS URL : %s
|
||||
BIND ADDRESS : %s
|
||||
JOB_CONCURRENCY : %s
|
||||
`, version, moduleName, relayConfig.serviceName, relayConfig.domain.Host, relayConfig.redisURL, relayConfig.serverBind, strconv.Itoa(relayConfig.jobConcurrency))
|
||||
}
|
||||
|
||||
// NewMachineryServer create Redis backed Machinery Server from RelayConfig.
|
||||
func NewMachineryServer(globalConfig *RelayConfig) (*machinery.Server, error) {
|
||||
cnf := &config.Config{
|
||||
Broker: globalConfig.redisURL,
|
||||
DefaultQueue: "relay",
|
||||
ResultBackend: globalConfig.redisURL,
|
||||
ResultsExpireIn: 1,
|
||||
}
|
||||
newServer, err := machinery.NewServer(cnf)
|
||||
|
||||
return newServer, err
|
||||
}
|
109
app/models/config_test.go
Normal file
109
app/models/config_test.go
Normal file
@ -0,0 +1,109 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func TestNewRelayConfig(t *testing.T) {
|
||||
t.Run("success valid configuration", func(t *testing.T) {
|
||||
relayConfig, err := NewRelayConfig()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if relayConfig.serverBind != "0.0.0.0:8080" {
|
||||
t.Error("Failed parse: RelayConfig.serverBind")
|
||||
}
|
||||
if relayConfig.domain.Host != "relay.toot.yukimochi.jp" {
|
||||
t.Error("Failed parse: RelayConfig.domain")
|
||||
}
|
||||
if relayConfig.serviceName != "YUKIMOCHI Toot Relay Service" {
|
||||
t.Error("Failed parse: RelayConfig.serviceName")
|
||||
}
|
||||
if relayConfig.serviceSummary != "YUKIMOCHI Toot Relay Service is Running by Activity-Relay" {
|
||||
t.Error("Failed parse: RelayConfig.serviceSummary")
|
||||
}
|
||||
if relayConfig.serviceIconURL.String() != "https://example.com/example_icon.png" {
|
||||
t.Error("Failed parse: RelayConfig.serviceIconURL")
|
||||
}
|
||||
if relayConfig.serviceImageURL.String() != "https://example.com/example_image.png" {
|
||||
t.Error("Failed parse: RelayConfig.serviceImageURL")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("fail invalid configuration", func(t *testing.T) {
|
||||
invalidConfig := map[string]string{
|
||||
"ACTOR_PEM@notFound": "../misc/test/notfound.pem",
|
||||
"ACTOR_PEM@invalidKey": "../misc/test/actor.dh.pem",
|
||||
"REDIS_URL@invalidURL": "",
|
||||
"REDIS_URL@unreachableHost": "redis://localhost:6380",
|
||||
}
|
||||
|
||||
for key, value := range invalidConfig {
|
||||
viperKey := strings.Split(key, "@")[0]
|
||||
valid := viper.GetString(viperKey)
|
||||
|
||||
viper.Set(viperKey, value)
|
||||
_, err := NewRelayConfig()
|
||||
if err == nil {
|
||||
t.Error("Failed catch error: " + key)
|
||||
}
|
||||
|
||||
viper.Set(viperKey, valid)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func createRelayConfig(t *testing.T) *RelayConfig {
|
||||
relayConfig, err := NewRelayConfig()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
return relayConfig
|
||||
}
|
||||
|
||||
func TestRelayConfig_ServerBind(t *testing.T) {
|
||||
relayConfig := createRelayConfig(t)
|
||||
if relayConfig.ServerBind() != relayConfig.serverBind {
|
||||
t.Error("Failed accessor: ServerBind()")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRelayConfig_ServerHostname(t *testing.T) {
|
||||
relayConfig := createRelayConfig(t)
|
||||
if relayConfig.ServerHostname() != relayConfig.domain {
|
||||
t.Error("Failed accessor: ServerHostname()")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRelayConfig_DumpWelcomeMessage(t *testing.T) {
|
||||
relayConfig := createRelayConfig(t)
|
||||
w := relayConfig.DumpWelcomeMessage("Testing", "")
|
||||
|
||||
informations := map[string]string{
|
||||
"module NAME": "Testing",
|
||||
"RELAY NANE": relayConfig.serviceName,
|
||||
"RELAY DOMAIN": relayConfig.domain.Host,
|
||||
"REDIS URL": relayConfig.redisURL,
|
||||
"BIND ADDRESS": relayConfig.serverBind,
|
||||
}
|
||||
|
||||
for key, information := range informations {
|
||||
if !strings.Contains(w, information) {
|
||||
t.Error("Missed welcome message information: ", key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewMachineryServer(t *testing.T) {
|
||||
relayConfig := createRelayConfig(t)
|
||||
|
||||
_, err := NewMachineryServer(relayConfig)
|
||||
if err != nil {
|
||||
t.Error("Failed create machinery server: ", err)
|
||||
}
|
||||
}
|
320
app/models/models.go
Normal file
320
app/models/models.go
Normal file
@ -0,0 +1,320 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"crypto/rsa"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
cache "github.com/patrickmn/go-cache"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
// PublicKey : Activity Certificate.
|
||||
type PublicKey struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Owner string `json:"owner,omitempty"`
|
||||
PublicKeyPem string `json:"publicKeyPem,omitempty"`
|
||||
}
|
||||
|
||||
//Endpoints : Contains SharedInbox address.
|
||||
type Endpoints struct {
|
||||
SharedInbox string `json:"sharedInbox,omitempty"`
|
||||
}
|
||||
|
||||
// Image : Image Object.
|
||||
type Image struct {
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// Actor : ActivityPub Actor.
|
||||
type Actor struct {
|
||||
Context interface{} `json:"@context,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
PreferredUsername string `json:"preferredUsername,omitempty"`
|
||||
Summary string `json:"summary,omitempty"`
|
||||
Inbox string `json:"inbox,omitempty"`
|
||||
Endpoints *Endpoints `json:"endpoints,omitempty"`
|
||||
PublicKey PublicKey `json:"publicKey,omitempty"`
|
||||
Icon *Image `json:"icon,omitempty"`
|
||||
Image *Image `json:"image,omitempty"`
|
||||
}
|
||||
|
||||
// GenerateSelfKey : Generate relay Actor from PublicKey.
|
||||
func (actor *Actor) GenerateSelfKey(hostname *url.URL, publicKey *rsa.PublicKey) {
|
||||
actor.Context = []string{"https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"}
|
||||
actor.ID = hostname.String() + "/actor"
|
||||
actor.Type = "Service"
|
||||
actor.PreferredUsername = "relay"
|
||||
actor.Inbox = hostname.String() + "/inbox"
|
||||
actor.PublicKey = PublicKey{
|
||||
hostname.String() + "/actor#main-key",
|
||||
hostname.String() + "/actor",
|
||||
generatePublicKeyPEMString(publicKey),
|
||||
}
|
||||
}
|
||||
|
||||
func NewActivityPubActorFromSelfKey(globalConfig *RelayConfig) Actor {
|
||||
hostname := globalConfig.domain.String()
|
||||
publicKey := &globalConfig.actorKey.PublicKey
|
||||
publicKeyPemString := generatePublicKeyPEMString(publicKey)
|
||||
|
||||
newActor := Actor{
|
||||
Context: []string{"https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"},
|
||||
ID: hostname + "/actor",
|
||||
Type: "Service",
|
||||
Name: globalConfig.serviceName,
|
||||
PreferredUsername: "relay",
|
||||
Summary: globalConfig.serviceSummary,
|
||||
Inbox: hostname + "/inbox",
|
||||
PublicKey: struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Owner string `json:"owner,omitempty"`
|
||||
PublicKeyPem string `json:"publicKeyPem,omitempty"`
|
||||
}{
|
||||
ID: hostname + "/actor#main-key",
|
||||
Owner: hostname + "/actor",
|
||||
PublicKeyPem: publicKeyPemString,
|
||||
},
|
||||
}
|
||||
|
||||
if globalConfig.serviceIconURL != nil {
|
||||
newActor.Icon = &Image{
|
||||
URL: globalConfig.serviceIconURL.String(),
|
||||
}
|
||||
}
|
||||
if globalConfig.serviceImageURL != nil {
|
||||
newActor.Image = &Image{
|
||||
URL: globalConfig.serviceImageURL.String(),
|
||||
}
|
||||
}
|
||||
|
||||
return newActor
|
||||
}
|
||||
|
||||
// RetrieveRemoteActor : Retrieve Actor from remote instance.
|
||||
func (actor *Actor) RetrieveRemoteActor(url string, uaString string, cache *cache.Cache) error {
|
||||
var err error
|
||||
cacheData, found := cache.Get(url)
|
||||
if found {
|
||||
err = json.Unmarshal(cacheData.([]byte), &actor)
|
||||
if err != nil {
|
||||
cache.Delete(url)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
req.Header.Set("Accept", "application/activity+json")
|
||||
req.Header.Set("User-Agent", uaString)
|
||||
client := new(http.Client)
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return errors.New(resp.Status)
|
||||
}
|
||||
|
||||
data, _ := ioutil.ReadAll(resp.Body)
|
||||
err = json.Unmarshal(data, &actor)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cache.Set(url, data, 5*time.Minute)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Activity : ActivityPub Activity.
|
||||
type Activity struct {
|
||||
Context interface{} `json:"@context,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Actor string `json:"actor,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Object interface{} `json:"object,omitempty"`
|
||||
To []string `json:"to,omitempty"`
|
||||
Cc []string `json:"cc,omitempty"`
|
||||
}
|
||||
|
||||
// GenerateResponse : Generate activity response.
|
||||
func (activity *Activity) GenerateResponse(host *url.URL, responseType string) Activity {
|
||||
return Activity{
|
||||
[]string{"https://www.w3.org/ns/activitystreams"},
|
||||
host.String() + "/activities/" + uuid.NewV4().String(),
|
||||
host.String() + "/actor",
|
||||
responseType,
|
||||
&activity,
|
||||
nil,
|
||||
nil,
|
||||
}
|
||||
}
|
||||
|
||||
// GenerateAnnounce : Generate Announce of activity.
|
||||
func (activity *Activity) GenerateAnnounce(host *url.URL) Activity {
|
||||
return Activity{
|
||||
[]string{"https://www.w3.org/ns/activitystreams"},
|
||||
host.String() + "/activities/" + uuid.NewV4().String(),
|
||||
host.String() + "/actor",
|
||||
"Announce",
|
||||
activity.ID,
|
||||
[]string{host.String() + "/actor/followers"},
|
||||
nil,
|
||||
}
|
||||
}
|
||||
|
||||
// NestedActivity : Unwrap nested activity.
|
||||
func (activity *Activity) NestedActivity() (*Activity, error) {
|
||||
mappedObject := activity.Object.(map[string]interface{})
|
||||
if id, ok := mappedObject["id"].(string); ok {
|
||||
if nestedType, ok := mappedObject["type"].(string); ok {
|
||||
actor, ok := mappedObject["actor"].(string)
|
||||
if !ok {
|
||||
actor = ""
|
||||
}
|
||||
switch object := mappedObject["object"].(type) {
|
||||
case string:
|
||||
return &Activity{
|
||||
ID: id,
|
||||
Type: nestedType,
|
||||
Actor: actor,
|
||||
Object: object,
|
||||
}, nil
|
||||
default:
|
||||
return &Activity{
|
||||
ID: id,
|
||||
Type: nestedType,
|
||||
Actor: actor,
|
||||
Object: mappedObject["object"],
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
return nil, errors.New("can't assert type")
|
||||
}
|
||||
return nil, errors.New("can't assert id")
|
||||
}
|
||||
|
||||
// ActivityObject : ActivityPub Activity.
|
||||
type ActivityObject struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Content string `json:"content,omitempty"`
|
||||
To []string `json:"to,omitempty"`
|
||||
Cc []string `json:"cc,omitempty"`
|
||||
}
|
||||
|
||||
// Signature : ActivityPub Header Signature.
|
||||
type Signature struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Creator string `json:"creator,omitempty"`
|
||||
Created string `json:"created,omitempty"`
|
||||
SignatureValue string `json:"signatureValue,omitempty"`
|
||||
}
|
||||
|
||||
// WebfingerLink : Webfinger Link Resource.
|
||||
type WebfingerLink struct {
|
||||
Rel string `json:"rel,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
}
|
||||
|
||||
// WebfingerResource : Webfinger Resource.
|
||||
type WebfingerResource struct {
|
||||
Subject string `json:"subject,omitempty"`
|
||||
Links []WebfingerLink `json:"links,omitempty"`
|
||||
}
|
||||
|
||||
// GenerateFromActor : Generate Webfinger resource from Actor.
|
||||
func (resource *WebfingerResource) GenerateFromActor(hostname *url.URL, actor *Actor) {
|
||||
resource.Subject = "acct:" + actor.PreferredUsername + "@" + hostname.Host
|
||||
resource.Links = []WebfingerLink{
|
||||
{
|
||||
"self",
|
||||
"application/activity+json",
|
||||
actor.ID,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// NodeinfoResources : Nodeinfo Resources.
|
||||
type NodeinfoResources struct {
|
||||
NodeinfoLinks NodeinfoLinks
|
||||
Nodeinfo Nodeinfo
|
||||
}
|
||||
|
||||
// NodeinfoLinks : Nodeinfo Link Resource.
|
||||
type NodeinfoLinks struct {
|
||||
Links []NodeinfoLink `json:"links"`
|
||||
}
|
||||
|
||||
// NodeinfoLink : Nodeinfo Link Resource.
|
||||
type NodeinfoLink struct {
|
||||
Rel string `json:"rel"`
|
||||
Href string `json:"href"`
|
||||
}
|
||||
|
||||
// Nodeinfo : Nodeinfo Resource.
|
||||
type Nodeinfo struct {
|
||||
Version string `json:"version"`
|
||||
Software NodeinfoSoftware `json:"software"`
|
||||
Protocols []string `json:"protocols"`
|
||||
Services NodeinfoServices `json:"services"`
|
||||
OpenRegistrations bool `json:"openRegistrations"`
|
||||
Usage NodeinfoUsage `json:"usage"`
|
||||
Metadata NodeinfoMetadata `json:"metadata"`
|
||||
}
|
||||
|
||||
// NodeinfoSoftware : NodeinfoSoftware Resource.
|
||||
type NodeinfoSoftware struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Repository string `json:"repository,omitempty"`
|
||||
}
|
||||
|
||||
// NodeinfoServices : NodeinfoSoftware Resource.
|
||||
type NodeinfoServices struct {
|
||||
Inbound []string `json:"inbound"`
|
||||
Outbound []string `json:"outbound"`
|
||||
}
|
||||
|
||||
// NodeinfoUsage : NodeinfoUsage Resource.
|
||||
type NodeinfoUsage struct {
|
||||
Users NodeinfoUsageUsers `json:"users"`
|
||||
}
|
||||
|
||||
// NodeinfoUsageUsers : NodeinfoUsageUsers Resource.
|
||||
type NodeinfoUsageUsers struct {
|
||||
Total int `json:"total"`
|
||||
ActiveMonth int `json:"activeMonth"`
|
||||
ActiveHalfyear int `json:"activeHalfyear"`
|
||||
}
|
||||
|
||||
// NodeinfoMetadata : NodeinfoMetadata Resource.
|
||||
type NodeinfoMetadata struct {
|
||||
}
|
||||
|
||||
// GenerateFromActor : Generate Webfinger resource from Actor.
|
||||
func (resource *NodeinfoResources) GenerateFromActor(hostname *url.URL, actor *Actor, serverVersion string) {
|
||||
resource.NodeinfoLinks.Links = []NodeinfoLink{
|
||||
{
|
||||
"http://nodeinfo.diaspora.software/ns/schema/2.1",
|
||||
"https://" + hostname.Host + "/nodeinfo/2.1",
|
||||
},
|
||||
}
|
||||
resource.Nodeinfo = Nodeinfo{
|
||||
"2.1",
|
||||
NodeinfoSoftware{"activity-relay", serverVersion, "https://github.com/yukimochi/Activity-Relay"},
|
||||
[]string{"activitypub"},
|
||||
NodeinfoServices{[]string{}, []string{}},
|
||||
true,
|
||||
NodeinfoUsage{NodeinfoUsageUsers{0, 0, 0}},
|
||||
NodeinfoMetadata{},
|
||||
}
|
||||
}
|
39
app/models/models_test.go
Normal file
39
app/models/models_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var globalConfig *RelayConfig
|
||||
var relayState RelayState
|
||||
var ch chan bool
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
var err error
|
||||
|
||||
testConfigPath := "../misc/test/config.yml"
|
||||
file, _ := os.Open(testConfigPath)
|
||||
defer file.Close()
|
||||
|
||||
viper.SetConfigType("yaml")
|
||||
viper.ReadConfig(file)
|
||||
viper.Set("ACTOR_PEM", "../misc/test/testKey.pem")
|
||||
viper.BindEnv("REDIS_URL")
|
||||
|
||||
globalConfig, err = NewRelayConfig()
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
relayState = NewState(globalConfig.RedisClient(), true)
|
||||
ch = make(chan bool)
|
||||
relayState.ListenNotify(ch)
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
code := m.Run()
|
||||
os.Exit(code)
|
||||
}
|
202
app/models/state.go
Normal file
202
app/models/state.go
Normal file
@ -0,0 +1,202 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/go-redis/redis"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Config : Enum for RelayConfig
|
||||
type Config int
|
||||
|
||||
const (
|
||||
// BlockService : Blocking for service-type actor
|
||||
BlockService Config = iota
|
||||
// ManuallyAccept : Manually accept follow-request
|
||||
ManuallyAccept
|
||||
// CreateAsAnnounce : Announce activity instead of relay create activity
|
||||
CreateAsAnnounce
|
||||
)
|
||||
|
||||
// RelayState : Store subscriptions and relay configurations
|
||||
type RelayState struct {
|
||||
RedisClient *redis.Client
|
||||
notifiable bool
|
||||
|
||||
RelayConfig relayConfig `json:"relayConfig,omitempty"`
|
||||
LimitedDomains []string `json:"limitedDomains,omitempty"`
|
||||
BlockedDomains []string `json:"blockedDomains,omitempty"`
|
||||
Subscriptions []Subscription `json:"subscriptions,omitempty"`
|
||||
}
|
||||
|
||||
// NewState : Create new RelayState instance with redis client
|
||||
func NewState(redisClient *redis.Client, notifiable bool) RelayState {
|
||||
var config RelayState
|
||||
config.RedisClient = redisClient
|
||||
config.notifiable = notifiable
|
||||
|
||||
config.Load()
|
||||
return config
|
||||
}
|
||||
|
||||
func (config *RelayState) ListenNotify(c chan<- bool) {
|
||||
_, err := config.RedisClient.Subscribe("relay_refresh").Receive()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ch := config.RedisClient.Subscribe("relay_refresh").Channel()
|
||||
|
||||
cNotify := c != nil
|
||||
go func() {
|
||||
for range ch {
|
||||
logrus.Info("Config refreshed from state changed notify.")
|
||||
config.Load()
|
||||
if cNotify {
|
||||
c <- true
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Load : Refrash content from redis
|
||||
func (config *RelayState) Load() {
|
||||
config.RelayConfig.load(config.RedisClient)
|
||||
var limitedDomains []string
|
||||
var blockedDomains []string
|
||||
var subscriptions []Subscription
|
||||
domains, _ := config.RedisClient.HKeys("relay:config:limitedDomain").Result()
|
||||
for _, domain := range domains {
|
||||
limitedDomains = append(limitedDomains, domain)
|
||||
}
|
||||
domains, _ = config.RedisClient.HKeys("relay:config:blockedDomain").Result()
|
||||
for _, domain := range domains {
|
||||
blockedDomains = append(blockedDomains, domain)
|
||||
}
|
||||
domains, _ = config.RedisClient.Keys("relay:subscription:*").Result()
|
||||
for _, domain := range domains {
|
||||
domainName := strings.Replace(domain, "relay:subscription:", "", 1)
|
||||
inboxURL, _ := config.RedisClient.HGet(domain, "inbox_url").Result()
|
||||
activityID, err := config.RedisClient.HGet(domain, "activity_id").Result()
|
||||
if err != nil {
|
||||
activityID = ""
|
||||
}
|
||||
actorID, err := config.RedisClient.HGet(domain, "actor_id").Result()
|
||||
if err != nil {
|
||||
actorID = ""
|
||||
}
|
||||
subscriptions = append(subscriptions, Subscription{domainName, inboxURL, activityID, actorID})
|
||||
}
|
||||
config.LimitedDomains = limitedDomains
|
||||
config.BlockedDomains = blockedDomains
|
||||
config.Subscriptions = subscriptions
|
||||
}
|
||||
|
||||
// SetConfig : Set relay configuration
|
||||
func (config *RelayState) SetConfig(key Config, value bool) {
|
||||
strValue := 0
|
||||
if value {
|
||||
strValue = 1
|
||||
}
|
||||
switch key {
|
||||
case BlockService:
|
||||
config.RedisClient.HSet("relay:config", "block_service", strValue).Result()
|
||||
case ManuallyAccept:
|
||||
config.RedisClient.HSet("relay:config", "manually_accept", strValue).Result()
|
||||
case CreateAsAnnounce:
|
||||
config.RedisClient.HSet("relay:config", "create_as_announce", strValue).Result()
|
||||
}
|
||||
|
||||
config.refresh()
|
||||
}
|
||||
|
||||
// AddSubscription : Add new instance for subscription list
|
||||
func (config *RelayState) AddSubscription(domain Subscription) {
|
||||
config.RedisClient.HMSet("relay:subscription:"+domain.Domain, map[string]interface{}{
|
||||
"inbox_url": domain.InboxURL,
|
||||
"activity_id": domain.ActivityID,
|
||||
"actor_id": domain.ActorID,
|
||||
})
|
||||
|
||||
config.refresh()
|
||||
}
|
||||
|
||||
// DelSubscription : Delete instance from subscription list
|
||||
func (config *RelayState) DelSubscription(domain string) {
|
||||
config.RedisClient.Del("relay:subscription:" + domain).Result()
|
||||
config.RedisClient.Del("relay:pending:" + domain).Result()
|
||||
|
||||
config.refresh()
|
||||
}
|
||||
|
||||
// SelectSubscription : Select instance from string
|
||||
func (config *RelayState) SelectSubscription(domain string) *Subscription {
|
||||
for _, subscription := range config.Subscriptions {
|
||||
if domain == subscription.Domain {
|
||||
return &subscription
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetBlockedDomain : Set/Unset instance for blocked domain
|
||||
func (config *RelayState) SetBlockedDomain(domain string, value bool) {
|
||||
if value {
|
||||
config.RedisClient.HSet("relay:config:blockedDomain", domain, "1").Result()
|
||||
} else {
|
||||
config.RedisClient.HDel("relay:config:blockedDomain", domain).Result()
|
||||
}
|
||||
|
||||
config.refresh()
|
||||
}
|
||||
|
||||
// SetLimitedDomain : Set/Unset instance for limited domain
|
||||
func (config *RelayState) SetLimitedDomain(domain string, value bool) {
|
||||
if value {
|
||||
config.RedisClient.HSet("relay:config:limitedDomain", domain, "1").Result()
|
||||
} else {
|
||||
config.RedisClient.HDel("relay:config:limitedDomain", domain).Result()
|
||||
}
|
||||
|
||||
config.refresh()
|
||||
}
|
||||
|
||||
func (config *RelayState) refresh() {
|
||||
if config.notifiable {
|
||||
config.RedisClient.Publish("relay_refresh", "Config refreshing request.")
|
||||
} else {
|
||||
config.Load()
|
||||
}
|
||||
}
|
||||
|
||||
// Subscription : Instance subscription information
|
||||
type Subscription struct {
|
||||
Domain string `json:"domain,omitempty"`
|
||||
InboxURL string `json:"inbox_url,omitempty"`
|
||||
ActivityID string `json:"activity_id,omitempty"`
|
||||
ActorID string `json:"actor_id,omitempty"`
|
||||
}
|
||||
|
||||
type relayConfig struct {
|
||||
BlockService bool `json:"blockService,omitempty"`
|
||||
ManuallyAccept bool `json:"manuallyAccept,omitempty"`
|
||||
CreateAsAnnounce bool `json:"createAsAnnounce,omitempty"`
|
||||
}
|
||||
|
||||
func (config *relayConfig) load(redisClient *redis.Client) {
|
||||
blockService, err := redisClient.HGet("relay:config", "block_service").Result()
|
||||
if err != nil {
|
||||
blockService = "0"
|
||||
}
|
||||
manuallyAccept, err := redisClient.HGet("relay:config", "manually_accept").Result()
|
||||
if err != nil {
|
||||
manuallyAccept = "0"
|
||||
}
|
||||
createAsAnnounce, err := redisClient.HGet("relay:config", "create_as_announce").Result()
|
||||
if err != nil {
|
||||
createAsAnnounce = "0"
|
||||
}
|
||||
config.BlockService = blockService == "1"
|
||||
config.ManuallyAccept = manuallyAccept == "1"
|
||||
config.CreateAsAnnounce = createAsAnnounce == "1"
|
||||
}
|
190
app/models/state_test.go
Normal file
190
app/models/state_test.go
Normal file
@ -0,0 +1,190 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLoadEmpty(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
relayState.Load()
|
||||
|
||||
if relayState.RelayConfig.BlockService != false {
|
||||
t.Fatalf("Failed read config.")
|
||||
}
|
||||
if relayState.RelayConfig.CreateAsAnnounce != false {
|
||||
t.Fatalf("Failed read config.")
|
||||
}
|
||||
if relayState.RelayConfig.ManuallyAccept != false {
|
||||
t.Fatalf("Failed read config.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetConfig(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
relayState.SetConfig(BlockService, true)
|
||||
<-ch
|
||||
if relayState.RelayConfig.BlockService != true {
|
||||
t.Fatalf("Failed enable config.")
|
||||
}
|
||||
relayState.SetConfig(CreateAsAnnounce, true)
|
||||
<-ch
|
||||
if relayState.RelayConfig.CreateAsAnnounce != true {
|
||||
t.Fatalf("Failed enable config.")
|
||||
}
|
||||
relayState.SetConfig(ManuallyAccept, true)
|
||||
<-ch
|
||||
if relayState.RelayConfig.ManuallyAccept != true {
|
||||
t.Fatalf("Failed enable config.")
|
||||
}
|
||||
|
||||
relayState.SetConfig(BlockService, false)
|
||||
<-ch
|
||||
if relayState.RelayConfig.BlockService != false {
|
||||
t.Fatalf("Failed disable config.")
|
||||
}
|
||||
relayState.SetConfig(CreateAsAnnounce, false)
|
||||
<-ch
|
||||
if relayState.RelayConfig.CreateAsAnnounce != false {
|
||||
t.Fatalf("Failed disable config.")
|
||||
}
|
||||
relayState.SetConfig(ManuallyAccept, false)
|
||||
<-ch
|
||||
if relayState.RelayConfig.ManuallyAccept != false {
|
||||
t.Fatalf("Failed disable config.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestTreatSubscriptionNotify(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
relayState.AddSubscription(Subscription{
|
||||
Domain: "example.com",
|
||||
InboxURL: "https://example.com/inbox",
|
||||
})
|
||||
<-ch
|
||||
|
||||
valid := false
|
||||
for _, domain := range relayState.Subscriptions {
|
||||
if domain.Domain == "example.com" && domain.InboxURL == "https://example.com/inbox" {
|
||||
valid = true
|
||||
}
|
||||
}
|
||||
if !valid {
|
||||
t.Fatalf("Failed write config.")
|
||||
}
|
||||
|
||||
relayState.DelSubscription("example.com")
|
||||
<-ch
|
||||
|
||||
for _, domain := range relayState.Subscriptions {
|
||||
if domain.Domain == "example.com" {
|
||||
valid = false
|
||||
}
|
||||
}
|
||||
if !valid {
|
||||
t.Fatalf("Failed write config.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSelectDomain(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
exampleSubscription := Subscription{
|
||||
Domain: "example.com",
|
||||
InboxURL: "https://example.com/inbox",
|
||||
}
|
||||
|
||||
relayState.AddSubscription(exampleSubscription)
|
||||
<-ch
|
||||
|
||||
subscription := relayState.SelectSubscription("example.com")
|
||||
if *subscription != exampleSubscription {
|
||||
t.Fatalf("Failed select domain.")
|
||||
}
|
||||
|
||||
subscription = relayState.SelectSubscription("example.org")
|
||||
if subscription != nil {
|
||||
t.Fatalf("Failed select domain.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBlockedDomain(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
relayState.SetBlockedDomain("example.com", true)
|
||||
<-ch
|
||||
|
||||
valid := false
|
||||
for _, domain := range relayState.BlockedDomains {
|
||||
if domain == "example.com" {
|
||||
valid = true
|
||||
}
|
||||
}
|
||||
if !valid {
|
||||
t.Fatalf("Failed write config.")
|
||||
}
|
||||
|
||||
relayState.SetBlockedDomain("example.com", false)
|
||||
<-ch
|
||||
|
||||
for _, domain := range relayState.BlockedDomains {
|
||||
if domain == "example.com" {
|
||||
valid = false
|
||||
}
|
||||
}
|
||||
if !valid {
|
||||
t.Fatalf("Failed write config.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLimitedDomain(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
relayState.SetLimitedDomain("example.com", true)
|
||||
<-ch
|
||||
|
||||
valid := false
|
||||
for _, domain := range relayState.LimitedDomains {
|
||||
if domain == "example.com" {
|
||||
valid = true
|
||||
}
|
||||
}
|
||||
if !valid {
|
||||
t.Fatalf("Failed write config.")
|
||||
}
|
||||
|
||||
relayState.SetLimitedDomain("example.com", false)
|
||||
<-ch
|
||||
|
||||
for _, domain := range relayState.LimitedDomains {
|
||||
if domain == "example.com" {
|
||||
valid = false
|
||||
}
|
||||
}
|
||||
if !valid {
|
||||
t.Fatalf("Failed write config.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadCompatibleSubscription(t *testing.T) {
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
relayState.AddSubscription(Subscription{
|
||||
Domain: "example.com",
|
||||
InboxURL: "https://example.com/inbox",
|
||||
})
|
||||
|
||||
relayState.RedisClient.HDel("relay:subscription:example.com", "activity_id", "actor_id")
|
||||
relayState.Load()
|
||||
|
||||
valid := false
|
||||
for _, domain := range relayState.Subscriptions {
|
||||
if domain.Domain == "example.com" && domain.InboxURL == "https://example.com/inbox" {
|
||||
valid = true
|
||||
}
|
||||
}
|
||||
if !valid {
|
||||
t.Fatalf("Failed load compati config.")
|
||||
}
|
||||
}
|
74
app/models/utils.go
Normal file
74
app/models/utils.go
Normal file
@ -0,0 +1,74 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/go-redis/redis"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func ReadPublicKeyRSAFromString(pemString string) (*rsa.PublicKey, error) {
|
||||
pemByte := []byte(pemString)
|
||||
decoded, _ := pem.Decode(pemByte)
|
||||
defer func() {
|
||||
recover()
|
||||
}()
|
||||
keyInterface, err := x509.ParsePKIXPublicKey(decoded.Bytes)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
pub := keyInterface.(*rsa.PublicKey)
|
||||
return pub, nil
|
||||
}
|
||||
|
||||
func redisHGetOrCreateWithDefault(redisClient *redis.Client, key string, field string, defaultValue string) (string, error) {
|
||||
keyExist, err := redisClient.HExists(key, field).Result()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if keyExist {
|
||||
value, err := redisClient.HGet(key, field).Result()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return value, nil
|
||||
} else {
|
||||
_, err := redisClient.HSet(key, field, defaultValue).Result()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return defaultValue, nil
|
||||
}
|
||||
}
|
||||
|
||||
func readPrivateKeyRSA(keyPath string) (*rsa.PrivateKey, error) {
|
||||
file, err := ioutil.ReadFile(keyPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
decoded, _ := pem.Decode(file)
|
||||
if decoded == nil {
|
||||
return nil, errors.New("ACTOR_PEM IS INVALID. FAILED TO READ")
|
||||
}
|
||||
privateKey, err := x509.ParsePKCS1PrivateKey(decoded.Bytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return privateKey, nil
|
||||
}
|
||||
|
||||
func generatePublicKeyPEMString(publicKey *rsa.PublicKey) string {
|
||||
publicKeyByte := x509.MarshalPKCS1PublicKey(publicKey)
|
||||
publicKeyPem := pem.EncodeToMemory(
|
||||
&pem.Block{
|
||||
Type: "RSA PUBLIC KEY",
|
||||
Bytes: publicKeyByte,
|
||||
},
|
||||
)
|
||||
return string(publicKeyPem)
|
||||
}
|
51
app/models/utils_test.go
Normal file
51
app/models/utils_test.go
Normal file
@ -0,0 +1,51 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRedisHGetOrCreateWithDefault(t *testing.T) {
|
||||
relayConfig := createRelayConfig(t)
|
||||
|
||||
t.Run("Execute HGet when value exist", func(t *testing.T) {
|
||||
_, err := relayConfig.redisClient.HSet("gotest:redis:hget:or:create:with:default", "exist", "1").Result()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
value, err := redisHGetOrCreateWithDefault(relayConfig.redisClient, "gotest:redis:hget:or:create:with:default", "exist", "2")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if value != "1" {
|
||||
t.Error(errors.New("value is override by redisHGetOrCreateWithDefault"))
|
||||
}
|
||||
|
||||
_, err = relayConfig.redisClient.HDel("gotest:redis:hget:or:create:with:default", "exist").Result()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Execute HGet when value not exist", func(t *testing.T) {
|
||||
_, err := redisHGetOrCreateWithDefault(relayConfig.redisClient, "gotest:redis:hget:or:create:with:default", "not_exist", "2")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
value, err := relayConfig.redisClient.HGet("gotest:redis:hget:or:create:with:default", "not_exist").Result()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if value != "2" {
|
||||
t.Error(errors.New("redisHGetOrCreateWithDefault is not write default value successfully"))
|
||||
}
|
||||
|
||||
_, err = relayConfig.redisClient.HDel("gotest:redis:hget:or:create:with:default", "not_exist").Result()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user