Initial commit :bom:
This commit is contained in:
commit
ab78b5e144
|
@ -0,0 +1,12 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
# Extensions we have: coffee, js, yml, json
|
||||
# and follow same settings for all of these
|
||||
charset = "utf8"
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
|
@ -0,0 +1,5 @@
|
|||
source "https://rubygems.org"
|
||||
ruby '2.2.2'
|
||||
|
||||
gem 'sinatra'
|
||||
gem 'minitest'
|
|
@ -0,0 +1,22 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
minitest (5.7.0)
|
||||
rack (1.6.4)
|
||||
rack-protection (1.5.3)
|
||||
rack
|
||||
sinatra (1.4.6)
|
||||
rack (~> 1.4)
|
||||
rack-protection (~> 1.4)
|
||||
tilt (>= 1.3, < 3)
|
||||
tilt (2.0.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
minitest
|
||||
sinatra
|
||||
|
||||
BUNDLED WITH
|
||||
1.10.5
|
|
@ -0,0 +1,24 @@
|
|||
# lightsaber
|
||||
|
||||
Lightsaber is a simple DNS Redirect service. It offers 301/302 redirects for
|
||||
your domains. The configuration is kept public on this github repository itself.
|
||||
|
||||
## Usage
|
||||
|
||||
To add a DNS record, point your domain via a CNAME entry to `lightsaber.captnemo.in`.
|
||||
|
||||
Next, you will need to do the following:
|
||||
|
||||
1. Fork this repo
|
||||
2. Edit the config.yml file and add your redirect in the relevant section
|
||||
3. File a Pull Request with your edit
|
||||
|
||||
Once the Pull Request is approved, the redirect will automatically be deployed
|
||||
via Travis.
|
||||
|
||||
If you do not wish to make your domain redirects public, or give away your domain
|
||||
names, you can self host this as well.
|
||||
|
||||
## License
|
||||
|
||||
Released under the [MIT License](http://nemo.mit-license.org/).
|
|
@ -0,0 +1,4 @@
|
|||
301:
|
||||
github.captnemo.in: https://github.com/captn3m0
|
||||
302:
|
||||
fb.captnemo.in: https://facebook.com/captn3m0
|
|
@ -0,0 +1,37 @@
|
|||
require 'minitest/autorun'
|
||||
require 'resolv'
|
||||
require 'yaml'
|
||||
require 'pp'
|
||||
|
||||
class TestConfig < Minitest::Test
|
||||
REDIRECTS = ['301', '302']
|
||||
def setup
|
||||
@config = YAML::load_file 'config.yml'
|
||||
end
|
||||
|
||||
def test_redirect_sections
|
||||
@config.each do |section, zone|
|
||||
assert REDIRECTS.include? section.to_s
|
||||
end
|
||||
end
|
||||
|
||||
def test_each_domain
|
||||
@config.each do |section, zone|
|
||||
zone.each do |domain, redirect|
|
||||
assert resolves_to_lightsaber(domain),
|
||||
"DNS for #{domain} isn't setup yet. See README"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def resolves_to_lightsaber(domain)
|
||||
flag = false
|
||||
Resolv::DNS.open do |dns|
|
||||
records = dns.getresources domain, Resolv::DNS::Resource::IN::CNAME
|
||||
records.each do |record|
|
||||
flag||=record.name.to_s === "lightsaber.captnemo.in"
|
||||
end
|
||||
end
|
||||
flag
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue