| 30 | } |
| 31 | |
| 32 | func (f DstAddrFilter) Access(ctx context.Context, req *http.Request, username, network, address string) error { |
| 33 | addrport, err := netip.ParseAddrPort(address) |
| 34 | if err != nil { |
| 35 | // not an IP address, no action needed |
| 36 | return f.next.Access(ctx, req, username, network, address) |
| 37 | } |
| 38 | addr := addrport.Addr().Unmap() |
| 39 | for _, pfx := range f.pfxList { |
| 40 | if pfx.Contains(addr) { |
| 41 | return ErrDestinationAddressNotAllowed{addr, pfx} |
| 42 | } |
| 43 | } |
| 44 | return f.next.Access(ctx, req, username, network, address) |
| 45 | } |