Skip to content

Add XFF/Forwarded custom filter strategy? #1

@adam-p

Description

@adam-p

It's possible that a user of the library may wish to use our X-Forwarded-For and Forwarded handling/parsers, but choose which IP to use in a different way (than "rightmost non-private", "trusted count", etc.). So they would like strategies like:

func NewLeftmostCustomStrategy(headerName string, filter func(ip string) bool) ...

func NewRightmostCustomStrategy(headerName string, filter func(ip string) bool) ...

Those would choose the left/rightmost IP for which filter returns true.

I don't want to add this just because someone "might" want them, but if anyone has any solid examples/use cases, please let us know here.

If we do add this, we might want to also export privateAndLocalRanges and/or isPrivateOrLocal. Those are likely to be needed by a custom filter. (Possibly other helpers, like goodIPAddr?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions