2019-07-03 02:37:10 +03:00
|
|
|
module Vere.Ames where
|
|
|
|
|
|
|
|
import ClassyPrelude
|
|
|
|
import Data.IP
|
|
|
|
import Data.Void
|
|
|
|
import Noun
|
|
|
|
|
2019-07-12 22:24:44 +03:00
|
|
|
import qualified Urbit.Time as Time
|
2019-07-03 02:37:10 +03:00
|
|
|
|
|
|
|
type Port = Word
|
|
|
|
|
2019-07-22 21:10:27 +03:00
|
|
|
newtype Turf = MkTurf { unTurf :: [Cord] }
|
|
|
|
deriving newtype (Eq, Ord, Show)
|
2019-07-03 02:37:10 +03:00
|
|
|
|
|
|
|
data Lane
|
|
|
|
= Ip4f Time.Wen Port IPv4 -- [%if @da @ud @if]
|
|
|
|
| Ip6 Void (Maybe Lane) Void -- [%is @ud (unit lane) @is]
|
|
|
|
| Ip4x Time.Wen Port IPv4 -- [%ix @da @ud @if]
|
|
|
|
deriving (Eq, Ord, Show)
|
|
|
|
|
|
|
|
-- todo: manual instance needed?
|
|
|
|
deriveNoun ''IPv4
|
|
|
|
deriveNoun ''Turf
|
|
|
|
deriveNoun ''Lane
|
|
|
|
|
|
|
|
toIpv4 :: Lane -> IPv4
|
|
|
|
toIpv4 = \case
|
|
|
|
Ip4f _ _ i -> i
|
|
|
|
Ip6 _ (Just l) _ -> toIpv4 l
|
|
|
|
Ip6 _ _ _ -> error "IPv6 doesn't exist in practice"
|
|
|
|
Ip4x _ _ i -> i
|