To stay in line with defaultPort and defaultHttpConf, I would also call it
defaultFamily and defaultBind, rest LGTM.

On Tue, Oct 27, 2015 at 11:21 AM 'Klaus Aehlig' via ganeti-devel <
[email protected]> wrote:

> Ganeti has a function providing the default configuration
> for Snap-based daemons (including, e.g., the monitoring daemon).
> However, if a bind-address is not explicitly specified, we should
> bind on all interfaces for the default IP family---and not for IPv4.
> Fix this.
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  src/Ganeti/Utils/Http.hs | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/src/Ganeti/Utils/Http.hs b/src/Ganeti/Utils/Http.hs
> index 670b939..2267024 100644
> --- a/src/Ganeti/Utils/Http.hs
> +++ b/src/Ganeti/Utils/Http.hs
> @@ -43,17 +43,21 @@ module Ganeti.Utils.Http
>  import Control.Monad (liftM)
>  import Data.ByteString.Char8 (pack)
>  import Data.Map ((!))
> +import Data.Maybe (fromMaybe)
>  import Network.BSD (getServicePortNumber)
> +import qualified Network.Socket as Socket
>  import Snap.Core (Snap, writeBS, modifyResponse, setResponseStatus)
>  import Snap.Http.Server.Config ( Config, ConfigLog(ConfigFileLog),
> emptyConfig
>                                 , setAccessLog, setErrorLog, setCompression
>                                 , setVerbose, setPort, setBind )
>  import qualified Text.JSON as J
>
> +import Ganeti.BasicTypes (GenericResult(..))
>  import qualified Ganeti.Constants as C
>  import Ganeti.Daemon (DaemonOptions(..))
>  import Ganeti.Runtime ( GanetiDaemon, daemonName
>                        , daemonsExtraLogFile, ExtraLogReason(..))
> +import qualified Ganeti.Ssconf as Ssconf
>  import Ganeti.Utils (withDefaultOnIOError)
>
>  -- * Configuration handling
> @@ -77,10 +81,11 @@ httpConfFromOpts daemon opts = do
>    defaultPort <- withDefaultOnIOError standardPort
>                   . liftM fromIntegral
>                   $ getServicePortNumber name
> +  defFamily <- Ssconf.getPrimaryIPFamily Nothing
> +  let defBind = if defFamily == Ok Socket.AF_INET6 then "::" else "*"
>    return .
> -    setPort
> -      (maybe defaultPort fromIntegral (optPort opts)) .
> -    maybe id (setBind . pack) (optBindAddress opts)
> +    setPort (maybe defaultPort fromIntegral (optPort opts)) .
> +    setBind (pack . fromMaybe defBind $ optBindAddress opts)
>      $ defaultHttpConf accessLog errorLog
>
>
> --
> 2.6.0.rc2.230.g3dd15c0
>
> --
Lisa Velden
Software Engineer
[email protected]

Google Germany GmbH
Dienerstraße 12
80331 München

Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

Reply via email to