driesmp / dynamicprefixvici Goto Github PK
View Code? Open in Web Editor NEWAdds the specified pool to strongSwan through the VICI protocol
License: MIT License
Adds the specified pool to strongSwan through the VICI protocol
License: MIT License
Right now, we take the prefix as is and add it to Strongswan, we should make it a command line arguments to specify the sla-id, the sla-size and prefix size.
Let's say we get a prefix fd00::1/56 as example, we should be able to specify eg; -sla-id 1,-sla-length 8, and -prefix-length 120.
Which results in the following prefix being added; fd00:0000:0000:0001::1/120.
Another example: sla-id 2, sla-length 4 results with prefix-length 64 in, fd00:0000:0000:0020::1/64. Similar code is available in dhcpcd to add the prefix on interfaces with these variables.
https://www.daemon-systems.org/man/dhcpcd.conf.5.html (see ia_pd section for logic)
getopt() seems the best here. sla-id can have a default value of 0, sla-size also has 0 as default value and prefix size has a default value of 97 (this is the max Strongswan supports).
sla_size should not be needed to do the necessary calculations for the address manipulation.
Take a look at the dhcp6_delegateaddr function in https://github.com/NetworkConfiguration/dhcpcd/blob/master/src/dhcp6.c
Also explained in the manual page of dhcpcd under "ia_pd": https://www.daemon-systems.org/man/dhcpcd.conf.5.html
Running "/usr/local/sbin/dynamicprefixvici -p "$prefix" -n "global-ipv6"" with the newest codebase results in "pool_name and prefix_address are required, see -h for usage". Both are specified.
I just noticed that we included some headers for the sla logic, but this was deleted.
Can we delete some headers?
Right now we just print the message to the console, does it make sense for example to exit(1) when "success: no"?
It doesn't have a lot of value to print it to the console except exit accordingly when it did not succeed.
Right now, "new_dhcp6_ia_pd1_prefix1" and "old_dhcp6_ia_pd1_prefix1" is hardcoded, it should be overwritable by specifying it as a command line argument, like "-old-prefixname" and "-new-prefixname" to make it more suitable for others to use it. The old and new prefix name has a default value equal to the current hardcoded one. getopt() seems the best here.
Right now, "global-ipv6" is hardcoded, it should probably be specified as a command line argument, like "-poolname global-ipv6" to make it more suitable for others to use it. The pool name should not have a default value, it should always be specified. (required). getopt() seems the best here.
Because of the CheckAddress function, we currently don't allow IPv4 pools to be added.
It should still be possible to do so, even though I do not require that functionality myself.
My opinion is to just get rid of the sla logic all together, its making the program more complicated than it should be.
So basically reverting the commit that added the functionality.
The NASA C-style was chosen, should convert one of these days.
Currently the return message from vici is not prossesed, so it is unsure whether or not the address pool is succesfully updated.
Lets hard specify the prefix to use on the CLI, so we can drop all the not defined logical or old and new not being the same.
We can adjust poolname to the -n flag, and prefix to the -p flag, we always add the pool when the program is being run (no logic, no checks). We can easily extract the env variable in a shell script to pass it along dynamicprerfixvici to add it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.