vpn 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/LICENSE.txt +21 -0
- data/README.md +49 -0
- data/Rakefile +1 -0
- data/bin/vpn +55 -0
- data/vpn.gemspec +20 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 72d2274111b70ff5980f5f47840ac98a9d3d7fc1
|
4
|
+
data.tar.gz: 0dd193d0bc4782d6cd9a3ed85942f1ca30099d40
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d0ddbacbdfb8f4b2e59a7f88ebc1be413a4e3b924bea7412f6b073a560adaa1db2a264ff23238e5b36bfb1809775b0c17f8d1c83bf963eaa90ebc1eeae04cbed
|
7
|
+
data.tar.gz: aa062ba4023e93ba67b5d87f2692e97603e14c4d990609bc8b22a52fe86207655348ac397dcdda7cca66dcefe51a09287dd46ecfda012fed89a410516d052b79
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 ronen barzel
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# vpn
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/vpn.png)](http://badge.fury.io/rb/vpn)
|
3
|
+
|
4
|
+
A shell command for making vpn connections. It's a convenience wrapper around [openconnect](http://www.infradead.org/openconnect/), in which you set up a configuration file with connection details, then just "vpn up" to connect.
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
```sh
|
9
|
+
$ vpn up [site]
|
10
|
+
$ vpn down
|
11
|
+
$ vpn reset # if your lan connection glitches
|
12
|
+
```
|
13
|
+
|
14
|
+
The script will prompt for your vpn password on the site as well as for the sudo password on your machine (if needed).
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
1. Install [openconnect](http://www.infradead.org/openconnect/). On OS X you can use [homebrew](http://brew.sh):
|
19
|
+
|
20
|
+
```sh
|
21
|
+
$ brew install openconnect
|
22
|
+
```
|
23
|
+
|
24
|
+
2. Install the `vpn` script, by either:
|
25
|
+
|
26
|
+
* `$ gem install vpn`
|
27
|
+
|
28
|
+
or
|
29
|
+
|
30
|
+
* Download the script from [here](https://raw.githubusercontent.com/ronen/vpn/master/bin/vpn) and put it somewhere in your PATH.
|
31
|
+
|
32
|
+
## Configuration
|
33
|
+
|
34
|
+
Create a config file `~/.vpn`, which is a YAML file containing one or more "site" entries of the form:
|
35
|
+
|
36
|
+
```yaml
|
37
|
+
mycompany:
|
38
|
+
server: vpn.mycompany.com
|
39
|
+
usergroup: OTP
|
40
|
+
user: mylogin
|
41
|
+
```
|
42
|
+
|
43
|
+
Each entry must specify a `server`. All other fields get passed as options to openconnect -- see `$ man openconnect` to find out what they are. Options that don't take values can be specified using the value `true`.
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/vpn
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
CONFIG_FILENAME = "~/.vpn"
|
7
|
+
PIDFILE = "/tmp/openconnect.pid"
|
8
|
+
|
9
|
+
defaults = {
|
10
|
+
"background" => true,
|
11
|
+
"passwd-on-stdin" => true,
|
12
|
+
"pid-file" => PIDFILE,
|
13
|
+
"quiet" => true,
|
14
|
+
}
|
15
|
+
|
16
|
+
def pid
|
17
|
+
File.read(PIDFILE).to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
def passwd(site)
|
21
|
+
STDOUT.write "#{site} vpn password: "
|
22
|
+
STDOUT.flush
|
23
|
+
begin
|
24
|
+
system "stty -echo"
|
25
|
+
@password = STDIN.gets.chomp
|
26
|
+
ensure
|
27
|
+
system "stty echo"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def sudo(cmd)
|
32
|
+
system "sudo -p 'sudo password: ' #{cmd}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def load_config
|
36
|
+
begin
|
37
|
+
YAML.load Pathname(CONFIG_FILENAME).expand_path.read
|
38
|
+
rescue Errno::ENOENT => e
|
39
|
+
abort "Could not open config file #{e.message.sub(".* - ", '')}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
case ARGV.shift
|
44
|
+
when "up" then
|
45
|
+
config = load_config
|
46
|
+
site = ARGV.shift || config.keys.first
|
47
|
+
config.include? site or abort "#{site} not listed in #{CONFIG_FILENAME}"
|
48
|
+
opts = defaults.merge config[site]
|
49
|
+
server = opts.delete("server") or abort "#{CONFIG_FILENAME} must specify a server"
|
50
|
+
args = opts.map{ |key, val| val == true ? "--#{key}" : "--#{key}=#{val}"}.join(' ')
|
51
|
+
sudo "openconnect #{args} #{server} <<< #{passwd site}"
|
52
|
+
when "down" then sudo "kill -s HUP #{pid}"
|
53
|
+
when "reset" then sudo "kill -s USR2 #{pid}"
|
54
|
+
else abort "usage: #{$0} up [site]|down|reset"
|
55
|
+
end
|
data/vpn.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "vpn"
|
5
|
+
spec.version = "0.1.0"
|
6
|
+
spec.authors = ["ronen barzel"]
|
7
|
+
spec.email = ["ronen@barzel.org"]
|
8
|
+
|
9
|
+
spec.summary = %q{A shell command for making vpn connections. It's a wrapper around openconnect.}
|
10
|
+
spec.description = %q{Lets you set up one or more vpn configurations, then connect via `vpn up` and `vpn down`.}
|
11
|
+
spec.homepage = "http://github.com/ronen/vpn"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
|
+
spec.bindir = "bin"
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
19
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vpn
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ronen barzel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Lets you set up one or more vpn configurations, then connect via `vpn
|
42
|
+
up` and `vpn down`.
|
43
|
+
email:
|
44
|
+
- ronen@barzel.org
|
45
|
+
executables:
|
46
|
+
- vpn
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/vpn
|
55
|
+
- vpn.gemspec
|
56
|
+
homepage: http://github.com/ronen/vpn
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.4.5.1
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: A shell command for making vpn connections. It's a wrapper around openconnect.
|
80
|
+
test_files: []
|