Ejemplo n.º 1
0
func cmdUserhost(source interface{}, params [][]byte) {
	c := source.(*Client)

	nicks := strings.Fields(string(params[0]))
	var replyline string
	for _, nick := range nicks {
		var user *core.User
		if user = core.GetUserByNick(nick); user == nil {
			continue
		}

		if replyline != "" {
			replyline += " "
		}

		replyline += nick
		if user.Data("op") != "" {
			replyline += "*"
		}
		replyline += "="
		if user.Data("away") != "" {
			replyline += "-"
		} else {
			replyline += "+"
		}
		replyline += user.GetHostname()
	}

	c.SendLineTo(nil, "302", ":%s", replyline)
}
Ejemplo n.º 2
0
func cmdOperflags(source interface{}, params [][]byte) {
	c := source.(*Client)

	var target *core.User
	if target = core.GetUserByNick(string(params[0])); target == nil {
		c.SendLineTo(nil, "401", "%s %s :No such user.", c.u.Nick(),
			params[0])
		return
	}

	var flags string
	if flags = target.Data("op"); flags == "" {
		c.SendLineTo(nil, "304", ":OPERFLAGS: %s has no server oper flags.", target.Nick())
		return
	}

	if flags == "on" {
		flags = perm.DefaultServerOp()
	}
	c.SendLineTo(nil, "304", ":OPERFLAGS: %s has server oper flags: %s", target.Nick(), flags)

	var commands string
	if commands = target.Data("opcommands"); commands == "" {
		return
	}
	c.SendLineTo(nil, "304", ":OPERFLAGS: %s also has the following specific commands: %s", target.Nick(), commands)
}
Ejemplo n.º 3
0
// HasOperCommand returns whether the user has access to the given oper command.
// This checks for the presence of the command in their opcommand list, and
// if a flag is given, also checks for the presence of that, including the
// "on" keyword for default privileges.
//
// Unlike HasOpFlag, this SHOULD be used directly to determine if a user can
// run the given command, as we extend the ability to adjust who has access to
// commands to the server administration via configuration instead of modules
// in the case of oper commands.
func HasOperCommand(u *core.User, flag, command string) bool {
	var words []string

	// Check commands.
	words = strings.Fields(u.Data("opcommands"))
	for _, word := range words {
		if word == command {
			return true
		}
	}

	// Check flags.
	words = strings.Fields(u.Data("op"))
	for _, word := range words {
		if word == flag {
			return true
		}
		if word == "on" {
			for _, defword := range defServerOp {
				if defword == flag {
					return true
				}
			}
		}
	}

	return false
}
Ejemplo n.º 4
0
// Introduce a user to a given local server.
func send_uid(l *local, u *core.User) {
	irc.SendFrom(l, from(nil), "UID %s 1 %d +i %s %s %s %s :%s", u.Nick(),
		u.NickTS(), u.GetIdent(), u.GetHostname(), u.GetIP(), u.ID(),
		u.Data("realname"))
}