Skip to content

Commit

Permalink
init (#28)
Browse files Browse the repository at this point in the history
* add docs

* tunnel: seperate errs

* refactor: init 0.1

* build: enable CGO

* ci(release): remove docker job

* ci(release): install build-essential

* build(goreleaser): refactor envs & archives

* build(goreleaser): remove unused envs

* build(make): seperate ldflags

* ci(tests): add branch trigger, build & clean steps

* build(mod): tidy up

* feat(cmd): print detailed err

* misc: add more ignore files

* build(mod): tidy up

* build(mod): bump teler-waf

* fix(common): typo option desc

* build: add Dockerfile

* feat(runner): implement graceful shutdown

* feat(runner): add reachable dest addr check

* feat(runner): add runner server util funcs

* build(deps): bump golangci/golangci-lint-action from 2 to 3 (#5)

Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 2 to 3.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](golangci/golangci-lint-action@v2...v3)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat(runner): add file config watcher

* fix(runner): add err handle on watch config file

* fix(runner): handle concurrent access to shutdown

* feat(common): add TLS interface

* feat(runner): implement TLS server

* chore(cmd): change field

* feat(tunnel): move up the validation

* build(mod): bump teler-waf

* build(deps): bump github.com/fsnotify/fsnotify from 1.4.9 to 1.6.0 (#6)

Bumps [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) from 1.4.9 to 1.6.0.
- [Release notes](https://github.com/fsnotify/fsnotify/releases)
- [Changelog](https://github.com/fsnotify/fsnotify/blob/main/CHANGELOG.md)
- [Commits](fsnotify/fsnotify@v1.4.9...v1.6.0)

---
updated-dependencies:
- dependency-name: github.com/fsnotify/fsnotify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: add example configs

* chore: update readme

* docs: update arc

* docs: update usage

* chore: add demo

* chore: update docker stuff

* doc(README): add configuration

* doc: update demo readme

* chore(ISSUE_TEMPLATE): update bug_report tpl

* chore: update demo

* chore: bump teler-waf

* docs: update readme

* chore: add .semgrepignore

* chore: add goreleaser config

* ci: add release & publish workflow

* ci(release-publish): fix relase & publish

* ci(release-publish): add new input for workflow dispatch event

* ci(release-publish): add working-directory for release step

* ci(release-publish): add debug

* docs(README): update config doc

* build(deps): bump github.com/charmbracelet/log from 0.2.2 to 0.2.3 (#8)

Bumps [github.com/charmbracelet/log](https://github.com/charmbracelet/log) from 0.2.2 to 0.2.3.
- [Release notes](https://github.com/charmbracelet/log/releases)
- [Commits](charmbracelet/log@v0.2.2...v0.2.3)

---
updated-dependencies:
- dependency-name: github.com/charmbracelet/log
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ci(release-publish): add debug by git cmd

* ci(release-publish): debug step

* ci(release-publish): debug step

* ci(release-publish): debug step

* fix(internal): signal handling for notify Windows runner

Previously, the signal handling in `runner` method caused
compilation errors on Windows due to references to Unix-specific
signals. This commit addresses the issue by removing the
reference to `syscall.SIGUSR1`, which is not available on Windows.

Signed-off-by: Dwi Siswanto <[email protected]>

* ci(release-publish): add fallback for inputs.tag with github.ref_name

* ci(release-publish): add fallback for inputs.tag with github.ref_name

* fix(internal): signal handling for notify Windows runner

Previously, the signal handling in `runner` method caused
compilation errors on Windows due to references to Unix-specific
signals. This commit addresses the issue by removing the
reference to `syscall.SIGUSR1`, which is not available on Windows.

Signed-off-by: Dwi Siswanto <[email protected]>

* ci(release-publish): remove fetch-depth param

* docs(README): update installation usage

* docs(README): add custom response usage

* build(deps): bump teler-waf

* build(deps): bump teler-waf

* chore: update example configs

* test(tunnel): add test cases

* refactor(tunnel): check dest URL protocol

Previously, the NewTunnel function assumed that the destination
URL always starts with "http://" and added it if not present.
This commit refactors the logic to properly check for the scheme
and add "http://" if the scheme is missing or invalid.

The changes include:

* Checking for "http://" or "https://" prefixes in the destination
URL.
* If the prefix is missing or invalid, "http://" is appended to the
destination URL.
* This ensures that the ReverseProxy uses a valid destination URL
for forwarding requests.

This fix addresses potential issues when the destination URL is
provided without a proper scheme, leading to incorrect behavior of
the tunnel.

Signed-off-by: Dwi Siswanto <[email protected]>

* test(common): add tests for validator

* build(deps): bump teler-waf

* docs(README): minor install notice & link to latest pkg

* docs(README): add assets

* chore: add codeowners

* docs: update blockquote notices

* build(deps): bump docker/build-push-action from 4.0.0 to 4.1.1 (#11)

Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4.0.0 to 4.1.1.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](docker/build-push-action@v4.0.0...v4.1.1)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump docker/login-action from 2.1.0 to 2.2.0 (#10)

Bumps [docker/login-action](https://github.com/docker/login-action) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](docker/login-action@v2.1.0...v2.2.0)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: add dest builder

* test: add tunnel test case

* ci: add disable analyze tests arg for golangci job

* build(deps): bump teler-waf

* test(tunnel): add test case for ServeHTTP method

* buid(deps): tidy up & add go-colorable pkg

* feat(common): add Logger interface

* feat(*): using common Logger

* docs(README): add community

* docs(README): add Excludes warning

* fix(runner): check for dest address instead of 0 arg

* chore: bump teler-waf

* build(deps): bump github.com/charmbracelet/log from 0.2.3 to 0.2.4 (#12)

Bumps [github.com/charmbracelet/log](https://github.com/charmbracelet/log) from 0.2.3 to 0.2.4.
- [Release notes](https://github.com/charmbracelet/log/releases)
- [Commits](charmbracelet/log@v0.2.3...v0.2.4)

---
updated-dependencies:
- dependency-name: github.com/charmbracelet/log
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump github.com/kitabisa/teler-waf from 1.1.2 to 1.1.3 (#13)

Bumps [github.com/kitabisa/teler-waf](https://github.com/kitabisa/teler-waf) from 1.1.2 to 1.1.3.
- [Release notes](https://github.com/kitabisa/teler-waf/releases)
- [Commits](teler-sh/teler-waf@v1.1.2...v1.1.3)

---
updated-dependencies:
- dependency-name: github.com/kitabisa/teler-waf
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(demo): add make scripts && build args

* docs(demo): update run commands

* build(deps): bump teler-waf

* chore: add chart (#14)

* build(deps): bump github.com/kitabisa/teler-waf from 1.1.4 to 1.1.5 (#15)

Bumps [github.com/kitabisa/teler-waf](https://github.com/kitabisa/teler-waf) from 1.1.4 to 1.1.5.
- [Release notes](https://github.com/kitabisa/teler-waf/releases)
- [Commits](teler-sh/teler-waf@v1.1.4...v1.1.5)

---
updated-dependencies:
- dependency-name: github.com/kitabisa/teler-waf
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump github.com/kitabisa/teler-waf from 1.1.5 to 1.1.7 (#16)

Bumps [github.com/kitabisa/teler-waf](https://github.com/kitabisa/teler-waf) from 1.1.5 to 1.1.7.
- [Release notes](https://github.com/kitabisa/teler-waf/releases)
- [Commits](teler-sh/teler-waf@v1.1.5...v1.1.7)

---
updated-dependencies:
- dependency-name: github.com/kitabisa/teler-waf
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(make): add -trimpath for build

* chore: update goreleaser cfg

* add hooks
* set prelease for release
* additional archive files

Signed-off-by: Dwi Siswanto <[email protected]>

* chore: update gitignore

* test(tunnel): DRYing dest input

* docs(README): update video url

* build(make): add build-pgo cmd

* build(make): add bench, cover, and pprof

* test(tunnel): add benchmark funcs

* build: generate-pgo workflow

* build(generate-pgo): update job name

* build(generate-pgo): add module download step

* build(make): add test-all & '-race' flag for test

* build(generate-pgo): add http server

* build(pgo): generate default PGO profile 🤖

* docs(README): add note for go1.20+

* docs(README): add additional step for manual build and
add notes for excludes

* build(go.mod): bump teler-waf

* build(pgo): generate default PGO profile 🤖

* build(codeql): update trigger events

* build(tests): add tests as dependents jobs

* build(make): set none run test for bench

* build(release): add setup-go action
and use stable go version

* build(goreleaser): add -pgo flag

* build(docker): add -pgo flag

* build: disable analyze tests for linter

* feat: add datasets watcher (#23)

* feat(internal): add cron pkg

* feat: add datasets watcher

* chore: rm unused file

* feat: add const err msg

* fix: add err check for run.cron

* build(pgo): generate default PGO profile 🤖

* build(mod): bump teler-waf to v1.2.0-beta.2

* build(pgo): generate default PGO profile 🤖

* docs(README): add config warn note

* fix: nil pointer of `run.watcher.{config,datasets}.Events`

Signed-off-by: Dwi Siswanto <[email protected]>

* fix(runner): return `true` if no cfg path in `shouldCron`

* refactor(runner): use `sync.Once` instead of `sync.Mutex`

Signed-off-by: Dwi Siswanto <[email protected]>

* build(mod): bump teler-waf

* build(pgo): generate default PGO profile 🤖

* docs: add verbose field

* build(ci): remove wip from branches

---------

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Dwi Siswanto <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: ghost <[email protected]>
  • Loading branch information
3 people authored Oct 6, 2023
1 parent 0eb6316 commit d3d9e04
Show file tree
Hide file tree
Showing 64 changed files with 3,406 additions and 127 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/.git
**/.gitignore
**/.github
**/Dockerfile
**/.dockerignore
**/demo
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: ["dwisiswant0"]
48 changes: 48 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: Bug report
about: Create a report to help us improve
title: "[bug]"
labels: 'bug'
assignees: dwisiswant0

---

**Describe the bug**

A clear and concise description of what the bug is.

**To Reproduce**

Steps to reproduce the behavior:

```go
Your teler usage & options...
```

teler WAF configuration:

```yaml
# your teler WAF configuration...
```

```json
// or in JSON format...
```

**Expected behavior**

A clear and concise description of what you expected to happen.

**Screenshots**

If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information):**

- OS: [e.g. mac, linux]
- OS version: [uname -a]
- teler Proxy version: [teler-proxy -V]

**Additional context**

Add any other context about the problem here. Full output log is probably a helpful thing to add here.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Ask a question
url: https://github.com/kitabisa/teler-proxy/discussions
about: Ask questions and discuss with other community members
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Documentation
about: Suggest better docs coverage for a particular tool or process.
title: "[docs]"
labels: 'documentation'
---

<!--
To make it easier for us to help you, please include as much useful information as possible.
Before opening a new issue, please search existing issues https://github.com/kitabisa/teler-proxy/issues
-->

## Summary

_What problem(s) did you run into that caused you to request additional documentation? What questions do you think we should answer? What, if any, existing documentation relates to this proposal?_

Some recommended topics to cover:

- _List the topics you think should be here._
- _This list does not need to be exhaustive!_

### Motivation

_Why should we document this and who will benefit from it?_
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[feature]"
labels: 'enhancement'
assignees: dwisiswant0

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
45 changes: 45 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
**IMPORTANT: Please do not create a PR without creating an issue first!**

_(Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request)._

### Summary

<!-- Please provide enough information so that others can review your pull request. -->
<!-- For more information, see the CONTRIBUTING.md guide. -->

_Explains the information and/or motivation for making this changes..._


### Proposed of changes

This PR fixes/implements the following **bugs/features**:

- Bug 1
- Bug 2
- Feature 1
- Feature 2
- Breaking changes

<!-- What existing problem does the pull request solve? -->

### How has this been tested?

Proof:

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output or/ screenshots. -->

### Closing issues

Fixes #

### Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] My code follows the code style of this project.
- [ ] My changes successfully ran and pass linters locally (run `make lint`).
- [ ] I have written new tests for my changes.
- [ ] My changes successfully ran and pass tests locally.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
15 changes: 15 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
labels:
- "dependencies"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels:
- "dependencies"
32 changes: 32 additions & 0 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "CodeQL"

on:
schedule:
- cron: '37 11 * * 3'
workflow_call:

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: go

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:go"
39 changes: 39 additions & 0 deletions .github/workflows/generate-pgo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Generate PGO"

on:
push:
branches:
- master
paths:
- "pkg/tunnel/**.go"
- "go.*"
workflow_dispatch:

env:
PGO_FILE: "default.pgo"

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 'stable'
- run: go mod download
- run: |
sudo python3 -m http.server 80 &> /dev/null &
echo "pid=$!" >> "$GITHUB_OUTPUT"
id: server
- run: |
make pprof
kill -9 ${{ steps.server.outputs.pid }}
echo "changes=$(git status -s ${{ env.PGO_FILE }} | wc -l)" >> "$GITHUB_OUTPUT"
id: pprof
- if: ${{ steps.pprof.outputs.changes > 0 }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "ghost"
git add ${{ env.PGO_FILE }}
git commit -m "build(pgo): generate default PGO profile :robot:"
git push origin ${{ github.ref_name }}
63 changes: 63 additions & 0 deletions .github/workflows/release-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release & Publish

on:
push:
tags: ["v*.*.**"]
workflow_dispatch:
inputs:
tag:
description: "Target tag to release/publish"
required: true
type: string
job:
description: "Choose job to run"
required: true
default: 'both'
type: choice
options:
- both
- release
- publish

jobs:
release:
name: goreleaser-cross
runs-on: ubuntu-latest
container:
image: ghcr.io/goreleaser/goreleaser-cross:latest
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && (inputs.job == 'release' || inputs.job == 'both')) }}
steps:
- uses: actions/checkout@master
with:
ref: "${{ inputs.tag || github.ref_name }}"

- uses: actions/setup-go@v4
with:
go-version: 'stable'

- run: git config --global --add safe.directory "$(pwd)"

- run: goreleaser release
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

publish:
name: publish images
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && (inputs.job == 'publish' || inputs.job == 'both')) }}
steps:
- uses: actions/checkout@master
with:
ref: "${{ inputs.tag || github.ref_name }}"

- uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/[email protected]
with:
push: true
build-args: "VERSION=${{ inputs.tag || github.ref_name }},PGO_FILE=${{ github.workspace }}/default.pgo"
tags: "ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ inputs.tag || github.ref_name }}"
54 changes: 54 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Tests"

on:
push:
branches:
- master
paths:
- "**.go"
- "go.mod"
pull_request:
branches:
- "**"

jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 'stable'
- uses: actions/checkout@v3
- name: Vetting
run: make vet
- name: Build
run: make build
- name: Clean up
run: make clean

golangci:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
args: --timeout=5m --tests=false

semgrep:
runs-on: ubuntu-latest
needs: tests
container:
image: returntocorp/semgrep
if: (github.actor != 'dependabot[bot]')
steps:
- uses: actions/checkout@v3
- run: semgrep ci
env:
SEMGREP_RULES: auto

codeql:
needs: tests
uses: ./.github/workflows/codeql.yaml
Loading

0 comments on commit d3d9e04

Please sign in to comment.