From f05921420fcea5293f582163f242c64aea5f6896 Mon Sep 17 00:00:00 2001 From: Naoki Kosaka Date: Sun, 20 Jun 2021 17:26:15 +0900 Subject: [PATCH] Words typo in codes fixed. --- api/decode.go | 10 +++++----- api/handle.go | 26 +++++++++++++------------- api/handle_test.go | 12 ++++++------ control/config.go | 14 +++++++------- control/config_test.go | 12 ++++++------ control/domain.go | 2 +- control/domain_test.go | 10 +++++----- control/follow.go | 8 ++++---- control/follow_test.go | 6 +++--- deliver/deriver.go | 8 ++++---- deliver/deriver_test.go | 16 ++++++++-------- deliver/logger.go | 2 +- deliver/sender.go | 2 +- models/config.go | 6 +++--- models/config_test.go | 12 ++++++------ models/models.go | 14 +++++++------- models/state.go | 2 +- models/state_test.go | 2 +- models/utils.go | 2 +- readme.md | 4 ++-- 20 files changed, 85 insertions(+), 85 deletions(-) diff --git a/api/decode.go b/api/decode.go index 99ec81e..5f010b7 100644 --- a/api/decode.go +++ b/api/decode.go @@ -26,11 +26,11 @@ func decodeActivity(request *http.Request) (*models.Activity, *models.Actor, []b } 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) + 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) + PubKey, err := models.ReadPublicKeyRSAFromString(keyOwnerActor.PublicKey.PublicKeyPem) if PubKey == nil { return nil, nil, nil, errors.New("Failed parse PublicKey from string") } @@ -47,9 +47,9 @@ func decodeActivity(request *http.Request) (*models.Activity, *models.Actor, []b hash := sha256.New() hash.Write(body) b := hash.Sum(nil) - calcurateDigest := "SHA-256=" + base64.StdEncoding.EncodeToString(b) + calculatedDigest := "SHA-256=" + base64.StdEncoding.EncodeToString(b) - if givenDigest != calcurateDigest { + if givenDigest != calculatedDigest { return nil, nil, nil, errors.New("Digest header is mismatch") } @@ -61,7 +61,7 @@ func decodeActivity(request *http.Request) (*models.Activity, *models.Actor, []b } 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) + 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 } diff --git a/api/handle.go b/api/handle.go index ea4a562..c3e8c12 100644 --- a/api/handle.go +++ b/api/handle.go @@ -20,13 +20,13 @@ func handleWebfinger(writer http.ResponseWriter, request *http.Request) { } else { request := resource[0] if request == WebfingerResource.Subject { - wfresource, err := json.Marshal(&WebfingerResource) + webfingerResource, err := json.Marshal(&WebfingerResource) if err != nil { panic(err) } writer.Header().Add("Content-Type", "application/json") writer.WriteHeader(200) - writer.Write(wfresource) + writer.Write(webfingerResource) } else { writer.WriteHeader(404) writer.Write(nil) @@ -39,13 +39,13 @@ func handleNodeinfoLink(writer http.ResponseWriter, request *http.Request) { writer.WriteHeader(400) writer.Write(nil) } else { - linksresource, err := json.Marshal(&Nodeinfo.NodeinfoLinks) + linksResource, err := json.Marshal(&Nodeinfo.NodeinfoLinks) if err != nil { panic(err) } writer.Header().Add("Content-Type", "application/json") writer.WriteHeader(200) - writer.Write(linksresource) + writer.Write(linksResource) } } @@ -58,13 +58,13 @@ func handleNodeinfo(writer http.ResponseWriter, request *http.Request) { Nodeinfo.Nodeinfo.Usage.Users.Total = userCount Nodeinfo.Nodeinfo.Usage.Users.ActiveMonth = userCount Nodeinfo.Nodeinfo.Usage.Users.ActiveHalfyear = userCount - linksresource, err := json.Marshal(&Nodeinfo.Nodeinfo) + linksResource, err := json.Marshal(&Nodeinfo.Nodeinfo) if err != nil { panic(err) } writer.Header().Add("Content-Type", "application/json") writer.WriteHeader(200) - writer.Write(linksresource) + writer.Write(linksResource) } } @@ -132,9 +132,9 @@ func pushRelayJob(sourceInbox string, body []byte) { } } -func pushRegistorJob(inboxURL string, body []byte) { +func pushRegisterJob(inboxURL string, body []byte) { job := &tasks.Signature{ - Name: "registor", + Name: "register", RetryCount: 2, Args: []tasks.Arg{ { @@ -181,13 +181,13 @@ func suitableFollow(activity *models.Activity, actor *models.Actor) bool { 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") + 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") + return errors.New("to use the relay service, Subscribe me in advance") } func suitableRelay(activity *models.Activity, actor *models.Actor) bool { @@ -216,7 +216,7 @@ func handleInbox(writer http.ResponseWriter, request *http.Request, activityDeco if err != nil { resp := activity.GenerateResponse(globalConfig.ServerHostname(), "Reject") jsonData, _ := json.Marshal(&resp) - go pushRegistorJob(actor.Inbox, jsonData) + go pushRegisterJob(actor.Inbox, jsonData) fmt.Println("Reject Follow Request : ", err.Error(), activity.Actor) writer.WriteHeader(202) @@ -235,7 +235,7 @@ func handleInbox(writer http.ResponseWriter, request *http.Request, activityDeco } else { resp := activity.GenerateResponse(globalConfig.ServerHostname(), "Accept") jsonData, _ := json.Marshal(&resp) - go pushRegistorJob(actor.Inbox, jsonData) + go pushRegisterJob(actor.Inbox, jsonData) relayState.AddSubscription(models.Subscription{ Domain: domain.Host, InboxURL: actor.Endpoints.SharedInbox, @@ -247,7 +247,7 @@ func handleInbox(writer http.ResponseWriter, request *http.Request, activityDeco } else { resp := activity.GenerateResponse(globalConfig.ServerHostname(), "Reject") jsonData, _ := json.Marshal(&resp) - go pushRegistorJob(actor.Inbox, jsonData) + go pushRegisterJob(actor.Inbox, jsonData) fmt.Println("Reject Follow Request : ", activity.Actor) } diff --git a/api/handle_test.go b/api/handle_test.go index 7880654..da57df5 100644 --- a/api/handle_test.go +++ b/api/handle_test.go @@ -42,13 +42,13 @@ func TestHandleWebfingerGet(t *testing.T) { defer r.Body.Close() data, _ := ioutil.ReadAll(r.Body) - var wfresource models.WebfingerResource - err = json.Unmarshal(data, &wfresource) + var webfingerResource models.WebfingerResource + err = json.Unmarshal(data, &webfingerResource) if err != nil { t.Fatalf("WebfingerResource response is not valid.") } - domain, _ := url.Parse(wfresource.Links[0].Href) + domain, _ := url.Parse(webfingerResource.Links[0].Href) if domain.Host != globalConfig.ServerHostname().Host { t.Fatalf("WebfingerResource's Host not valid.") } @@ -305,7 +305,7 @@ func mockActivity(req string) models.Activity { json.Unmarshal(body, &activity) return activity default: - panic("No assined request.") + panic("No assigned request.") } } @@ -330,7 +330,7 @@ func mockActor(req string) models.Actor { json.Unmarshal(body, &actor) return actor default: - panic("No assined request.") + panic("No assigned request.") } } @@ -642,7 +642,7 @@ func TestHandleInboxValidCreate(t *testing.T) { relayState.RedisClient.Del("relay:subscription:example.org").Result() } -func TestHandleInboxlimitedCreate(t *testing.T) { +func TestHandleInboxLimitedCreate(t *testing.T) { activity := mockActivity("Create") actor := mockActor("Person") domain, _ := url.Parse(activity.Actor) diff --git a/control/config.go b/control/config.go index ca9d404..c04e44d 100644 --- a/control/config.go +++ b/control/config.go @@ -20,13 +20,13 @@ func configCmdInit() *cobra.Command { var config = &cobra.Command{ Use: "config", Short: "Manage configuration for relay", - Long: "Enable/disable relay costomize and import/export relay database.", + Long: "Enable/disable relay customize and import/export relay database.", } var configList = &cobra.Command{ Use: "list", - Short: "List all relay configration", - Long: "List all relay configration.", + Short: "List all relay configuration", + Long: "List all relay configuration.", Run: func(cmd *cobra.Command, args []string) { initProxy(listConfig, cmd, args) }, @@ -57,8 +57,8 @@ func configCmdInit() *cobra.Command { var configEnable = &cobra.Command{ Use: "enable", - Short: "Enable/disable relay configration", - Long: `Enable or disable relay configration. + Short: "Enable/disable relay configuration", + Long: `Enable or disable relay configuration. - service-block Blocking feature for service-type actor. - manually-accept @@ -70,7 +70,7 @@ func configCmdInit() *cobra.Command { return initProxyE(configEnable, cmd, args) }, } - configEnable.Flags().BoolP("disable", "d", false, "Disable configration instead of Enable") + configEnable.Flags().BoolP("disable", "d", false, "Disable configuration instead of Enable") config.AddCommand(configEnable) return config @@ -168,6 +168,6 @@ func importConfig(cmd *cobra.Command, args []string) { ActivityID: Subscription.ActivityID, ActorID: Subscription.ActorID, }) - cmd.Println("Regist [" + Subscription.Domain + "] as subscriber") + cmd.Println("Register [" + Subscription.Domain + "] as subscriber") } } diff --git a/control/config_test.go b/control/config_test.go index c9cb99c..77414ba 100644 --- a/control/config_test.go +++ b/control/config_test.go @@ -73,7 +73,7 @@ func TestInvalidConfig(t *testing.T) { app := configCmdInit() buffer := new(bytes.Buffer) - app.SetOutput(buffer) + app.SetOut(buffer) app.SetArgs([]string{"enable", "hoge"}) app.Execute() @@ -89,7 +89,7 @@ func TestListConfig(t *testing.T) { app := configCmdInit() buffer := new(bytes.Buffer) - app.SetOutput(buffer) + app.SetOut(buffer) app.SetArgs([]string{"list"}) app.Execute() @@ -118,7 +118,7 @@ func TestExportConfig(t *testing.T) { app := configCmdInit() buffer := new(bytes.Buffer) - app.SetOutput(buffer) + app.SetOut(buffer) app.SetArgs([]string{"export"}) app.Execute() @@ -127,7 +127,7 @@ func TestExportConfig(t *testing.T) { if err != nil { t.Fatalf("Test resource fetch error.") } - jsonData, err := ioutil.ReadAll(file) + jsonData, _ := ioutil.ReadAll(file) output := buffer.String() if strings.Split(output, "\n")[0] != string(jsonData) { t.Fatalf("Invalid Response.") @@ -144,7 +144,7 @@ func TestImportConfig(t *testing.T) { relayState.Load() buffer := new(bytes.Buffer) - app.SetOutput(buffer) + app.SetOut(buffer) app.SetArgs([]string{"export"}) app.Execute() @@ -153,7 +153,7 @@ func TestImportConfig(t *testing.T) { if err != nil { t.Fatalf("Test resource fetch error.") } - jsonData, err := ioutil.ReadAll(file) + jsonData, _ := ioutil.ReadAll(file) output := buffer.String() if strings.Split(output, "\n")[0] != string(jsonData) { t.Fatalf("Invalid Response.") diff --git a/control/domain.go b/control/domain.go index f8220e6..136e384 100644 --- a/control/domain.go +++ b/control/domain.go @@ -64,7 +64,7 @@ func createUnfollowRequestResponse(subscription models.Subscription) error { resp := activity.GenerateResponse(globalConfig.ServerHostname(), "Reject") jsonData, _ := json.Marshal(&resp) - pushRegistorJob(subscription.InboxURL, jsonData) + pushRegisterJob(subscription.InboxURL, jsonData) return nil } diff --git a/control/domain_test.go b/control/domain_test.go index 0a9e751..6c7cf74 100644 --- a/control/domain_test.go +++ b/control/domain_test.go @@ -17,7 +17,7 @@ func TestListDomainSubscriber(t *testing.T) { buffer := new(bytes.Buffer) app = domainCmdInit() - app.SetOutput(buffer) + app.SetOut(buffer) app.SetArgs([]string{"list"}) app.Execute() @@ -43,7 +43,7 @@ func TestListDomainLimited(t *testing.T) { buffer := new(bytes.Buffer) app = domainCmdInit() - app.SetOutput(buffer) + app.SetOut(buffer) app.SetArgs([]string{"list", "-t", "limited"}) app.Execute() @@ -69,7 +69,7 @@ func TestListDomainBlocked(t *testing.T) { buffer := new(bytes.Buffer) app = domainCmdInit() - app.SetOutput(buffer) + app.SetOut(buffer) app.SetArgs([]string{"list", "-t", "blocked"}) app.Execute() @@ -187,7 +187,7 @@ func TestSetDomainInvalid(t *testing.T) { buffer := new(bytes.Buffer) app = domainCmdInit() - app.SetOutput(buffer) + app.SetOut(buffer) app.SetArgs([]string{"set", "-t", "hoge", "hoge.example.jp"}) app.Execute() @@ -234,7 +234,7 @@ func TestInvalidUnfollowDomain(t *testing.T) { buffer := new(bytes.Buffer) app = domainCmdInit() - app.SetOutput(buffer) + app.SetOut(buffer) app.SetArgs([]string{"unfollow", "unknown.tld"}) app.Execute() diff --git a/control/follow.go b/control/follow.go index 46b5eaf..88f955a 100644 --- a/control/follow.go +++ b/control/follow.go @@ -64,9 +64,9 @@ func followCmdInit() *cobra.Command { return follow } -func pushRegistorJob(inboxURL string, body []byte) { +func pushRegisterJob(inboxURL string, body []byte) { job := &tasks.Signature{ - Name: "registor", + Name: "register", RetryCount: 25, Args: []tasks.Arg{ { @@ -105,7 +105,7 @@ func createFollowRequestResponse(domain string, response string) error { if err != nil { return err } - pushRegistorJob(data["inbox_url"], jsonData) + pushRegisterJob(data["inbox_url"], jsonData) relayState.RedisClient.Del("relay:pending:" + domain) if response == "Accept" { relayState.AddSubscription(models.Subscription{ @@ -133,7 +133,7 @@ func createUpdateActorActivity(subscription models.Subscription) error { if err != nil { return err } - pushRegistorJob(subscription.InboxURL, jsonData) + pushRegisterJob(subscription.InboxURL, jsonData) return nil } diff --git a/control/follow_test.go b/control/follow_test.go index d9940a1..47c3240 100644 --- a/control/follow_test.go +++ b/control/follow_test.go @@ -12,7 +12,7 @@ func TestListFollows(t *testing.T) { app := followCmdInit() buffer := new(bytes.Buffer) - app.SetOutput(buffer) + app.SetOut(buffer) relayState.RedisClient.HMSet("relay:pending:example.com", map[string]interface{}{ "inbox_url": "https://example.com/inbox", @@ -95,7 +95,7 @@ func TestInvalidFollow(t *testing.T) { app := followCmdInit() buffer := new(bytes.Buffer) - app.SetOutput(buffer) + app.SetOut(buffer) app.SetArgs([]string{"accept", "unknown.tld"}) app.Execute() @@ -112,7 +112,7 @@ func TestInvalidRejectFollow(t *testing.T) { app := followCmdInit() buffer := new(bytes.Buffer) - app.SetOutput(buffer) + app.SetOut(buffer) app.SetArgs([]string{"reject", "unknown.tld"}) app.Execute() diff --git a/deliver/deriver.go b/deliver/deriver.go index 93766b9..a389e23 100644 --- a/deliver/deriver.go +++ b/deliver/deriver.go @@ -32,13 +32,13 @@ func relayActivity(args ...string) error { err := sendActivity(inboxURL, Actor.ID, []byte(body), globalConfig.ActorKey()) if err != nil { domain, _ := url.Parse(inboxURL) - eval_script := "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(eval_script, []string{"relay:statistics:" + domain.Host}, err.Error(), 60).Result() + 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 registorActivity(args ...string) error { +func registerActivity(args ...string) error { inboxURL := args[0] body := args[1] err := sendActivity(inboxURL, Actor.ID, []byte(body), globalConfig.ActorKey()) @@ -55,7 +55,7 @@ func Entrypoint(g *models.RelayConfig, v string) error { return err } - err = machineryServer.RegisterTask("registor", registorActivity) + err = machineryServer.RegisterTask("register", registerActivity) if err != nil { return err } diff --git a/deliver/deriver_test.go b/deliver/deriver_test.go index 56af7bb..eb4708c 100644 --- a/deliver/deriver_test.go +++ b/deliver/deriver_test.go @@ -56,7 +56,7 @@ func TestRelayActivity(t *testing.T) { err := relayActivity(s.URL, "data") if err != nil { - t.Fatal("Failed - Data transfar not collect") + t.Fatal("Failed - Data transfer not collect") } } @@ -95,7 +95,7 @@ func TestRelayActivityResp500(t *testing.T) { } } -func TestRegistorActivity(t *testing.T) { +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" { @@ -108,32 +108,32 @@ func TestRegistorActivity(t *testing.T) { })) defer s.Close() - err := registorActivity(s.URL, "data") + err := registerActivity(s.URL, "data") if err != nil { - t.Fatal("Failed - Data transfar not collect") + t.Fatal("Failed - Data transfer not collect") } } -func TestRegistorActivityNoHost(t *testing.T) { +func TestRegisterActivityNoHost(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { })) defer s.Close() - err := registorActivity("http://nohost.example.jp", "data") + err := registerActivity("http://nohost.example.jp", "data") if err == nil { t.Fatal("Failed - Error not reported.") } } -func TestRegistorActivityResp500(t *testing.T) { +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 := registorActivity(s.URL, "data") + err := registerActivity(s.URL, "data") if err == nil { t.Fatal("Failed - Error not reported.") } diff --git a/deliver/logger.go b/deliver/logger.go index 16dbfe3..32e69ac 100644 --- a/deliver/logger.go +++ b/deliver/logger.go @@ -4,7 +4,7 @@ package deliver type NullLogger struct { } -// NewNullLogger : Create Nulllogger +// NewNullLogger : Create NullLogger func NewNullLogger() *NullLogger { var newNullLogger NullLogger return &newNullLogger diff --git a/deliver/sender.go b/deliver/sender.go index 5391bd1..a38d352 100644 --- a/deliver/sender.go +++ b/deliver/sender.go @@ -35,7 +35,7 @@ func appendSignature(request *http.Request, body *[]byte, KeyID string, publicKe func sendActivity(inboxURL string, KeyID string, body []byte, publicKey *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("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, publicKey) resp, err := httpClient.Do(req) diff --git a/models/config.go b/models/config.go index f593437..8a7d4a7 100644 --- a/models/config.go +++ b/models/config.go @@ -94,8 +94,8 @@ func (relayConfig *RelayConfig) ServerHostname() *url.URL { return relayConfig.domain } -// ServerHostname is API Server's servername definition. -func (relayConfig *RelayConfig) ServerServicename() string { +// ServerServiceName is API Server's servername definition. +func (relayConfig *RelayConfig) ServerServiceName() string { return relayConfig.serviceName } @@ -109,7 +109,7 @@ func (relayConfig *RelayConfig) ActorKey() *rsa.PrivateKey { return relayConfig.actorKey } -// CreateRedisClient is create new redis client from RelayConfig. +// RedisClient is return redis client from RelayConfig. func (relayConfig *RelayConfig) RedisClient() *redis.Client { return relayConfig.redisClient } diff --git a/models/config_test.go b/models/config_test.go index 1db3c47..dbfa288 100644 --- a/models/config_test.go +++ b/models/config_test.go @@ -81,15 +81,15 @@ func TestRelayConfig_ServerHostname(t *testing.T) { } func TestRelayConfig_DumpWelcomeMessage(t *testing.T) { - relayconfig := createRelayConfig(t) - w := relayconfig.DumpWelcomeMessage("Testing", "") + 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, + "RELAY NANE": relayConfig.serviceName, + "RELAY DOMAIN": relayConfig.domain.Host, + "REDIS URL": relayConfig.redisURL, + "BIND ADDRESS": relayConfig.serverBind, } for key, information := range informations { diff --git a/models/models.go b/models/models.go index c141398..3af2bd6 100644 --- a/models/models.go +++ b/models/models.go @@ -45,8 +45,8 @@ type Actor struct { Image *Image `json:"image,omitempty"` } -// GenerateSelfKey : Generate relay Actor from Publickey. -func (actor *Actor) GenerateSelfKey(hostname *url.URL, publickey *rsa.PublicKey) { +// 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" @@ -55,7 +55,7 @@ func (actor *Actor) GenerateSelfKey(hostname *url.URL, publickey *rsa.PublicKey) actor.PublicKey = PublicKey{ hostname.String() + "/actor#main-key", hostname.String() + "/actor", - generatePublicKeyPEMString(publickey), + generatePublicKeyPEMString(publicKey), } } @@ -195,9 +195,9 @@ func (activity *Activity) NestedActivity() (*Activity, error) { }, nil } } - return nil, errors.New("Can't assart type") + return nil, errors.New("can't assert type") } - return nil, errors.New("Can't assart id") + return nil, errors.New("can't assert id") } // ActivityObject : ActivityPub Activity. @@ -235,7 +235,7 @@ type WebfingerResource struct { func (resource *WebfingerResource) GenerateFromActor(hostname *url.URL, actor *Actor) { resource.Subject = "acct:" + actor.PreferredUsername + "@" + hostname.Host resource.Links = []WebfingerLink{ - WebfingerLink{ + { "self", "application/activity+json", actor.ID, @@ -303,7 +303,7 @@ type NodeinfoMetadata struct { // GenerateFromActor : Generate Webfinger resource from Actor. func (resource *NodeinfoResources) GenerateFromActor(hostname *url.URL, actor *Actor, serverVersion string) { resource.NodeinfoLinks.Links = []NodeinfoLink{ - NodeinfoLink{ + { "http://nodeinfo.diaspora.software/ns/schema/2.1", "https://" + hostname.Host + "/nodeinfo/2.1", }, diff --git a/models/state.go b/models/state.go index 95b834f..ae41d62 100644 --- a/models/state.go +++ b/models/state.go @@ -92,7 +92,7 @@ func (config *RelayState) Load() { config.Subscriptions = subscriptions } -// SetConfig : Set relay configration +// SetConfig : Set relay configuration func (config *RelayState) SetConfig(key Config, value bool) { strValue := 0 if value { diff --git a/models/state_test.go b/models/state_test.go index d86634d..080bf15 100644 --- a/models/state_test.go +++ b/models/state_test.go @@ -167,7 +167,7 @@ func TestLimitedDomain(t *testing.T) { } } -func TestLoadCompatiSubscription(t *testing.T) { +func TestLoadCompatibleSubscription(t *testing.T) { relayState.RedisClient.FlushAll().Result() relayState.AddSubscription(Subscription{ diff --git a/models/utils.go b/models/utils.go index b2dd069..18d4cf0 100644 --- a/models/utils.go +++ b/models/utils.go @@ -12,7 +12,7 @@ import ( "github.com/go-redis/redis" ) -func ReadPublicKeyRSAfromString(pemString string) (*rsa.PublicKey, error) { +func ReadPublicKeyRSAFromString(pemString string) (*rsa.PublicKey, error) { pemByte := []byte(pemString) decoded, _ := pem.Decode(pemByte) defer func() { diff --git a/readme.md b/readme.md index 130fad8..7d7335b 100644 --- a/readme.md +++ b/readme.md @@ -60,7 +60,7 @@ JOB_CONCURRENCY: 50 ### Environment Variable - This is **Optional** : When `config.yml` not exists, use environment variable. + This is **Optional** : When `config.yaml` not exists, use environment variable. - ACTOR_PEM - REDIS_URL @@ -81,7 +81,7 @@ Thank you for your support. ### Monthly Donation -**[My Doner List](https://relay.toot.yukimochi.jp#patreon-list)** +**[My Donner List](https://relay.toot.yukimochi.jp#patreon-list)** #### Donation Platform - [Patreon](https://www.patreon.com/yukimochi)