Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method for plugin to set HTTP headers #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chovanecadam
Copy link

Hi. This MR adds a method for plugins to set HTTP headers on connection.

Proposed changes

The function generate_headers is called every time a new websocket connection is initialized and the headers are added after headers set on the command line. The plugin can keep state and change the headers for every new connection (e.g. set X-Forwarded-For to a new value, or update some token), which wasn't possible until now.

What remains to be done

The diagram in the repository should be updated. It would be great if the source of the diagram was in the repository too with instructions on how to generate it. Could you share the source of the diagram please?

Before writing more docs I would like to hear your thoughts on the change. Thanks for the tool, it's great.

@chovanecadam
Copy link
Author

An example use-case:

class MyPlugin(Plugin):
    def init(self):
        self.random_ips = iter(ipaddress.IPv4Network("10.0.0.0/8"))

    def headers_callback(self):
        return [f"X-Forwarded-For: {next(self.random_ips)}"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant