space-daemon开源项目

我要开发同款
匿名用户2021年11月30日
109阅读
所属分类Google Go、大数据、数据存储
授权协议Apache-2.0 License

作品详情

SpaceDaemon

SpaceDaemonisawrapperbuiltinGoaroundawesomeIPFStoolssothatyoucanhavestartcodingadecentralizeddesktopappasfastaspossible.It'sbuiltontopofTextileThreadsandBuckets.Outoftheboxitincludes:

ArunninglocalinstanceofTextileThreads.

Interfacestocreatelocalprivate,encryptedbuckets.

Interfacesforsharingthosebucketsandthefileswithin.

Identityservicesothatsharingcanbedonethroughusernamesoremails.

FUSEfordrivemounting,sothatthefilescanbeexplorednativelyinyourOS.

Keymanagement.

Note:Thisprojectisinactivedevelopment,soitmightchangeitsAPIuntilitreachesastableversion.

Installation

Bydefault,SpaceDaemonconnectstohostedservicesprovidedbyFleek.Thisshouldbegoodifyoujustwanttogetitrunningquickly.However,ifyouwanttoconnecttoyourownservices,readtheModulesSection.

Downloadingthebinary

Checkoutthereleaseshere.YoucandownloadthelatestversionforyourOSandyoushouldbegoodtogo.

IfyouwanttorunSpaceDaemonbysource,checkoutthissection

Usage

SpaceDaemonprovidesagRPCinterface.Youcanreaditsprotoschemahere.Itcontainsmethodsto:

Createfilesanddirectories

Listfilesanddirectories

Creatingbuckets

Sharingbuckets

Creatingidentities

YoucanalsousetheJavaScriptclientherehttps://github.com/FleekHQ/space-client

Thiscanbeusefulif,forexample,youarebuildingawebappthatneedstointeractwithauser'slocallyrunningSpaceDaemon.

Modules

SpaceDaemonrequiresafewmodulestorunsuccessfully.Ifyoudownloadedthebinary,youdon'thavetoworryaboutthissinceitwillbeconnectingtoourservices.It'sgoodtounderstandwhat'shappeningbehindthescenesthough.

IPFSNode

AllencryptedfilesarestoredinanIPFSnode.Forconvenience,SpaceDaemonrunsanembeddednodewithinthedaemonthatcanbeconfiguredaswellastheoptiontospecifyanexternalnodetoconnectto.

Ifyouhaveyourownnodeoutsideofthedaemon,thensettheflag-ipfsnodetofalse.Thiswillnotspinupanembeddednode.Youcanthenconnecttoyourexternalnodebyprovidingthe-ipfsaddrflag(e.g.-ipfsaddr=/ip4/127.0.0.1/tcp/5001).

InthecaseyouarerunningtheembeddedIPFSnode,youcanfurtherconfigurethelistenaddressanddatadirectorybysettingtheseflagsrespectively:-ipfsnodeaddrand-ipfsnodepath.

TextileHub

Requiredforsharingfilesbetweenusersandbackingitup.Itstoresallbackedupfilesencryptedusingasetofkeyssothatonlyyou,andpeopleyousharefileswith,canreadthedata.WehostourowninstanceoftheTextileHub,andbydefault,SpaceDaemonwillconecttoit.Itcanbecustomizedbyprovidingthe-textilehubflagand-textilethreadsflag.

IfyouwanttohostyourownTextileHubnode,youcanreaditsdocumentationhere

SpaceServices

Weprovidehostedalternativesfortheseservices.Youcandeployyourownbyfollowingtheinstructionsinitsrepo:

https://github.com/fleekHQ/space-services

Identity

Thesearecentralizedservicesthatareoptional,butofferadditionalconvenience.Usedmainlyforidentity.Byusingtheseservices,youcanallowuserstoclaimusernames,sothatSpaceDaemoncanknowthepublickeyofagivenusernameandinthatwaysharefilesviausernamewithouthavingtoinputpublickeysdirectly.

Authentication

OurhostedTextileHubrequiresauthenticationviapublickeyforloggingin.ThisservicesendsachallengetoSpaceDaemon,whichsignsthechallengewiththeprivatekeyoftheuserandinthatwayourhostedTextileHubcanallowtheusertostoredata.

Runningfromsource

Aftercloningthisrepo,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.

Contributting

Wearehappytoreceiveissuesandreviewpullrequests.Pleasemakesuretowritetestsforthecodeyouareintroducingandmakesureitdoesn'tbreakalreadypassingtests.

Readthefollowingsectionsforanintroductionintothecode.

PackageStructure

Looselybasedontheseresources: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:wrapperaroundTextilebootingandoperationsGeneratingMocks

Mocksaregeneratedusinghttps://github.com/vektra/mockery.

ForLinuxitneedstobebuiltfromsource.

mockery--nameInterfaceToMock--dirpath/to/go/files

Protobuf

IfyouupdatethegRPCAPI,youneedtoregeneratetheProtobuffile.

YouwillneedtoinstallthefollowingbinariesinyourGopath:

goget-ugithub.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway

Checkingthebinaries: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,ProfilingandTracing

Thefollowingflagscanberunwiththebinarytooutputprofilingfilesfordebugging.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.

CISecrets

SecretsaresetbyaddingtheminGithubandthenspecifyingtheminrelease.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
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论