Skip to content

Commit dc5c304

Browse files
committed
run 'go fix' on all packages
1 parent bd0f520 commit dc5c304

9 files changed

Lines changed: 19 additions & 20 deletions

File tree

cmd/interactsh-client/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func main() {
299299

300300
func generatePayloadURL(numberOfPayloads int, client *client.Client) []string {
301301
interactshURLs := make([]string, numberOfPayloads)
302-
for i := 0; i < numberOfPayloads; i++ {
302+
for i := range numberOfPayloads {
303303
interactshURLs[i] = client.URL()
304304
}
305305
return interactshURLs

pkg/client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ func (c *Client) performRegistration(serverURL string, payload []byte) error {
624624
data, _ := io.ReadAll(resp.Body)
625625
return fmt.Errorf("could not register to server: %s", string(data))
626626
}
627-
response := make(map[string]interface{})
627+
response := make(map[string]any)
628628
if err := jsoniter.NewDecoder(resp.Body).Decode(&response); err != nil {
629629
return errkit.Wrap(err, "could not register to server")
630630
}

pkg/server/ftp_server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ func (h *FTPServer) recordInteraction(remoteAddress, data string) {
141141
}
142142
}
143143

144-
func (h *FTPServer) Print(sessionID string, message interface{}) {}
145-
func (h *FTPServer) Printf(sessionID string, format string, v ...interface{}) {}
144+
func (h *FTPServer) Print(sessionID string, message any) {}
145+
func (h *FTPServer) Printf(sessionID string, format string, v ...any) {}
146146
func (h *FTPServer) PrintCommand(sessionID string, command string, params string) {
147147
h.Print(sessionID, fmt.Sprintf("%s %s", command, params))
148148
}

pkg/server/http_server.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/base64"
66
"fmt"
77
"log"
8+
"maps"
89
"net"
910
"net/http"
1011
"net/http/httptest"
@@ -126,9 +127,7 @@ func (h *HTTPServer) logger(handler http.Handler) http.HandlerFunc {
126127
resp, _ := httputil.DumpResponse(rec.Result(), true)
127128
respString := string(resp)
128129

129-
for k, v := range rec.Header() {
130-
w.Header()[k] = v
131-
}
130+
maps.Copy(w.Header(), rec.Header())
132131
data := rec.Body.Bytes()
133132

134133
w.WriteHeader(rec.Result().StatusCode)
@@ -507,7 +506,7 @@ func jsonBody(w http.ResponseWriter, key, value string, code int) {
507506
w.Header().Set("Content-Type", "application/json; charset=utf-8")
508507
w.Header().Set("X-Content-Type-Options", "nosniff")
509508
w.WriteHeader(code)
510-
_ = jsoniter.NewEncoder(w).Encode(map[string]interface{}{key: value})
509+
_ = jsoniter.NewEncoder(w).Encode(map[string]any{key: value})
511510
}
512511

513512
func jsonError(w http.ResponseWriter, err string, code int) {

pkg/server/ldap_server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ func (ldapServer *LDAPServer) handleExtended(w ldap.ResponseWriter, m *ldap.Mess
387387
}
388388
}
389389

390-
func (ldapServer *LDAPServer) handleLog(host string, f string, v ...interface{}) {
390+
func (ldapServer *LDAPServer) handleLog(host string, f string, v ...any) {
391391
// just discard logs if logger is disabled
392392
if !ldapServer.WithLogger {
393393
return

pkg/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ type Options struct {
118118
Certificates []tls.Certificate
119119
CertFiles []acme.CertificateFiles
120120
}
121-
type OnResultCallback func(out interface{})
121+
type OnResultCallback func(out any)
122122

123123
func (options *Options) GetIdLength() int {
124124
return options.CorrelationIdLength + options.CorrelationIdNonceLength

pkg/storage/roundtrip_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
"testing"
1515
"time"
1616

17-
jsoniter "github.com/json-iterator/go"
1817
"github.com/google/uuid"
18+
jsoniter "github.com/json-iterator/go"
1919
"github.com/rs/xid"
2020
"github.com/stretchr/testify/require"
2121
)
@@ -105,7 +105,7 @@ func TestFullRoundTripInMemory(t *testing.T) {
105105
require.NoError(t, err)
106106

107107
// Create and store 3 DNS interactions (like dns_server.go does)
108-
for i := 0; i < 3; i++ {
108+
for i := range 3 {
109109
inter := &interaction{
110110
Protocol: "dns",
111111
UniqueID: "abc123def456ghi",
@@ -158,7 +158,7 @@ func TestFullRoundTripDisk(t *testing.T) {
158158
require.NoError(t, err)
159159

160160
// Create and store 3 DNS interactions
161-
for i := 0; i < 3; i++ {
161+
for i := range 3 {
162162
inter := &interaction{
163163
Protocol: "dns",
164164
UniqueID: "abc123def456ghi",

pkg/storage/storagedb.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func (s *StorageDB) GetInteractionsWithIdForConsumer(id, consumerID string) ([]s
282282
}
283283
return nil, err
284284
}
285-
for _, d := range bytes.Split(raw, []byte("\n")) {
285+
for d := range bytes.SplitSeq(raw, []byte("\n")) {
286286
if len(d) > 0 {
287287
allData = append(allData, string(d))
288288
}
@@ -387,7 +387,7 @@ func (s *StorageDB) applyTrim(value *CorrelationData, id string, trimCount int)
387387
return
388388
}
389389
var allData []string
390-
for _, d := range bytes.Split(raw, []byte("\n")) {
390+
for d := range bytes.SplitSeq(raw, []byte("\n")) {
391391
if len(d) > 0 {
392392
allData = append(allData, string(d))
393393
}
@@ -418,7 +418,7 @@ func (s *StorageDB) dataLen(value *CorrelationData, id string) int {
418418
return 0
419419
}
420420
count := 0
421-
for _, d := range bytes.Split(raw, []byte("\n")) {
421+
for d := range bytes.SplitSeq(raw, []byte("\n")) {
422422
if len(d) > 0 {
423423
count++
424424
}
@@ -479,7 +479,7 @@ func (s *StorageDB) getInteractions(correlationData *CorrelationData, id string)
479479
return nil, err
480480
}
481481
var dataString []string
482-
for _, d := range bytes.Split(data, []byte("\n")) {
482+
for d := range bytes.SplitSeq(data, []byte("\n")) {
483483
if len(d) == 0 {
484484
continue
485485
}

pkg/storage/storagedb_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func BenchmarkCacheParallelOther(b *testing.B) {
128128
}
129129

130130
func doStuffWithOtherCache(cache cache.Cache) {
131-
for i := 0; i < 1e2; i++ {
131+
for i := range int(1e2) {
132132
cache.Put(strconv.Itoa(i), "test")
133133
_, _ = cache.GetIfPresent(strconv.Itoa(i))
134134
}
@@ -347,7 +347,7 @@ func TestSlidingEvictionStrategy(t *testing.T) {
347347
require.True(t, ok)
348348

349349
// Still present after original TTL due to sliding window
350-
time.Sleep(testTTL / 2 + smallDelay)
350+
time.Sleep(testTTL/2 + smallDelay)
351351
_, ok = mem.cache.GetIfPresent("test-sliding")
352352
require.True(t, ok)
353353

@@ -372,7 +372,7 @@ func TestFixedEvictionStrategy(t *testing.T) {
372372
require.True(t, ok)
373373

374374
// Should be expired after full TTL despite access
375-
time.Sleep(testTTL / 2 + 10 * time.Millisecond)
375+
time.Sleep(testTTL/2 + 10*time.Millisecond)
376376
_, ok = mem.cache.GetIfPresent("test-fixed")
377377
require.False(t, ok)
378378
}

0 commit comments

Comments
 (0)