Created
February 9, 2016 16:55
-
-
Save johnhamelink/ea5da9c7cc21bc240aa2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule XmppChecker do | |
| use Application | |
| require Logger | |
| use Yodel.Handler | |
| # See http://elixir-lang.org/docs/stable/elixir/Application.html | |
| # for more information on OTP Applications | |
| def check do | |
| Logger.info "Running" | |
| File.stream!("sessions.csv") | |
| |> CSV.decode | |
| |> Enum.map(&check_session/1) | |
| end | |
| def check_session([id, _email, _encrypted_pass, _, _, _, _, _, _, _, _, _type, _, _, _postcode, _, _, token, _digits_id, _coords]) do | |
| {:ok, conn} = connect('54.229.134.179', 5222) | |
| try do | |
| opts = [ | |
| jid: "user_#{id}@chat-production.findaplayer.com", | |
| password: token, | |
| nickname: "user_#{id}" | |
| ] | |
| start_yodeling( | |
| conn, | |
| initial_stream("chat-production.findaplayer.com", "user_#{id}", token, "xmpp_checker") | |
| ) | |
| rescue | |
| e in RuntimeError -> e | |
| Logger.warn("Error for User ID => #{id}: #{inspect(e)}") | |
| end | |
| end | |
| def initial_stream(xmpp_serv, username, password, resource) do | |
| [ | |
| open_stream(xmpp_serv, header: true), | |
| authenticate(username, password) | |
| ] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment