explorer 0.0.2 → 0.0.3

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: 92c4c5434dfa27aea21de62e797f79e5634aee95
4
- data.tar.gz: 332c6ce3352491289eaf6c3199f599e9216395b8
3
+ metadata.gz: 6868f036ef96d91102731a1f805024563e7a8e84
4
+ data.tar.gz: 2072dfb48e958eb3800b0a3179e82af2c53d6153
5
5
  SHA512:
6
- metadata.gz: d574b77ff7efdb07ba7821823fc1c96152459812a9c0f4ef111bc9ffa1b1c9eb5d6c0b6a342220f05a82824d51a0390f4346cf4a12a4e5e179f07d33cf23cdf1
7
- data.tar.gz: 98d3806a19b602d463d44cbe8652194664b84923bf0b1220ab3378837230131ceea14e7dac30645547730e294237db04a2201950960f400ccf34c45a2656cc09
6
+ metadata.gz: ce3d4c72345746c75b82294c9e860bdc4bc89436991d79c32bac09778198e7da978699d098c38eaaecee66854a2b244e310fe83e52e22768d0ad0c63aaea544f
7
+ data.tar.gz: 358e8b32723334191182b56f87b6c066628b52123ea1c6f23086c4c8a1dc035179c0a243299e396fd80e1bec1d8a3c950171f9cb83c0d3b8b268475c3cbe9802
data/README.md CHANGED
@@ -3,26 +3,28 @@
3
3
  Explorer is a replacement for Pow! written in Ruby.
4
4
 
5
5
  [![Dependency Status](https://gemnasium.com/Darksecond/explorer.svg)](https://gemnasium.com/Darksecond/explorer)
6
+ [![Gem Version](https://badge.fury.io/rb/explorer.svg)](http://badge.fury.io/rb/explorer)
6
7
 
7
8
  ## Installation
8
9
 
9
- Add this line to your application's Gemfile:
10
+ Install it yourself as:
10
11
 
11
- ```ruby
12
- gem 'explorer'
13
- ```
12
+ $ gem install explorer
14
13
 
15
- And then execute:
14
+ ## Usage
16
15
 
17
- $ bundle
16
+ Run the following command to start up the server
18
17
 
19
- Or install it yourself as:
18
+ $ explore boot
20
19
 
21
- $ gem install explorer
20
+ The server can be controlled using various subcommands.
21
+ More information can be gotten by running:
22
22
 
23
- ## Usage
23
+ $ explore help proxy
24
+
25
+ and
24
26
 
25
- TODO: Write usage instructions here
27
+ $ explore help process
26
28
 
27
29
  ## Contributing
28
30
 
@@ -0,0 +1,2 @@
1
+ nameserver 127.0.0.1
2
+ port 23400
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>Label</key>
6
+ <string>nl.darksecond.explorer</string>
7
+ <key>ProgramArguments</key>
8
+ <array>
9
+ <string>sh</string>
10
+ <string>-c</string>
11
+ <string>echo "rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 23401
12
+ rdr pass on lo0 inet proto tcp from any to any port 443 -> 127.0.0.1 port 23402" | pfctl -a 'com.apple/250.ExplorerFirewall' -f - -E</string>
13
+ </array>
14
+ <key>RunAtLoad</key>
15
+ <true/>
16
+ <key>UserName</key>
17
+ <string>root</string>
18
+ </dict>
19
+ </plist>
@@ -11,6 +11,7 @@ require 'explorer/ipc_client'
11
11
  require 'explorer/process'
12
12
  require 'explorer/process_manager'
13
13
  require 'explorer/log_watcher'
14
+ require 'explorer/setup'
14
15
 
15
16
  module Explorer
16
17
  DATADIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'data'))
@@ -1,6 +1,7 @@
1
1
  require 'thor'
2
2
  require 'explorer/cli/proxy'
3
3
  require 'explorer/cli/process'
4
+ require 'explorer/cli/setup'
4
5
 
5
6
  module Explorer
6
7
  module CLI
@@ -18,6 +19,9 @@ module Explorer
18
19
  desc 'process SUBCOMMAND ...ARGS', 'manage processes'
19
20
  subcommand 'process', Process
20
21
 
22
+ desc 'setup SUBCOMMAND ...ARGS', 'manage explorer setup'
23
+ subcommand 'setup', Setup
24
+
21
25
  desc "boot [CONFIG]", 'Start explorer'
22
26
  def boot(config=nil)
23
27
  servers = Servers.new hostmap: {'test.dev' => {host: 'localhost', port: 8080}}
@@ -1,5 +1,6 @@
1
1
  require 'rainbow'
2
2
  require 'formatador'
3
+ require 'thor'
3
4
 
4
5
  module Explorer
5
6
  module CLI
@@ -0,0 +1,26 @@
1
+ require 'thor'
2
+ require 'rainbow'
3
+
4
+ module Explorer
5
+ module CLI
6
+ class Setup < Thor
7
+ desc 'install', 'install explorer so that it can be used with `.dev` domains'
8
+ def install
9
+ setup = Explorer::Setup.new
10
+ return puts Rainbow('Explorer is already installed').color(:red) if setup.installed?
11
+ return puts Rainbow('Cannot install, not suitable').color(:red) unless setup.suitable?
12
+ setup.install
13
+ puts Rainbow('Done installing `.dev` support').color(:green).bright
14
+ end
15
+
16
+ desc 'uninstall', 'uninstall `.dev` domain support'
17
+ def uninstall
18
+ setup = Explorer::Setup.new
19
+ return puts Rainbow('Explorer is not installed').color(:red) unless setup.installed?
20
+ return puts Rainbow('Cannot uninstall, not suitable').color(:red) unless setup.suitable?
21
+ setup.uninstall
22
+ puts Rainbow('Done uninstalling `.dev` support').color(:green).bright
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,68 @@
1
+ require 'etc'
2
+
3
+ module Explorer
4
+ class Setup
5
+ FIREWALL_PLIST_DST = '/Library/LaunchDaemons/nl.darksecond.explorer.firewall.plist'
6
+ RESOLVER_FILE_DST = '/etc/resolver/dev'
7
+ RESOLVER_DIR_DST = '/etc/resolver'
8
+
9
+ def install
10
+ firewall_plist_src = File.join(Explorer::DATADIR, 'setup', 'firewall.plist')
11
+ resolver_file_src = File.join(Explorer::DATADIR, 'setup', 'dev')
12
+
13
+ mkdir(RESOLVER_DIR_DST)
14
+ FileUtils.cp resolver_file_src, RESOLVER_FILE_DST
15
+ puts Rainbow("Installed `#{RESOLVER_FILE_DST}`").color(:green).bright
16
+
17
+ FileUtils.cp firewall_plist_src, FIREWALL_PLIST_DST
18
+ puts Rainbow("Installed `#{FIREWALL_PLIST_DST}`").color(:green).bright
19
+
20
+ unload_firewall
21
+ load_firewall
22
+ puts Rainbow('Loaded firwall rules').color(:green).bright
23
+
24
+ rescue Errno::EACCES => e
25
+ puts Rainbow("Something went wrong installing (#{e.message})").color(:red).bright
26
+ end
27
+
28
+ def uninstall
29
+ FileUtils.rm RESOLVER_FILE_DST
30
+ puts Rainbow("Removed `#{RESOLVER_FILE_DST}`").color(:green).bright
31
+
32
+ unload_firewall
33
+ puts Rainbow("Unloaded firewall rules").color(:green).bright
34
+
35
+ FileUtils.rm FIREWALL_PLIST_DST
36
+ puts Rainbow("Removed `#{FIREWALL_PLIST_DST}`").color(:green).bright
37
+
38
+ rescue Errno::EACCES => e
39
+ puts Rainbow("Something went wrong uninstalling (#{e.message})").color(:red).bright
40
+ end
41
+
42
+ def installed?
43
+ return false unless File.exists? FIREWALL_PLIST_DST
44
+ return false unless File.exists? RESOLVER_FILE_DST
45
+ true
46
+ end
47
+
48
+ def suitable?
49
+ return false unless Etc.uname[:sysname] == 'Darwin'
50
+ true
51
+ end
52
+
53
+ private
54
+
55
+ def unload_firewall
56
+ system("pfctl -a com.apple/250.ExplorerFirewall -F nat 2>/dev/null")
57
+ system("launchctl unload -w #{FIREWALL_PLIST_DST} 2>/dev/null")
58
+ end
59
+
60
+ def load_firewall
61
+ system("launchctl load -Fw #{FIREWALL_PLIST_DST} 2>/dev/null")
62
+ end
63
+
64
+ def mkdir(dir)
65
+ FileUtils.mkdir(dir) unless Dir.exists? dir
66
+ end
67
+ end
68
+ end
@@ -1,3 +1,3 @@
1
1
  module Explorer
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: explorer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Peters
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-08 00:00:00.000000000 Z
11
+ date: 2015-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -166,12 +166,15 @@ files:
166
166
  - bin/explore
167
167
  - data/server.crt
168
168
  - data/server.key
169
+ - data/setup/dev
170
+ - data/setup/firewall.plist
169
171
  - explorer.gemspec
170
172
  - lib/celluloid/io/pty.rb
171
173
  - lib/explorer.rb
172
174
  - lib/explorer/cli.rb
173
175
  - lib/explorer/cli/process.rb
174
176
  - lib/explorer/cli/proxy.rb
177
+ - lib/explorer/cli/setup.rb
175
178
  - lib/explorer/ipc_client.rb
176
179
  - lib/explorer/log_watcher.rb
177
180
  - lib/explorer/process.rb
@@ -183,6 +186,7 @@ files:
183
186
  - lib/explorer/server/https.rb
184
187
  - lib/explorer/server/ipc.rb
185
188
  - lib/explorer/servers.rb
189
+ - lib/explorer/setup.rb
186
190
  - lib/explorer/version.rb
187
191
  homepage: ''
188
192
  licenses: