From 0e841e0f513d5eb783e2aecb91d6c13ce28c802d Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 6 Nov 2014 13:31:58 -0300 Subject: [PATCH] Rename pkg/misc to pkg/hashutil It only had one function anyway. Change-Id: Iec4b7868d823148c8e1d2607347fe9d3c1463403 --- pkg/client/client.go | 4 ++-- pkg/{misc/misc.go => hashutil/hashutil.go} | 6 ++---- server/camlistored/camlistored.go | 6 +++--- 3 files changed, 7 insertions(+), 9 deletions(-) rename pkg/{misc/misc.go => hashutil/hashutil.go} (87%) diff --git a/pkg/client/client.go b/pkg/client/client.go index 77c375fbc..b4ede84e1 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -39,8 +39,8 @@ import ( "camlistore.org/pkg/blob" "camlistore.org/pkg/blobserver" "camlistore.org/pkg/client/android" + "camlistore.org/pkg/hashutil" "camlistore.org/pkg/httputil" - "camlistore.org/pkg/misc" "camlistore.org/pkg/osutil" "camlistore.org/pkg/schema" "camlistore.org/pkg/search" @@ -930,7 +930,7 @@ func (c *Client) DialFunc() func(network, addr string) (net.Conn, error) { if certs == nil || len(certs) < 1 { return nil, errors.New("Could not get server's certificate from the TLS connection.") } - sig := misc.SHA256Prefix(certs[0].Raw) + sig := hashutil.SHA256Prefix(certs[0].Raw) for _, v := range trustedCerts { if v == sig { return conn, nil diff --git a/pkg/misc/misc.go b/pkg/hashutil/hashutil.go similarity index 87% rename from pkg/misc/misc.go rename to pkg/hashutil/hashutil.go index 785bf9827..0f5240740 100644 --- a/pkg/misc/misc.go +++ b/pkg/hashutil/hashutil.go @@ -14,10 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package misc contains stuff which should probably move elsewhere. -// -// This is a gross place to put code. -package misc +// Package hashutil contains misc hashing functions lacking homes elsewhere. +package hashutil import ( "crypto/sha256" diff --git a/server/camlistored/camlistored.go b/server/camlistored/camlistored.go index 63d7b762f..a1a0f07ca 100644 --- a/server/camlistored/camlistored.go +++ b/server/camlistored/camlistored.go @@ -41,9 +41,9 @@ import ( "time" "camlistore.org/pkg/buildinfo" + "camlistore.org/pkg/hashutil" "camlistore.org/pkg/httputil" "camlistore.org/pkg/legal/legalprint" - "camlistore.org/pkg/misc" "camlistore.org/pkg/netutil" "camlistore.org/pkg/osutil" "camlistore.org/pkg/serverinit" @@ -184,7 +184,7 @@ func genSelfTLS(listen string) error { if err != nil { return fmt.Errorf("Failed to parse certificate: %v", err) } - sig := misc.SHA256Prefix(cert.Raw) + sig := hashutil.SHA256Prefix(cert.Raw) hint := "You must add this certificate's fingerprint to your client's trusted certs list to use it. Like so:\n" + `"trustedCerts": ["` + sig + `"],` log.Printf(hint) @@ -303,7 +303,7 @@ func setupTLS(ws *webserver.Server, config *serverinit.Config, listen string) { if err != nil { exitf("Failed to parse certificate: %v", err) } - sig := misc.SHA256Prefix(certif.Raw) + sig := hashutil.SHA256Prefix(certif.Raw) log.Printf("TLS enabled, with SHA-256 certificate fingerprint: %v", sig) ws.SetTLS(cert, key) }