Exemple #1
0
func load(addr *net.TCPAddr, vardir string, key []byte) n.Addr {
	//debug.InstallCtrlCPanic()

	// Randomize execution
	rand.Seed(time.Now().UnixNano())

	// Generate worker ID
	id := n.ChooseWorkerID()
	vardir = strings.Replace(vardir, "%W", id.String(), 1)

	// Ensure chroot directory exists and we have access to it
	dir, err := filepath.Abs(vardir)
	if err != nil {
		log.Fatalf("abs (%s)", err)
	}
	if err := os.MkdirAll(dir, 0700); err != nil {
		log.Fatalf("mkdir %s (%s)", dir, err)
	}

	// Initialize networking
	if len(key) > 0 {
		log.Println("Using symmetric HMAC authentication and RC4 encryption.")
	}
	t := n.NewTransport(id, addr, key)
	fmt.Println(t.Addr().String())

	// Initialize language runtime
	circuit.Bind(lang.New(t))
	return t.Addr()
}
Exemple #2
0
func load(addr, mutex string) {
	//debug.InstallCtrlCPanic()

	// Randomize execution
	rand.Seed(time.Now().UnixNano())

	// Generate worker ID
	id := n.ChooseWorkerID()
	mutex = strings.Replace(mutex, "%W", id.String(), 1)

	// Ensure chroot directory exists and we have access to it
	dir, err := filepath.Abs(mutex)
	if err != nil {
		log.Fatalf("abs (%s)", err)
	}
	if err := os.MkdirAll(dir, 0700); err != nil {
		log.Fatalf("mkdir %s (%s)", dir, err)
	}

	// Create a lock file in the chroot directory so its not managed by two circuit instances at the same time
	lockname := path.Join(dir, ".lock")
	if _, err := lockfile.Create(lockname); err != nil {
		log.Fatalf("obtain lock (%s)\n", err)
	}
	log.Printf("Created and locked %s", lockname)

	// Initialize networking
	bindaddr_, err := n.ParseNetAddr(addr)
	if err != nil {
		log.Fatalf("resolve %s (%s)\n", addr, err)
	}
	bindaddr := bindaddr_.(*net.TCPAddr)
	if len(bindaddr.IP) == 0 {
		bindaddr.IP = net.IPv4zero
	}
	t := n.NewTransport(id, bindaddr)
	fmt.Println(t.Addr().String())

	// Initialize language runtime
	circuit.Bind(lang.New(t))
}
Exemple #3
0
func _init(key []byte) {
	rand.Seed(time.Now().UnixNano())
	t := n.NewTransport(n.ChooseWorkerID(), &net.TCPAddr{}, key)
	//fmt.Println(t.Addr().String())
	circuit.Bind(lang.New(t))
}