示例#1
0
文件: execute.go 项目: udhos/nexthop
func isAnyUserDefined(root *command.ConfNode) bool {
	node, err := root.Get("username")
	if err != nil {
		return false
	}

	return len(node.Children) > 0
}
示例#2
0
文件: execute.go 项目: udhos/nexthop
func getHostname(root *command.ConfNode) string {
	node, err := root.Get("hostname")
	if err != nil {
		return "hostname?"
	}

	return command.LastToken(node.Children[0].Path)
}
示例#3
0
文件: execute.go 项目: udhos/nexthop
func checkPassword(root *command.ConfNode, username, password string) bool {
	path := fmt.Sprintf("username %s password", username)

	node, err := root.Get(path)
	if err != nil {
		return false
	}

	if len(node.Children) != 1 {
		return false
	}

	return password == command.LastToken(node.Children[0].Path)
}