From: Creed Haymond Date: Sun, 6 Dec 2020 06:34:23 +0000 (-0700) Subject: adding creedasaurus/gprox X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=6c514f63237f5ccbab4559021a77330467c9bb27;p=webi-installers%2F.git adding creedasaurus/gprox --- diff --git a/gprox/README.md b/gprox/README.md new file mode 100644 index 0000000..9d94565 --- /dev/null +++ b/gprox/README.md @@ -0,0 +1,60 @@ +--- +title: gprox +homepage: https://github.com/creedasaurus/gprox +tagline: | + gprox: a simple local ssl proxy for development +--- + +### Updating `gprox` + +`webi gprox` + +## Cheat Sheet + +`gprox` was built to be a no-dependency development tool for simply proxying HTTPS traffic to a local HTTP endpoint. It was written as a port of [local-ssl-proxy](https://github.com/cameronhunter/local-ssl-proxy), a perfectly good NodeJS app for the same purpose. But the benefit is that you can install `gprox` very simply from `webi` or `go` (if you must), and you dont have to worry at all about NodeJS versions, etc! Plus there isn't any elevated access given to an interpreter you dont know much about if you're using `webi`. + +The fastest way to get started is just by running: + +```bash +gprox +# example output +# 9:12PM INF Running proxy! from=https://localhost:9001 to=http://localhost:9000 +``` +And you're off to the races! + +That is... if you're app happens to be running on port `9000`. If not, no worries! Simply pass the target port option `-t, --target` and specify the port your app _is_ running on. + +```bash +gprox -t 8080 +``` + +Feeling like you should save this magic built-in cert so you can inspect it for anything? +```bash +gprox --dropcert +``` + +Want to use your own cert/key? +```bash +gprox -c testcert.crt -k testkey.key +``` + +And for anything else, just use the `-h, --help` flag to get a little more information or refer to the [README](https://github.com/creedasaurus/gprox/blob/main/README.md): + +``` +❯ gprox --help +Usage: + gprox [OPTIONS] + +Application Options: + -n, --hostname= The hostname to be used for the local proxy (default: localhost) + -s, --source= The source port that you will hit to go through the proxy (default: 9001) + -t, --target= The port you are targeting (default: 9000) + -c, --cert= Path to a .cert file + -k, --key= Path to a .key file + -o, --config= + -d, --dropcerts Save the built-in cert/key files to disk + --version + +Help Options: + -h, --help Show this help message +``` diff --git a/gprox/install.ps1 b/gprox/install.ps1 new file mode 100644 index 0000000..a5ec5f9 --- /dev/null +++ b/gprox/install.ps1 @@ -0,0 +1,61 @@ +#!/usr/bin/env pwsh + +################## +# Install gprox # +################## + +# Every package should define these variables +$pkg_cmd_name = "gprox" + +$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\gprox.exe" +$pkg_dst = "$pkg_dst_cmd" + +$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\gprox-v$Env:WEBI_VERSION\bin\gprox.exe" +$pkg_src_bin = "$Env:USERPROFILE\.local\opt\gprox-v$Env:WEBI_VERSION\bin" +$pkg_src_dir = "$Env:USERPROFILE\.local\opt\gprox-v$Env:WEBI_VERSION" +$pkg_src = "$pkg_src_cmd" + +$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" + +# Fetch archive +IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE")) +{ + # TODO: arch detection + echo "Downloading gprox from $Env:WEBI_PKG_URL to $pkg_download" + & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" + & move "$pkg_download.part" "$pkg_download" +} + +IF (!(Test-Path -Path "$pkg_src_cmd")) +{ + echo "Installing gprox" + + # TODO: create package-specific temp directory + # Enter tmp + pushd .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path ".\gprox-v*" -Recurse -ErrorAction Ignore + Remove-Item -Path ".\gprox.exe" -Recurse -ErrorAction Ignore + + # NOTE: DELETE THIS COMMENT IF NOT USED + # Move single binary into root of temporary folder + #& move "$pkg_download" "gprox.exe" + + # Unpack archive file into this temporary directory + # Windows BSD-tar handles zip. Imagine that. + echo "Unpacking $pkg_download" + & tar xf "$pkg_download" + + # Settle unpacked archive into place + echo "Install Location: $pkg_src_cmd" + New-Item "$pkg_src_bin" -ItemType Directory + Move-Item -Path ".\gprox-*\gprox.exe" -Destination "$pkg_src_bin" + + # Exit tmp + popd +} + +echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'" +Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse diff --git a/gprox/install.sh b/gprox/install.sh new file mode 100644 index 0000000..ab63c80 --- /dev/null +++ b/gprox/install.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +{ + set -e + set -u + + ################## + # Install gprox # + ################## + + # Every package should define these 6 variables + pkg_cmd_name="gprox" + + pkg_dst_cmd="$HOME/.local/bin/gprox" + pkg_dst="$pkg_dst_cmd" + + pkg_src_cmd="$HOME/.local/opt/gprox-v$WEBI_VERSION/bin/gprox" + pkg_src_dir="$HOME/.local/opt/gprox-v$WEBI_VERSION" + pkg_src="$pkg_src_cmd" + + # pkg_install must be defined by every package + pkg_install() { + # ~/.local/opt/gprox-v0.99.9/bin + mkdir -p "$(dirname $pkg_src_cmd)" + + # mv ./gprox-*/gprox ~/.local/opt/gprox-v0.99.9/bin/gprox + mv ./gprox-*/gprox "$pkg_src_cmd" + } + + # pkg_get_current_version is recommended, but (soon) not required + pkg_get_current_version() { + # 'gprox --version' has output in this format: + # gprox 0.99.9 (rev abcdef0123) + # This trims it down to just the version number: + # 0.99.9 + echo $(gprox --version 2>/dev/null | head -n 1 | cut -d ' ' -f 2) + } + +} diff --git a/gprox/releases.js b/gprox/releases.js new file mode 100644 index 0000000..4cb80fa --- /dev/null +++ b/gprox/releases.js @@ -0,0 +1,20 @@ +'use strict'; + +var github = require('../_common/github.js'); +var owner = 'creedasaurus'; +var repo = 'gprox'; + +module.exports = function (request) { + return github(request, owner, repo).then(function (all) { + return all; + }); +}; + +if (module === require.main) { + module.exports(require('@root/request')).then(function (all) { + all = require('../_webi/normalize.js')(all); + // just select the first 5 for demonstration + all.releases = all.releases.slice(0, 5); + console.info(JSON.stringify(all, null, 2)); + }); +}