natpmp: also detect 172.16.0/0/12 ips as private.

This commit is contained in:
Elliot Glaysher 2020-08-19 14:02:03 -04:00
parent 1401d7bc5c
commit 88428961dd
2 changed files with 6 additions and 2 deletions

View File

@ -445,8 +445,8 @@ host = do
) <|> ) <|>
( flag' NatWhenPrivateNetwork ( flag' NatWhenPrivateNetwork
$ long "port-forwarding-when-internal" $ long "port-forwarding-when-internal"
<> help ("Try asking the router to forward when ip is 192.168.0.0/24 or" <> <> help ("Try asking the router to forward when ip is 192.168.0.0/16, " <>
"10.0.0.0/8 (default).") "172.16.0.0/12 or 10.0.0.0/8 (default).")
<> hidden <> hidden
) <|> ) <|>
(pure $ NatWhenPrivateNetwork) (pure $ NatWhenPrivateNetwork)

View File

@ -104,6 +104,8 @@ portThread q stderr = do
Left err -> do Left err -> do
likelyIPAddress >>= \case likelyIPAddress >>= \case
Just ip@(192, 168, _, _) -> warnBehindRouterAndErr ip err Just ip@(192, 168, _, _) -> warnBehindRouterAndErr ip err
Just ip@(172, x, _, _)
| (x >= 16 && x <= 31) -> warnBehindRouterAndErr ip err
Just ip@(10, _, _, _) -> warnBehindRouterAndErr ip err Just ip@(10, _, _, _) -> warnBehindRouterAndErr ip err
_ -> assumeOnPublicInternet _ -> assumeOnPublicInternet
Right pmp -> foundRouter pmp Right pmp -> foundRouter pmp
@ -245,6 +247,8 @@ likelyBehindRouter :: MonadIO m => m Bool
likelyBehindRouter = do likelyBehindRouter = do
likelyIPAddress >>= \case likelyIPAddress >>= \case
Just ip@(192, 168, _, _) -> pure True Just ip@(192, 168, _, _) -> pure True
Just ip@(172, x, _, _)
| (x >= 16 && x <= 31) -> pure True
Just ip@(10, _, _, _) -> pure True Just ip@(10, _, _, _) -> pure True
_ -> pure False _ -> pure False