Skip to content

Commit

Permalink
use go1.23 (#4495)
Browse files Browse the repository at this point in the history
  • Loading branch information
fatedier authored Oct 17, 2024
1 parent 3a08c2a commit f7a06cb
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
go-version: '1.23'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.57
version: v1.61

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
go-version: '1.23'

- name: Make All
run: |
Expand Down
5 changes: 3 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
service:
golangci-lint-version: 1.57.x # use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: 1.61.x # use the fixed version to not introduce new linters unexpectedly

run:
concurrency: 4
Expand All @@ -14,7 +14,7 @@ linters:
enable:
- unused
- errcheck
- exportloopref
- copyloopvar
- gocritic
- gofumpt
- goimports
Expand Down Expand Up @@ -90,6 +90,7 @@ linters-settings:
- G402
- G404
- G501
- G115 # integer overflow conversion

issues:
# List of regexps of issue texts to exclude, empty list by default.
Expand Down
3 changes: 1 addition & 2 deletions Release.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
### Features

* The frpc visitor command-line parameter adds the `--server-user` option to specify the username of the server-side proxy to connect to.

* Support multiple frpc instances with different subjects when using oidc authentication.
* Support multiple frpc instances with different subjects when using oidc authentication.
2 changes: 1 addition & 1 deletion client/proxy/proxy_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (pw *Wrapper) SetRunningStatus(remoteAddr string, respErr string) error {
pw.Phase = ProxyPhaseStartErr
pw.Err = respErr
pw.lastStartErr = time.Now()
return fmt.Errorf(pw.Err)
return fmt.Errorf("%s", pw.Err)
}

if err := pw.pxy.Run(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile-for-frpc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22 AS building
FROM golang:1.23 AS building

COPY . /building
WORKDIR /building
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile-for-frps
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22 AS building
FROM golang:1.23 AS building

COPY . /building
WORKDIR /building
Expand Down
8 changes: 4 additions & 4 deletions pkg/config/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,18 @@ func NewPortsRangeSliceFromString(str string) ([]PortsRange, error) {
out = append(out, PortsRange{Single: int(singleNum)})
case 2:
// range numbers
min, err := strconv.ParseInt(strings.TrimSpace(numArray[0]), 10, 64)
minNum, err := strconv.ParseInt(strings.TrimSpace(numArray[0]), 10, 64)
if err != nil {
return nil, fmt.Errorf("range number is invalid, %v", err)
}
max, err := strconv.ParseInt(strings.TrimSpace(numArray[1]), 10, 64)
maxNum, err := strconv.ParseInt(strings.TrimSpace(numArray[1]), 10, 64)
if err != nil {
return nil, fmt.Errorf("range number is invalid, %v", err)
}
if max < min {
if maxNum < minNum {
return nil, fmt.Errorf("range number is invalid")
}
out = append(out, PortsRange{Start: int(min), End: int(max)})
out = append(out, PortsRange{Start: int(minNum), End: int(maxNum)})
default:
return nil, fmt.Errorf("range number is invalid")
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/nathole/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ func ListAllLocalIPs() ([]net.IP, error) {
return ips, nil
}

func ListLocalIPsForNatHole(max int) ([]string, error) {
if max <= 0 {
return nil, fmt.Errorf("max must be greater than 0")
func ListLocalIPsForNatHole(maxItems int) ([]string, error) {
if maxItems <= 0 {
return nil, fmt.Errorf("maxItems must be greater than 0")
}

ips, err := ListAllLocalIPs()
if err != nil {
return nil, err
}

filtered := make([]string, 0, max)
filtered := make([]string, 0, maxItems)
for _, ip := range ips {
if len(filtered) >= max {
if len(filtered) >= maxItems {
break
}

Expand Down
18 changes: 9 additions & 9 deletions pkg/util/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,21 @@ func ParseRangeNumbers(rangeStr string) (numbers []int64, err error) {
numbers = append(numbers, singleNum)
case 2:
// range numbers
min, errRet := strconv.ParseInt(strings.TrimSpace(numArray[0]), 10, 64)
minValue, errRet := strconv.ParseInt(strings.TrimSpace(numArray[0]), 10, 64)
if errRet != nil {
err = fmt.Errorf("range number is invalid, %v", errRet)
return
}
max, errRet := strconv.ParseInt(strings.TrimSpace(numArray[1]), 10, 64)
maxValue, errRet := strconv.ParseInt(strings.TrimSpace(numArray[1]), 10, 64)
if errRet != nil {
err = fmt.Errorf("range number is invalid, %v", errRet)
return
}
if max < min {
if maxValue < minValue {
err = fmt.Errorf("range number is invalid")
return
}
for i := min; i <= max; i++ {
for i := minValue; i <= maxValue; i++ {
numbers = append(numbers, i)
}
default:
Expand All @@ -118,13 +118,13 @@ func GenerateResponseErrorString(summary string, err error, detailed bool) strin
}

func RandomSleep(duration time.Duration, minRatio, maxRatio float64) time.Duration {
min := int64(minRatio * 1000.0)
max := int64(maxRatio * 1000.0)
minValue := int64(minRatio * 1000.0)
maxValue := int64(maxRatio * 1000.0)
var n int64
if max <= min {
n = min
if maxValue <= minValue {
n = minValue
} else {
n = mathrand.Int64N(max-min) + min
n = mathrand.Int64N(maxValue-minValue) + minValue
}
d := duration * time.Duration(n) / time.Duration(1000)
time.Sleep(d)
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package version

var version = "0.60.0"
var version = "0.61.0"

func Full() string {
return version
Expand Down
12 changes: 6 additions & 6 deletions server/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@ func (pxy *BaseProxy) GetWorkConnFromPool(src, dst net.Addr) (workConn net.Conn,
dstAddr string
srcPortStr string
dstPortStr string
srcPort int
dstPort int
srcPort uint64
dstPort uint64
)

if src != nil {
srcAddr, srcPortStr, _ = net.SplitHostPort(src.String())
srcPort, _ = strconv.Atoi(srcPortStr)
srcPort, _ = strconv.ParseUint(srcPortStr, 10, 16)
}
if dst != nil {
dstAddr, dstPortStr, _ = net.SplitHostPort(dst.String())
dstPort, _ = strconv.Atoi(dstPortStr)
dstPort, _ = strconv.ParseUint(dstPortStr, 10, 16)
}
err := msg.WriteMsg(workConn, &msg.StartWorkConn{
ProxyName: pxy.GetName(),
Expand Down Expand Up @@ -190,8 +190,8 @@ func (pxy *BaseProxy) startCommonTCPListenersHandler() {
} else {
tempDelay *= 2
}
if max := 1 * time.Second; tempDelay > max {
tempDelay = max
if maxTime := 1 * time.Second; tempDelay > maxTime {
tempDelay = maxTime
}
xl.Infof("met temporary error: %s, sleep for %s ...", err, tempDelay)
time.Sleep(tempDelay)
Expand Down

0 comments on commit f7a06cb

Please sign in to comment.