Mercurial > prosody-modules
annotate mod_auth_external/examples/go/prosody-auth-example/main.go @ 2491:5fbca7de2088
mod_smacks: Send out more ack requests where needed
Under some circumstances it was possible that more than "max_unacked_stanzas"
where left in the outgoing stanza queue without forcing an ack.
This could happen, when more stanzas entered the queue while the last ack request
was still unanswered.
Now the test "#queue > max_unacked_stanzas" is done upon receiving
an ack as well as when sending out stanzas, which fixes this bug.
author | tmolitor <thilo@eightysoft.de> |
---|---|
date | Sun, 12 Feb 2017 19:27:50 +0100 |
parents | b6280e8886f4 |
children |
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 } |