Example #1
0
func join(ctl *NetCtl, words []string) {
	if len(words) < 2 || len(words) > 3 {
		fmt.Fprintf(ctl.status, "<< syntax: join <network> <channel> [optional-key]\n")
		return
	}
	var key string
	if len(words) == 4 {
		key = words[2]
	}
	name := words[1]
	if _, err := ctl.net.Whois([]string{name}, ""); err != nil {
		name = chanName(name)
		if err := ctl.net.Join([]string{name}, []string{key}); err != nil { //TODO: join multiple chans, users?
			fmt.Fprintf(ctl.status, "<< couldn't join %s: %s\n", name, err.String())
			return
		}
	}

	f := new(srv.File)
	if err := f.Add(ctl.parent, name, user, nil, p.DMDIR|0771, nil); err != nil {
		fmt.Fprintf(ctl.status, "<< %v\n", err)
		return
	}

	c := new(ChanCtl)
	c.net = ctl.net
	c.status = new(bytes.Buffer)
	c.ircch = name
	if err := c.Add(f, "in", user, nil, 0660, c); err != nil {
		fmt.Fprintf(ctl.status, "<< %v\n", err)
		return
	}

	l := new(ChanLog)
	l.fname = *logdir + "/" + ctl.netPretty + "/" + name + ".log"
	if err := l.Add(f, "out", user, nil, 0440, l); err != nil {
		fmt.Fprintf(ctl.status, "<< Couldn't create log file: %v\n", err)
		return
	}

	exch := make(chan bool) //FIXME: need to have a list of chans and their logger's exchs
	go logloop(name, c, exch, l.fname)
	fmt.Fprintf(ctl.status, "<< ok %v\n", words)
}
Example #2
0
func connect(ctl *Ctl, words []string) {
	var network, server, nick, username, realname, pass string
	if len(words) < 4 {
		return
	}
	network = words[1]
	server = words[2]
	nick = words[3]
	if len(words) < 5 {
		username = nick
	} else {
		username = words[4]
	}
	if len(words) < 6 {
		realname = username
	} else {
		realname = words[5]
	}
	if len(words) > 6 {
		pass = words[6]
	}
	n := irc.NewNetwork(server, nick, username, realname, pass, "/dev/null")
	if err := n.Connect(); err != nil {
		fmt.Fprintf(ctl.status, "<< %v\n", err)
		return
	}
	f := new(srv.File)
	if err := f.Add(root, network, user, nil, p.DMDIR|0771, nil); err != nil {
		fmt.Fprintf(ctl.status, "<< %v\n", err)
		return
	}
	c := new(NetCtl)
	c.status = new(bytes.Buffer)
	c.net = n
	c.parent = f
	c.netPretty = network
	if err := c.Add(f, "in", user, nil, 0660, c); err != nil {
		fmt.Fprintf(ctl.status, "<< %v\n", err)
		return
	}
	fmt.Fprintf(ctl.status, "<< ok %v\n", words)
	exch := make(chan bool)
	go keepalive(c, exch) //TODO: have list of networks and their keepalive's exchs
}
Example #3
0
func NewStoreSrv(local *fs.LocalStore) (storeSrv *StoreSrv, err os.Error) {
	user := p.OsUsers.Uid2User(os.Geteuid())

	root := new(srv.File)
	err = root.Add(nil, "/", user, nil, p.DMDIR|0555, nil)

	noderoot := &RootFile{store: local}
	err = noderoot.Add(root, r9p.ROOT_FILE, user, nil, 0444, noderoot)

	strongdir := &StrongDir{store: local, File: new(srv.File)}
	err = strongdir.Add(root, r9p.STRONG_DIR, user, nil, p.DMDIR|0555, strongdir)

	storeSrv = &StoreSrv{
		local: local,
		user:  user}
	storeSrv.Fsrv = srv.NewFileSrv(root)

	return storeSrv, nil
}