Skip to content

Instantly share code, notes, and snippets.

@arnehormann
Created May 8, 2014 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnehormann/4ea311dbab125eba2752 to your computer and use it in GitHub Desktop.
Save arnehormann/4ea311dbab125eba2752 to your computer and use it in GitHub Desktop.
A (broken) brew for sigmavpn
require "formula"
class Sigmavpn < Formula
homepage "http://frozenriver.net/SigmaVPN"
url "https://codeload.github.com/neilalexander/sigmavpn/tar.gz/0.3alpha1"
sha1 "49020d4db52878756fbbc45c05c2deeedaa7b6d2"
head do
url 'https://github.com/neilalexander/sigmavpn.git'
end
depends_on 'libsodium'
pubkey_self = '0' * 64
config_file = "#{etc}/sigmavpn.conf"
ip_addr = ENV['SIGMAVPN_ADDRESS'] || '127.0.0.1'
port = ENV['SIGMAVPN_PORT'] || '7654'
device = ENV['SIGMAVPN_DEVICE'] || '/dev/tun0'
peername = ENV['SIGMAVPN_PEER'] || 'name_of_peer'
pubkey_other = ENV['SIGMAVPN_PEER_PUBKEY'] || '0' * 64
def install
ENV["INSTALLDIR"] = prefix
ENV["SYSCONFDIR"] = etc
ENV["SODIUM_CPPFLAGS"] = ""
ENV["SODIUM_LDFLAGS"] = "-lsodium"
system "make", "install"
# create a default configuration file
keypairs = Hash[`./naclkeypair`.scan(/(PRIVATE|PUBLIC) KEY: ([0-9a-f]{64})/)]
privkey_self = keypairs['PRIVATE']
pubkey_self = keypairs['PUBLIC']
inreplace config_file do |s|
<<-CONFIG_EOF.undent
[#{peername}]
proto = nacltai
proto_privatekey = #{privkey_self}
proto_publickey = #{pubkey_other}
local = tuntap
local_interface = #{device}
local_tunmode = 1
peer = udp
peer_remotefloat = 1
peer_ipv6 = 0
peer_localport = #{port}
peer_localaddr = #{ip_addr}
CONFIG_EOF
end
end
caveat
s = ""
unless ENV['SIGMAVPN_ADDRESS'] && ENV['SIGMAVPN_PEER_PUBKEY']
s += <<-EOS.undent
Set these variables before calling brew to generate a fully usable configuration:
SIGMAVPN_ADDRESS local udp address
SIGMAVPN_PORT local udp port
SIGMAVPN_DEVICE device name, usually /dev/tun0
SIGMAVPN_PEER peer name
SIGMAVPN_PEER_PUBKEY peer public key
EOS
end
s += <<-EOS.undent
The configuration is located at
#{config_file}
Read https://code.google.com/p/sigmavpn/wiki/Configuration for available options.
Add your public key and your address to the configuration file used by your peer:
proto_publickey = #{pubkey_self}
peer_remoteaddr = #{ip_addr}
Further directions can be found at
https://code.google.com/p/sigmavpn/wiki/SecureTunnelHowto
EOS
s
end
test do
system "naclkeypair"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment