Skip to content

Commit

Permalink
Revert "fix: change plugin receiver from value to pointer"
Browse files Browse the repository at this point in the history
This reverts commit dd04458.
  • Loading branch information
nscuro committed Apr 3, 2022
1 parent dd04458 commit be49915
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func New(_ context.Context, next http.Handler, cfg *Config, name string) (http.H
}

// ServeHTTP implements the http.Handler interface.
func (p *Plugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
func (p Plugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
if !p.enabled {
p.next.ServeHTTP(rw, req)
return
Expand All @@ -108,7 +108,7 @@ func (p *Plugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
}

// GetRemoteIPs collects the remote IPs from the X-Forwarded-For and X-Real-IP headers.
func (p *Plugin) GetRemoteIPs(req *http.Request) []string {
func (p Plugin) GetRemoteIPs(req *http.Request) []string {
uniqIPs := make(map[string]struct{})

if xff := req.Header.Get("x-forwarded-for"); xff != "" {
Expand Down Expand Up @@ -158,7 +158,7 @@ func (e NotAllowedError) Error() (err string) {
}

// CheckAllowed checks whether a given IP address is allowed according to the configured allowed countries.
func (p *Plugin) CheckAllowed(ip string) error {
func (p Plugin) CheckAllowed(ip string) error {
country, err := p.Lookup(ip)
if err != nil {
return fmt.Errorf("lookup of %s failed: %w", ip, err)
Expand Down Expand Up @@ -193,7 +193,7 @@ func (p *Plugin) CheckAllowed(ip string) error {
}

// Lookup queries the ip2location database for a given IP address.
func (p *Plugin) Lookup(ip string) (string, error) {
func (p Plugin) Lookup(ip string) (string, error) {
record, err := p.db.Get_country_short(ip)
if err != nil {
return "", err
Expand Down

0 comments on commit be49915

Please sign in to comment.