masquito 1.0.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 475805dc608ba0ec90ad60fe06e97e808c6df2d4
4
- data.tar.gz: 064c50eede7608e545e02882de927db547aef397
3
+ metadata.gz: 10d01491a5d517a67884d816e177870592f4b9a1
4
+ data.tar.gz: e9aa4089332f7948e84ee93d358e7c6dc856cff4
5
5
  SHA512:
6
- metadata.gz: 2c47cb5b111aadaa9aec0c214c2078b2c2d423b04e4d6a5d8a7f2d026d153dd801d4fcdcb0937d5a20c7158ae768afe4f303a60eb34b5d159f1f5a03b13c8945
7
- data.tar.gz: b1788664477278498a85ff82db93607c751f3669b10abc2cbf2ee1a8a566f9bd0b7ab131ff1689de060bebfa131daa52438d8d5b14c1f0a65009f8f6f3d76e8f
6
+ metadata.gz: 106f4fd5b3f2741265bceb1021c8c4813d6235f956df46ce441592a513c2ca384becd690725d9d494a03b5ec45d913ef3dd7dd45aaa177f2fcf83a6113fe453a
7
+ data.tar.gz: ba2ff985b9504500ea9073be2311b0dfe5169059e3663115f8f0c4ee2bac6b22f460baf95281e785a422fe5f49adb79b2053252d5a41bb3cb5910d1ff2b24b1c
data/config/masquito.erb CHANGED
@@ -1,3 +1,2 @@
1
1
  nameserver 127.0.0.1
2
2
  port <%= Masquito::DNS::PORT %>
3
- domain dev
data/lib/masquito/dns.rb CHANGED
@@ -12,9 +12,9 @@ module Masquito
12
12
  }
13
13
  @@ttl = 10800 # 3 hours
14
14
 
15
- def initialize(addr = ADDRESS, port = PORT, config_path = CONFIG_PATH)
15
+ def initialize(addr = ADDRESS, port = PORT, settings = Settings.new)
16
16
  puts "Starting Masquito on #{addr}:#{port}"
17
- @settings = Settings.new(config_path)
17
+ @settings = settings
18
18
 
19
19
  # Bind port to receive requests
20
20
  socket = UDPSocket.new
@@ -2,6 +2,7 @@ require 'erb'
2
2
  require 'fileutils'
3
3
  require 'lunchy'
4
4
  require 'tempfile'
5
+ require 'pathname'
5
6
 
6
7
  module Masquito
7
8
  GEM_PATH = File.expand_path('../../../', __FILE__)
@@ -10,7 +11,7 @@ module Masquito
10
11
  SERVICE_NAME = File.basename(PLIST_NAME, '.plist')
11
12
 
12
13
  RESOLVER_TEMPLATE_PATH = File.join(GEM_PATH, 'config', 'masquito.erb')
13
- RESOLVER_PATH = '/etc/resolver/masquito'
14
+ RESOLVERS_PATH = Pathname.new('/etc/resolver')
14
15
 
15
16
  module Install
16
17
  class << self
@@ -43,12 +44,16 @@ module Masquito
43
44
  abort_unless_superuser
44
45
  resolver = ERB.new(File.read(RESOLVER_TEMPLATE_PATH))
45
46
  template = resolver.result(binding)
46
- File.open(RESOLVER_PATH, 'w') { |f| f.write(template) }
47
+ Masquito::Settings.new.domains.each do |domain|
48
+ File.open(RESOLVERS_PATH.join(domain.to_s), 'w') { |f| f.write(template) }
49
+ end
47
50
  end
48
51
 
49
52
  def resolver_uninstall
50
53
  abort_unless_superuser
51
- FileUtils.rm_rf(RESOLVER_PATH)
54
+ Masquito::Settings.new.domains.each do |domain|
55
+ FileUtils.rm_rf(RESOLVERS_PATH.join(domain.to_s))
56
+ end
52
57
  end
53
58
 
54
59
  private
@@ -3,7 +3,7 @@ require 'pathname'
3
3
 
4
4
  module Masquito
5
5
  class Settings
6
- def initialize(config_path)
6
+ def initialize(config_path = CONFIG_PATH)
7
7
  @pattern = File.join(config_path, '*')
8
8
  end
9
9
 
@@ -1,3 +1,3 @@
1
1
  module Masquito
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.1'
3
3
  end
data/lib/masquito.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Masquito
2
2
  CONFIG_PATH = File.join(ENV['HOME'], '.masquito')
3
3
 
4
- autoload :DNS, 'masquito/dns'
4
+ autoload :DNS, 'masquito/dns'
5
5
  autoload :Settings, 'masquito/settings'
6
- autoload :Install, 'masquito/install'
7
- autoload :VERSION, 'masquito/version'
6
+ autoload :Install, 'masquito/install'
7
+ autoload :VERSION, 'masquito/version'
8
8
  end
data/masquito.gemspec CHANGED
@@ -17,4 +17,6 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ['lib']
18
18
 
19
19
  gem.add_runtime_dependency 'lunchy'
20
+
21
+ gem.add_development_dependency 'rake'
20
22
  end
data/test/dns_test.rb CHANGED
@@ -17,7 +17,7 @@ class TestMasquitoDNS < Test::Unit::TestCase
17
17
  end
18
18
 
19
19
  @thread = Thread.new do
20
- Masquito::DNS.new('127.0.0.1', '51234', TEMP_DIR)
20
+ Masquito::DNS.new('127.0.0.1', '51234', Masquito::Settings.new(TEMP_DIR))
21
21
  end
22
22
  end
23
23
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: masquito
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Vorotilin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-05 00:00:00.000000000 Z
12
+ date: 2013-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lunchy
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - '>='
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
28
42
  description: Masquito is a dns masquerading server for rubists
29
43
  email:
30
44
  - d.vorotilin@gmail.com
@@ -78,3 +92,4 @@ test_files:
78
92
  - test/dns_test.rb
79
93
  - test/settings_test.rb
80
94
  - test/test_helper.rb
95
+ has_rdoc: