Skip to content

Commit

Permalink
feat: initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
comradequinn committed Dec 30, 2022
0 parents commit 5927d45
Show file tree
Hide file tree
Showing 132 changed files with 261,420 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Setup Go environment
uses: actions/setup-go@v3.5.0
with:
go-version: 1.19

- uses: actions/checkout@v3

- name: Build
run: make build

- name: Test
run: make test

23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
*.srl
*.xml
*.log

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Build output directories
bin/
release/

*.hflow.edit

.DS_Store
38 changes: 38 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Start",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/hflow.go",
"env": {},
"args": ["-v=1"]
},
{
"name": "TestBed",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/test/test.go",
"env": {}
},
{
"name": "Attach",
"type": "go",
"request": "attach",
"mode": "local",
"processId": "${command:pickProcess}",
"showLog": true
},
{
"name": "Test",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${fileDirname}",
"env": {}
}
]
}
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

91 changes: 91 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

.PHONY: build
build :
@-rm -f ./bin/hflow 2> /dev/null
@go build -o ./bin/hflow

.PHONY: test
test :
@go test -cover -count=1 ./...

.PHONY: bench
bench:
@go test -run=XXX -bench=. -benchtime=5s -benchmem ./...

.PHONY: install
install: build
@-sudo rm -f /usr/local/bin/hflow 2> /dev/null
@sudo cp ./bin/hflow /usr/local/bin/hflow && sudo chmod +x /usr/local/bin/hflow
@echo "hflow successfully installed"

.PHONY: release
release: build
@./scripts/release.sh

URL_PATTERN=""
STATUS_PATTERN=""
CAPTURE_FILE=""
REROUTE_DIRECTIVE=""

.PHONY: start
start : stop build
@./bin/hflow -v=1 -u="${URL_PATTERN}" -s="${STATUS_PATTERN}" -f=${CAPTURE_FILE}

.PHONY: stop
stop :
-@pkill hflow

.PHONY: ca-export
ca-export : stop build
@-mkdir ./bin 2> /dev/null
@./bin/hflow -e=e > ./bin/hflow-ca-export.pem

.PHONY: exec
exec : stub start
@echo "hello"
#__________________________________________________________________________________________________________________________
#
# Stub server related targets
#__________________________________________________________________________________________________________________________

.PHONY: stub-stop
stub-stop:
-@pkill stub

.PHONY: stub
stub : stub-stop
@-rm ./bin/stub
@go build -o ./bin/stub ./cmd/stub/
@./bin/stub -port=8081 -tls=4431 -v=2 2> ./bin/stub-01.log &
@./bin/stub -port=8082 -tls=4432 -v=2 2> ./bin/stub-02.log &
@echo "ensure '127.0.0.1 stub-server-01' is in your host file"
@echo "ensure '127.0.0.1 stub-server-02' is in your host file"

temp :
@curl -i -k -x http://127.0.0.1:4443 https://duckduckgo.com/?q=these+are+not+the+droids+you+are+looking+for&va=b&t=hc&ia=web

.PHONY: example
example :
@echo "for the examples to work, ensure hflow is running (make start), the stubs are running (make stub) and the hflow root cert is exported to the bin (make ca-export)"
@echo "" && echo "press enter to continue or ^c to exit...." && read
@echo "sending http get request to stub-server via hflow...."
@curl -i -x http://127.0.0.1:8080 http://stub-server-01:8081/echo/?qs=http-get-qs-data
@echo "sending http post request to stub-server via hflow...."
@curl -i -XPOST -d "http-body-data" -x http://127.0.0.1:8080 http://stub-server-01:8081/echo/?qs=http-qs-data
@echo "" && echo "sending https request to stub-server via hflow while ignoring cert validation...."
@curl -i -k --tlsv1.3 -XPOST -d "https-body-data" -x http://127.0.0.1:4443 https://stub-server-01:4431/echo/?qs=https-qs-data
@echo "" && echo "sending https request to stub-server via hflow with hflow root ca configured...."
@curl -i --cacert bin/hflow-ca-export.pem --tlsv1.3 -XPOST -d "https-ca-body-data" -x http://127.0.0.1:4443 https://stub-server-01:4431/echo/?qs=https-ca-qs-data

#__________________________________________________________________________________________________________________________
#
# PKI related targets. If updating pki files for use in hflow, ensure variables in pem.go files are updated with output
#__________________________________________________________________________________________________________________________

.PHONY: ca
ca :
@./scripts/gen_ca.sh

.PHONY: cert
cert : # ex: `make cert DOMAIN="stub-server"`. ca certs must be present, if not, run `make ca`
@./scripts/gen_cert.sh ${DOMAIN}
Loading

0 comments on commit 5927d45

Please sign in to comment.