Skip to content

Commit 69763b1

Browse files
committed
Delete dead code
1 parent 011090e commit 69763b1

File tree

6 files changed

+0
-139
lines changed

6 files changed

+0
-139
lines changed

core/challenges.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package core
22

3-
import "fmt"
4-
53
func newChallenge(challengeType AcmeChallenge, token string) Challenge {
64
return Challenge{
75
Type: challengeType,
@@ -29,20 +27,3 @@ func TLSALPNChallenge01(token string) Challenge {
2927
func DNSAccountChallenge01(token string) Challenge {
3028
return newChallenge(ChallengeTypeDNSAccount01, token)
3129
}
32-
33-
// NewChallenge constructs a challenge of the given kind. It returns an
34-
// error if the challenge type is unrecognized.
35-
func NewChallenge(kind AcmeChallenge, token string) (Challenge, error) {
36-
switch kind {
37-
case ChallengeTypeHTTP01:
38-
return HTTPChallenge01(token), nil
39-
case ChallengeTypeDNS01:
40-
return DNSChallenge01(token), nil
41-
case ChallengeTypeTLSALPN01:
42-
return TLSALPNChallenge01(token), nil
43-
case ChallengeTypeDNSAccount01:
44-
return DNSAccountChallenge01(token), nil
45-
default:
46-
return Challenge{}, fmt.Errorf("unrecognized challenge type %q", kind)
47-
}
48-
}

log/mock.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"log/syslog"
66
"regexp"
77
"strings"
8-
"time"
98
)
109

1110
// UseMock sets a mock logger as the default logger, and returns it.
@@ -20,13 +19,6 @@ func NewMock() *Mock {
2019
return &Mock{impl{newMockWriter()}}
2120
}
2221

23-
// NewWaitingMock creates a mock logger implementing the writer interface.
24-
// It stores all logged messages in a buffer for inspection by test
25-
// functions.
26-
func NewWaitingMock() *WaitingMock {
27-
return &WaitingMock{impl{newWaitingMockWriter()}}
28-
}
29-
3022
// Mock is a logger that stores all log messages in memory to be examined by a
3123
// test.
3224
type Mock struct {
@@ -130,39 +122,3 @@ func (m *Mock) Clear() {
130122
w := m.w.(*mockWriter)
131123
w.clearChan <- struct{}{}
132124
}
133-
134-
type waitingMockWriter struct {
135-
logChan chan string
136-
}
137-
138-
// newWaitingMockWriter returns a new waitingMockWriter
139-
func newWaitingMockWriter() *waitingMockWriter {
140-
logChan := make(chan string, 1000)
141-
return &waitingMockWriter{
142-
logChan,
143-
}
144-
}
145-
146-
func (m *waitingMockWriter) logAtLevel(p syslog.Priority, msg string, a ...any) {
147-
m.logChan <- fmt.Sprintf("%s: %s", levelName[p&7], fmt.Sprintf(msg, a...))
148-
}
149-
150-
// WaitForMatch returns the first log line matching a regex. It accepts a
151-
// regexp string and timeout. If the timeout value is met before the
152-
// matching pattern is read from the channel, an error is returned.
153-
func (m *WaitingMock) WaitForMatch(reString string, timeout time.Duration) (string, error) {
154-
w := m.w.(*waitingMockWriter)
155-
deadline := time.After(timeout)
156-
re := regexp.MustCompile(reString)
157-
for {
158-
select {
159-
case logLine := <-w.logChan:
160-
if re.MatchString(logLine) {
161-
close(w.logChan)
162-
return logLine, nil
163-
}
164-
case <-deadline:
165-
return "", fmt.Errorf("timeout waiting for match: %q", reString)
166-
}
167-
}
168-
}

mocks/sa.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ type StorageAuthority struct {
3939
StorageAuthorityReadOnly
4040
}
4141

42-
// NewStorageAuthority creates a new mock storage authority
43-
// with the given clock.
44-
func NewStorageAuthority(clk clock.Clock) *StorageAuthority {
45-
return &StorageAuthority{StorageAuthorityReadOnly{clk}}
46-
}
47-
4842
const (
4943
test1KeyPublicJSON = `{"kty":"RSA","n":"yNWVhtYEKJR21y9xsHV-PD_bYwbXSeNuFal46xYxVfRL5mqha7vttvjB_vc7Xg2RvgCxHPCqoxgMPTzHrZT75LjCwIW2K_klBYN8oYvTwwmeSkAz6ut7ZxPv-nZaT5TJhGk0NT2kh_zSpdriEJ_3vW-mqxYbbBmpvHqsa1_zx9fSuHYctAZJWzxzUZXykbWMWQZpEiE0J4ajj51fInEzVn7VxV-mzfMyboQjujPh7aNJxAWSq4oQEJJDgWwSh9leyoJoPpONHxh5nEE5AjE01FkGICSxjpZsF-w8hOTI3XXohUdu29Se26k2B0PolDSuj0GIQU6-W9TdLXSjBb2SpQ","e":"AQAB"}`
5044
test2KeyPublicJSON = `{"kty":"RSA","n":"qnARLrT7Xz4gRcKyLdydmCr-ey9OuPImX4X40thk3on26FkMznR3fRjs66eLK7mmPcBZ6uOJseURU6wAaZNmemoYx1dMvqvWWIyiQleHSD7Q8vBrhR6uIoO4jAzJZR-ChzZuSDt7iHN-3xUVspu5XGwXU_MVJZshTwp4TaFx5elHIT_ObnTvTOU3Xhish07AbgZKmWsVbXh5s-CrIicU4OexJPgunWZ_YJJueOKmTvnLlTV4MzKR2oZlBKZ27S0-SfdV_QDx_ydle5oMAyKVtlAV35cyPMIsYNwgUGBCdY_2Uzi5eX0lTc7MPRwz6qR1kip-i59VcGcUQgqHV6Fyqw","e":"AQAB"}`

probs/probs.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -312,19 +312,6 @@ func UnsupportedIdentifier(detail string, a ...any) *ProblemDetails {
312312
// Additional helper functions that return variations on MalformedProblem with
313313
// different HTTP status codes set.
314314

315-
// Canceled returns a ProblemDetails with a MalformedProblem and a 408 Request
316-
// Timeout status code.
317-
func Canceled(detail string, a ...any) *ProblemDetails {
318-
if len(a) > 0 {
319-
detail = fmt.Sprintf(detail, a...)
320-
}
321-
return &ProblemDetails{
322-
Type: MalformedProblem,
323-
Detail: detail,
324-
HTTPStatus: http.StatusRequestTimeout,
325-
}
326-
}
327-
328315
// Conflict returns a ProblemDetails with a ConflictProblem and a 409 Conflict
329316
// status code.
330317
func Conflict(detail string) *ProblemDetails {

test/certs.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,20 @@ package test
22

33
import (
44
"bytes"
5-
"crypto"
65
"crypto/ecdsa"
76
"crypto/elliptic"
87
"crypto/rand"
9-
"crypto/rsa"
108
"crypto/x509"
119
"encoding/hex"
12-
"encoding/pem"
13-
"errors"
1410
"fmt"
1511
"math/big"
1612
"net"
17-
"os"
1813
"testing"
1914
"time"
2015

2116
"github.com/jmhodges/clock"
2217
)
2318

24-
// LoadSigner loads a PEM private key specified by filename or returns an error.
25-
// Can be paired with issuance.LoadCertificate to get both a CA cert and its
26-
// associated private key for use in signing throwaway test certs.
27-
func LoadSigner(filename string) (crypto.Signer, error) {
28-
keyBytes, err := os.ReadFile(filename)
29-
if err != nil {
30-
return nil, err
31-
}
32-
33-
// pem.Decode does not return an error as its 2nd arg, but instead the "rest"
34-
// that was leftover from parsing the PEM block. We only care if the decoded
35-
// PEM block was empty for this test function.
36-
block, _ := pem.Decode(keyBytes)
37-
if block == nil {
38-
return nil, errors.New("Unable to decode private key PEM bytes")
39-
}
40-
41-
// Try decoding as an RSA private key
42-
if rsaKey, err := x509.ParsePKCS1PrivateKey(block.Bytes); err == nil {
43-
return rsaKey, nil
44-
}
45-
46-
// Try decoding as a PKCS8 private key
47-
if key, err := x509.ParsePKCS8PrivateKey(block.Bytes); err == nil {
48-
// Determine the key's true type and return it as a crypto.Signer
49-
switch k := key.(type) {
50-
case *rsa.PrivateKey:
51-
return k, nil
52-
case *ecdsa.PrivateKey:
53-
return k, nil
54-
}
55-
}
56-
57-
// Try as an ECDSA private key
58-
if ecdsaKey, err := x509.ParseECPrivateKey(block.Bytes); err == nil {
59-
return ecdsaKey, nil
60-
}
61-
62-
// Nothing worked! Fail hard.
63-
return nil, errors.New("Unable to decode private key PEM bytes")
64-
}
65-
6619
// ThrowAwayCert is a small test helper function that creates a self-signed
6720
// certificate with one SAN. It returns the parsed certificate and its serial
6821
// in string form for convenience.

web/context.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,16 +208,6 @@ func (th *TopHandler) logEvent(logEvent *RequestEvent) {
208208
int(logEvent.Latency*1000), logEvent.RealIP, jsonEvent)
209209
}
210210

211-
// GetClientAddr returns a comma-separated list of HTTP clients involved in
212-
// making this request, starting with the original requester and ending with the
213-
// remote end of our TCP connection (which is typically our own proxy).
214-
func GetClientAddr(r *http.Request) string {
215-
if xff := r.Header.Get("X-Forwarded-For"); xff != "" {
216-
return xff + "," + r.RemoteAddr
217-
}
218-
return r.RemoteAddr
219-
}
220-
221211
func KeyTypeToString(pub crypto.PublicKey) string {
222212
switch pk := pub.(type) {
223213
case *rsa.PublicKey:

0 commit comments

Comments
 (0)