Skip to content

Commit

Permalink
dep: remove jmhodges/clock dependency. (#231)
Browse files Browse the repository at this point in the history
It was inherited from Boulder but was never used anywhere in Pebble.
  • Loading branch information
cpu authored Apr 12, 2019
1 parent 194da59 commit 8bc2d56
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 390 deletions.
8 changes: 3 additions & 5 deletions cmd/pebble/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/http"
"os"

"github.com/jmhodges/clock"
"github.com/letsencrypt/pebble/ca"
"github.com/letsencrypt/pebble/cmd"
"github.com/letsencrypt/pebble/db"
Expand Down Expand Up @@ -57,12 +56,11 @@ func main() {
setupCustomDNSResolver(*resolverAddress)
}

clk := clock.New()
db := db.NewMemoryStore(clk)
db := db.NewMemoryStore()
ca := ca.New(logger, db)
va := va.New(logger, clk, c.Pebble.HTTPPort, c.Pebble.TLSPort, *strictMode)
va := va.New(logger, c.Pebble.HTTPPort, c.Pebble.TLSPort, *strictMode)

wfeImpl := wfe.New(logger, clk, db, va, ca, *strictMode)
wfeImpl := wfe.New(logger, db, va, ca, *strictMode)
muxHandler := wfeImpl.Handler()

logger.Printf("Listening on: %s\n", c.Pebble.ListenAddress)
Expand Down
5 changes: 2 additions & 3 deletions core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"sync"
"time"

"github.com/jmhodges/clock"
"github.com/letsencrypt/pebble/acme"
"gopkg.in/square/go-jose.v2"
)
Expand All @@ -28,7 +27,7 @@ type Order struct {
CertificateObject *Certificate
}

func (o *Order) GetStatus(clk clock.Clock) (string, error) {
func (o *Order) GetStatus() (string, error) {
// Lock the order for reading
o.RLock()
defer o.RUnlock()
Expand All @@ -49,7 +48,7 @@ func (o *Order) GetStatus(clk clock.Clock) (string, error) {

authzStatuses[authzStatus]++

if authzExpires.Before(clk.Now()) {
if authzExpires.Before(time.Now()) {
authzStatuses[acme.StatusExpired]++
}
}
Expand Down
8 changes: 2 additions & 6 deletions db/memorystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"gopkg.in/square/go-jose.v2"

"github.com/jmhodges/clock"
"github.com/letsencrypt/pebble/core"
)

Expand All @@ -32,8 +31,6 @@ func (e ExistingAccountError) Error() string {
type MemoryStore struct {
sync.RWMutex

clk clock.Clock

accountIDCounter int

accountsByID map[string]*core.Account
Expand All @@ -52,9 +49,8 @@ type MemoryStore struct {
revokedCertificatesByID map[string]*core.Certificate
}

func NewMemoryStore(clk clock.Clock) *MemoryStore {
func NewMemoryStore() *MemoryStore {
return &MemoryStore{
clk: clk,
accountIDCounter: 1,
accountsByID: make(map[string]*core.Account),
accountsByKeyID: make(map[string]*core.Account),
Expand Down Expand Up @@ -180,7 +176,7 @@ func (m *MemoryStore) GetOrderByID(id string) *core.Order {
defer m.RUnlock()

if order, ok := m.ordersByID[id]; ok {
orderStatus, err := order.GetStatus(m.clk)
orderStatus, err := order.GetStatus()
if err != nil {
panic(err)
}
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module github.com/letsencrypt/pebble

require (
github.com/jmhodges/clock v0.0.0-20160418191101-880ee4c33548
github.com/letsencrypt/challtestsrv v1.1.0
golang.org/x/net v0.0.0-20181207154023-610586996380 // indirect
golang.org/x/sys v0.0.0-20181206074257-70b957f3b65e // indirect
Expand Down
18 changes: 7 additions & 11 deletions va/va.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"strings"
"time"

"github.com/jmhodges/clock"
"github.com/letsencrypt/challtestsrv"
"github.com/letsencrypt/pebble/acme"
"github.com/letsencrypt/pebble/core"
Expand Down Expand Up @@ -95,7 +94,6 @@ type vaTask struct {

type VAImpl struct {
log *log.Logger
clk clock.Clock
httpPort int
tlsPort int
tasks chan *vaTask
Expand All @@ -107,12 +105,10 @@ type VAImpl struct {

func New(
log *log.Logger,
clk clock.Clock,
httpPort, tlsPort int,
strict bool) *VAImpl {
va := &VAImpl{
log: log,
clk: clk,
httpPort: httpPort,
tlsPort: tlsPort,
tasks: make(chan *vaTask, taskQueueSize),
Expand Down Expand Up @@ -181,7 +177,7 @@ func (va VAImpl) setAuthzValid(authz *core.Authorization, chal *core.Challenge)
authz.Lock()
defer authz.Unlock()
// Update the authz expiry for the new validity period
now := va.clk.Now().UTC()
now := time.Now().UTC()
authz.ExpiresDate = now.Add(validAuthzExpire)
authz.Expires = authz.ExpiresDate.Format(time.RFC3339)
// Update the authz status
Expand Down Expand Up @@ -229,7 +225,7 @@ func (va VAImpl) process(task *vaTask) {
chal := task.Challenge
chal.Lock()
// Update the validated date for the challenge
now := va.clk.Now().UTC()
now := time.Now().UTC()
chal.ValidatedDate = now
chal.Validated = chal.ValidatedDate.Format(time.RFC3339)
authz := chal.Authz
Expand Down Expand Up @@ -262,7 +258,7 @@ func (va VAImpl) performValidation(task *vaTask, results chan<- *core.Validation
// Sleep for a random amount of time between 0 and va.sleepTime seconds
len := time.Duration(rand.Intn(va.sleepTime))
va.log.Printf("Sleeping for %s seconds before validating", time.Second*len)
va.clk.Sleep(time.Second * len)
time.Sleep(time.Second * len)
}

// If `alwaysValid` is true then return a validation record immediately
Expand All @@ -277,7 +273,7 @@ func (va VAImpl) performValidation(task *vaTask, results chan<- *core.Validation
// the URL to the `_acme-challenge` subdomain.
results <- &core.ValidationRecord{
URL: task.Identifier,
ValidatedAt: va.clk.Now(),
ValidatedAt: time.Now(),
}
return
}
Expand All @@ -300,7 +296,7 @@ func (va VAImpl) validateDNS01(task *vaTask) *core.ValidationRecord {

result := &core.ValidationRecord{
URL: challengeSubdomain,
ValidatedAt: va.clk.Now(),
ValidatedAt: time.Now(),
}

ctx, cancelfunc := context.WithTimeout(context.Background(), validationTimeout)
Expand Down Expand Up @@ -341,7 +337,7 @@ func (va VAImpl) validateTLSALPN01(task *vaTask) *core.ValidationRecord {

result := &core.ValidationRecord{
URL: hostPort,
ValidatedAt: va.clk.Now(),
ValidatedAt: time.Now(),
}

cs, problem := va.fetchConnectionState(hostPort, &tls.Config{
Expand Down Expand Up @@ -438,7 +434,7 @@ func (va VAImpl) validateHTTP01(task *vaTask) *core.ValidationRecord {

result := &core.ValidationRecord{
URL: url,
ValidatedAt: va.clk.Now(),
ValidatedAt: time.Now(),
Error: err,
}
if result.Error != nil {
Expand Down

This file was deleted.

20 changes: 0 additions & 20 deletions vendor/github.com/jmhodges/clock/LICENSE

This file was deleted.

27 changes: 0 additions & 27 deletions vendor/github.com/jmhodges/clock/README.md

This file was deleted.

Loading

0 comments on commit 8bc2d56

Please sign in to comment.