From 88428961dd061b1d1ff444ade4f4bda554289af5 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 19 Aug 2020 14:02:03 -0400 Subject: [PATCH] natpmp: also detect 172.16.0/0/12 ips as private. --- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 4 ++-- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index 4f91709a2f..5657ce8c8c 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -445,8 +445,8 @@ host = do ) <|> ( flag' NatWhenPrivateNetwork $ long "port-forwarding-when-internal" - <> help ("Try asking the router to forward when ip is 192.168.0.0/24 or" <> - "10.0.0.0/8 (default).") + <> help ("Try asking the router to forward when ip is 192.168.0.0/16, " <> + "172.16.0.0/12 or 10.0.0.0/8 (default).") <> hidden ) <|> (pure $ NatWhenPrivateNetwork) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index bfb0ae61e9..18493b342b 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -104,6 +104,8 @@ portThread q stderr = do Left err -> do likelyIPAddress >>= \case Just ip@(192, 168, _, _) -> warnBehindRouterAndErr ip err + Just ip@(172, x, _, _) + | (x >= 16 && x <= 31) -> warnBehindRouterAndErr ip err Just ip@(10, _, _, _) -> warnBehindRouterAndErr ip err _ -> assumeOnPublicInternet Right pmp -> foundRouter pmp @@ -245,6 +247,8 @@ likelyBehindRouter :: MonadIO m => m Bool likelyBehindRouter = do likelyIPAddress >>= \case Just ip@(192, 168, _, _) -> pure True + Just ip@(172, x, _, _) + | (x >= 16 && x <= 31) -> pure True Just ip@(10, _, _, _) -> pure True _ -> pure False