Re: [Haskell-cafe] Binding a socket to all interfaces

2011-09-20 Thread Johan Tibell
Hi Michael,

Kazu recently fixed this (in the stable branch on GitHub) in
Network.listenOn but perhaps the more basic Network.Socket.listen should
also be changed. Lets discuss what's the right thing to do in this thread.

On Wed, Sep 21, 2011 at 1:38 PM, Michael Snoyman wrote:

> Hi,
>
> One of the recurring issues that comes up in Warp is binding to IPv4
> versus IPv6 hosts. Our current code is available at [1]. It was
> updated to look like that in this commit [2] in order to support both
> IPv4 and IPv6 hosts by default. However, now it seems than on Debian
> and FreeBSD, it *only* responds to IPv6 by default[3][4]. I'm frankly
> stumped at this point on how to have our cake and eat it too.
>
> Does anyone have an idea of the correct incantation to get Warp to do
> the Right Thing(tm) here? And if not, is there any advice on sensible
> default behavior? I'm considering allowing a few special host values:
>
> * "*" (default, what we have now): Make this bind to IPv4
> * "ipv4": Again, bind to IPv4. Guaranteed not to change in the future
> * "ipv6": Bind to IPv6.
>
> Michael
>
> [1]
> https://github.com/yesodweb/wai/blob/master/warp/Network/Wai/Handler/Warp.hs#L119
> [2]
> https://github.com/snoyberg/warp/commit/02c1396c86e3fceb48cbe7df58cb631c804e24d4
> [3] https://github.com/snoyberg/warp/issues/9
> [4]
> http://stackoverflow.com/questions/7486257/yesod-devel-server-only-listening-on-ipv6
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Binding a socket to all interfaces

2011-09-21 Thread 山本和彦
Hello,

My fix intended that Haskell code behaves the same in various
environments. That is, one socket catches both IPv4 and IPv6. And the
fix works even in both IPv4-only env and IPv6-only env.

Johan's observation is correct. Network.listenOn is alreay fixed but
Network.Socket.listen, which Warp relies on, is not fixed yet. I will
try to fix it. When the next version of the network library will be
released, the problem will disappear, I hope.

--Kazu

> Hi Michael,
> 
> Kazu recently fixed this (in the stable branch on GitHub) in Network.listenOn
> but perhaps the more basic Network.Socket.listen should also be changed. Lets
> discuss what's the right thing to do in this thread.
> 
> On Wed, Sep 21, 2011 at 1:38 PM, Michael Snoyman  wrote:
> 
>> Hi,
>> 
>> One of the recurring issues that comes up in Warp is binding to IPv4
>> versus IPv6 hosts. Our current code is available at [1]. It was
>> updated to look like that in this commit [2] in order to support both
>> IPv4 and IPv6 hosts by default. However, now it seems than on Debian
>> and FreeBSD, it *only* responds to IPv6 by default[3][4]. I'm frankly
>> stumped at this point on how to have our cake and eat it too.
>> 
>> Does anyone have an idea of the correct incantation to get Warp to do
>> the Right Thing(tm) here? And if not, is there any advice on sensible
>> default behavior? I'm considering allowing a few special host values:
>> 
>> * "*" (default, what we have now): Make this bind to IPv4
>> * "ipv4": Again, bind to IPv4. Guaranteed not to change in the future
>> * "ipv6": Bind to IPv6.
>> 
>> Michael
>> 
>> [1] https://github.com/yesodweb/wai/blob/master/warp/Network/Wai/Handler/
> Warp.hs#L119
>> [2] https://github.com/snoyberg/warp/commit/
> 02c1396c86e3fceb48cbe7df58cb631c804e24d4
>> [3] https://github.com/snoyberg/warp/issues/9
>> [4] http://stackoverflow.com/questions/7486257/
> yesod-devel-server-only-listening-on-ipv6
>> 
>> ___
>> Haskell-Cafe mailing list
>> Haskell-Cafe@haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Binding a socket to all interfaces

2011-09-21 Thread Johan Tibell
Hi,

On Wed, Sep 21, 2011 at 7:38 PM, Kazu Yamamoto  wrote:

> Johan's observation is correct. Network.listenOn is alreay fixed but
> Network.Socket.listen, which Warp relies on, is not fixed yet. I will
> try to fix it. When the next version of the network library will be
> released, the problem will disappear, I hope.
>

We should consider how we fix this. Right now N.S.listen just wraps the
underlying system call. Is that the right place to set socket options?
Perhaps we should set them when creating the socket instead?

-- Johan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Binding a socket to all interfaces

2011-09-21 Thread 山本和彦
Hi,

> We should consider how we fix this. Right now N.S.listen just wraps the
> underlying system call. Is that the right place to set socket options? Perhaps
> we should set them when creating the socket instead?

Yes, of course.

If I remember correctly, this option works only between socket() and
listen(). I need to check that this option is effective to all sockets
or only to listing sockets. Anyway, I will try this in the next week.

I used to be an expert of IPv6 but I forget many things recently...
I should remember.

--Kazu

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Binding a socket to all interfaces

2011-09-28 Thread 山本和彦
Hello,

Sorry for the delay but I made a patch and sent a pull request:

https://github.com/haskell/network/pull/18

After consideration, I realized that Johan's opinion is better.
Please read the comment of this request above.

When the next network package will be released, this problem will
disappear, I hope. We don't have to change Warp at all.

--Kazu

> Hi,
> 
>> We should consider how we fix this. Right now N.S.listen just wraps the
>> underlying system call. Is that the right place to set socket options? 
>> Perhaps
>> we should set them when creating the socket instead?
> 
> Yes, of course.
> 
> If I remember correctly, this option works only between socket() and
> listen(). I need to check that this option is effective to all sockets
> or only to listing sockets. Anyway, I will try this in the next week.
> 
> I used to be an expert of IPv6 but I forget many things recently...
> I should remember.
> 
> --Kazu
> 
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Binding a socket to all interfaces

2011-09-28 Thread Johan Tibell
I've released a new version of network, 2.3.0.6, that contains the fix.

On Wed, Sep 28, 2011 at 1:34 AM, Kazu Yamamoto  wrote:

> Hello,
>
> Sorry for the delay but I made a patch and sent a pull request:
>
>https://github.com/haskell/network/pull/18
>
> After consideration, I realized that Johan's opinion is better.
> Please read the comment of this request above.
>
> When the next network package will be released, this problem will
> disappear, I hope. We don't have to change Warp at all.
>
> --Kazu
>
> > Hi,
> >
> >> We should consider how we fix this. Right now N.S.listen just wraps the
> >> underlying system call. Is that the right place to set socket options?
> Perhaps
> >> we should set them when creating the socket instead?
> >
> > Yes, of course.
> >
> > If I remember correctly, this option works only between socket() and
> > listen(). I need to check that this option is effective to all sockets
> > or only to listing sockets. Anyway, I will try this in the next week.
> >
> > I used to be an expert of IPv6 but I forget many things recently...
> > I should remember.
> >
> > --Kazu
> >
> > ___
> > Haskell-Cafe mailing list
> > Haskell-Cafe@haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe