Skip to content

Commit

Permalink
🪛 clientgroups, probe: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
database64128 committed Feb 21, 2025
1 parent feb0f41 commit 5971795
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
4 changes: 2 additions & 2 deletions clientgroups/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,9 @@ type latencyProbeJob[C any] struct {

func (j *latencyProbeJob[C]) Run(ctx context.Context) {
defer j.wg.Done()
ctx, cancel := context.WithTimeout(ctx, j.timeout)
defer cancel()
start := time.Now()
ctx, cancel := context.WithDeadline(ctx, start.Add(j.timeout))
defer cancel()
if err := j.probe(ctx, j.client); err == nil {
j.result[j.count%32] = time.Since(start)
} else {
Expand Down
8 changes: 0 additions & 8 deletions probe/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"net"
"net/http"
"time"

"github.com/database64128/shadowsocks-go/conn"
"github.com/database64128/shadowsocks-go/zerocopy"
Expand Down Expand Up @@ -74,10 +73,3 @@ func (p TCPProbe) Probe(ctx context.Context, client zerocopy.TCPClient) error {

return nil
}

// ProbeRTT runs the connectivity test and returns the round-trip time.
func (p TCPProbe) ProbeRTT(ctx context.Context, client zerocopy.TCPClient) (rtt time.Duration, err error) {
start := time.Now()
err = p.Probe(ctx, client)
return time.Since(start), err
}
8 changes: 0 additions & 8 deletions probe/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"math/rand/v2"
"os"
"slices"
"time"

"github.com/database64128/shadowsocks-go/conn"
"github.com/database64128/shadowsocks-go/zerocopy"
Expand Down Expand Up @@ -243,10 +242,3 @@ func (p UDPProbe) Probe(ctx context.Context, client zerocopy.UDPClient) error {
return nil
}
}

// ProbeRTT runs the connectivity test and returns the round-trip time.
func (p UDPProbe) ProbeRTT(ctx context.Context, client zerocopy.UDPClient) (rtt time.Duration, err error) {
start := time.Now()
err = p.Probe(ctx, client)
return time.Since(start), err
}

0 comments on commit 5971795

Please sign in to comment.