diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8c6cf8a..0c084ec 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -69,10 +69,16 @@ jobs: for arch in amd64; do mkdir -p build/package/rvpn_linux_$arch/{,bin/,systemd/} cp build/client_linux_$arch build/package/rvpn_linux_$arch/bin/rvpn - cp -r support/systemd/ build/package/rvpn_linux_$arch/systemd/ + cp -r support/systemd/ build/package/rvpn_linux_$arch/ tar --owner root --group root --sort name \ -C build/package/ -czvf rvpn_linux_$arch.tar.gz rvpn_linux_$arch done + for arch in amd64 arm64; do + mkdir -p build/package/rvpn_darwin_$arch/{,bin/,systemd/} + cp build/client_darwin_$arch build/package/rvpn_darwin_$arch/bin/rvpn + cp -r support/launchd/ build/package/rvpn_darwin_$arch/ + tar --owner root --group root --sort name \ + -C build/package/ -czvf rvpn_darwin_$arch.tar.gz rvpn_darwin_$arch - uses: softprops/action-gh-release@v1 with: diff --git a/cmd/client/client.go b/cmd/client/client.go index e93a212..f38cb22 100644 --- a/cmd/client/client.go +++ b/cmd/client/client.go @@ -143,6 +143,9 @@ func ClientConnectProfile(profile string, opts common.ClientOptions) { os.Exit(1) } + // either receive message from connectEvent chan or timeout 5 seconds + // if connectEvent then test for connectivity by pinging the VPN server + fmt.Printf("rVPN successfully connected to profile %s\n", profile) } diff --git a/support/install-darwin.sh b/support/install-darwin.sh new file mode 100644 index 0000000..c8fa275 --- /dev/null +++ b/support/install-darwin.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +set -euo pipefail + +version="v0.0.1" +arch="amd64" # FIXME + +err() { + echo "$@" >&2 +} + +main() { + + # setup tempdir + tmpdir="$(mktemp -d)" + cd "$tmpdir" + cleanup() { + [ -z "$tmpdir" ] || rm -rf "$tmpdir" + } + trap cleanup EXIT + + # detect sudo + if [ "$(id -u)" -eq 0 ]; then + sudo='' + elif command -v sudo >/dev/null; then + sudo=sudo + elif command -v doas >/dev/null; then + sudo=doas + else + err 'You must be root' + exit 1 + fi + + # download tar + curl -sSLo rvpn.tar.gz "https://github.com/redpwn/rvpn/releases/download/$version/rvpn_darwin_$arch.tar.gz" + + # extract tar + tar -xzvf rvpn.tar.gz + + # install rvpn and rvpn service + $sudo install -Dm 644 -t /Library/LaunchDaemons rvpn_darwin_$arch/launchd/rvpn.service + $sudo install -m 755 -t /usr/local/bin/ rvpn_linux_$arch/bin/rvpn + + $sudo launchctl load /Library/LaunchDaemons/dev.rvpn.plist + + echo "Start rvpn daemon?" + select yn in "Start" "Skip"; do + case $yn in + "Start" ) $sudo launchctl start /Library/LaunchDaemons/dev.rvpn.plist break;; + "Skip" ) break;; + esac + done + + # print success and remind user to allow rvpn serve port (21820) through firewall if serving + echo "Successfully installed rVPN!" +} + +main \ No newline at end of file diff --git a/support/install.sh b/support/install-linux.sh similarity index 76% rename from support/install.sh rename to support/install-linux.sh index e6acd7f..512b31a 100644 --- a/support/install.sh +++ b/support/install-linux.sh @@ -45,7 +45,7 @@ main() { # ask user if they want to enable ip forwarding if not already enabled if [ "$(cat /proc/sys/net/ipv4/ip_forward)" -eq 0 ]; then - echo "Do you wish to enable IP Forwarding (only used if this device is a VPN server)? [1,2]" + echo "Do you wish to enable IP Forwarding (only used if this device is a VPN server)?" select yn in "Yes" "No"; do case $yn in Yes ) enable_ip4_forwarding $sudo ; break;; @@ -55,12 +55,21 @@ main() { fi # install rvpn and rvpn service - $sudo install -Dm 644 -t /usr/local/lib/systemd/system/ rvpn_linux_$arch/systemd/systemd/rvpn.service + $sudo install -Dm 644 -t /usr/local/lib/systemd/system/ rvpn_linux_$arch/systemd/rvpn.service $sudo install -m 755 -t /usr/local/bin/ rvpn_linux_$arch/bin/rvpn + echo "Start rvpn daemon?" + select yn in "Enable (start on boot)" "Start" "Skip"; do + case $yn in + "Enable (start on boot)" ) $sudo systemctl enable --now rvpn ; break;; + "Start" ) $sudo systemctl start rvpn break;; + "Skip" ) break;; + esac + done + # print success and remind user to allow rvpn serve port (21820) through firewall if serving echo "Successfully installed rVPN!" - echo "If using this device as a VPN server please allow rVPN serve port (default 21820) through firewall" + echo "NOTE: If using this device as a VPN server please allow rVPN serve port (default 21820) through firewall" } main \ No newline at end of file diff --git a/support/launchd/dev.rvpn.plist b/support/launchd/dev.rvpn.plist new file mode 100644 index 0000000..1cbd800 --- /dev/null +++ b/support/launchd/dev.rvpn.plist @@ -0,0 +1,26 @@ + + + + + EnvironmentVariables + + PATH + /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin: + + Label + dev.rvpn + ProgramArguments + + /usr/local/bin/rvpn + daemon + + RunAtLoad + + KeepAlive + + StandardOutPath + /tmp/startup.stdout + StandardErrorPath + /tmp/startup.stderr + +