diff options
author | lain <lain@soykaf.club> | 2019-03-31 14:55:09 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2019-03-31 14:55:09 +0200 |
commit | c810fb81a489dc3faeb1f21092c89a3131188ac1 (patch) | |
tree | c24de8ef4f821add56d8cb4770e7d39afcf2d0ba /lib | |
parent | dc39d8d3fb941bad9fe26586c321bb00a0b92fe4 (diff) | |
download | pleroma-c810fb81a489dc3faeb1f21092c89a3131188ac1.tar.gz |
Basic SSH daemon.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/bbs/bbs.ex | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/pleroma/bbs/bbs.ex b/lib/pleroma/bbs/bbs.ex new file mode 100644 index 000000000..486ab9183 --- /dev/null +++ b/lib/pleroma/bbs/bbs.ex @@ -0,0 +1,34 @@ +defmodule Pleroma.BBS do + def start_daemon do + :ok = :ssh.start() + + options = [ + system_dir: 'ssh_keys', + auth_method_kb_interactive_data: fn (_, user, _) -> { + 'Welcome to Pleroma BBS', + 'Hello #{user}', + 'Password: ', + false } + end, + auth_methods: 'keyboard-interactive,password', + pwdfun: fn(user, password) -> true end, + shell: &start_prompt/1 + ] + :ssh.daemon(13121, options) + end + + def start_prompt(user) do + spawn(__MODULE__, :prompt, [user]) + end + + def prompt(user) do + IO.puts("Hey #{user}.\n") + IO.puts("Here's your timeline:\n") + + user = Pleroma.User.get_cached_by_nickname(to_string(user)) + Pleroma.Web.TwitterAPI.TwitterAPI.fetch_friend_statuses(user) + |> Enum.each(fn (status) -> + IO.puts("#{status["user"]["name"]} (#{status["user"]["screen_name"]}): #{status["text"]}") + end) + end +end |