Skip to content

Commit ed1d95c

Browse files
authoredMar 16, 2022
use go1.18 to build gitea (#19099)
* use go1.18 to build gitea& update min go version to 1.17 * bump in a few more places * add a few simple tests for isipprivate * update go.mod * update URL to https://go.dev/dl/ * golangci-lint * attempt golangci-lint workaround * change version * bump fumpt version * skip strings.title test * go mod tidy * update tests as some aren't private?? * update tests
1 parent fe9626a commit ed1d95c

File tree

10 files changed

+259
-63
lines changed

10 files changed

+259
-63
lines changed
 

‎.drone.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ steps:
2525
- make deps-frontend
2626

2727
- name: deps-backend
28-
image: golang:1.17
28+
image: golang:1.18
2929
pull: always
3030
commands:
3131
- make deps-backend
@@ -88,7 +88,7 @@ steps:
8888
depends_on: [deps-frontend]
8989

9090
- name: checks-backend
91-
image: golang:1.17
91+
image: golang:1.18
9292
commands:
9393
- make checks-backend
9494
depends_on: [deps-backend]
@@ -122,7 +122,7 @@ steps:
122122
path: /go
123123

124124
- name: build-backend-arm64
125-
image: golang:1.17
125+
image: golang:1.18
126126
environment:
127127
GO111MODULE: on
128128
GOPROXY: https://goproxy.cn
@@ -138,7 +138,7 @@ steps:
138138
path: /go
139139

140140
- name: build-backend-windows
141-
image: golang:1.17
141+
image: golang:1.18
142142
environment:
143143
GO111MODULE: on
144144
GOPROXY: https://goproxy.cn
@@ -153,7 +153,7 @@ steps:
153153
path: /go
154154

155155
- name: build-backend-386
156-
image: golang:1.17
156+
image: golang:1.18
157157
environment:
158158
GO111MODULE: on
159159
GOPROXY: https://goproxy.cn
@@ -242,7 +242,7 @@ steps:
242242
- pull_request
243243

244244
- name: deps-backend
245-
image: golang:1.17
245+
image: golang:1.18
246246
pull: always
247247
commands:
248248
- make deps-backend
@@ -359,7 +359,7 @@ steps:
359359
path: /go
360360

361361
- name: generate-coverage
362-
image: golang:1.17
362+
image: golang:1.18
363363
commands:
364364
- make coverage
365365
environment:
@@ -434,7 +434,7 @@ steps:
434434
- pull_request
435435

436436
- name: deps-backend
437-
image: golang:1.17
437+
image: golang:1.18
438438
pull: always
439439
commands:
440440
- make deps-backend
@@ -576,7 +576,7 @@ trigger:
576576

577577
steps:
578578
- name: download
579-
image: golang:1.17
579+
image: golang:1.18
580580
pull: always
581581
commands:
582582
- timeout -s ABRT 40m make generate-license generate-gitignore
@@ -637,7 +637,7 @@ steps:
637637
- make deps-frontend
638638

639639
- name: deps-backend
640-
image: golang:1.17
640+
image: golang:1.18
641641
pull: always
642642
commands:
643643
- make deps-backend
@@ -646,7 +646,7 @@ steps:
646646
path: /go
647647

648648
- name: static
649-
image: techknowlogick/xgo:go-1.17.x
649+
image: techknowlogick/xgo:go-1.18.x
650650
pull: always
651651
commands:
652652
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
@@ -755,7 +755,7 @@ steps:
755755
- make deps-frontend
756756

757757
- name: deps-backend
758-
image: golang:1.17
758+
image: golang:1.18
759759
pull: always
760760
commands:
761761
- make deps-backend
@@ -764,7 +764,7 @@ steps:
764764
path: /go
765765

766766
- name: static
767-
image: techknowlogick/xgo:go-1.17.x
767+
image: techknowlogick/xgo:go-1.18.x
768768
pull: always
769769
commands:
770770
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs

‎.golangci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ linters:
1313
#- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
1414
- gofmt
1515
- misspell
16-
- gocritic
16+
#- gocritic # TODO: disabled until fixed with go 1.18
1717
- bidichk
1818
- ineffassign
1919
- revive
@@ -64,7 +64,7 @@ linters-settings:
6464
- name: modifies-value-receiver
6565
gofumpt:
6666
extra-rules: true
67-
lang-version: 1.17
67+
lang-version: 1.18
6868

6969
issues:
7070
exclude-rules:
@@ -152,3 +152,5 @@ issues:
152152
- path: models/user/openid.go
153153
linters:
154154
- golint
155+
- linters: staticcheck
156+
text: "strings.Title is deprecated: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead."

‎Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Build stage
2-
FROM golang:1.17-alpine3.15 AS build-env
2+
FROM golang:1.18-alpine3.15 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY ${GOPROXY:-direct}

‎Dockerfile.rootless

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Build stage
2-
FROM golang:1.17-alpine3.15 AS build-env
2+
FROM golang:1.18-alpine3.15 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY ${GOPROXY:-direct}

‎Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ SHASUM ?= shasum -a 256
2424
HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
2525
COMMA := ,
2626

27-
XGO_VERSION := go-1.17.x
27+
XGO_VERSION := go-1.18.x
2828
MIN_GO_VERSION := 001017000
2929
MIN_NODE_VERSION := 012017000
3030

3131
AIR_PACKAGE ?= github.com/cosmtrek/air@bedc18201271882c2be66d216d0e1a275b526ec4
3232
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@50adf46752da119dfef66e57be3ce2693ea4aa9c
3333
ERRCHECK_PACKAGE ?= github.com/kisielk/errcheck@8ddee489636a8311a376fc92e27a6a13c6658344
3434
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.3.0
35-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.44.0
35+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.44.2
3636
GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.10
3737
MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/misspell@v0.3.4
3838
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.27.0

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ or if SQLite support is required:
7373

7474
The `build` target is split into two sub-targets:
7575

76-
- `make backend` which requires [Go 1.17](https://golang.org/dl/) or greater.
76+
- `make backend` which requires [Go 1.17](https://go.dev/dl/) or greater.
7777
- `make frontend` which requires [Node.js LTS](https://nodejs.org/en/download/) or greater and Internet connectivity to download npm dependencies.
7878

7979
When building from the official source tarballs which include pre-built frontend files, the `frontend` target will not be triggered, making it possible to build without Node.js and Internet connectivity.

‎docs/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ params:
2020
website: https://docs.gitea.io
2121
version: 1.16.4
2222
minGoVersion: 1.17
23-
goVersion: 1.17
23+
goVersion: 1.18
2424
minNodeVersion: 12.17
2525

2626
outputs:

‎go.mod

Lines changed: 179 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,12 @@ require (
1111
gitea.com/go-chi/session v0.0.0-20211218221615-e3605d8b28b8
1212
gitea.com/lunny/levelqueue v0.4.1
1313
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121
14-
github.com/Azure/go-ntlmssp v0.0.0-20211209120228-48547f28849e // indirect
15-
github.com/Microsoft/go-winio v0.5.2 // indirect
1614
github.com/NYTimes/gziphandler v1.1.1
17-
github.com/ProtonMail/go-crypto v0.0.0-20220113124808-70ae35bab23f // indirect
1815
github.com/PuerkitoBio/goquery v1.8.0
1916
github.com/alecthomas/chroma v0.10.0
20-
github.com/andybalholm/brotli v1.0.4 // indirect
21-
github.com/bits-and-blooms/bitset v1.2.1 // indirect
2217
github.com/blevesearch/bleve/v2 v2.3.1
23-
github.com/boombuler/barcode v1.0.1 // indirect
24-
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect
2518
github.com/caddyserver/certmagic v0.15.4
2619
github.com/chi-middleware/proxy v1.1.1
27-
github.com/couchbase/go-couchbase v0.0.0-20210224140812-5740cd35f448 // indirect
28-
github.com/couchbase/gomemcached v0.1.2 // indirect
29-
github.com/couchbase/goutils v0.0.0-20210118111533-e33d3ffb5401 // indirect
3020
github.com/denisenkom/go-mssqldb v0.12.0
3121
github.com/djherbis/buffer v1.2.0
3222
github.com/djherbis/nio/v3 v3.0.1
@@ -36,7 +26,6 @@ require (
3626
github.com/emirpasic/gods v1.12.0
3727
github.com/ethantkoenig/rupture v1.0.1
3828
github.com/gliderlabs/ssh v0.3.3
39-
github.com/go-asn1-ber/asn1-ber v1.5.3 // indirect
4029
github.com/go-chi/chi/v5 v5.0.7
4130
github.com/go-chi/cors v1.2.0
4231
github.com/go-enry/go-enry/v2 v2.8.0
@@ -52,84 +41,60 @@ require (
5241
github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14
5342
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85
5443
github.com/golang-jwt/jwt/v4 v4.3.0
55-
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
56-
github.com/golang/snappy v0.0.4 // indirect
5744
github.com/google/go-github/v39 v39.2.0
5845
github.com/google/uuid v1.3.0
5946
github.com/gorilla/feeds v1.1.1
60-
github.com/gorilla/mux v1.8.0 // indirect
6147
github.com/gorilla/sessions v1.2.1
62-
github.com/hashicorp/go-retryablehttp v0.7.0 // indirect
6348
github.com/hashicorp/go-version v1.4.0
6449
github.com/hashicorp/golang-lru v0.5.4
6550
github.com/huandu/xstrings v1.3.2
6651
github.com/jaytaylor/html2text v0.0.0-20211105163654-bc68cce691ba
6752
github.com/json-iterator/go v1.1.12
6853
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
69-
github.com/kevinburke/ssh_config v1.1.0 // indirect
7054
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4
7155
github.com/klauspost/compress v1.15.0
7256
github.com/klauspost/cpuid/v2 v2.0.11
7357
github.com/lib/pq v1.10.4
7458
github.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96
7559
github.com/markbates/goth v1.69.0
7660
github.com/mattn/go-isatty v0.0.14
77-
github.com/mattn/go-runewidth v0.0.13 // indirect
7861
github.com/mattn/go-sqlite3 v1.14.12
79-
github.com/mholt/acmez v1.0.2 // indirect
8062
github.com/mholt/archiver/v3 v3.5.1
8163
github.com/microcosm-cc/bluemonday v1.0.18
82-
github.com/miekg/dns v1.1.46 // indirect
83-
github.com/minio/md5-simd v1.1.2 // indirect
8464
github.com/minio/minio-go/v7 v7.0.23
85-
github.com/minio/sha256-simd v1.0.0 // indirect
86-
github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450 // indirect
8765
github.com/msteinert/pam v1.0.0
8866
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
8967
github.com/niklasfasching/go-org v1.6.2
90-
github.com/nwaples/rardecode v1.1.3 // indirect
9168
github.com/oliamb/cutter v0.2.2
9269
github.com/olivere/elastic/v7 v7.0.31
93-
github.com/pierrec/lz4/v4 v4.1.14 // indirect
9470
github.com/pkg/errors v0.9.1
9571
github.com/pquerna/otp v1.3.0
9672
github.com/prometheus/client_golang v1.12.1
9773
github.com/quasoft/websspi v1.1.2
98-
github.com/rs/xid v1.3.0 // indirect
9974
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0
10075
github.com/sergi/go-diff v1.2.0
101-
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
10276
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546
103-
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
10477
github.com/stretchr/testify v1.7.0
10578
github.com/syndtr/goleveldb v1.0.0
10679
github.com/tstranex/u2f v1.0.0
107-
github.com/ulikunitz/xz v0.5.10 // indirect
10880
github.com/unknwon/com v1.0.1
10981
github.com/unknwon/i18n v0.0.0-20210904045753-ff3a8617e361
11082
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae
11183
github.com/unrolled/render v1.4.1
11284
github.com/urfave/cli v1.22.5
11385
github.com/xanzy/go-gitlab v0.58.0
114-
github.com/xanzy/ssh-agent v0.3.1 // indirect
11586
github.com/yohcop/openid-go v1.0.0
11687
github.com/yuin/goldmark v1.4.8
11788
github.com/yuin/goldmark-highlighting v0.0.0-20220208100518-594be1970594
11889
github.com/yuin/goldmark-meta v1.1.0
119-
go.etcd.io/bbolt v1.3.6 // indirect
12090
go.jolheiser.com/hcaptcha v0.0.4
12191
go.jolheiser.com/pwn v0.0.3
122-
go.uber.org/atomic v1.9.0 // indirect
123-
go.uber.org/multierr v1.8.0 // indirect
124-
go.uber.org/zap v1.21.0 // indirect
12592
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd
12693
golang.org/x/net v0.0.0-20220225172249-27dd8689420f
12794
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b
12895
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9
12996
golang.org/x/text v0.3.7
130-
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
13197
golang.org/x/tools v0.1.9
132-
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
13398
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
13499
gopkg.in/ini.v1 v1.66.4
135100
gopkg.in/yaml.v2 v2.4.0
@@ -139,6 +104,185 @@ require (
139104
xorm.io/xorm v1.2.5
140105
)
141106

107+
require (
108+
cloud.google.com/go v0.99.0 // indirect
109+
github.com/Azure/go-ntlmssp v0.0.0-20211209120228-48547f28849e // indirect
110+
github.com/Microsoft/go-winio v0.5.2 // indirect
111+
github.com/ProtonMail/go-crypto v0.0.0-20220113124808-70ae35bab23f // indirect
112+
github.com/PuerkitoBio/purell v1.1.1 // indirect
113+
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
114+
github.com/RoaringBitmap/roaring v0.9.4 // indirect
115+
github.com/acomagu/bufpipe v1.0.3 // indirect
116+
github.com/andybalholm/brotli v1.0.4 // indirect
117+
github.com/andybalholm/cascadia v1.3.1 // indirect
118+
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
119+
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
120+
github.com/aymerick/douceur v0.2.0 // indirect
121+
github.com/beorn7/perks v1.0.1 // indirect
122+
github.com/bgentry/speakeasy v0.1.0 // indirect
123+
github.com/bits-and-blooms/bitset v1.2.1 // indirect
124+
github.com/blevesearch/bleve_index_api v1.0.1 // indirect
125+
github.com/blevesearch/go-porterstemmer v1.0.3 // indirect
126+
github.com/blevesearch/mmap-go v1.0.3 // indirect
127+
github.com/blevesearch/scorch_segment_api/v2 v2.1.0 // indirect
128+
github.com/blevesearch/segment v0.9.0 // indirect
129+
github.com/blevesearch/snowballstem v0.9.0 // indirect
130+
github.com/blevesearch/upsidedown_store_api v1.0.1 // indirect
131+
github.com/blevesearch/vellum v1.0.7 // indirect
132+
github.com/blevesearch/zapx/v11 v11.3.3 // indirect
133+
github.com/blevesearch/zapx/v12 v12.3.3 // indirect
134+
github.com/blevesearch/zapx/v13 v13.3.3 // indirect
135+
github.com/blevesearch/zapx/v14 v14.3.3 // indirect
136+
github.com/blevesearch/zapx/v15 v15.3.3 // indirect
137+
github.com/boombuler/barcode v1.0.1 // indirect
138+
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect
139+
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
140+
github.com/cespare/xxhash/v2 v2.1.2 // indirect
141+
github.com/cloudflare/cfssl v1.6.1 // indirect
142+
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4 // indirect
143+
github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490 // indirect
144+
github.com/coreos/go-semver v0.3.0 // indirect
145+
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
146+
github.com/couchbase/go-couchbase v0.0.0-20210224140812-5740cd35f448 // indirect
147+
github.com/couchbase/gomemcached v0.1.2 // indirect
148+
github.com/couchbase/goutils v0.0.0-20210118111533-e33d3ffb5401 // indirect
149+
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
150+
github.com/davecgh/go-spew v1.1.1 // indirect
151+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
152+
github.com/dlclark/regexp2 v1.4.0 // indirect
153+
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
154+
github.com/envoyproxy/go-control-plane v0.10.1 // indirect
155+
github.com/envoyproxy/protoc-gen-validate v0.6.2 // indirect
156+
github.com/felixge/httpsnoop v1.0.2 // indirect
157+
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
158+
github.com/fsnotify/fsnotify v1.5.1 // indirect
159+
github.com/fullstorydev/grpcurl v1.8.1 // indirect
160+
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
161+
github.com/go-asn1-ber/asn1-ber v1.5.3 // indirect
162+
github.com/go-enry/go-oniguruma v1.2.1 // indirect
163+
github.com/go-git/gcfg v1.5.0 // indirect
164+
github.com/go-openapi/analysis v0.21.2 // indirect
165+
github.com/go-openapi/errors v0.20.2 // indirect
166+
github.com/go-openapi/inflect v0.19.0 // indirect
167+
github.com/go-openapi/jsonpointer v0.19.5 // indirect
168+
github.com/go-openapi/jsonreference v0.19.6 // indirect
169+
github.com/go-openapi/loads v0.21.0 // indirect
170+
github.com/go-openapi/runtime v0.21.1 // indirect
171+
github.com/go-openapi/spec v0.20.4 // indirect
172+
github.com/go-openapi/strfmt v0.21.1 // indirect
173+
github.com/go-openapi/swag v0.19.15 // indirect
174+
github.com/go-openapi/validate v0.20.3 // indirect
175+
github.com/go-stack/stack v1.8.1 // indirect
176+
github.com/goccy/go-json v0.9.5 // indirect
177+
github.com/gogo/protobuf v1.3.2 // indirect
178+
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
179+
github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188 // indirect
180+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
181+
github.com/golang/mock v1.6.0 // indirect
182+
github.com/golang/protobuf v1.5.2 // indirect
183+
github.com/golang/snappy v0.0.4 // indirect
184+
github.com/google/btree v1.0.1 // indirect
185+
github.com/google/certificate-transparency-go v1.1.2-0.20210511102531-373a877eec92 // indirect
186+
github.com/google/go-querystring v1.1.0 // indirect
187+
github.com/gorilla/css v1.0.0 // indirect
188+
github.com/gorilla/handlers v1.5.1 // indirect
189+
github.com/gorilla/mux v1.8.0 // indirect
190+
github.com/gorilla/securecookie v1.1.1 // indirect
191+
github.com/gorilla/websocket v1.4.2 // indirect
192+
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
193+
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
194+
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
195+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
196+
github.com/hashicorp/go-retryablehttp v0.7.0 // indirect
197+
github.com/hashicorp/hcl v1.0.0 // indirect
198+
github.com/imdario/mergo v0.3.12 // indirect
199+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
200+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
201+
github.com/jessevdk/go-flags v1.5.0 // indirect
202+
github.com/jhump/protoreflect v1.8.2 // indirect
203+
github.com/jonboulle/clockwork v0.2.2 // indirect
204+
github.com/josharian/intern v1.0.0 // indirect
205+
github.com/kevinburke/ssh_config v1.1.0 // indirect
206+
github.com/klauspost/pgzip v1.2.5 // indirect
207+
github.com/kr/pretty v0.3.0 // indirect
208+
github.com/kr/text v0.2.0 // indirect
209+
github.com/libdns/libdns v0.2.1 // indirect
210+
github.com/magiconair/properties v1.8.5 // indirect
211+
github.com/mailru/easyjson v0.7.7 // indirect
212+
github.com/markbates/going v1.0.0 // indirect
213+
github.com/mattn/go-runewidth v0.0.13 // indirect
214+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
215+
github.com/mholt/acmez v1.0.2 // indirect
216+
github.com/miekg/dns v1.1.46 // indirect
217+
github.com/minio/md5-simd v1.1.2 // indirect
218+
github.com/minio/sha256-simd v1.0.0 // indirect
219+
github.com/mitchellh/go-homedir v1.1.0 // indirect
220+
github.com/mitchellh/mapstructure v1.4.3 // indirect
221+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
222+
github.com/modern-go/reflect2 v1.0.2 // indirect
223+
github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450 // indirect
224+
github.com/mschoch/smat v0.2.0 // indirect
225+
github.com/nwaples/rardecode v1.1.3 // indirect
226+
github.com/oklog/ulid v1.3.1 // indirect
227+
github.com/olekukonko/tablewriter v0.0.5 // indirect
228+
github.com/pelletier/go-toml v1.9.4 // indirect
229+
github.com/pierrec/lz4/v4 v4.1.14 // indirect
230+
github.com/pmezard/go-difflib v1.0.0 // indirect
231+
github.com/prometheus/client_model v0.2.0 // indirect
232+
github.com/prometheus/common v0.32.1 // indirect
233+
github.com/prometheus/procfs v0.7.3 // indirect
234+
github.com/rivo/uniseg v0.2.0 // indirect
235+
github.com/rogpeppe/go-internal v1.8.1 // indirect
236+
github.com/rs/xid v1.3.0 // indirect
237+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
238+
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
239+
github.com/sirupsen/logrus v1.8.1 // indirect
240+
github.com/soheilhy/cmux v0.1.5 // indirect
241+
github.com/spf13/afero v1.8.0 // indirect
242+
github.com/spf13/cast v1.4.1 // indirect
243+
github.com/spf13/cobra v1.3.0 // indirect
244+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
245+
github.com/spf13/pflag v1.0.5 // indirect
246+
github.com/spf13/viper v1.10.1 // indirect
247+
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
248+
github.com/steveyen/gtreap v0.1.0 // indirect
249+
github.com/subosito/gotenv v1.2.0 // indirect
250+
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 // indirect
251+
github.com/toqueteos/webbrowser v1.2.0 // indirect
252+
github.com/ulikunitz/xz v0.5.10 // indirect
253+
github.com/x448/float16 v0.8.4 // indirect
254+
github.com/xanzy/ssh-agent v0.3.1 // indirect
255+
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
256+
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
257+
go.etcd.io/bbolt v1.3.6 // indirect
258+
go.etcd.io/etcd/api/v3 v3.5.1 // indirect
259+
go.etcd.io/etcd/client/pkg/v3 v3.5.1 // indirect
260+
go.etcd.io/etcd/client/v2 v2.305.1 // indirect
261+
go.etcd.io/etcd/client/v3 v3.5.0-alpha.0 // indirect
262+
go.etcd.io/etcd/etcdctl/v3 v3.5.0-alpha.0 // indirect
263+
go.etcd.io/etcd/pkg/v3 v3.5.0-alpha.0 // indirect
264+
go.etcd.io/etcd/raft/v3 v3.5.0-alpha.0 // indirect
265+
go.etcd.io/etcd/server/v3 v3.5.0-alpha.0 // indirect
266+
go.etcd.io/etcd/tests/v3 v3.5.0-alpha.0 // indirect
267+
go.etcd.io/etcd/v3 v3.5.0-alpha.0 // indirect
268+
go.mongodb.org/mongo-driver v1.8.2 // indirect
269+
go.uber.org/atomic v1.9.0 // indirect
270+
go.uber.org/multierr v1.8.0 // indirect
271+
go.uber.org/zap v1.21.0 // indirect
272+
golang.org/x/mod v0.5.1 // indirect
273+
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
274+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
275+
google.golang.org/appengine v1.6.7 // indirect
276+
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
277+
google.golang.org/grpc v1.43.0 // indirect
278+
google.golang.org/protobuf v1.27.1 // indirect
279+
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
280+
gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect
281+
gopkg.in/warnings.v0 v0.1.2 // indirect
282+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
283+
sigs.k8s.io/yaml v1.2.0 // indirect
284+
)
285+
142286
replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1
143287

144288
replace github.com/markbates/goth v1.68.0 => github.com/zeripath/goth v1.68.1-0.20220109111530-754359885dce

‎modules/util/net.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ import (
88
"net"
99
)
1010

11-
// IsIPPrivate for net.IP.IsPrivate. TODO: replace with `ip.IsPrivate()` if min go version is bumped to 1.17
1211
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
12+
return ip.IsPrivate()
1913
}

‎modules/util/net_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2022 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+
"testing"
10+
11+
"github.com/stretchr/testify/assert"
12+
)
13+
14+
func TestIsIPPPrivate(t *testing.T) {
15+
cases := []struct {
16+
ip string
17+
isPrivate bool
18+
}{
19+
// case 0
20+
{
21+
ip: "127.0.0.1",
22+
isPrivate: false, // TODO: according to go, this isn't private?
23+
},
24+
// case 1
25+
{
26+
ip: "127.1.2.3",
27+
isPrivate: false, // TODO: according to go, this isn't private?
28+
},
29+
// case 2
30+
{
31+
ip: "10.255.255.0",
32+
isPrivate: true,
33+
},
34+
// case 3
35+
{
36+
ip: "8.8.8.8",
37+
isPrivate: false,
38+
},
39+
// case 4
40+
{
41+
ip: "::1",
42+
isPrivate: false, // TODO: according to go, this isn't private?
43+
},
44+
// case 4
45+
{
46+
ip: "2a12:7c40::f00d",
47+
isPrivate: false,
48+
},
49+
}
50+
51+
for n, c := range cases {
52+
i := net.ParseIP(c.ip)
53+
p := IsIPPrivate(i)
54+
assert.Equal(t, c.isPrivate, p, "case %d: should be equal", n)
55+
}
56+
}

0 commit comments

Comments
 (0)
Please sign in to comment.