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 config file support #42

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

AASanchezA
Copy link

first implementation for config file support issue #17

@@ -365,6 +373,16 @@ def parse_args_and_env(args=None, environ=os.environ):
env = parse_env(environ)
return p, args, env

def parse_routes_from_list(args, routes):
for x in routes:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameter x need to parse by net_or_host_param() before checking.
Otherwise it will not handle the subnet and alias cases.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check 2f0b464

@scw1109
Copy link

scw1109 commented Apr 15, 2020

Any idea what would the startup performance looks like when putting in a large configuration file?
I did i brief try with 10k more line of subnet configuration, it doesn't look good.
But I am not familiar with vpn-slice enough to get into details.

@AASanchezA
Copy link
Author

for my use case I try with 10-20 lines, if you need 10k line are you sure you need to slice the vpn tunel? I will check the performance when I get some time.
thanks for the comments

@AASanchezA
Copy link
Author

I tested the file parsing, here are the results:

  • 10 lines file
got config file: vpn_slice_10.txt
elapsed time: 8.869171142578125e-05 s; number lines: 10
Must be called as vpnc-script, with $reason set; use --help for more information
  • 10k lines
got config file: vpn_slice_10k.txt
elapsed time: 0.0041501522064208984 s; number lines: 10000
Must be called as vpnc-script, with $reason set; use --help for more information

the bottle neck should be somewhere else, not in the file parsing

@dlenski
Copy link
Owner

dlenski commented Apr 15, 2020

Is there a reason that you wrote this to accept only routes/hostnames/aliases in the configuration file, and not other arbitrary arguments?

@AASanchezA
Copy link
Author

no reason, I took the idea from here #17 (comment)
but, yeah it could be extended to use a yml or json or toml, what do you think?

@AASanchezA
Copy link
Author

last commit d988aa3 enable from_prefix_chars option for ArgumentParser which enable the parse from file by prefixing the character "@" to config filename

vpn-slice @list_of_routes.txt

with this change, option --config could be remove, what do you think?
also remove some complexity introduce by file parsing

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.

3 participants