Skip to content

Commit b6b46b7

Browse files
committed
Fix linter errors
1 parent 07f19ac commit b6b46b7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

geoblock.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"fmt"
77
"io"
8+
"io/fs"
89
"log"
910
"net"
1011
"net/http"
@@ -110,11 +111,11 @@ func New(ctx context.Context, next http.Handler, config *Config, name string) (h
110111
}
111112

112113
// set default HTTP status code for denied requests if non other is supplied
113-
deniedRequestHttpStatusCode, err := getHttpStatusCodeDeniedRequest(config.HTTPStatusCodeDeniedRequest)
114+
deniedRequestHTTPStatusCode, err := getHTTPStatusCodeDeniedRequest(config.HTTPStatusCodeDeniedRequest)
114115
if err != nil {
115116
return nil, err
116117
}
117-
config.HTTPStatusCodeDeniedRequest = deniedRequestHttpStatusCode
118+
config.HTTPStatusCodeDeniedRequest = deniedRequestHTTPStatusCode
118119

119120
// build allowed IP and IP ranges lists
120121
allowedIPAddresses, allowedIPRanges := parseAllowedIPAddresses(config.AllowedIPAddresses, infoLogger)
@@ -235,7 +236,7 @@ func (a *GeoBlock) allowDenyIPAddress(requestIPAddr *net.IP, req *http.Request)
235236
}
236237

237238
// check if the GeoIP database contains an entry for the request IP address
238-
allowed, countryCode := a.allowDenyCachedRequestIp(requestIPAddr, req)
239+
allowed, countryCode := a.allowDenyCachedRequestIP(requestIPAddr, req)
239240

240241
if a.addCountryHeader && len(countryCode) > 0 {
241242
req.Header.Set(countryHeader, countryCode)
@@ -244,7 +245,7 @@ func (a *GeoBlock) allowDenyIPAddress(requestIPAddr *net.IP, req *http.Request)
244245
return allowed
245246
}
246247

247-
func (a *GeoBlock) allowDenyCachedRequestIp(requestIPAddr *net.IP, req *http.Request) (bool, string) {
248+
func (a *GeoBlock) allowDenyCachedRequestIP(requestIPAddr *net.IP, req *http.Request) (bool, string) {
248249
ipAddressString := requestIPAddr.String()
249250
cacheEntry, ok := a.database.Get(ipAddressString)
250251

@@ -492,7 +493,7 @@ func isPrivateIP(ip net.IP, privateIPBlocks []*net.IPNet) bool {
492493
return false
493494
}
494495

495-
func getHttpStatusCodeDeniedRequest(code int) (int, error) {
496+
func getHTTPStatusCodeDeniedRequest(code int) (int, error) {
496497
if code != 0 {
497498
// check if given status code is valid
498499
if len(http.StatusText(code)) == 0 {
@@ -567,7 +568,8 @@ func initializeLogFile(logFilePath string, logger *log.Logger) (*os.File, error)
567568
return nil, fmt.Errorf("folder is not writable: %s", logFilePath)
568569
}
569570

570-
logFile, err := os.OpenFile(logFilePath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
571+
filePermissions := fs.FileMode(0666)
572+
logFile, err := os.OpenFile(logFilePath, os.O_RDWR|os.O_CREATE|os.O_APPEND, filePermissions)
571573
if err != nil {
572574
logger.Printf("Failed to open log file: %v\n", err)
573575
return nil, err

geoblock_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ func TestMultipleAllowedCountry(t *testing.T) {
153153
assertStatusCode(t, recorder.Result(), http.StatusOK)
154154
}
155155

156-
// TODO: test multiple IP addresses in the header, maybee switch the order to test if the same behaviour?
157-
158156
func TestMultipleIpAddresses(t *testing.T) {
159157
cfg := createTesterConfig()
160158

0 commit comments

Comments
 (0)