Skip to content

Commit 070355e

Browse files
authored
chore: golines (#200)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 03fdc76 commit 070355e

File tree

6 files changed

+70
-19
lines changed

6 files changed

+70
-19
lines changed

cmd/cdnsd/main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,16 @@ func main() {
9898

9999
// Start metrics listener
100100
if cfg.Metrics.ListenPort > 0 {
101-
metricsListenAddr := fmt.Sprintf("%s:%d", cfg.Metrics.ListenAddress, cfg.Metrics.ListenPort)
101+
metricsListenAddr := fmt.Sprintf(
102+
"%s:%d",
103+
cfg.Metrics.ListenAddress,
104+
cfg.Metrics.ListenPort,
105+
)
102106
slog.Info(
103-
fmt.Sprintf("starting listener for prometheus metrics connections on %s", metricsListenAddr),
107+
fmt.Sprintf(
108+
"starting listener for prometheus metrics connections on %s",
109+
metricsListenAddr,
110+
),
104111
)
105112
metricsMux := http.NewServeMux()
106113
metricsMux.Handle("/metrics", promhttp.Handler())

internal/config/config.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ type Config struct {
2626
}
2727

2828
type LoggingConfig struct {
29-
Debug bool `yaml:"debug" envconfig:"LOGGING_DEBUG"`
30-
QueryLog bool `yaml:"queryLog" envconfig:"LOGGING_QUERY_LOG"`
29+
Debug bool `yaml:"debug" envconfig:"LOGGING_DEBUG"`
30+
QueryLog bool `yaml:"queryLog" envconfig:"LOGGING_QUERY_LOG"`
3131
}
3232

3333
type DnsConfig struct {
@@ -136,7 +136,8 @@ func Load(configFile string) (*Config, error) {
136136
}
137137
}
138138
// Update intercept slot/hash if earlier than any other profiles so far
139-
if interceptSlot == 0 || profileData.InterceptSlot < interceptSlot {
139+
if interceptSlot == 0 ||
140+
profileData.InterceptSlot < interceptSlot {
140141
interceptSlot = profileData.InterceptSlot
141142
interceptHash = profileData.InterceptHash
142143
}
@@ -145,7 +146,11 @@ func Load(configFile string) (*Config, error) {
145146
}
146147
}
147148
if !foundProfile {
148-
return nil, fmt.Errorf("unknown profile: %s: available profiles: %s", profile, strings.Join(availableProfiles, ","))
149+
return nil, fmt.Errorf(
150+
"unknown profile: %s: available profiles: %s",
151+
profile,
152+
strings.Join(availableProfiles, ","),
153+
)
149154
}
150155
}
151156
// Provide default intercept point from profile(s)

internal/dns/dns.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ func handleQuery(w dns.ResponseWriter, r *dns.Msg) {
109109
tmpRR, err := stateRecordToDnsRR(tmpRecord)
110110
if err != nil {
111111
slog.Error(
112-
fmt.Sprintf("failed to convert state record to dns.RR: %s", err),
112+
fmt.Sprintf(
113+
"failed to convert state record to dns.RR: %s",
114+
err,
115+
),
113116
)
114117
return
115118
}
@@ -367,20 +370,25 @@ func findNameserversForDomain(
367370
lookupDomainName := strings.Join(queryLabels[startLabelIdx:], ".")
368371
// Convert to canonical form for consistency
369372
lookupDomainName = dns.CanonicalName(lookupDomainName)
370-
nsRecords, err := state.GetState().LookupRecords([]string{"NS"}, lookupDomainName)
373+
nsRecords, err := state.GetState().
374+
LookupRecords([]string{"NS"}, lookupDomainName)
371375
if err != nil {
372376
return "", nil, err
373377
}
374378
if len(nsRecords) > 0 {
375379
ret := map[string][]net.IP{}
376380
for _, nsRecord := range nsRecords {
377381
// Get matching A/AAAA records for NS entry
378-
aRecords, err := state.GetState().LookupRecords([]string{"A", "AAAA"}, nsRecord.Rhs)
382+
aRecords, err := state.GetState().
383+
LookupRecords([]string{"A", "AAAA"}, nsRecord.Rhs)
379384
if err != nil {
380385
return "", nil, err
381386
}
382387
for _, aRecord := range aRecords {
383-
ret[nsRecord.Rhs] = append(ret[nsRecord.Rhs], net.ParseIP(aRecord.Rhs))
388+
ret[nsRecord.Rhs] = append(
389+
ret[nsRecord.Rhs],
390+
net.ParseIP(aRecord.Rhs),
391+
)
384392
}
385393
}
386394
return dns.Fqdn(lookupDomainName), ret, nil

internal/indexer/datum.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,34 @@ func (d *DNSReferenceRefScriptDatum) UnmarshalCBOR(cborData []byte) error {
2727
return err
2828
}
2929
if tmpData.Constructor() != 3 {
30-
return fmt.Errorf("unexpected outer constructor index: %d", tmpData.Constructor())
30+
return fmt.Errorf(
31+
"unexpected outer constructor index: %d",
32+
tmpData.Constructor(),
33+
)
3134
}
3235
tmpDataFields := tmpData.Fields()
3336
if len(tmpDataFields) != 1 {
34-
return fmt.Errorf("unexpected inner field count: expected 1, got %d", len(tmpDataFields))
37+
return fmt.Errorf(
38+
"unexpected inner field count: expected 1, got %d",
39+
len(tmpDataFields),
40+
)
3541
}
3642
fieldInner, ok := tmpDataFields[0].(cbor.Constructor)
3743
if !ok {
38-
return fmt.Errorf("unexpected data type %T for outer constructor field", tmpDataFields[0])
44+
return fmt.Errorf(
45+
"unexpected data type %T for outer constructor field",
46+
tmpDataFields[0],
47+
)
3948
}
4049
var tmpDataInner cbor.Constructor
4150
if _, err := cbor.Decode(fieldInner.Cbor(), &tmpDataInner); err != nil {
4251
return err
4352
}
4453
if tmpDataInner.Constructor() != 1 {
45-
return fmt.Errorf("unexpected inner constructor index: %d", tmpDataInner.Constructor())
54+
return fmt.Errorf(
55+
"unexpected inner constructor index: %d",
56+
tmpDataInner.Constructor(),
57+
)
4658
}
4759
return cbor.DecodeGeneric(tmpDataInner.FieldsCbor(), d)
4860
}

internal/indexer/indexer.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ func (i *Indexer) handleEvent(evt event.Event) error {
235235
}
236236
for _, watchedAddr := range i.watched {
237237
if watchedAddr.Discovery {
238-
if outAddr.String() == watchedAddr.Address || outAddrPayment.String() == watchedAddr.Address {
238+
if outAddr.String() == watchedAddr.Address ||
239+
outAddrPayment.String() == watchedAddr.Address {
239240
if err := i.handleEventOutputDiscovery(eventCtx, watchedAddr.PolicyId, txOutput); err != nil {
240241
return err
241242
}
@@ -254,7 +255,12 @@ func (i *Indexer) handleEvent(evt event.Event) error {
254255
return nil
255256
}
256257

257-
func (i *Indexer) handleEventOutputDns(eventCtx input_chainsync.TransactionContext, tldName string, policyId string, txOutput ledger.TransactionOutput) error {
258+
func (i *Indexer) handleEventOutputDns(
259+
eventCtx input_chainsync.TransactionContext,
260+
tldName string,
261+
policyId string,
262+
txOutput ledger.TransactionOutput,
263+
) error {
258264
cfg := config.GetConfig()
259265
datum := txOutput.Datum()
260266
if datum != nil {
@@ -364,7 +370,11 @@ func (i *Indexer) handleEventOutputDns(eventCtx input_chainsync.TransactionConte
364370
return nil
365371
}
366372

367-
func (i *Indexer) handleEventOutputDiscovery(eventCtx input_chainsync.TransactionContext, policyId string, txOutput ledger.TransactionOutput) error {
373+
func (i *Indexer) handleEventOutputDiscovery(
374+
eventCtx input_chainsync.TransactionContext,
375+
policyId string,
376+
txOutput ledger.TransactionOutput,
377+
) error {
368378
cfg := config.GetConfig()
369379
datum := txOutput.Datum()
370380
if datum != nil {

internal/state/state.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,21 @@ func (s *State) UpdateDomain(
281281
return err
282282
}
283283

284-
func (s *State) LookupRecords(recordTypes []string, recordName string) ([]DomainRecord, error) {
284+
func (s *State) LookupRecords(
285+
recordTypes []string,
286+
recordName string,
287+
) ([]DomainRecord, error) {
285288
ret := []DomainRecord{}
286289
recordName = strings.Trim(recordName, `.`)
287290
err := s.db.View(func(txn *badger.Txn) error {
288291
for _, recordType := range recordTypes {
289-
keyPrefix := []byte(fmt.Sprintf("r_%s_%s_", strings.ToUpper(recordType), recordName))
292+
keyPrefix := []byte(
293+
fmt.Sprintf(
294+
"r_%s_%s_",
295+
strings.ToUpper(recordType),
296+
recordName,
297+
),
298+
)
290299
it := txn.NewIterator(badger.DefaultIteratorOptions)
291300
defer it.Close()
292301
for it.Seek(keyPrefix); it.ValidForPrefix(keyPrefix); it.Next() {

0 commit comments

Comments
 (0)