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

Ipv6 #11

Closed
hellow554 opened this issue May 22, 2018 · 5 comments
Closed

Ipv6 #11

hellow554 opened this issue May 22, 2018 · 5 comments

Comments

@hellow554
Copy link

You are currently only allow Ipv4 access to the host, but no IPv6.
I would like to see either a command line argument to enable one/both or make dual stack the default :)

@svenstaro
Copy link
Owner

Good idea. Will do. Of course, you can also go ahead and make a PR if you would like to take a stab at this yourself.

@hellow554
Copy link
Author

hellow554 commented May 22, 2018

I just discovered, that it is already capable of running Ipv6, just pass e.g. :: as interface and it will serve it just fine.

cargo run --release -- -i '::' .
    Finished release [optimized] target(s) in 1.25s
    Running `target/release/miniserve -i '::' .`
miniserve is serving your files at http://:::8080
Currently serving path /tmp/tmp.Mkfpy6fbam/miniserve

(please note the "wrong" format:

http://:::8080
       ^-- here

it should be http://[::]:8080)

There is a problem though.
On linux, it will bind on both, IPv4 and IPv6. On windows on the otherhand, it will only bind on either (source).
So I have a few ideas in mind.

  1. Check if it is an IPv6 addr and try to bind on both. This will mean we get an error on Linux, but not on windows. Shall be check the OS (on compile- or runtime?) and do different things?
  2. Check explicitly in is_valid_interface for Ipv4 addr (which is trivial :) ) and only accept IPv4 addr on --if and add another option (maybe --if6)?
  3. When default is given (no --if parameter at all) do a double bind, and only if either option is given (--if or --if6) bind to that protocol but not on the other (unless both options are given)
  4. ??? -> Profit?

@svenstaro
Copy link
Owner

One more note: If it is an IPv6, the URL should be displayed like this: `http://[::]:8080'.

@svenstaro
Copy link
Owner

@hellow554 Thanks for considering this so thoroughly!

About your 1.: I don't quite understand. How would you even go about binding on both interfaces if you provide an IPv6? It could just be that an interface does not even have an IPv4 even if it has an IPv6. Basically, I think that if an explicit IPv4 or IPv6 is given, we should not try to bind on anything except those provided.

I think --if should accept both IPv6 and IPv4. There doesn't really seem to be an issue with that. Also, we should allow for --if to be called multiple times.

  1. I agree with this. It should try to bind on all interfaces on both protocols in the correct way on all OS.

@svenstaro
Copy link
Owner

Fixed in v0.2.0.

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