diff --git a/.drone.yml b/.drone.yml index b3b1682619..7bfdefa266 100644 --- a/.drone.yml +++ b/.drone.yml @@ -109,7 +109,7 @@ steps: depends_on: [test-frontend] - name: build-backend-no-gcc - image: golang:1.17 # this step is kept as the lowest version of golang that we support + image: golang:1.16 # this step is kept as the lowest version of golang that we support pull: always environment: GO111MODULE: on diff --git a/Makefile b/Makefile index bbd099ed28..a15caf7a8f 100644 --- a/Makefile +++ b/Makefile @@ -203,10 +203,13 @@ help: go-check: $(eval MIN_GO_VERSION_STR := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2)) $(eval MIN_GO_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' '))) - $(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');)) + $(eval GO_VERSION_STR := $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+')) + $(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(GO_VERSION_STR)' | tr '.' ' '))) @if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \ - echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \ + 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/"; \ exit 1; \ + else \ + 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/"; \ fi .PHONY: git-check diff --git a/docs/config.yaml b/docs/config.yaml index c3614e4bc8..e77f98bd21 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -19,7 +19,7 @@ params: author: The Gitea Authors website: https://docs.gitea.io version: 1.16.4 - minGoVersion: 1.17 + minGoVersion: 1.16 goVersion: 1.18 minNodeVersion: 12.17 diff --git a/go.mod b/go.mod index 2fc582fa78..57234d70c2 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module code.gitea.io/gitea -go 1.17 +go 1.16 require ( cloud.google.com/go v0.99.0 // indirect diff --git a/modules/hostmatcher/hostmatcher.go b/modules/hostmatcher/hostmatcher.go index 6c5c2a74d9..9492a479f1 100644 --- a/modules/hostmatcher/hostmatcher.go +++ b/modules/hostmatcher/hostmatcher.go @@ -8,6 +8,8 @@ import ( "net" "path/filepath" "strings" + + "code.gitea.io/gitea/modules/util" ) // 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 { for _, builtin := range hl.builtins { switch builtin { case MatchBuiltinExternal: - if ip.IsGlobalUnicast() && !ip.IsPrivate() { + if ip.IsGlobalUnicast() && !util.IsIPPrivate(ip) { return true } case MatchBuiltinPrivate: - if ip.IsPrivate() { + if util.IsIPPrivate(ip) { return true } case MatchBuiltinLoopback: diff --git a/modules/util/net.go b/modules/util/net.go new file mode 100644 index 0000000000..e4fbf393b4 --- /dev/null +++ b/modules/util/net.go @@ -0,0 +1,19 @@ +// Copyright 2021 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package util + +import ( + "net" +) + +// IsIPPrivate for net.IP.IsPrivate. +func IsIPPrivate(ip net.IP) bool { + if ip4 := ip.To4(); ip4 != nil { + return ip4[0] == 10 || + (ip4[0] == 172 && ip4[1]&0xf0 == 16) || + (ip4[0] == 192 && ip4[1] == 168) + } + return len(ip) == net.IPv6len && ip[0]&0xfe == 0xfc +}