From b6361fb143c727cdf034ccebb4068e4f2117899c Mon Sep 17 00:00:00 2001 From: fatedier Date: Mon, 19 Feb 2024 21:27:56 +0800 Subject: [PATCH] use go built-in min & max functions to replace lo.Min and lo.Max (#4007) --- pkg/nathole/analysis.go | 2 +- pkg/nathole/controller.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/nathole/analysis.go b/pkg/nathole/analysis.go index 75f9a55c..eb44d6d9 100644 --- a/pkg/nathole/analysis.go +++ b/pkg/nathole/analysis.go @@ -224,7 +224,7 @@ func (mhr *MakeHoleRecords) ReportSuccess(mode int, index int) { } score.Score += 2 - score.Score = lo.Min([]int{score.Score, 10}) + score.Score = min(score.Score, 10) return } } diff --git a/pkg/nathole/controller.go b/pkg/nathole/controller.go index dd134abe..03c05b35 100644 --- a/pkg/nathole/controller.go +++ b/pkg/nathole/controller.go @@ -317,7 +317,7 @@ func (c *Controller) analysis(session *Session) (*msg.NatHoleResp, *msg.NatHoleR session.cBehavior = cBehavior session.vBehavior = vBehavior - timeoutMs := lo.Max([]int{cBehavior.SendDelayMs, vBehavior.SendDelayMs}) + 5000 + timeoutMs := max(cBehavior.SendDelayMs, vBehavior.SendDelayMs) + 5000 if cBehavior.ListenRandomPorts > 0 || vBehavior.ListenRandomPorts > 0 { timeoutMs += 30000 } @@ -384,8 +384,8 @@ func getRangePorts(addrs []string, difference, maxNumber int) []msg.PortsRange { return nil } ports = append(ports, msg.PortsRange{ - From: lo.Max([]int{port - difference - 5, port - maxNumber, 1}), - To: lo.Min([]int{port + difference + 5, port + maxNumber, 65535}), + From: max(port-difference-5, port-maxNumber, 1), + To: min(port+difference+5, port+maxNumber, 65535), }) return ports }