示例#1
0
func main() {
	var message string
	fmt.Print("Please enter the message to be exchanged in encrypted form: ")
	reader := bufio.NewReader(os.Stdin)
	for {
		line, err := reader.ReadString('\n')
		if err != nil {
			panic(err)
		}
		message = line
		if line != "" || err != nil {
			break
		}
	}

	imp, err := netchan.Import("tcp", "127.0.0.1:9999")
	handleError(err)

	channelAliceSend := make(chan []*big.Int)
	channelAliceReceive := make(chan []*big.Int)

	imp.Import("BobToAlice", channelAliceReceive, netchan.Recv, 1)
	fmt.Println("Empfangskanal importiert")
	imp.Import("AliceToBob", channelAliceSend, netchan.Send, 1)
	fmt.Println("Sendekanal importiert")

	stop := make(chan int)

	go alice(message, channelAliceReceive, channelAliceSend, stop)
	<-stop
}
示例#2
0
文件: workers.go 项目: paulosuzart/gb
//Helper function to import the Master channel from masterAddr
func importMasterChan(t Task) (c chan WorkSummary, err error) {
	mu.Lock()
	defer mu.Unlock()
	if c, present := _sessions[t.Session.Id]; present {
		log.Printf("Cached Session %v", t.Session.Id)
		return c, nil
	}

	imp, err := netchan.Import("tcp", t.MasterAddr)
	if err != nil {
		log.Printf("Failed to create importer for %v", t.MasterAddr)
		return nil, err
	}

	c = make(chan WorkSummary, 10)
	imp.Import("masterChannel", c, netchan.Send, 10)
	go func() {
		err := <-imp.Errors()
		log.Print(err)
	}()

	_sessions[t.Session.Id] = c
	go cacheWatcher(t.Session)
	return c, nil
}
示例#3
0
func Client(msg string) {
	imp, err := netchan.Import("tcp", "127.0.0.1:9999")
	handleError(err)

	channelAliceSend := make(chan string)
	imp.Import("AliceToBob", channelAliceSend, netchan.Send, 1)
	for i := 1; i < 101; i++ {
		channelAliceSend <- msg
	}
}
示例#4
0
文件: workers.go 项目: paulosuzart/gb
//Creates a new Proxy importing 'workerChannel' from Worker running
//on workerAddr
func NewProxyWorker(workerAddr string) (p *ProxyWorker, err error) {
	log.Printf("Setting up a ProxyWorker for %s", workerAddr)
	p = new(ProxyWorker)

	imp, err := netchan.Import("tcp", workerAddr)
	if err != nil {
		return
	}
	p.importer = imp
	return
}