saschpe/libvirt-hook-qemu

Use Range port

Opened this issue · 4 comments

Hi,

I have been using this scripts for while and I am pretty satisfied with them, great job and so great you shared it. Anyhow some days ago I needed to open a port range so i modified a little the script and the schema in order to accept an entrance like:

"port_range": [{"range": [10000, 10128], "protocol": "udp"}]

Assuming that the mapping is done using the same port numbers. I was wondering if it would be of your interest to include such a modifications in your code, I can provide a Pull Request if you'd like. Some modifications or enhancements could be done, like provide start port number and the number of port to open (instead of min-max ports).

Thanks,
David

Sure! I'd be great to have unit tests for that too

Hi, just done the pull request. I did not have time now to make the unit test, I foresee that maybe tomorrow I am gonna have time to make them. You'll see I am suggesting a different name for the script, as I am no using it for qemu but lxc.

I sure do wish this came with an example.

In case anyone ever comes across this here is an example of usage in hooks.json:

                               "port_range": [
                                       {
                                               "init_port": 5060,
                                               "ports_num": 21,
                                               "protocol": "udp"
                                       },
                                       {
                                               "init_port": 10000,
                                               "ports_num": 10001,
                                               "protocol": "udp"
                                       }
                               ]

Obviously this is for Asterisk but unfortunately it does not work. There is some problem with the data going FROM the vm -> host -> end_user that just isnt working.