internalbind command vuser_commands
 
proc vuser_commands {client parameters} {
	if {[string equal -nocase [lindex $parameters 0] "help"] && [getbncuser $client "admin"]} {
		bncaddcommand vuser Admin "List users of a certain VHOST" "Syntax: vuser <ip>\nList users with <ip> as VHOST."
	} elseif {[string equal -nocase [lindex $parameters 0] "vuser"] && [getbncuser $client "admin"]} {
		haltoutput
		if {[llength $parameters] > 1} {
			set ip [lindex $parameters 1]
			set results {}
			foreach user [bncuserlist] {
				if {([getbncuser $user "vhost"] eq $ip) || ([getbncuser $user "vhost"] eq "" && $ip eq "default")} {
					lappend results $user
				}
			}
			if {$ip eq "default"} {
				set t "the default"
			} else {
				set t "$ip as"
			}
			if {[llength $results] > 0} {
				bncreply "Users using $t VHOST = [join $results ", "]"
			} else {
				bncreply "Found no users using $t VHOST."
			}
		} else {
			bncreply "Please specify an IP (or \"default\")."
		}
	}
}
