titech-pubnet-auth 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +13 -8
- data/bin/titech-pubnet-auth +4 -6
- data/config/private.yml.example +3 -0
- data/lib/titech_pubnet_auth.rb +8 -6
- data/titech_pubnet_auth.gemspec +1 -1
- metadata +3 -4
- data/config/private.yml +0 -4
- data/config/proxy.yml +0 -3
data/README.md
CHANGED
@@ -4,12 +4,12 @@
|
|
4
4
|
|
5
5
|
Mac OS X Mountain Lion, Ruby1.9.3 で動作確認済みです。たぶん Ruby1.9 じゃないと動きません。
|
6
6
|
|
7
|
-
titech-pubnet
|
7
|
+
titech-pubnet の認証の仕様に依存しているため、仕様が変われば動かなくなるかもしれません。その時はこの gem をバージョンアップして対応するかもしれません。主に以下のようなものの内容に依存していると思います。
|
8
8
|
|
9
9
|
- 認証ページのドメイン
|
10
10
|
- 認証ページのフォーム
|
11
11
|
- 認証ページのloginscript.js
|
12
|
-
- titech-pubnet の HTTP
|
12
|
+
- titech-pubnet の HTTPプロキシ
|
13
13
|
|
14
14
|
## 使い方
|
15
15
|
|
@@ -18,9 +18,9 @@ titech-pubnet の認証の仕様に依存しているため、仕様が変われ
|
|
18
18
|
$ sudo port install ruby19 # MacPortsを使うなら
|
19
19
|
$ brew install ruby # Homebrewを使うなら
|
20
20
|
|
21
|
-
gem のインストール
|
21
|
+
gem のインストール [^1]
|
22
22
|
|
23
|
-
gem install titech-pubnet-auth
|
23
|
+
$ gem install titech-pubnet-auth
|
24
24
|
|
25
25
|
最初に、ユーザー名、パスワードを設定
|
26
26
|
|
@@ -40,15 +40,20 @@ gem のインストール
|
|
40
40
|
|
41
41
|
### ログイン時に起動する方法(Mac OS X の場合)
|
42
42
|
|
43
|
-
|
43
|
+
色々あるけど以下だとほぼGUIで完結する。
|
44
44
|
|
45
|
-
1. 「システム環境設定」→「ユーザとグループ」→「ログイン項目」に起動スクリプト`titech-pubnet-auth-daemon
|
46
|
-
2. (デフォルトだとプロセス終了時にターミナル.app
|
45
|
+
1. 「システム環境設定」→「ユーザとグループ」→「ログイン項目」に起動スクリプト`titech-pubnet-auth-daemon`を追加(`$ which titech-pubnet-auth-daemon`とかで場所を調べて、Finder上で⌘gでパス指定して移動できる)。
|
46
|
+
2. (デフォルトだとプロセス終了時にターミナル.appが閉じない。これが煩わしい場合、)ターミナルを起動して、「環境設定」→「設定タブ」→「シェル」で、「シェルの終了時」の動作を「ウィンドウを閉じる」にする。
|
47
47
|
|
48
48
|
## TODO
|
49
49
|
|
50
|
-
-
|
50
|
+
- ライセンス明示
|
51
|
+
- 連絡先明示
|
52
|
+
- 接続確認のサンプル増やしたい
|
53
|
+
- Notification Center 使う
|
51
54
|
- パスワードを暗号化して保管
|
52
55
|
- 正しいやり方調べる
|
53
56
|
- Logger
|
54
57
|
- テスト
|
58
|
+
|
59
|
+
[^1]: 依存している gem の一つである nokogiri(XMLパーサー)が native extension を使っていて必要なものが無いと install で失敗するかも。http://nokogiri.org/tutorials/installing_nokogiri.html を参照。
|
data/bin/titech-pubnet-auth
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- coding: utf-8 -*-
|
3
|
-
require 'pry'
|
4
3
|
|
5
4
|
$:.unshift File.expand_path('../lib', File.dirname(__FILE__))
|
6
5
|
require 'titech_pubnet_auth'
|
@@ -36,11 +35,9 @@ if configure
|
|
36
35
|
system "stty -echo"
|
37
36
|
puts 'Please type your password (typing will be hidden):'
|
38
37
|
password = gets.strip
|
39
|
-
conf = {
|
40
|
-
{
|
38
|
+
conf = {
|
41
39
|
'username' => username,
|
42
40
|
'password' => password
|
43
|
-
}
|
44
41
|
}
|
45
42
|
f = File::open(File.expand_path('../config/private.yml', File.dirname(__FILE__)),'w'){|f|
|
46
43
|
f << conf.to_yaml
|
@@ -60,12 +57,13 @@ loop do
|
|
60
57
|
mputs 'network_available?', pubnet_auth.network_available?
|
61
58
|
mputs 'is_connected?', pubnet_auth.is_connected? if pubnet_auth.network_available?
|
62
59
|
mputs 'auth', pubnet_auth.auth if pubnet_auth.network_available? and not pubnet_auth.is_connected?
|
63
|
-
|
64
|
-
sleep interval
|
60
|
+
|
65
61
|
rescue => e
|
66
62
|
p e
|
67
63
|
ensure
|
64
|
+
print "\n"
|
68
65
|
$stdout.flush
|
66
|
+
sleep interval
|
69
67
|
end
|
70
68
|
break if single
|
71
69
|
end
|
data/lib/titech_pubnet_auth.rb
CHANGED
@@ -12,17 +12,20 @@ class TitechPubnetAuth
|
|
12
12
|
BASE_DIR = File.expand_path('..',File.dirname(__FILE__))
|
13
13
|
|
14
14
|
SAMPLE_URI = URI.parse('http://github.com')
|
15
|
+
|
16
|
+
HTTP_PROXY = {ip: '131.112.125.238', port: 3128}
|
17
|
+
OPEN_TIMEOUT = 5
|
15
18
|
|
16
19
|
def initialize
|
20
|
+
@private = YAML.load(File::open(File::expand_path('config/private.yml',BASE_DIR),'r'))
|
21
|
+
|
17
22
|
@agent, @agent_with_proxy = Mechanize.new, Mechanize.new
|
18
23
|
[@agent,@agent_with_proxy].each{|agent|
|
19
24
|
agent.follow_meta_refresh = true
|
20
|
-
agent.open_timeout =
|
25
|
+
agent.open_timeout = OPEN_TIMEOUT
|
21
26
|
}
|
22
|
-
|
23
|
-
@agent_with_proxy.set_proxy(proxy['ip'], proxy['port'])
|
27
|
+
@agent_with_proxy.set_proxy(HTTP_PROXY[:ip], HTTP_PROXY[:port])
|
24
28
|
|
25
|
-
@private = YAML.load(File::open(File::expand_path('config/private.yml',BASE_DIR),'r'))['private']
|
26
29
|
end
|
27
30
|
|
28
31
|
def auth
|
@@ -45,8 +48,7 @@ class TitechPubnetAuth
|
|
45
48
|
|
46
49
|
def is_connected?
|
47
50
|
return @agent_with_proxy.get(SAMPLE_URI).uri.hostname == SAMPLE_URI.hostname
|
48
|
-
rescue
|
49
|
-
# retry without the proxy
|
51
|
+
rescue # retry without the proxy
|
50
52
|
return @agent.get(SAMPLE_URI) == SAMPLE_URI.hostname
|
51
53
|
end
|
52
54
|
|
data/titech_pubnet_auth.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
15
|
gem.name = "titech-pubnet-auth"
|
16
16
|
gem.require_paths = ["lib"]
|
17
|
-
gem.version = "0.1.
|
17
|
+
gem.version = "0.1.4"
|
18
18
|
|
19
19
|
gem.add_dependency 'colorize'
|
20
20
|
gem.add_dependency 'mechanize', '~> 2.5'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: titech-pubnet-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colorize
|
@@ -56,8 +56,7 @@ files:
|
|
56
56
|
- lib/titech_pubnet_auth.rb
|
57
57
|
- bin/titech-pubnet-auth
|
58
58
|
- bin/titech-pubnet-auth-daemon
|
59
|
-
- config/private.yml
|
60
|
-
- config/proxy.yml
|
59
|
+
- config/private.yml.example
|
61
60
|
- Rakefile
|
62
61
|
- Gemfile
|
63
62
|
- README.md
|
data/config/private.yml
DELETED
data/config/proxy.yml
DELETED