shyoboi-ddns 0.0.1
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.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +21 -0
- data/config.ru +2 -0
- data/lib/shyoboi-ddns.rb +22 -0
- data/lib/shyoboi-ddns/providers.rb +2 -0
- data/lib/shyoboi-ddns/providers/route53.rb +58 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f82a00d700eae37e8ae62cedb95aa69643e35d7a
|
4
|
+
data.tar.gz: 63851e5d74d6ab2e9e4c427b687534bfbfed9111
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d92134fa99361c0a581d6cc146b7e4ff25e4d5989dcc7f19fd4db059e16b280423746bca930ca8d792d2567f2f448856ca7270656a3c14c95c34c30de4b2f062
|
7
|
+
data.tar.gz: 3e493b2b60d355c93bb18ff8ddc5021cfd5879ca3ab7891ddaec64b49913f8b2b988c88504100200a0a019c6a70c40395715e2f4007e29b38d51f7ede85b39f9
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Seiei Higa.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
shyoboi-ddns
|
2
|
+
============
|
3
|
+
Cheap Dynamic DNS Server.
|
4
|
+
|
5
|
+
- - -
|
6
|
+
|
7
|
+
しょぼいDDNSサーバです。
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
```
|
12
|
+
$ git clone git@github.com:hanachin/shyoboi-ddns.git
|
13
|
+
$ heroku create yourapp
|
14
|
+
$ git push heroku
|
15
|
+
$ heroku config:add AWS_ACCESS_KEY_ID=YOUR_AWS_ACCESS_KEY_ID
|
16
|
+
$ heroku config:add AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY
|
17
|
+
$ heroku config:add HOSTED_ZONE_ID=YOUR_ROUTE53_HOSTED_ZONE_ID
|
18
|
+
$ heroku config:add SHYOBOI_DOMAIN=YOUR_FQN_DOMAIN_NAME
|
19
|
+
```
|
20
|
+
|
21
|
+
Then add `curl http://yourapp.herokuapp.com` to crontab.
|
data/config.ru
ADDED
data/lib/shyoboi-ddns.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
class ShyoboiDdns < Sinatra::Base
|
4
|
+
require 'shyoboi-ddns/providers'
|
5
|
+
|
6
|
+
get '/' do
|
7
|
+
provider.update(domain, request.ip)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
def provider
|
12
|
+
ShyoboiDdns::Providers::Route53.new(hosted_zone_id)
|
13
|
+
end
|
14
|
+
|
15
|
+
def domain
|
16
|
+
@domain ||= ENV['SHYOBOI_DOMAIN']
|
17
|
+
end
|
18
|
+
|
19
|
+
def hosted_zone_id
|
20
|
+
@hosted_zone_id ||= ENV['HOSTED_ZONE_ID']
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'aws-sdk'
|
2
|
+
|
3
|
+
class ShyoboiDdns::Providers::Route53
|
4
|
+
attr_accessor :access_key_id, :secret_access_key
|
5
|
+
|
6
|
+
def access_key_id
|
7
|
+
@access_key_id ||= ENV['AWS_ACCESS_KEY_ID']
|
8
|
+
end
|
9
|
+
|
10
|
+
def secret_access_key
|
11
|
+
@secret_access_key ||= ENV['AWS_SECRET_ACCESS_KEY']
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(hosted_zone_id)
|
15
|
+
@hosted_zone_id = hosted_zone_id
|
16
|
+
end
|
17
|
+
|
18
|
+
def update(domain, ip)
|
19
|
+
r53.client.change_resource_record_sets(
|
20
|
+
hosted_zone_id: @hosted_zone_id,
|
21
|
+
change_batch: {changes: [change(domain, ip)]}
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def r53
|
27
|
+
@r53 ||= AWS::Route53.new(
|
28
|
+
access_key_id: access_key_id,
|
29
|
+
secret_access_key: secret_access_key
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def action
|
34
|
+
'UPSERT'
|
35
|
+
end
|
36
|
+
|
37
|
+
def ttl
|
38
|
+
360
|
39
|
+
end
|
40
|
+
|
41
|
+
def type
|
42
|
+
'A'
|
43
|
+
end
|
44
|
+
|
45
|
+
def change(domain, ip)
|
46
|
+
{
|
47
|
+
action: action,
|
48
|
+
resource_record_set: {
|
49
|
+
name: domain,
|
50
|
+
type: type,
|
51
|
+
ttl: ttl,
|
52
|
+
resource_records: [
|
53
|
+
{value: ip}
|
54
|
+
]
|
55
|
+
}
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shyoboi-ddns
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Seiei Higa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sinatra
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
42
|
+
email: hanachin@gmail.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- LICENSE
|
48
|
+
- README.md
|
49
|
+
- config.ru
|
50
|
+
- lib/shyoboi-ddns.rb
|
51
|
+
- lib/shyoboi-ddns/providers.rb
|
52
|
+
- lib/shyoboi-ddns/providers/route53.rb
|
53
|
+
homepage: https://github.com/hanachin/shyoboi-ddns
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - "~>"
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 2.1.2
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.2.2
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: Simple DDNS Server
|
77
|
+
test_files: []
|