Beispiel #1
0
func main() {
	cachedir := flag.String("cachedir", "/tmp/fsserver-cache", "content cache")
	port := flag.Int("port", 1234, "file server")
	secretFile := flag.String("secret", "/tmp/secret.txt", "file containing password.")

	flag.Parse()
	if flag.NArg() < 1 {
		log.Fatalf("usage: %s EXPORTED-ROOT\n", os.Args[0])
	}
	secret, err := ioutil.ReadFile(*secretFile)
	if err != nil {
		log.Fatal("ReadFile", err)
	}
	cache := termite.NewDiskFileCache(*cachedir)
	fileServer := termite.NewFsServer(flag.Arg(0), cache, []string{"/proc"})

	out := make(chan net.Conn)
	go termite.SetupServer(*port, secret, out)

	conn := <-out
	rpcServer := rpc.NewServer()
	err = rpcServer.Register(fileServer)
	if err != nil {
		log.Fatal("could not register file server", err)
	}
	log.Println("Server started...")
	rpcServer.ServeConn(conn)
}
Beispiel #2
0
func main() {
	cachedir := flag.String("cachedir", "/tmp/worker-cache", "content cache")
	secretFile := flag.String("secret", "/tmp/secret.txt", "file containing password.")
	port := flag.Int("port", 1235, "Where to listen for work requests.")
	chrootBinary := flag.String("chroot", "", "binary to use for chroot'ing.")
	flag.Parse()
	secret, err := ioutil.ReadFile(*secretFile)
	if err != nil {
		log.Fatal("ReadFile", err)
	}

	daemon := termite.NewWorkerDaemon(secret, *cachedir)
	daemon.ChrootBinary = *chrootBinary

	out := make(chan net.Conn)
	go termite.SetupServer(*port, secret, out)
	for {
		conn := <-out
		log.Println("Opening RPC channel from", conn.RemoteAddr())
		rpcServer := rpc.NewServer()
		rpcServer.Register(daemon)
		go rpcServer.ServeConn(conn)
	}
}