unitard 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 024c63b8ad3a235bd9c7c7ef1f23ca72e5b131f1
4
+ data.tar.gz: 1a4e8caf31cde771d837530edb189e6d85c0cd79
5
+ SHA512:
6
+ metadata.gz: b28d08bb6406bec0cff58a050878267297860edc31042cfb016dab8cc1f996403c2165e5afdc3212329224c741f203d33a19eb2ed94d50c280dab90ae8a9b43b
7
+ data.tar.gz: 02f0b63bc110e33f1c0bdc2d340cf3a8eedde0104a341468eba461ff9c2ee3cf0e26a743b5a08eaaced5de84327deecfa4ff156af85f1fd276c60382cac1c33e
@@ -0,0 +1,21 @@
1
+ MIT LICENSE
2
+ #
3
+ #Copyright (c) 2013 Artem Chernikov
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
13
+ #all 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
21
+ #THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = unitard
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to unitard
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 KalabiYau. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'thor'
3
+ require 'unitard'
4
+
5
+ Unitard.start(ARGV)
@@ -0,0 +1,48 @@
1
+ class Unitard < Thor
2
+
3
+ RULE_NUM = 4242
4
+ PIPE_NUM = 7777
5
+
6
+ option :iface, :required => true, :type => :string
7
+ option :bw, :required => true, :type => :numeric
8
+
9
+ desc 'zip', 'limit bandwidth on IFACE interface for bw Kbits/sec'
10
+ def zip
11
+
12
+ unzip(true)
13
+
14
+ if system("sudo ipfw pipe #{PIPE_NUM} config bw #{options[:bw]}Kbit/s delay 30 plr 0 2>&1 > /dev/null") &&
15
+ system("sudo ipfw add #{RULE_NUM} pipe #{PIPE_NUM} ip from any to any via #{options[:iface]} 2>&1 > /dev/null")
16
+ say "speed throttled. Your skintight Unitard is ready. Really tight :) only #{options[:bw]} Kbit/sec", :green
17
+ else
18
+ say "error - exit status #{$?.exitstatus}", :red
19
+ end
20
+
21
+ end
22
+
23
+ desc 'status', 'get status of the current limits'
24
+ def status
25
+
26
+ pipe_line = `sudo ipfw pipe show #{PIPE_NUM} 2>/dev/null`.split(/\n/).first
27
+ iface_line = `sudo ipfw show #{RULE_NUM} 2>/dev/null`.split(/\n/).first
28
+
29
+ if pipe_line && iface_line
30
+ speed_limit = pipe_line.scan(/\d+\.\d+/).join
31
+ iface = iface_line.scan(/^.*\s+([a-z]{2,3}\d+)$/).join
32
+ say "Current limit is set to #{speed_limit} Kbits/sec via interface #{iface}", :green
33
+ else
34
+ say 'No matching rule found. Probably no limit was set by Unitard', :red
35
+ end
36
+
37
+ end
38
+
39
+ desc 'unzip', 'remove bandwidth limits added by Unitard'
40
+ def unzip(silent=false)
41
+ `sudo ipfw pipe delete #{PIPE_NUM} 2>&1 > /dev/null` and `sudo ipfw delete #{RULE_NUM} 2>&1 > /dev/null`
42
+ unless silent
43
+ say 'Phew! That was very skintight Unitard.', :green
44
+ say '...all created by Unitard rules are deleted.', :blue
45
+ end
46
+ end
47
+
48
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unitard
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - KalabiYau
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.18.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.18.1
27
+ description: allow you to limit troughput of via particular interface
28
+ email: skullzeek@gmail.com
29
+ executables:
30
+ - unitard
31
+ extensions: []
32
+ extra_rdoc_files:
33
+ - LICENSE.txt
34
+ - README.markdown
35
+ files:
36
+ - bin/unitard
37
+ - lib/unitard.rb
38
+ - LICENSE.txt
39
+ - README.markdown
40
+ homepage: http://github.com/kalabiyau/unitard
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.0.3
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: simple trafic shaper for MacOS
64
+ test_files: []