From 8e6f6679bd0387d499ce6b821f5c47a9215109fe Mon Sep 17 00:00:00 2001 From: Naoki Kosaka Date: Sun, 9 Dec 2018 19:12:49 +0900 Subject: [PATCH] Fix some stderr. --- KeyLoader/keyloader.go | 3 ++- cli/cli.go | 2 +- cli/config.go | 6 +++--- cli/follow.go | 3 ++- handle.go | 6 +++--- main.go | 2 +- worker/worker.go | 2 +- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/KeyLoader/keyloader.go b/KeyLoader/keyloader.go index 3ba58f2..4bd9c05 100644 --- a/KeyLoader/keyloader.go +++ b/KeyLoader/keyloader.go @@ -6,6 +6,7 @@ import ( "encoding/pem" "fmt" "io/ioutil" + "os" ) func ReadPrivateKeyRSAfromPath(path string) (*rsa.PrivateKey, error) { @@ -26,7 +27,7 @@ func ReadPublicKeyRSAfromString(pemString string) (*rsa.PublicKey, error) { decoded, _ := pem.Decode(pemByte) keyInterface, err := x509.ParsePKIXPublicKey(decoded.Bytes) if err != nil { - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) return nil, err } pub := keyInterface.(*rsa.PublicKey) diff --git a/cli/cli.go b/cli/cli.go index 6552c77..dc7db57 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -57,7 +57,7 @@ func main() { macServer, err = machinery.NewServer(macConfig) if err != nil { - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) } app := cli.NewApp() diff --git a/cli/config.go b/cli/config.go index 3419b48..8aa4327 100644 --- a/cli/config.go +++ b/cli/config.go @@ -60,18 +60,18 @@ func exportConfigs(c *cli.Context) { func importConfigs(c *cli.Context) { file, err := os.Open(c.String("json")) if err != nil { - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) return } jsonData, err := ioutil.ReadAll(file) if err != nil { - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) return } var data relayconf.ExportConfig err = json.Unmarshal(jsonData, &data) if err != nil { - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) return } diff --git a/cli/follow.go b/cli/follow.go index 80e48e7..64800de 100644 --- a/cli/follow.go +++ b/cli/follow.go @@ -3,6 +3,7 @@ package main import ( "encoding/json" "fmt" + "os" "strings" "github.com/RichardKnop/machinery/v1/tasks" @@ -29,7 +30,7 @@ func pushRegistorJob(inboxURL string, body []byte) { } _, err := macServer.SendTask(job) if err != nil { - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) } } diff --git a/handle.go b/handle.go index d2b39da..83ebc45 100644 --- a/handle.go +++ b/handle.go @@ -6,6 +6,7 @@ import ( "fmt" "net/http" "net/url" + "os" "github.com/RichardKnop/machinery/v1/tasks" "github.com/yukimochi/Activity-Relay/ActivityPub" @@ -92,7 +93,7 @@ func pushRelayJob(sourceInbox string, body []byte) { } _, err := macServer.SendTask(job) if err != nil { - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) } } } @@ -117,7 +118,7 @@ func pushRegistorJob(inboxURL string, body []byte) { } _, err := macServer.SendTask(job) if err != nil { - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) } } @@ -139,7 +140,6 @@ func unFollowAcceptable(activity *activitypub.Activity, actor *activitypub.Actor func suitableFollow(activity *activitypub.Activity, actor *activitypub.Actor) bool { domain, _ := url.Parse(activity.Actor) - fmt.Println(exportConfig.BlockedDomains, domain.Host) if contains(exportConfig.BlockedDomains, domain.Host) { return false } diff --git a/main.go b/main.go index 841a379..8233688 100644 --- a/main.go +++ b/main.go @@ -67,7 +67,7 @@ func main() { macServer, err = machinery.NewServer(macConfig) if err != nil { - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) } Actor.GenerateSelfKey(hostname, &hostkey.PublicKey) diff --git a/worker/worker.go b/worker/worker.go index 933e9e3..04a6c47 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -102,6 +102,6 @@ func main() { err = worker.Launch() if err != nil { - fmt.Println(err.Error()) + fmt.Fprintln(os.Stderr, err) } }