From bbb6eb2fab8c31cd85ccc124834dc345b1b6376c Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Fri, 27 Dec 2019 02:21:24 -0700 Subject: [PATCH] adds torrc endpoints --- config/routes | 2 ++ src/Handler/Apps.hs | 3 +++ src/Handler/Version.hs | 3 +++ test/Live/Serialize.hs | 25 ------------------------- test/Live/UpdateAgent.hs | 24 ------------------------ 5 files changed, 8 insertions(+), 49 deletions(-) delete mode 100644 test/Live/Serialize.hs delete mode 100644 test/Live/UpdateAgent.hs diff --git a/config/routes b/config/routes index b199f9e..2d05274 100644 --- a/config/routes +++ b/config/routes @@ -6,9 +6,11 @@ /apps/version/#Text VersionAppR GET --get most recent appId version /sys/version/agent VersionAgentR GET --get most recent agent version /sys/version/appmgr VersionAppMgrR GET --get most recent appmgr version +/sys/version/torrc VersionTorrcR GET --get most recent torrc version !/apps/#S9PK AppR GET --get most recent appId at appversion spec, defaults to >=0.0.0 -- ?spec={semver-spec} /sys/agent AgentR GET --get most recent agent at appversion -- ?spec={semver-spec} /sys/appmgr AppMgrR GET --get most recent appmgr at appversion -- ?spec={semver-spec} +/sys/torrc TorrcR GET --get most recent torrc at appversion -- ?spec={semver-spec} /sys.tar.gz ImageR GET --get most recent iso image, ?spec={semver-spec} \ No newline at end of file diff --git a/src/Handler/Apps.hs b/src/Handler/Apps.hs index ad31cb6..bc48459 100644 --- a/src/Handler/Apps.hs +++ b/src/Handler/Apps.hs @@ -46,6 +46,9 @@ getAgentR = getApp sysResourceDir "agent" getAppMgrR :: Handler TypedContent getAppMgrR = getApp sysResourceDir "appmgr" +getTorrcR :: Handler TypedContent +getTorrcR = getApp sysResourceDir "torrc" + getAppR :: S9PK -> Handler TypedContent getAppR (S9PK appId) = getApp appResourceDir appId diff --git a/src/Handler/Version.hs b/src/Handler/Version.hs index d49c8b8..90633af 100644 --- a/src/Handler/Version.hs +++ b/src/Handler/Version.hs @@ -24,6 +24,9 @@ getVersionAgentR = getVersionWSpec sysResourceDir "agent" getVersionAppMgrR :: Handler (Maybe AppVersionRes) getVersionAppMgrR = getVersionWSpec sysResourceDir "appmgr" +getVersionTorrcR :: Handler (Maybe AppVersionRes) +getVersionTorrcR = getVersionWSpec sysResourceDir "torrc" + getVersionWSpec :: FilePath -> Text -> Handler (Maybe AppVersionRes) getVersionWSpec rootDir appId = do spec <- querySpecD mostRecentVersion <$> lookupGetParam "spec" diff --git a/test/Live/Serialize.hs b/test/Live/Serialize.hs deleted file mode 100644 index 9f916f1..0000000 --- a/test/Live/Serialize.hs +++ /dev/null @@ -1,25 +0,0 @@ -{-# LANGUAGE QuasiQuotes #-} - -module Live.Serialize where - -import Data.String.Interpolate.IsString - -import Application -import Lib.External.Registry -import Startlude - -someYaml :: ByteString -someYaml = [i| -bitcoind: - title: "Bitcoin Core" - description: - short: "A Bitcoin Full Node" - long: "The bitcoin full node implementation by Bitcoin Core." - version-info: - - version: 0.18.1 - release-notes: "Some stuff" - icon-type: png -|] - -appRegistryTest :: IO (Either String RegistryRes) -appRegistryTest = flip parseBsManifest someYaml <$> getAppSettings diff --git a/test/Live/UpdateAgent.hs b/test/Live/UpdateAgent.hs deleted file mode 100644 index ce3e1eb..0000000 --- a/test/Live/UpdateAgent.hs +++ /dev/null @@ -1,24 +0,0 @@ -module Live.UpdateAgent where - -import Application -import Lib.Types.StoreApp -import Lib.UpdateAgent -import Startlude - -av :: AppVersion -av = AppVersion (0,0,0) - -avs :: AppVersionSpecification -avs = AppVersionSpecification SVEquals av - --- Need a few things to run this... --- 1) a running "registry" server, pointed to by the settings.yml this file is run against. --- 2) that server needs to serve up an executable file at /agent.0.0.0 (the version of av above) --- 3) the executable file must itself spin up a server on the same port as this application, defined again in settings.yml --- 4) that server must also respond to /version with a semver version in the format "0.0.0" --- 5) If all goes well, the stack ghci session which calls updateAgentLive should have been killed, and the executable should still be running - -updateAgentLive :: IO () -updateAgentLive = do - (_, agentCtx, _) <- getApplicationRepl - updateAgent' avs agentCtx