hokaido 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +19 -0
- data/Rakefile +2 -0
- data/bin/hokaido +14 -0
- data/hokaido.gemspec +25 -0
- data/lib/hokaido/cli.rb +96 -0
- data/lib/hokaido/version.rb +3 -0
- data/lib/hokaido.rb +4 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0fbf74813f35f4cbaaab55e0d594a25b9471c587
|
4
|
+
data.tar.gz: 3b4ed0a1da6a8ce4baa37adb85230d6bc4dbafeb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 103a2efc58a70cb4c62f10c5df776269c704f944268a5849205880a77f44ea949a407bb58fcf63ee0a805342b7a7068faeb6cc26e355dd957b67ac406511b054
|
7
|
+
data.tar.gz: e1c00a7e5f144292f84995f312a5c8a27eaba5e51cd10dcfa7d917cf01c7097d17d35f9cec7a0341eb7fca29a818850e86e5fb30750a58e53e452ac8cfe9e7a0
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/*
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 ursmhbry
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Hokaido
|
2
|
+
|
3
|
+
## 1. Start server (Anywhere in internet)
|
4
|
+
|
5
|
+
``` sh
|
6
|
+
$ hokaido server # on 203.0.113.10:4423
|
7
|
+
```
|
8
|
+
|
9
|
+
## 2. Start viewer (Tokyo)
|
10
|
+
|
11
|
+
``` sh
|
12
|
+
$ hokaido viewer --host 203.0.113.10
|
13
|
+
```
|
14
|
+
|
15
|
+
## 3. Start new live shell (Hokaido!)
|
16
|
+
|
17
|
+
``` sh
|
18
|
+
$ hokaido sh --host 203.0.113.10
|
19
|
+
```
|
data/Rakefile
ADDED
data/bin/hokaido
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'hokaido/cli'
|
4
|
+
|
5
|
+
# 1. Start server (Anywhere in internet)
|
6
|
+
# hokaido server # on 203.0.113.10:4423
|
7
|
+
#
|
8
|
+
# 2. Start viewer (Tokyo)
|
9
|
+
# hokaido viewer --host 203.0.113.10
|
10
|
+
#
|
11
|
+
# 3. Start new live shell (Hokaido!)
|
12
|
+
# hokaido sh --host 203.0.113.10
|
13
|
+
|
14
|
+
Hokaido::CLI.start
|
data/hokaido.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hokaido/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hokaido"
|
8
|
+
spec.version = Hokaido::VERSION
|
9
|
+
spec.authors = %w(ursm hibariya)
|
10
|
+
spec.email = %w(ursm@ursm.jp celluloid.key@gmail.com)
|
11
|
+
spec.summary = 'HND✈CTS'
|
12
|
+
spec.homepage = 'https://github.com/ursmhbry/hokaido'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'thor'
|
21
|
+
spec.add_runtime_dependency 'ruby-terminfo'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
end
|
data/lib/hokaido/cli.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'io/console'
|
2
|
+
require 'pty'
|
3
|
+
require 'socket'
|
4
|
+
require 'terminfo'
|
5
|
+
require 'thor'
|
6
|
+
require 'thread'
|
7
|
+
|
8
|
+
module Hokaido
|
9
|
+
class CLI < Thor
|
10
|
+
class_option :host, aliases: :h, default: 0
|
11
|
+
class_option :port, aliases: :p, default: 4423
|
12
|
+
|
13
|
+
desc :sh, 'Start live shell'
|
14
|
+
def sh(shell = ENV['SHELL'])
|
15
|
+
pty_out, pty_in, pid = *PTY.getpty(shell)
|
16
|
+
nonbloq = Queue.new
|
17
|
+
|
18
|
+
trap :SIGWINCH do
|
19
|
+
TermInfo.tiocswinsz pty_in, *TermInfo.screen_size
|
20
|
+
end
|
21
|
+
|
22
|
+
Thread.start do
|
23
|
+
client = TCPSocket.open(*options.values_at(:host, :port))
|
24
|
+
client.puts 'write'
|
25
|
+
|
26
|
+
while c = nonbloq.deq
|
27
|
+
client.putc c
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Thread.start do
|
32
|
+
while c = pty_out.getc
|
33
|
+
$stdout.putc c
|
34
|
+
nonbloq.enq c
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Thread.start do
|
39
|
+
TermInfo.tiocswinsz pty_in, *TermInfo.screen_size
|
40
|
+
|
41
|
+
while c = $stdin.getch
|
42
|
+
pty_in.putc c
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Process.waitpid pid
|
47
|
+
end
|
48
|
+
|
49
|
+
desc :server, 'Start server'
|
50
|
+
def server
|
51
|
+
queue = Queue.new
|
52
|
+
server = TCPServer.open(*options.values_at(:host, :port))
|
53
|
+
|
54
|
+
loop do
|
55
|
+
Thread.start server.accept do |client|
|
56
|
+
case client.gets.chomp
|
57
|
+
when 'write'
|
58
|
+
client.puts ':)'
|
59
|
+
|
60
|
+
while c = client.getc
|
61
|
+
queue.enq c
|
62
|
+
end
|
63
|
+
when 'read'
|
64
|
+
client.puts '=)'
|
65
|
+
|
66
|
+
while c = queue.deq
|
67
|
+
client.putc c
|
68
|
+
end
|
69
|
+
else
|
70
|
+
client.puts ':('
|
71
|
+
end
|
72
|
+
|
73
|
+
client.close
|
74
|
+
end
|
75
|
+
end
|
76
|
+
rescue Interrupt
|
77
|
+
server.close
|
78
|
+
|
79
|
+
exit
|
80
|
+
end
|
81
|
+
|
82
|
+
desc :viewer, 'Open viewer'
|
83
|
+
def viewer
|
84
|
+
client = TCPSocket.open(*options.values_at(:host, :port))
|
85
|
+
client.puts 'read'
|
86
|
+
|
87
|
+
while c = client.getc
|
88
|
+
$stdout.putc c
|
89
|
+
end
|
90
|
+
rescue Interrupt
|
91
|
+
client.close
|
92
|
+
|
93
|
+
exit
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/hokaido.rb
ADDED
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hokaido
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ursm
|
8
|
+
- hibariya
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-10-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: ruby-terminfo
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.7'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.7'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '10.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '10.0'
|
70
|
+
description:
|
71
|
+
email:
|
72
|
+
- ursm@ursm.jp
|
73
|
+
- celluloid.key@gmail.com
|
74
|
+
executables:
|
75
|
+
- hokaido
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- ".gitignore"
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/hokaido
|
86
|
+
- hokaido.gemspec
|
87
|
+
- lib/hokaido.rb
|
88
|
+
- lib/hokaido/cli.rb
|
89
|
+
- lib/hokaido/version.rb
|
90
|
+
homepage: https://github.com/ursmhbry/hokaido
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.2.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: HND✈CTS
|
114
|
+
test_files: []
|