aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-03-18 20:17:57 +0100
committerGitHub <noreply@github.com>2022-03-18 20:17:57 +0100
commit60fbaa90683add2a8af891fc2ca8448b9b75c92e (patch)
tree2cbb35f6b260986750452f0659623dd1eda59ae6
parentfda5b9fc3e6dd831987979f37fe39f08963b875d (diff)
downloadgitea-60fbaa90683add2a8af891fc2ca8448b9b75c92e.tar.gz
gitea-60fbaa90683add2a8af891fc2ca8448b9b75c92e.zip
remove not needed (#19128)
-rw-r--r--modules/hostmatcher/hostmatcher.go6
-rw-r--r--modules/util/net.go13
-rw-r--r--modules/util/net_test.go56
3 files changed, 2 insertions, 73 deletions
diff --git a/modules/hostmatcher/hostmatcher.go b/modules/hostmatcher/hostmatcher.go
index 9492a479f1..6c5c2a74d9 100644
--- a/modules/hostmatcher/hostmatcher.go
+++ b/modules/hostmatcher/hostmatcher.go
@@ -8,8 +8,6 @@ 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.
@@ -104,11 +102,11 @@ func (hl *HostMatchList) checkIP(ip net.IP) bool {
for _, builtin := range hl.builtins {
switch builtin {
case MatchBuiltinExternal:
- if ip.IsGlobalUnicast() && !util.IsIPPrivate(ip) {
+ if ip.IsGlobalUnicast() && !ip.IsPrivate() {
return true
}
case MatchBuiltinPrivate:
- if util.IsIPPrivate(ip) {
+ if ip.IsPrivate() {
return true
}
case MatchBuiltinLoopback:
diff --git a/modules/util/net.go b/modules/util/net.go
deleted file mode 100644
index 0339325dc3..0000000000
--- a/modules/util/net.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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"
-)
-
-func IsIPPrivate(ip net.IP) bool {
- return ip.IsPrivate()
-}
diff --git a/modules/util/net_test.go b/modules/util/net_test.go
deleted file mode 100644
index 93a95ab123..0000000000
--- a/modules/util/net_test.go
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2022 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"
- "testing"
-
- "github.com/stretchr/testify/assert"
-)
-
-func TestIsIPPPrivate(t *testing.T) {
- cases := []struct {
- ip string
- isPrivate bool
- }{
- // case 0
- {
- ip: "127.0.0.1",
- isPrivate: false, // TODO: according to go, this isn't private?
- },
- // case 1
- {
- ip: "127.1.2.3",
- isPrivate: false, // TODO: according to go, this isn't private?
- },
- // case 2
- {
- ip: "10.255.255.0",
- isPrivate: true,
- },
- // case 3
- {
- ip: "8.8.8.8",
- isPrivate: false,
- },
- // case 4
- {
- ip: "::1",
- isPrivate: false, // TODO: according to go, this isn't private?
- },
- // case 4
- {
- ip: "2a12:7c40::f00d",
- isPrivate: false,
- },
- }
-
- for n, c := range cases {
- i := net.ParseIP(c.ip)
- p := IsIPPrivate(i)
- assert.Equal(t, c.isPrivate, p, "case %d: should be equal", n)
- }
-}