Example #1
0
func main() {
	var err error
	var l *go9p.Logger

	flag.Parse()
	rsrv.user = go9p.OsUsers.Uid2User(os.Geteuid())
	rsrv.group = go9p.OsUsers.Gid2Group(os.Getegid())
	rsrv.blksz = *blksize
	rsrv.blkchan = make(chan []byte, 2048)
	rsrv.zero = make([]byte, rsrv.blksz)

	root := new(RFile)
	err = root.Add(nil, "/", rsrv.user, nil, go9p.DMDIR|0777, root)
	if err != nil {
		goto error
	}

	l = go9p.NewLogger(*logsz)
	rsrv.srv = srv.NewFileSrv(&root.File)
	rsrv.srv.Dotu = true
	rsrv.srv.Debuglevel = *debug
	rsrv.srv.Start(rsrv.srv)
	rsrv.srv.Id = "ramfs"
	rsrv.srv.Log = l

	err = rsrv.srv.StartNetListener("tcp", *addr)
	if err != nil {
		goto error
	}
	return

error:
	log.Println(fmt.Sprintf("Error: %s", err))
}
func main() {
	var err error

	flag.Parse()
	rsrv.user = go9p.OsUsers.Uid2User(os.Geteuid())
	rsrv.group = go9p.OsUsers.Gid2Group(os.Getegid())
	rsrv.blksz = *blksize
	rsrv.blkchan = make(chan []byte, 2048)
	rsrv.zero = make([]byte, rsrv.blksz)

	root := new(RFile)
	err = root.Add(nil, "/", rsrv.user, nil, go9p.DMDIR|0777, root)
	if err != nil {
		log.Println(fmt.Sprintf("Error: %s", err))
		return
	}

	l := go9p.NewLogger(*logsz)
	rsrv.srv = srv.NewFileSrv(&root.File)
	rsrv.srv.Dotu = true
	rsrv.srv.Debuglevel = *debug
	rsrv.srv.Start(rsrv.srv)
	rsrv.srv.Id = "ramfs"
	rsrv.srv.Log = l

	cert := make([]tls.Certificate, 1)
	cert[0].Certificate = [][]byte{testCertificate}
	cert[0].PrivateKey = testPrivateKey

	ls, oerr := tls.Listen("tcp", *addr, &tls.Config{
		Rand:               rand.Reader,
		Certificates:       cert,
		CipherSuites:       []uint16{tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA},
		InsecureSkipVerify: true,
	})
	if oerr != nil {
		log.Println("can't listen:", oerr)
		return
	}

	err = rsrv.srv.StartListener(ls)
	if err != nil {
		log.Println(fmt.Sprintf("Error: %s", err))
		return
	}
	return
}
Example #3
0
func main() {
	var err error
	var tm *Time
	var ntm *InfTime
	var s *srv.Fsrv

	flag.Parse()
	user := go9p.OsUsers.Uid2User(os.Geteuid())
	root := new(srv.File)
	err = root.Add(nil, "/", user, nil, go9p.DMDIR|0555, nil)
	if err != nil {
		goto error
	}

	tm = new(Time)
	err = tm.Add(root, "time", go9p.OsUsers.Uid2User(os.Geteuid()), nil, 0444, tm)
	if err != nil {
		goto error
	}
	ntm = new(InfTime)
	err = ntm.Add(root, "inftime", go9p.OsUsers.Uid2User(os.Geteuid()), nil, 0444, ntm)
	if err != nil {
		goto error
	}

	s = srv.NewFileSrv(root)
	s.Dotu = true

	if *debug {
		s.Debuglevel = 1
	}
	if *debugall {
		s.Debuglevel = 2
	}

	s.Start(s)
	err = s.StartNetListener("tcp", *addr)
	if err != nil {
		goto error
	}

	return

error:
	log.Println(fmt.Sprintf("Error: %s", err))
}
Example #4
0
func start() error {
	session, err := mgo.Dial(*mongo)
	if err != nil {
		return err
	}
	defer session.Close()
	user := go9p.OsUsers.Uid2User(os.Geteuid())
	root := new(srv.File)
	if err := root.Add(nil, "/", user, nil, go9p.DMDIR|0555, nil); err != nil {
		return err
	}
	if err := collections.Add(root, user, session.DB(*dbname)); err != nil {
		return err
	}
	s := srv.NewFileSrv(root)
	s.Dotu = true
	s.Start(s)
	//s.Debuglevel = srv.DbgPrintFcalls
	return s.StartNetListener("tcp", *addr)
}
func main() {
	var err error
	var cl *Clone
	var s *srv.Fsrv

	flag.Parse()
	user := go9p.OsUsers.Uid2User(os.Geteuid())
	root = new(srv.File)
	err = root.Add(nil, "/", user, nil, go9p.DMDIR|0777, nil)
	if err != nil {
		goto error
	}

	cl = new(Clone)
	err = cl.Add(root, "clone", go9p.OsUsers.Uid2User(os.Geteuid()), nil, 0444, cl)
	if err != nil {
		goto error
	}

	s = srv.NewFileSrv(root)
	s.Dotu = true

	if *debug {
		s.Debuglevel = 1
	}

	s.Start(s)
	err = s.StartNetListener("tcp", *addr)
	if err != nil {
		goto error
	}
	return

error:
	log.Println(fmt.Sprintf("Error: %s", err))
}