comparison mod_auth_external/examples/go/prosody-auth-example/main.go @ 1164:b6280e8886f4

mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
author Matthew Wild <mwild1@gmail.com>
date Thu, 15 Aug 2013 16:44:43 +0100
parents
children
comparison
equal deleted inserted replaced
1163:52bee1247014 1164:b6280e8886f4
1 package main
2
3 import "fmt"
4 import "bufio"
5 import "os"
6 import "strings"
7
8 const (
9 ACTION = iota
10 USER
11 HOST
12 PASSWORD
13 )
14
15 func main() {
16 stdin := bufio.NewScanner(os.Stdin)
17 for stdin.Scan() {
18 parts := strings.SplitN(stdin.Text(), ":", 4)
19 switch parts[ACTION] {
20 case "auth":
21 if parts[USER] == "someone" {
22 fmt.Printf("1\n")
23 continue
24 }
25
26 default: fmt.Printf("0\n")
27 }
28 }
29 }