File

mod_auth_external/examples/go/prosody-auth-example/main.go @ 1766:e4c3d335b07f

mod_list_inactive: Print some usage info when not called with enough arguments
author Kim Alvefur <zash@zash.se>
date Mon, 08 Jun 2015 15:27:28 +0200
parent 1164:b6280e8886f4
line wrap: on
line source

package main

import "fmt"
import "bufio"
import "os"
import "strings"

const (
	ACTION = iota
	USER
	HOST
	PASSWORD
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan() {
		parts := strings.SplitN(stdin.Text(), ":", 4)
		switch parts[ACTION] {
			case "auth":
				if parts[USER] == "someone" {
					fmt.Printf("1\n")
					continue
				}
				
			default: fmt.Printf("0\n")
		}
	}
}