SpaceDaemonisawrapperbuiltinGoaroundawesomeIPFStoolssothatyoucanhavestartcodingadecentralizeddesktopappasfastaspossible.It'sbuiltontopofTextileThreadsandBuckets.Outoftheboxitincludes:
ArunninglocalinstanceofTextileThreads.
Interfacestocreatelocalprivate,encryptedbuckets.
Interfacesforsharingthosebucketsandthefileswithin.
Identityservicesothatsharingcanbedonethroughusernamesoremails.
FUSEfordrivemounting,sothatthefilescanbeexplorednativelyinyourOS.
Keymanagement.
Note:Thisprojectisinactivedevelopment,soitmightchangeitsAPIuntilitreachesastableversion.
InstallationBydefault,SpaceDaemonconnectstohostedservicesprovidedbyFleek.Thisshouldbegoodifyoujustwanttogetitrunningquickly.However,ifyouwanttoconnecttoyourownservices,readtheModulesSection.
DownloadingthebinaryCheckoutthereleaseshere.YoucandownloadthelatestversionforyourOSandyoushouldbegoodtogo.
IfyouwanttorunSpaceDaemonbysource,checkoutthissection
UsageSpaceDaemonprovidesagRPCinterface.Youcanreaditsprotoschemahere.Itcontainsmethodsto:
Createfilesanddirectories
Listfilesanddirectories
Creatingbuckets
Sharingbuckets
Creatingidentities
YoucanalsousetheJavaScriptclientherehttps://github.com/FleekHQ/space-client
Thiscanbeusefulif,forexample,youarebuildingawebappthatneedstointeractwithauser'slocallyrunningSpaceDaemon.
ModulesSpaceDaemonrequiresafewmodulestorunsuccessfully.Ifyoudownloadedthebinary,youdon'thavetoworryaboutthissinceitwillbeconnectingtoourservices.It'sgoodtounderstandwhat'shappeningbehindthescenesthough.
IPFSNodeAllencryptedfilesarestoredinanIPFSnode.Forconvenience,SpaceDaemonrunsanembeddednodewithinthedaemonthatcanbeconfiguredaswellastheoptiontospecifyanexternalnodetoconnectto.
Ifyouhaveyourownnodeoutsideofthedaemon,thensettheflag-ipfsnodetofalse.Thiswillnotspinupanembeddednode.Youcanthenconnecttoyourexternalnodebyprovidingthe-ipfsaddrflag(e.g.-ipfsaddr=/ip4/127.0.0.1/tcp/5001).
InthecaseyouarerunningtheembeddedIPFSnode,youcanfurtherconfigurethelistenaddressanddatadirectorybysettingtheseflagsrespectively:-ipfsnodeaddrand-ipfsnodepath.
TextileHubRequiredforsharingfilesbetweenusersandbackingitup.Itstoresallbackedupfilesencryptedusingasetofkeyssothatonlyyou,andpeopleyousharefileswith,canreadthedata.WehostourowninstanceoftheTextileHub,andbydefault,SpaceDaemonwillconecttoit.Itcanbecustomizedbyprovidingthe-textilehubflagand-textilethreadsflag.
IfyouwanttohostyourownTextileHubnode,youcanreaditsdocumentationhere
SpaceServicesWeprovidehostedalternativesfortheseservices.Youcandeployyourownbyfollowingtheinstructionsinitsrepo:
https://github.com/fleekHQ/space-services
IdentityThesearecentralizedservicesthatareoptional,butofferadditionalconvenience.Usedmainlyforidentity.Byusingtheseservices,youcanallowuserstoclaimusernames,sothatSpaceDaemoncanknowthepublickeyofagivenusernameandinthatwaysharefilesviausernamewithouthavingtoinputpublickeysdirectly.
AuthenticationOurhostedTextileHubrequiresauthenticationviapublickeyforloggingin.ThisservicesendsachallengetoSpaceDaemon,whichsignsthechallengewiththeprivatekeyoftheuserandinthatwayourhostedTextileHubcanallowtheusertostoredata.
RunningfromsourceAftercloningthisrepo,youcanrunitfromsourcebyrunninggorun./cmd/space-daemon-dev.Considerthatyouwillneedthefollowingenvironmentvariablesexportedinyoursystem:
IPFS_ADDR=[YourIPFSnodeaddress]SERVICES_API_URL=[TheURLwhereSpaceServicesAPIislocated]VAULT_API_URL=[TheURLwhereSpaceVaultAPIislocated]VAULT_SALT_SECRET=[Arandomstringusedforkdffunctionsbeforestoringkeystothevault]SERVICES_HUB_AUTH_URL=[TheURLwhereSpaceServicesTextileHubAuthorizerislocated]TXL_HUB_TARGET=[TheURLoftheTextileHub]TXL_HUB_MA=[ThemultiaddressfortheTextilehub]TXL_THREADS_TARGET=[TheURLoftheTextileHubwhereThreadsarehosted,canbethesamethatTXL_HUB_TARGET]#NOTE:thefollowingarerequiredtemporarilyandwillberemovedoncehubauthwrapperissetupTXL_USER_KEY=[Spacelevelkeyforhubaccess]TXL_USER_SECRET=[Spacelevelsecretforhubaccess]Alternatively,youcanrunmaketocompilethebinary.Makesureyouhavetheseenvironmentvariablesexposedthough.Youcanseesomeexampleenvironmentvariablesin.env.example.
ContributtingWearehappytoreceiveissuesandreviewpullrequests.Pleasemakesuretowritetestsforthecodeyouareintroducingandmakesureitdoesn'tbreakalreadypassingtests.
Readthefollowingsectionsforanintroductionintothecode.
PackageStructureLooselybasedontheseresources:https://github.com/golang-standards/project-layout
/grpcFolderstructureforgRPCandRESTAPI./cmdEntrypointdirectoryforallbinariesthisrepohandles.E.gcmd/{binary-name}/main.go/configGlobalConfigcode/coreDirectoryforthecoreobjectsofthepackage/loggerDirectoryforapplogging/examplesDirectoryplaygroundforgeneralexamplesanddraftsMainclassesipfs:containsutilsforgeneralIPFSoperations.keychain:managesuserpublic/privatekeypair.libfuse:interoperateswithFUSEformountingdrives.space:containsthemainintegrationfromtheservicestothefinalTextileorFSoperations.store:containsawrapperaroundalocaldb.sync:keepstrackofopenfilessothattheupdatesgetpushedtoIPFStextile:wrapperaroundTextilebootingandoperationsGeneratingMocksMocksaregeneratedusinghttps://github.com/vektra/mockery.
ForLinuxitneedstobebuiltfromsource.
mockery--nameInterfaceToMock--dirpath/to/go/files
ProtobufIfyouupdatethegRPCAPI,youneedtoregeneratetheProtobuffile.
YouwillneedtoinstallthefollowingbinariesinyourGopath:
goget-ugithub.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gatewayCheckingthebinaries:ls$GOPATH/binShouldshowthefollowingbinariesinyourpath:protoc-gen-go,protoc-gen-grpc-gateway
Runtheprotobufgeneration:makeproto_gen
RuntheRESTproxygeneration:makegen_rest
**Ideallyyoushouldrunmakegen_allbeforecommitingasthiswouldrunalltheabovethreecodegenerationsandensureeverythingisuptodate**
NOTE:SeehereforinstructionsonReverseProxy:https://github.com/grpc-ecosystem/grpc-gateway
Debugging,ProfilingandTracingThefollowingflagscanberunwiththebinarytooutputprofilingfilesfordebugging.Flagssupportafullpathtoafile.-cpuprofilecpu.prof-memprofilemem.prof
Bydefault,thebinaryrunsindebugmode(thismaychangeafterrelease)anditbootsapprofserverinlocalhost:6060.Seedocshowtointeractwithpprofserverhere:https://github.com/google/pprof/blob/master/doc/README.md
Todisabledebugmodeaddthisflagtobinaryarguments-debug=false
Toenabletraceinthedaemon,pass-tracetothebinaryarguments.Thedaemonusesjaegarforcollectingtraceinformation.Runmakejaegartoquicklystartajaegeragentthatcollectsthedaemonstraceinformation.Youcanhttps://localhost:16686/toexplorethewebuifortracescollected.
CISecretsSecretsaresetbyaddingtheminGithubandthenspecifyingtheminrelease.yml.Secretscanbeconstantacrossenvironment/stagesorbestagespecific.
Ifspecified,thereleasefilewilldynamicallygeneratethesecretnamebasedonthestagebyaddinga_DEVor_PRDsuffixtothesecretnameonlyforthespecificedenvironmentvariable.Itwillalwaysuse_PRDunlessthetagendsin-dev.Soforexampletagv0.0.15willusePRDvalues,whilev0.0.15-devwilluseDEVvalues.
Stagespecificsecretnameswillonlybeusedforsecretsinrelease.ymlthatpointtothestepoutputinsteadofthesecretnamedirectly(i.e.,SERVICES_API_URL:${{secrets[steps.secretnames.outputs.SERVICES_API_URL]}}insteadofSERVICES_API_URL:${{secrets.SERVICES_API_URL}}.
Sotoaddanewsecret:
Ifit'snotstagespecificthenaddthesecretinGHwithnosuffixandinrelease.yml,refertoitbasedonthesecretname.Ifitisstagespecific,thencreatethe2secretsinGH(endingin_PRDand_DEV),addtheentryinstepsecretnames,andmakesurethesecretnameinthenextsteppointstothestepoutput
评论