Пример #1
0
func TestMulticastservice_GetBlob(t *testing.T) {
	//t.Skipf("Come back to this test")
	web.Start()
	//go BlobServerStart()

	AnswerKey := []struct {
		hcid     objects.HCID
		response objects.Blob
	}{
		{objects.Blob([]byte("blob found")).Hash(), objects.Blob([]byte("blob found"))},
	}
	for _, answer := range AnswerKey {

		localfile.Instance.PostBlob(answer.response)
		go func() {
			time.Sleep(1 * time.Millisecond)
			mcaddr, _ := net.ResolveUDPAddr("udp", "127.0.0.1:1234")
			Instance.receivemessage("{\"type\":\"blob\", \"hcid\": \"42cc3a4c4a9d9d3ee7de9322b45acb0e5a5c33550d9ad4791df6ae937a869e12\", \"URL\": \"/b/42cc3a4c4a9d9d3ee7de9322b45acb0e5a5c33550d9ad4791df6ae937a869e12\"}", mcaddr)
		}()

		output, err := Instance.GetBlob(answer.hcid)

		if err != nil {
			t.Errorf("Get Blob Failed \nError:%s", err)
		} else if !bytes.Equal(output.Hash(), answer.hcid) {
			t.Errorf("Get Blob Failed \nExpected:%s \nGot: %s", answer.response, output)
		}

	}
}
Пример #2
0
func start() {
	go func() { //defining, calling and throwing to a different thread
		ch := make(chan os.Signal, 1) //ch is the name of the channel.
		signal.Notify(ch, os.Interrupt, os.Kill)
		sig := <-ch
		log.Printf("Got signal: %s", sig)
		log.Printf("Stopping...")
		stopAll()
	}()

	//This Block registers the services for the object module to use
	objects.RegisterGeterPoster(
		services.GetPublicKeyForHkid,
		services.GetPrivateKeyForHkid,
		services.PostKey,
		services.PostBlob,
	)

	Flags, Command := parseFlags()
	go localfile.Start()
	go timeout.Start()

	if *Flags.serve {
		web.Start()
		crawler.Start()
	}
	//if *Flags.mount {
	//	fuse.Start()
	//}
	if *Flags.dht {
		kademliadht.Start()
	}
	if *Flags.apps {
		appsscript.Start()
	}
	//if *Flags.drive {
	//	googledrive.Start()
	//}
	if *Flags.direct {
		directhttp.Start()
	}
	if *Flags.lan {
		multicast.Start()
	}

	addCurators(Command)
}