summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-10-29 08:31:26 +0300
committerPaul Buetow <paul@buetow.org>2021-10-29 08:31:26 +0300
commitffa39a17f48ee9847cc85819d8134b5eb9482b77 (patch)
tree22ac90a46160ccc2927ba0a5b4406906072a56bb
parentf9c51eb8bc3295c52dfde821aaed324f9447a993 (diff)
explicitly use dlog.Server for server packages and dlog.Clent for client packages for logging
-rw-r--r--go.mod1
-rw-r--r--go.sum10
-rw-r--r--internal/mapr/client/aggregate.go2
-rw-r--r--internal/mapr/server/aggregate.go24
-rw-r--r--internal/ssh/client/clientkeypair.go14
-rw-r--r--internal/ssh/client/knownhostscallback.go12
-rw-r--r--internal/ssh/server/hostkey.go10
-rw-r--r--internal/ssh/server/publickeycallback.go10
8 files changed, 47 insertions, 36 deletions
diff --git a/go.mod b/go.mod
index b80ab08..1ef0269 100644
--- a/go.mod
+++ b/go.mod
@@ -5,6 +5,7 @@ go 1.15
require (
github.com/DataDog/zstd v1.4.5
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c
+ golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d // indirect
golang.org/x/term v0.0.0-20201207232118-ee85cb95a76b // indirect
)
diff --git a/go.sum b/go.sum
index 3f07cd7..1ae4c83 100644
--- a/go.sum
+++ b/go.sum
@@ -1,10 +1,17 @@
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c h1:9HhBz5L/UjnK9XLtiZhYAdue5BVKep3PMmS2LuPDt8k=
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
+golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
+golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d h1:MiWWjyhUzZ+jvhZvloX6ZrUsdEghn8a64Upd8EMHglE=
@@ -13,3 +20,6 @@ golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXR
golang.org/x/term v0.0.0-20201207232118-ee85cb95a76b h1:a0ErnNnPKmhDyIXQvdZr+Lq8dc8xpMeqkF8y5PgQU4Q=
golang.org/x/term v0.0.0-20201207232118-ee85cb95a76b/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7 h1:EBZoQjiKKPaLbPrbpssUfuHtwM6KV/vb4U85g/cigFY=
+golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/internal/mapr/client/aggregate.go b/internal/mapr/client/aggregate.go
index 02a6a5a..1704d43 100644
--- a/internal/mapr/client/aggregate.go
+++ b/internal/mapr/client/aggregate.go
@@ -54,7 +54,7 @@ func (a *Aggregate) Aggregate(message string) error {
for _, sc := range a.query.Select {
if val, ok := fields[sc.FieldStorage]; ok {
if err := set.Aggregate(sc.FieldStorage, sc.Operation, val, true); err != nil {
- dlog.Common.Error(err)
+ dlog.Client.Error(err)
continue
}
addedSamples = true
diff --git a/internal/mapr/server/aggregate.go b/internal/mapr/server/aggregate.go
index 4162828..cb0da2b 100644
--- a/internal/mapr/server/aggregate.go
+++ b/internal/mapr/server/aggregate.go
@@ -39,7 +39,7 @@ func NewAggregate(queryStr string) (*Aggregate, error) {
fqdn, err := config.Hostname()
if err != nil {
- dlog.Common.Error(err)
+ dlog.Server.Error(err)
}
s := strings.Split(fqdn, ".")
@@ -54,12 +54,12 @@ func NewAggregate(queryStr string) (*Aggregate, error) {
parserName = query.LogFormat
}
- dlog.Common.Info("Creating log format parser", parserName)
+ dlog.Server.Info("Creating log format parser", parserName)
logParser, err := logformat.NewParser(parserName, query)
if err != nil {
- dlog.Common.Error("Could not create log format parser. Falling back to 'generic'", err)
+ dlog.Server.Error("Could not create log format parser. Falling back to 'generic'", err)
if logParser, err = logformat.NewParser("generic", query); err != nil {
- dlog.Common.FatalPanic("Could not create log format parser", err)
+ dlog.Server.FatalPanic("Could not create log format parser", err)
}
}
@@ -115,7 +115,7 @@ func (a *Aggregate) aggregateTimer(ctx context.Context) {
func (a *Aggregate) nextLine() (line line.Line, ok bool, noMoreChannels bool) {
- dlog.Common.Trace("nextLine", "entry", line, ok, noMoreChannels)
+ dlog.Server.Trace("nextLine", "entry", line, ok, noMoreChannels)
select {
case line, ok = <-a.linesCh:
if !ok {
@@ -137,7 +137,7 @@ func (a *Aggregate) nextLine() (line line.Line, ok bool, noMoreChannels bool) {
// No new lines channel found.
}
}
- dlog.Common.Trace("nextLine", "exit", line, ok, noMoreChannels)
+ dlog.Server.Trace("nextLine", "exit", line, ok, noMoreChannels)
return
}
@@ -180,7 +180,7 @@ func (a *Aggregate) fieldsFromLines(ctx context.Context) <-chan map[string]strin
if err != nil {
// Should fields be ignored anyway?
if err != logformat.ErrIgnoreFields {
- dlog.Common.Error(fields, err)
+ dlog.Server.Error(fields, err)
}
continue
}
@@ -210,7 +210,7 @@ func (a *Aggregate) setAdditionalFields(ctx context.Context,
return
}
if err := a.query.SetClause(fields); err != nil {
- dlog.Common.Error(err)
+ dlog.Server.Error(err)
}
select {
@@ -227,7 +227,7 @@ func (a *Aggregate) aggregateAndSerialize(ctx context.Context,
group := mapr.NewGroupSet()
serialize := func() {
- dlog.Common.Info("Serializing mapreduce result")
+ dlog.Server.Info("Serializing mapreduce result")
group.Serialize(ctx, maprMessages)
group = mapr.NewGroupSet()
}
@@ -264,7 +264,7 @@ func (a *Aggregate) aggregate(group *mapr.GroupSet, fields map[string]string) {
for _, sc := range a.query.Select {
if val, ok := fields[sc.Field]; ok {
if err := set.Aggregate(sc.FieldStorage, sc.Operation, val, false); err != nil {
- dlog.Common.Error(err)
+ dlog.Server.Error(err)
continue
}
addedSample = true
@@ -275,7 +275,7 @@ func (a *Aggregate) aggregate(group *mapr.GroupSet, fields map[string]string) {
set.Samples++
return
}
- dlog.Common.Trace("Aggregated data locally without adding new samples")
+ dlog.Server.Trace("Aggregated data locally without adding new samples")
}
// Serialize all the aggregated data.
@@ -283,7 +283,7 @@ func (a *Aggregate) Serialize(ctx context.Context) {
select {
case a.serialize <- struct{}{}:
case <-time.After(time.Minute):
- dlog.Common.Warn("Starting to serialize mapredice data takes over a minute")
+ dlog.Server.Warn("Starting to serialize mapredice data takes over a minute")
case <-ctx.Done():
}
}
diff --git a/internal/ssh/client/clientkeypair.go b/internal/ssh/client/clientkeypair.go
index 0e21d0c..b35b25d 100644
--- a/internal/ssh/client/clientkeypair.go
+++ b/internal/ssh/client/clientkeypair.go
@@ -16,7 +16,7 @@ import (
// GeneratePrivatePublicKeyPairIfNotExists generates a SSH key pair (used by the integration tests)
func GeneratePrivatePublicKeyPairIfNotExists(keyPath string, bitSize int) {
if _, err := os.Stat(keyPath); err == nil {
- dlog.Common.Debug("Private/public key pair already exists", keyPath)
+ dlog.Client.Debug("Private/public key pair already exists", keyPath)
return
}
GeneratePrivatePublicKeyPair(keyPath, bitSize)
@@ -27,27 +27,27 @@ func GeneratePrivatePublicKeyPair(keyPath string, bitSize int) {
privateKeyPath := keyPath
publicKeyPath := fmt.Sprintf("%s.pub", keyPath)
- dlog.Common.Debug("Generating private/public key pair", privateKeyPath, publicKeyPath)
+ dlog.Client.Debug("Generating private/public key pair", privateKeyPath, publicKeyPath)
privateKey, err := generatePrivateKey(bitSize)
if err != nil {
- dlog.Common.FatalPanic(err)
+ dlog.Client.FatalPanic(err)
}
publicKeyBytes, err := generatePublicKey(&privateKey.PublicKey)
if err != nil {
- dlog.Common.FatalPanic(err)
+ dlog.Client.FatalPanic(err)
}
privateKeyBytes := encodePrivateKeyToPEM(privateKey)
err = writeKey(privateKeyBytes, privateKeyPath)
if err != nil {
- dlog.Common.FatalPanic(err)
+ dlog.Client.FatalPanic(err)
}
err = writeKey([]byte(publicKeyBytes), publicKeyPath)
if err != nil {
- dlog.Common.FatalPanic(err)
+ dlog.Client.FatalPanic(err)
}
- dlog.Common.Debug("Done generating private/public key pair", privateKeyPath, publicKeyPath)
+ dlog.Client.Debug("Done generating private/public key pair", privateKeyPath, publicKeyPath)
}
func generatePrivateKey(bitSize int) (*rsa.PrivateKey, error) {
diff --git a/internal/ssh/client/knownhostscallback.go b/internal/ssh/client/knownhostscallback.go
index dd58925..393c4c7 100644
--- a/internal/ssh/client/knownhostscallback.go
+++ b/internal/ssh/client/knownhostscallback.go
@@ -93,7 +93,7 @@ func (c KnownHostsCallback) Wrap() ssh.HostKeyCallback {
ipLine: knownhosts.Line([]string{remote.String()}, key),
responseCh: make(chan response),
}
- dlog.Common.Warn("Encountered unknown host", unknown)
+ dlog.Client.Warn("Encountered unknown host", unknown)
// Notify user that there is an unknown host
c.unknownCh <- unknown
// Wait for user input.
@@ -132,7 +132,7 @@ func (c KnownHostsCallback) PromptAddHosts(ctx context.Context) {
hosts = []unknownHost{}
}
case <-ctx.Done():
- dlog.Common.Debug("Stopping goroutine prompting new hosts...")
+ dlog.Client.Debug("Stopping goroutine prompting new hosts...")
return
}
}
@@ -146,7 +146,7 @@ func (c KnownHostsCallback) promptAddHosts(hosts []unknownHost) {
select {
case <-c.trustAllHostsCh:
- dlog.Common.Warn("Trusting host keys of servers", servers)
+ dlog.Client.Warn("Trusting host keys of servers", servers)
c.trustHosts(hosts)
return
default:
@@ -166,7 +166,7 @@ func (c KnownHostsCallback) promptAddHosts(hosts []unknownHost) {
c.trustHosts(hosts)
},
EndCallback: func() {
- dlog.Common.Info("Added hosts to known hosts file", c.knownHostsPath)
+ dlog.Client.Info("Added hosts to known hosts file", c.knownHostsPath)
},
}
p.Add(a)
@@ -179,7 +179,7 @@ func (c KnownHostsCallback) promptAddHosts(hosts []unknownHost) {
c.trustHosts(hosts)
},
EndCallback: func() {
- dlog.Common.Info("Added hosts to known hosts file", c.knownHostsPath)
+ dlog.Client.Info("Added hosts to known hosts file", c.knownHostsPath)
},
}
p.Add(a)
@@ -191,7 +191,7 @@ func (c KnownHostsCallback) promptAddHosts(hosts []unknownHost) {
c.dontTrustHosts(hosts)
},
EndCallback: func() {
- dlog.Common.Info("Didn't add hosts to known hosts file", c.knownHostsPath)
+ dlog.Client.Info("Didn't add hosts to known hosts file", c.knownHostsPath)
},
}
p.Add(a)
diff --git a/internal/ssh/server/hostkey.go b/internal/ssh/server/hostkey.go
index 4844d36..be23d85 100644
--- a/internal/ssh/server/hostkey.go
+++ b/internal/ssh/server/hostkey.go
@@ -18,25 +18,25 @@ func PrivateHostKey() []byte {
_, err := os.Stat(hostKeyFile)
if os.IsNotExist(err) {
- dlog.Common.Info("Generating private server RSA host key")
+ dlog.Server.Info("Generating private server RSA host key")
privateKey, err := ssh.GeneratePrivateRSAKey(config.Server.HostKeyBits)
if err != nil {
- dlog.Common.FatalPanic("Failed to generate private server RSA host key", err)
+ dlog.Server.FatalPanic("Failed to generate private server RSA host key", err)
}
pem := ssh.EncodePrivateKeyToPEM(privateKey)
if err := ioutil.WriteFile(hostKeyFile, pem, 0600); err != nil {
- dlog.Common.Error("Unable to write private server RSA host key to file",
+ dlog.Server.Error("Unable to write private server RSA host key to file",
hostKeyFile, err)
}
return pem
}
- dlog.Common.Info("Reading private server RSA host key from file", hostKeyFile)
+ dlog.Server.Info("Reading private server RSA host key from file", hostKeyFile)
pem, err := ioutil.ReadFile(hostKeyFile)
if err != nil {
- dlog.Common.FatalPanic("Failed to load private server RSA host key", err)
+ dlog.Server.FatalPanic("Failed to load private server RSA host key", err)
}
return pem
}
diff --git a/internal/ssh/server/publickeycallback.go b/internal/ssh/server/publickeycallback.go
index 585469f..c661419 100644
--- a/internal/ssh/server/publickeycallback.go
+++ b/internal/ssh/server/publickeycallback.go
@@ -23,9 +23,9 @@ func PublicKeyCallback(c gossh.ConnMetadata,
return nil, err
}
- dlog.Common.Info(user, "Incoming authorization")
+ dlog.Server.Info(user, "Incoming authorization")
if config.ServerRelaxedAuthEnable {
- dlog.Common.Fatal(user, "Granting permissions via relaxed-auth")
+ dlog.Server.Fatal(user, "Granting permissions via relaxed-auth")
return nil, nil
}
@@ -34,7 +34,7 @@ func PublicKeyCallback(c gossh.ConnMetadata,
return nil, err
}
- dlog.Common.Info(user, "Reading", authorizedKeysFile)
+ dlog.Server.Info(user, "Reading", authorizedKeysFile)
authorizedKeysBytes, err := ioutil.ReadFile(authorizedKeysFile)
if err != nil {
return nil, fmt.Errorf("Unable to read authorized keys file|%s|%s|%s",
@@ -56,11 +56,11 @@ func verifyAuthorizedKeys(user *user.User, authorizedKeysBytes []byte,
}
authorizedKeysMap[string(authorizedPubKey.Marshal())] = true
authorizedKeysBytes = restBytes
- dlog.Common.Debug(user, "Authorized public key fingerprint",
+ dlog.Server.Debug(user, "Authorized public key fingerprint",
gossh.FingerprintSHA256(authorizedPubKey))
}
- dlog.Common.Debug(user, "Offered public key fingerprint", gossh.FingerprintSHA256(offeredPubKey))
+ dlog.Server.Debug(user, "Offered public key fingerprint", gossh.FingerprintSHA256(offeredPubKey))
if authorizedKeysMap[string(offeredPubKey.Marshal())] {
return &gossh.Permissions{
Extensions: map[string]string{"pubkey-fp": gossh.FingerprintSHA256(offeredPubKey)},