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

Beginner question about write handers for RoundRobinIPMapper #459

Open
sarahhercock opened this issue Jul 14, 2020 · 2 comments
Open

Beginner question about write handers for RoundRobinIPMapper #459

sarahhercock opened this issue Jul 14, 2020 · 2 comments

Comments

@sarahhercock
Copy link

Hi, I'm new to using click and am attempting to use it to dynamically redirect TCP flows among a few servers.

I have a RoundRobinIPMapper defining patterns for an IPRewriter. It simply rewrites the destination IP to the IP address of one of my servers.

My issue is that I cannot update the configuration of the RoundRobinIPMapper from a controller through a tcp ControlSocket element. I can successfully call write handlers for other elements, but the IP mapper element does not have write permissions, only read.

I would be incredibly grateful if anyone has an idea of steps I can take to solve the problem, thank you in advance!

@ahenning
Copy link

If the objective is to solve this in code then a custom version of the element can be made with new write handlers to change the patterns. Maybe also take a look at can_live_reconfigure.

But if the objective is just to simply update element configuration infrequently, then hot reconfigure is an option:
"-R, --allow-reconfigure Provide a writable 'hotconfig' handler."

To use this option start click initially with reconfigure enabled:
click -R -f ipmapper-test.click

Then the config can updated and hotswapped using the hotconfig write handler. Here is an idiom to replace the live config:
perl -e 'print "write hotconfig "; open(my $f, "<", "ipmapper-test.click") ; while (<$f>) { chomp; print $_ . " "; } print "\nquit\n";' | nc localhost 13000

note the hotconfig handler has a default 65K input limit.

@sarahhercock
Copy link
Author

Thank you so much, this works well!

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

No branches or pull requests

2 participants