Skip to content

Commit 0704009

Browse files
lunnyjolheisertechknowlogickGusted
authored
Revert the minimal golang version requirement from 1.17 to 1.16 and add a warning in Makefile (#19319)
* Revert the minimal golang version requirement from 1.17 to 1.16 and add a warning in Makefile * Apply suggestions from code review Co-authored-by: John Olheiser <[email protected]> * 1.16 * Update modules/util/net.go Co-authored-by: Gusted <[email protected]> * correct bool conditional yay tests for catching this :) * Update hostmatcher.go Co-authored-by: John Olheiser <[email protected]> Co-authored-by: techknowlogick <[email protected]> Co-authored-by: Gusted <[email protected]>
1 parent 14a6aaf commit 0704009

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
lines changed

.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ steps:
109109
depends_on: [test-frontend]
110110

111111
- name: build-backend-no-gcc
112-
image: golang:1.17 # this step is kept as the lowest version of golang that we support
112+
image: golang:1.16 # this step is kept as the lowest version of golang that we support
113113
pull: always
114114
environment:
115115
GO111MODULE: on

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,13 @@ help:
203203
go-check:
204204
$(eval MIN_GO_VERSION_STR := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2))
205205
$(eval MIN_GO_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' ')))
206-
$(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');))
206+
$(eval GO_VERSION_STR := $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+'))
207+
$(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(GO_VERSION_STR)' | tr '.' ' ')))
207208
@if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \
208-
echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \
209+
echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build, but $(GO_VERSION) was found. You can get an updated version at https://go.dev/dl/"; \
209210
exit 1; \
211+
else \
212+
echo "WARNING: Please ensure Go $(GO_VERSION_STR) is still maintained to avoid possible security problems. You can check it at https://go.dev/dl/"; \
210213
fi
211214

212215
.PHONY: git-check

docs/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ params:
1919
author: The Gitea Authors
2020
website: https://docs.gitea.io
2121
version: 1.16.4
22-
minGoVersion: 1.17
22+
minGoVersion: 1.16
2323
goVersion: 1.18
2424
minNodeVersion: 12.17
2525

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module code.gitea.io/gitea
22

3-
go 1.17
3+
go 1.16
44

55
require (
66
cloud.google.com/go v0.99.0 // indirect

modules/hostmatcher/hostmatcher.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"net"
99
"path/filepath"
1010
"strings"
11+
12+
"code.gitea.io/gitea/modules/util"
1113
)
1214

1315
// HostMatchList is used to check if a host or IP is in a list.
@@ -102,11 +104,11 @@ func (hl *HostMatchList) checkIP(ip net.IP) bool {
102104
for _, builtin := range hl.builtins {
103105
switch builtin {
104106
case MatchBuiltinExternal:
105-
if ip.IsGlobalUnicast() && !ip.IsPrivate() {
107+
if ip.IsGlobalUnicast() && !util.IsIPPrivate(ip) {
106108
return true
107109
}
108110
case MatchBuiltinPrivate:
109-
if ip.IsPrivate() {
111+
if util.IsIPPrivate(ip) {
110112
return true
111113
}
112114
case MatchBuiltinLoopback:

modules/util/net.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2021 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package util
6+
7+
import (
8+
"net"
9+
)
10+
11+
// IsIPPrivate for net.IP.IsPrivate.
12+
func IsIPPrivate(ip net.IP) bool {
13+
if ip4 := ip.To4(); ip4 != nil {
14+
return ip4[0] == 10 ||
15+
(ip4[0] == 172 && ip4[1]&0xf0 == 16) ||
16+
(ip4[0] == 192 && ip4[1] == 168)
17+
}
18+
return len(ip) == net.IPv6len && ip[0]&0xfe == 0xfc
19+
}

0 commit comments

Comments
 (0)