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

Make --redir work again #36

Merged
merged 3 commits into from
Jul 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions arm_now/arm_now.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Options:
--sync Synchronize the current directory with the vm home.
--redir protocol:host::guest Redirect the host port to the guest (example: --redir tcp:8000::80)
--redir protocol:host:guest Redirect the host port to the guest (example: --redir tcp:8000:80)
--clean Clean the current image before starting.
--add-qemu-options=<options> Add options to qemu-system-<arch>.
(example: --add-qemu-options="-sandbox on" to Enable seccomp mode 2 system call filter )
Expand Down Expand Up @@ -249,19 +249,22 @@ def check_dependencies_or_exit():
sys.exit(1)


re_redir = re.compile(r"(tcp|udp):\d+::\d+")

re_redir = re.compile(r"(tcp|udp):\d+:\d+")

def convert_redir_to_qemu_args(redir):
args = ["-nic user"]

for r in redir:
if not re_redir.match(r):
pred("ERROR: Invalid argument: --redir {}".format(r))
print("example:")
print("\tredirect tcp host 8000 to guest 80: --redir tcp:8000::80")
print("\tredirect udp host 4444 to guest 44: --redir udp:4444::44")
print("\tredirect tcp host 8000 to guest 80: --redir tcp:8000:80")
print("\tredirect udp host 4444 to guest 44: --redir udp:4444:44")
sys.exit(1)
return ''.join(map("-redir {} ".format, redir))

args.append("hostfwd={}::{}-:{}".format(*r.split(":")))

return ",".join(args) + " "

def do_resize(size, correct):
""" Resize filesystem.
Expand Down