This repository was archived by the owner on Aug 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for multiple tunnels simultaneously (#8)
- Loading branch information
Showing
17 changed files
with
336 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
name: Playwright Tests | ||
on: | ||
push: | ||
branches: [ main, master ] | ||
branches: [main, master] | ||
pull_request: | ||
branches: [ main, master ] | ||
branches: [main, master] | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install pnpm | ||
run: npm i -g pnpm | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: 'pnpm' | ||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Install Playwright Browsers | ||
run: pnpm dlx playwright install --with-deps | ||
- name: Add hosts to /etc/hosts | ||
run: | | ||
- name: Install pnpm | ||
run: npm i -g pnpm | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: "pnpm" | ||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Install Playwright Browsers | ||
run: pnpm dlx playwright install --with-deps | ||
- name: Add hosts to /etc/hosts | ||
run: | | ||
sudo echo "127.0.0.1 test.localhost" | sudo tee -a /etc/hosts | ||
- name: Build client and server | ||
run: | | ||
- name: Build client and server | ||
run: | | ||
go build -ldflags="-s -w" -o beaver ./cmd/beaver_client | ||
go build -ldflags="-s -w" -o beaver_server ./cmd/beaver_server | ||
go build -ldflags="-s -w" -o test_server ./e2e/server.go | ||
- name: Start test servers | ||
run: | | ||
- name: Start test servers | ||
run: | | ||
./test_server & | ||
sleep 5 | ||
./beaver_server --config docs/beaver_server.yaml & | ||
sleep 5 | ||
- name: Start test client | ||
run: | | ||
./beaver --config docs/beaver_client.yaml --port 9999 --subdomain test & | ||
- name: Start test client | ||
run: | | ||
./beaver --config docs/beaver_client.yaml http 9999 --subdomain test & | ||
sleep 3 | ||
- name: Run Playwright tests | ||
run: pnpm dlx playwright test | ||
- name: Kill test servers | ||
run: | | ||
- name: Run Playwright tests | ||
run: pnpm dlx playwright test | ||
- name: Kill test servers | ||
run: | | ||
make kill-test-servers | ||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 | ||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ node_modules | |
/playwright/.cache/ | ||
|
||
dist/ | ||
!beaver_server/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
"github.com/amalshaji/beaver/client" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
port int | ||
subdomain string | ||
httpCmd = &cobra.Command{ | ||
Use: "http [PORT]", | ||
Short: "Tunnel local http servers", | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
if len(args) == 0 { | ||
return fmt.Errorf("local server port is required") | ||
} | ||
if len(args) > 1 { | ||
return fmt.Errorf("only one port number is allowed") | ||
} | ||
|
||
var err error | ||
port, err = strconv.Atoi(args[0]) | ||
if err != nil { | ||
return fmt.Errorf("port must be a number") | ||
} | ||
|
||
return nil | ||
}, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var tunnels = make([]client.TunnelConfig, 0) | ||
tunnels = append(tunnels, client.TunnelConfig{Port: port, Subdomain: subdomain}) | ||
startTunnels(tunnels) | ||
}, | ||
} | ||
) | ||
|
||
func init() { | ||
httpCmd.Flags().StringVar(&subdomain, "subdomain", "", "Subdomain to tunnel http requests (default \"<random_subdomain>\")") | ||
} |
Oops, something went wrong.