diff options
author | James Crayne <jim.crayne@gmail.com> | 2019-10-18 05:31:00 +0000 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-01 19:48:28 -0500 |
commit | 4676dec52aec8f67f6d1c5a40365fe54103c135d (patch) | |
tree | 76fd1631b069b81b84381fbf65217545e23d9b63 | |
parent | 327359956edf957b571a92e26b8fe89114f7f81d (diff) |
implement --noavahi
-rw-r--r-- | dht/examples/dhtd.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/dht/examples/dhtd.hs b/dht/examples/dhtd.hs index 2f1e5831..6bbb3388 100644 --- a/dht/examples/dhtd.hs +++ b/dht/examples/dhtd.hs | |||
@@ -1121,6 +1121,7 @@ data Options = Options | |||
1121 | -- [ 2 ] Log all stanzas, even pings. | 1121 | -- [ 2 ] Log all stanzas, even pings. |
1122 | , verbosity :: Int | 1122 | , verbosity :: Int |
1123 | , verboseTags :: [DebugTag] | 1123 | , verboseTags :: [DebugTag] |
1124 | , advertiseOnAvahi :: Bool | ||
1124 | } | 1125 | } |
1125 | deriving (Eq,Show) | 1126 | deriving (Eq,Show) |
1126 | 1127 | ||
@@ -1135,16 +1136,18 @@ sensibleDefaults = Options | |||
1135 | , dhtkey = Nothing | 1136 | , dhtkey = Nothing |
1136 | , verbosity = 2 | 1137 | , verbosity = 2 |
1137 | , verboseTags = [XUnexpected, XUnused] | 1138 | , verboseTags = [XUnexpected, XUnused] |
1139 | , advertiseOnAvahi = True | ||
1138 | } | 1140 | } |
1139 | 1141 | ||
1140 | data ShowHelp = ShowHelp | 1142 | data ShowHelp = ShowHelp |
1141 | deriving (Eq,Show) | 1143 | deriving (Eq,Show) |
1142 | 1144 | ||
1143 | usage ShowHelp | 1145 | usage ShowHelp |
1144 | = let { cs = [ ([["--help"]] ,["display this help"]) | 1146 | = let { cs = [([["--help"]] ,["Display this help"]) |
1145 | , ([["--dhtkey ",dhtkey] | 1147 | , ([["--dhtkey ",dhtkey] |
1146 | ,["--dht-key ",dhtkey]],["use ",dhtkey," as the dht key"]) | 1148 | ,["--dht-key ",dhtkey]],["Use ",dhtkey," as the dht key"]) |
1147 | , ([["-4"]] ,["Use IPv4 only"]) | 1149 | , ([["-4"]] ,["Use IPv4 only"]) |
1150 | , ([["--noavahi"]] ,["Disable avahi advertising on LAN"]) | ||
1148 | , ([["-v ",tags]] ,["Enable or disable specified DebugTags.\n DebugTags = ", listDebugTags]) | 1151 | , ([["-v ",tags]] ,["Enable or disable specified DebugTags.\n DebugTags = ", listDebugTags]) |
1149 | ] ; | 1152 | ] ; |
1150 | dhtkey ="<dhtkey>" ; | 1153 | dhtkey ="<dhtkey>" ; |
@@ -1164,6 +1167,7 @@ usage ShowHelp | |||
1164 | parseArgs :: [String] -> Options -> Either ShowHelp Options | 1167 | parseArgs :: [String] -> Options -> Either ShowHelp Options |
1165 | parseArgs [] opts = Right opts | 1168 | parseArgs [] opts = Right opts |
1166 | parseArgs ("--help":args) opts = Left ShowHelp | 1169 | parseArgs ("--help":args) opts = Left ShowHelp |
1170 | parseArgs ("--noavahi":args) opts = parseArgs args opts { advertiseOnAvahi = False } | ||
1167 | parseArgs ("--dhtkey":k:args) opts = parseArgs args opts | 1171 | parseArgs ("--dhtkey":k:args) opts = parseArgs args opts |
1168 | { dhtkey = decodeSecret $ B.pack k } | 1172 | { dhtkey = decodeSecret $ B.pack k } |
1169 | parseArgs ("--dht-key":k:args) opts = parseArgs args opts | 1173 | parseArgs ("--dht-key":k:args) opts = parseArgs args opts |
@@ -1386,7 +1390,7 @@ initTox opts ssvar keysdb mbxmpp invc = case porttox opts of | |||
1386 | (dhtkey opts) | 1390 | (dhtkey opts) |
1387 | (\_ _ -> return ()) -- TODO: TCP relay send | 1391 | (\_ _ -> return ()) -- TODO: TCP relay send |
1388 | -- addrTox <- getBindAddress toxport (ip6tox opts) | 1392 | -- addrTox <- getBindAddress toxport (ip6tox opts) |
1389 | (quitTox, toxStrap4, toxStrap6) <- Tox.forkTox tox True | 1393 | (quitTox, toxStrap4, toxStrap6) <- Tox.forkTox tox (advertiseOnAvahi opts) |
1390 | 1394 | ||
1391 | toxSearches <- atomically $ newTVar Map.empty | 1395 | toxSearches <- atomically $ newTVar Map.empty |
1392 | 1396 | ||