SelectServerCache searches the server list for a cached entry matching the given IP and optional user. It returns the matching config, its index, and whether a match was found.
(user string, ip string, conf *MainConfig)
| 5 | // IP and optional user. It returns the matching config, its index, and whether a |
| 6 | // match was found. |
| 7 | func SelectServerCache(user string, ip string, conf *MainConfig) (*ServerListConfig, int, bool) { |
| 8 | for index, server := range conf.ServerLists { |
| 9 | if server.IP == ip { |
| 10 | if user != "" { |
| 11 | if server.User == user { |
| 12 | return &conf.ServerLists[index], index, true |
| 13 | } |
| 14 | } else { |
| 15 | return &conf.ServerLists[index], index, true |
| 16 | } |
| 17 | } |
| 18 | } |
| 19 | return nil, 0, false |
| 20 | } |
| 21 | |
| 22 | // ResolveAlias looks up the given alias in the server list and returns the |
| 23 | // corresponding IP address. If no match is found, the alias string itself is returned. |
no outgoing calls