Skip to content

Commit c68c882

Browse files
committed
initial import
0 parents  commit c68c882

File tree

21 files changed

+2338
-0
lines changed

21 files changed

+2338
-0
lines changed

.github/workflows/dev-release.yaml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: "Latest Development Build"
2+
3+
on:
4+
push:
5+
branches: [ 'main' ]
6+
7+
jobs:
8+
binaries:
9+
name: "Binaries"
10+
runs-on: "ubuntu-latest"
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 1
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v2
20+
with:
21+
go-version: ^1.17
22+
23+
- name: Build
24+
run: make dist
25+
26+
- name: Publish binaries
27+
uses: marvinpinto/action-automatic-releases@latest
28+
with:
29+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
30+
automatic_release_tag: "latest"
31+
prerelease: true
32+
title: "Development Build"
33+
files: |
34+
dist/*
35+
36+
docker:
37+
name: "Docker"
38+
runs-on: "ubuntu-latest"
39+
40+
permissions:
41+
contents: read
42+
packages: write
43+
44+
steps:
45+
- name: Checkout repository
46+
uses: actions/checkout@v2
47+
with:
48+
fetch-depth: 1
49+
50+
- name: Set Username/Repo and ImagePrefix as ENV vars
51+
run: |
52+
echo "USER_REPO"=$(echo "$GITHUB_REPOSITORY" | awk '{print tolower($1)}' | sed -e "s/:refs//") >> $GITHUB_ENV && \
53+
echo "IMAGE_PREFIX"=$(echo "ghcr.io/$GITHUB_REPOSITORY" | awk '{print tolower($1)}' | sed -e "s/:refs//") >> $GITHUB_ENV
54+
55+
- name: Set up QEMU
56+
uses: docker/setup-qemu-action@v1
57+
58+
- name: Set up Docker Buildx
59+
uses: docker/setup-buildx-action@v1
60+
61+
- name: Login to Github Container Registry
62+
uses: docker/login-action@v1
63+
with:
64+
registry: ghcr.io
65+
username: ${{ github.repository_owner }}
66+
password: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Build and Push container images
69+
uses: docker/build-push-action@v2
70+
with:
71+
context: .
72+
file: ./Dockerfile
73+
platforms: linux/amd64,linux/arm/v7,linux/arm64
74+
build-args: |
75+
VERSION=latest
76+
GIT_COMMIT=${{ github.sha }}
77+
REPO_URL=https://github.com/${{ env.USER_REPO }}
78+
push: true
79+
tags: |
80+
${{ env.IMAGE_PREFIX }}:${{ github.sha }}
81+
${{ env.IMAGE_PREFIX }}:latest

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
.vagrant
3+
*.log
4+
dist

Dockerfile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.17.2-alpine3.14 as build
2+
3+
ARG TARGETPLATFORM
4+
ARG BUILDPLATFORM
5+
ARG TARGETOS
6+
ARG TARGETARCH
7+
8+
ENV CGO_ENABLED=0
9+
10+
WORKDIR /src
11+
COPY . .
12+
13+
RUN apk add git
14+
RUN VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \
15+
&& GIT_COMMIT=$(git rev-list -1 HEAD) \
16+
&& GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=${CGO_ENABLED} go build \
17+
--ldflags "-s -w \
18+
-X github.com/jsiebens/proxiro/internal/version.GitCommit=${GIT_COMMIT}\
19+
-X github.com/jsiebens/proxiro/internal/version.Version=${VERSION}" \
20+
-a -installsuffix cgo -o proxiro cmd/proxiro/main.go
21+
22+
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.14.2 as ship
23+
24+
RUN apk --no-cache add ca-certificates
25+
RUN addgroup -S proxiro && adduser -S -g proxiro proxiro
26+
27+
COPY --from=build /src/proxiro /usr/local/bin
28+
29+
USER proxiro
30+
ENTRYPOINT ["proxiro"]

Makefile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
SHELL := bash
2+
Version := $(shell git describe --tags --dirty)
3+
# Version := "dev"
4+
GitCommit := $(shell git rev-parse HEAD)
5+
LDFLAGS := "-s -w -X github.com/jsiebens/proxiro/internal/version.Version=$(Version) -X github.com/jsiebens/proxiro/internal/version.GitCommit=$(GitCommit)"
6+
.PHONY: all
7+
8+
.PHONY: build
9+
build:
10+
go build -ldflags $(LDFLAGS) -a -installsuffix cgo cmd/proxiro/main.go
11+
12+
.PHONY: dist
13+
dist:
14+
mkdir -p dist
15+
GOOS=linux go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o dist/proxiro cmd/proxiro/main.go
16+
GOOS=darwin go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o dist/proxiro-darwin cmd/proxiro/main.go
17+
GOOS=linux GOARCH=arm64 go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o dist/proxiro-arm64 cmd/proxiro/main.go
18+
GOOS=linux GOARCH=arm GOARM=6 go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o dist/proxiro-armhf cmd/proxiro/main.go
19+
GOOS=windows go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o dist/proxiro.exe cmd/proxiro/main.go
20+
21+
.PHONY: hash
22+
hash:
23+
for f in dist/proxiro*; do shasum -a 256 $$f > $$f.sha256; done

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# proxiro
2+
3+
a lightweight identity-aware proxy

cmd/proxiro/main.go

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"github.com/jsiebens/proxiro/internal/auth"
6+
"github.com/jsiebens/proxiro/internal/client"
7+
"github.com/jsiebens/proxiro/internal/proxy"
8+
"github.com/jsiebens/proxiro/internal/version"
9+
"github.com/spf13/cobra"
10+
"os"
11+
)
12+
13+
func main() {
14+
cmd := rootCommand()
15+
cmd.AddCommand(serverCommand())
16+
cmd.AddCommand(proxyCommand())
17+
cmd.AddCommand(connectCommand())
18+
cmd.AddCommand(versionCommand())
19+
20+
if err := cmd.Execute(); err != nil {
21+
os.Exit(1)
22+
}
23+
}
24+
25+
func rootCommand() *cobra.Command {
26+
return &cobra.Command{
27+
Use: "proxiro",
28+
}
29+
}
30+
31+
func serverCommand() *cobra.Command {
32+
command := &cobra.Command{
33+
Use: "server",
34+
SilenceUsage: true,
35+
}
36+
37+
var configFile string
38+
39+
command.Flags().StringVarP(&configFile, "config", "c", "", "Path to the configuration file.")
40+
41+
command.RunE = func(command *cobra.Command, args []string) error {
42+
c, err := auth.LoadConfig(configFile)
43+
if err != nil {
44+
return err
45+
}
46+
47+
return auth.StartServer(c)
48+
}
49+
50+
return command
51+
}
52+
53+
func proxyCommand() *cobra.Command {
54+
command := &cobra.Command{
55+
Use: "proxy",
56+
SilenceUsage: true,
57+
}
58+
59+
var configFile string
60+
61+
command.Flags().StringVarP(&configFile, "config", "c", "", "Path to the configuration file.")
62+
63+
command.RunE = func(command *cobra.Command, args []string) error {
64+
c, err := proxy.LoadConfig(configFile)
65+
if err != nil {
66+
return err
67+
}
68+
69+
return proxy.StartServer(c)
70+
}
71+
72+
return command
73+
}
74+
75+
func connectCommand() *cobra.Command {
76+
command := &cobra.Command{
77+
Use: "connect",
78+
SilenceUsage: true,
79+
Args: cobra.MinimumNArgs(1),
80+
ArgAliases: []string{"target"},
81+
}
82+
83+
var listeners []string
84+
var tlsSkipVerify bool
85+
var caFile string
86+
87+
command.Flags().StringSliceVarP(&listeners, "listen-addr", "l", []string{}, "")
88+
command.Flags().BoolVar(&tlsSkipVerify, "tls-skip-verify", false, "")
89+
command.Flags().StringVar(&caFile, "ca-file", "", "")
90+
91+
command.RunE = func(cmd *cobra.Command, args []string) error {
92+
return client.StartClient(cmd.Context(), args[0], listeners, caFile, tlsSkipVerify)
93+
}
94+
95+
return command
96+
}
97+
98+
func versionCommand() *cobra.Command {
99+
var command = &cobra.Command{
100+
Use: "version",
101+
Short: "Display version information",
102+
SilenceUsage: true,
103+
}
104+
105+
command.Run = func(cmd *cobra.Command, args []string) {
106+
clientVersion, clientRevision := version.GetReleaseInfo()
107+
fmt.Printf(`
108+
Version: %s
109+
Git Revision: %s
110+
`, clientVersion, clientRevision)
111+
}
112+
113+
return command
114+
}

go.mod

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
module github.com/jsiebens/proxiro
2+
3+
go 1.17
4+
5+
require (
6+
github.com/coreos/go-oidc/v3 v3.1.0
7+
github.com/go-resty/resty/v2 v2.7.0
8+
github.com/gorilla/websocket v1.4.2
9+
github.com/hashicorp/go-multierror v1.0.0
10+
github.com/iamolegga/enviper v1.3.0
11+
github.com/klauspost/compress v1.13.6
12+
github.com/labstack/echo/v4 v4.6.1
13+
github.com/mitchellh/go-homedir v1.1.0
14+
github.com/mr-tron/base58 v1.2.0
15+
github.com/patrickmn/go-cache v2.1.0+incompatible
16+
github.com/rancher/remotedialer v0.2.6-0.20210802164054-73730a94f4a1
17+
github.com/sirupsen/logrus v1.4.2
18+
github.com/spf13/cobra v1.2.1
19+
github.com/spf13/viper v1.10.0
20+
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5
21+
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
22+
)
23+
24+
require (
25+
github.com/beorn7/perks v1.0.1 // indirect
26+
github.com/cespare/xxhash/v2 v2.1.2 // indirect
27+
github.com/fsnotify/fsnotify v1.5.1 // indirect
28+
github.com/golang/protobuf v1.5.2 // indirect
29+
github.com/hashicorp/errwrap v1.0.0 // indirect
30+
github.com/hashicorp/hcl v1.0.0 // indirect
31+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
32+
github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect
33+
github.com/kr/pretty v0.2.0 // indirect
34+
github.com/labstack/gommon v0.3.0 // indirect
35+
github.com/magiconair/properties v1.8.5 // indirect
36+
github.com/mattn/go-colorable v0.1.12 // indirect
37+
github.com/mattn/go-isatty v0.0.14 // indirect
38+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
39+
github.com/mitchellh/mapstructure v1.4.3 // indirect
40+
github.com/pelletier/go-toml v1.9.4 // indirect
41+
github.com/pkg/errors v0.8.1 // indirect
42+
github.com/prometheus/client_golang v1.4.0 // indirect
43+
github.com/prometheus/client_model v0.2.0 // indirect
44+
github.com/prometheus/common v0.9.1 // indirect
45+
github.com/prometheus/procfs v0.0.8 // indirect
46+
github.com/spf13/afero v1.6.0 // indirect
47+
github.com/spf13/cast v1.4.1 // indirect
48+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
49+
github.com/spf13/pflag v1.0.5 // indirect
50+
github.com/subosito/gotenv v1.2.0 // indirect
51+
github.com/valyala/bytebufferpool v1.0.0 // indirect
52+
github.com/valyala/fasttemplate v1.2.1 // indirect
53+
golang.org/x/net v0.0.0-20211029224645-99673261e6eb // indirect
54+
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect
55+
golang.org/x/text v0.3.7 // indirect
56+
google.golang.org/appengine v1.6.7 // indirect
57+
google.golang.org/protobuf v1.27.1 // indirect
58+
gopkg.in/ini.v1 v1.66.2 // indirect
59+
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
60+
gopkg.in/yaml.v2 v2.4.0 // indirect
61+
)

0 commit comments

Comments
 (0)