Software /
code /
prosody-modules
Annotate
mod_auth_external/examples/go/prosody-auth-example/main.go @ 3436:12c7c0d7e1b0
mod_pubsub_text_interface/README: Fix typo (thanks perflyst)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 07 Jan 2019 19:46:04 +0100 |
parent | 1164:b6280e8886f4 |
rev | line source |
---|---|
1164
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 package main |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 import "fmt" |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 import "bufio" |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 import "os" |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 import "strings" |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 const ( |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 ACTION = iota |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 USER |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 HOST |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 PASSWORD |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 ) |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 func main() { |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 stdin := bufio.NewScanner(os.Stdin) |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 for stdin.Scan() { |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 parts := strings.SplitN(stdin.Text(), ":", 4) |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 switch parts[ACTION] { |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 case "auth": |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 if parts[USER] == "someone" { |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 fmt.Printf("1\n") |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 continue |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 } |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 default: fmt.Printf("0\n") |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 } |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 } |
b6280e8886f4
mod_auth_external: Move example scripts to new examples/ dir, and add Lua and Go examples
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 } |