Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ in the best possible VPN bandwidth and throughput.
### Debian (stretch)

```
# apt install build-essential lua5.2 lua5.2-dev lua-posix lua-luaossl lua-cqueues libssl-dev liblzo2-dev
# apt install build-essential lua5.2 lua5.2-dev lua-cliargs lua-posix lua-luaossl lua-cqueues libssl-dev liblzo2-dev
```

### Ubuntu 17.10

```
# apt install build-essential lua liblua5.2-dev lua-posix lua-luaossl lua-cqueues libssl-dev liblzo2-dev
# apt install build-essential lua liblua5.2-dev lua-cliargs lua-posix lua-luaossl lua-cqueues libssl-dev liblzo2-dev
```

## Build it
Expand Down
36 changes: 33 additions & 3 deletions frivpn_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local x509 = require "openssl.x509"
local castore = require "openssl.x509.store"
local pkey = require "openssl.pkey"
local posix = require "posix"
local cli = require "cliargs"

require "libfrivpn"
require "utils"
Expand Down Expand Up @@ -65,6 +66,14 @@ local syscalls = {

}

function prequire(...)
local status, lib = pcall(require, ...)
if status then
return lib
end
return nil
end

function lookup_ip(host)
local res = posix.getaddrinfo(host, 1195)
return res[1].addr
Expand Down Expand Up @@ -464,6 +473,11 @@ function vpn:connect(host, port)
end
end

local function print_version()
print("frivpn_client: version 0.0.1")
os.exit(0)
end

function ssl_preload()
local a, b = csock.pair()
-- do a dummy checktls so cqueues socket loads & keeps the ossl module
Expand All @@ -475,13 +489,29 @@ end

ssl_preload()

-- cliargs handling
cli:set_name("frivpn_client")
cli:argument("CONFIG", "config module to load (e.g. configs/ipredator)")
cli:flag("-v, --version", "print frivpn's version", print_version)
cli:flag("--notun", "creates no tun device")

local args, err = cli:parse(arg)
if not args and err then
print(string.format('%s: %s', cli.name, err))
os.exit(1)
end

-- load config
local config = require(arg[1])
config.port = config.port or 1195
local config = prequire(args["CONFIG"])
if not config then
print(string.format("Could not load config module %s", arg[1]))
os.exit(1)
end

config.port = config.port or 1195
local tun = nil

if arg[2] ~= "notun" then
if not args["notun"] then
local status, tun_fd, tun_dev = pcall(tun_create)
if status then
local tun_pipe, tun_pid = tun_fork(tun_dev, config.netmask, config.on_connected)
Expand Down