From 718f00853fa3b42940d6544c054bb23fb38ba0c2 Mon Sep 17 00:00:00 2001 From: joe Date: Fri, 15 Sep 2017 03:29:46 -0400 Subject: Moved Global6 to hierarchical name. --- DHTHandlers.hs | 2 +- Global6.hs | 28 ---------------------------- Mainline.hs | 2 +- Tox.hs | 2 +- src/System/Global6.hs | 28 ++++++++++++++++++++++++++++ 5 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 Global6.hs create mode 100644 src/System/Global6.hs diff --git a/DHTHandlers.hs b/DHTHandlers.hs index e2b4ec05..73a8fc41 100644 --- a/DHTHandlers.hs +++ b/DHTHandlers.hs @@ -13,7 +13,7 @@ import Kademlia import Network.Address (WantIP (..), ipFamily, testIdBit,fromSockAddr, sockAddrPort) import qualified Network.DHT.Routing as R import TriadCommittee -import Global6 +import System.Global6 import qualified Data.ByteArray as BA import qualified Data.ByteString.Char8 as C8 diff --git a/Global6.hs b/Global6.hs deleted file mode 100644 index 346be708..00000000 --- a/Global6.hs +++ /dev/null @@ -1,28 +0,0 @@ -module Global6 where - -import Control.Monad -import Data.IP -import Data.List -import Data.Maybe -import Network.Socket -import System.Process -import Text.Read - -parseIpAddr :: String -> Maybe IPv6 -parseIpAddr s = do - let ws = words s - (addr,bs) = splitAt 1 $ drop 1 $ dropWhile (/= "inet6") ws - guard ("global" `elem` bs) - addr <- listToMaybe addr - guard (not $ isPrefixOf "fd" addr) - guard (not $ isPrefixOf "fc" addr) - let (addr',slash) = break (=='/') addr - ip6 <- readMaybe addr' - return $ (ip6 :: IPv6) - - -global6 :: IO (Maybe IPv6) -global6 = do - addrs <- lines <$> readProcess "ip" ["-o","-6","addr"] "" - return $ foldr1 mplus $ map parseIpAddr addrs - diff --git a/Mainline.hs b/Mainline.hs index 54de925d..bdd0470f 100644 --- a/Mainline.hs +++ b/Mainline.hs @@ -78,7 +78,7 @@ import Control.Exception (SomeException (..), handle) import qualified Data.Aeson as JSON ;import Data.Aeson (FromJSON, ToJSON, (.=)) import Text.Read -import Global6 +import System.Global6 import TriadCommittee newtype NodeId = NodeId ByteString diff --git a/Tox.hs b/Tox.hs index 690ba128..1dd134c0 100644 --- a/Tox.hs +++ b/Tox.hs @@ -64,7 +64,7 @@ import Foreign.Marshal.Alloc import Foreign.Ptr import Foreign.Storable import GHC.Generics (Generic) -import Global6 +import System.Global6 import Kademlia import Network.Address (Address, WantIP (..), either4or6, fromSockAddr, ipFamily, setPort, diff --git a/src/System/Global6.hs b/src/System/Global6.hs new file mode 100644 index 00000000..f70a8547 --- /dev/null +++ b/src/System/Global6.hs @@ -0,0 +1,28 @@ +module System.Global6 where + +import Control.Monad +import Data.IP +import Data.List +import Data.Maybe +import Network.Socket +import System.Process +import Text.Read + +parseIpAddr :: String -> Maybe IPv6 +parseIpAddr s = do + let ws = words s + (addr,bs) = splitAt 1 $ drop 1 $ dropWhile (/= "inet6") ws + guard ("global" `elem` bs) + addr <- listToMaybe addr + guard (not $ isPrefixOf "fd" addr) + guard (not $ isPrefixOf "fc" addr) + let (addr',slash) = break (=='/') addr + ip6 <- readMaybe addr' + return $ (ip6 :: IPv6) + + +global6 :: IO (Maybe IPv6) +global6 = do + addrs <- lines <$> readProcess "ip" ["-o","-6","addr"] "" + return $ foldr1 mplus $ map parseIpAddr addrs + -- cgit v1.2.3