Compare commits

..

10 Commits

Author SHA1 Message Date
Renovate-Clanker e190d9b4bc chore(deps): update docker/login-action action to v4
Tests / Run Tests (pull_request) Successful in 2m4s
2026-04-01 04:05:02 +00:00
bagas 6d4403012f Merge pull request 'chore(deps): update golang docker tag to v1.26.1' (#124) from renovate/golang-1.x into main
SonarQube Scan / SonarQube Trigger (push) Successful in 3m32s
Reviewed-on: #124
2026-04-01 08:33:13 +07:00
Renovate-Clanker e69abd85b6 chore(deps): update golang docker tag to v1.26.1
Tests / Run Tests (pull_request) Successful in 2m34s
2026-04-01 01:07:17 +00:00
bagas 54179a7112 refactor: move server, session, and types package to internal
SonarQube Scan / SonarQube Trigger (push) Successful in 3m39s
Docker Build and Push / Run Tests (push) Successful in 2m10s
Docker Build and Push / Build and Push Docker Image (push) Successful in 19m55s
Reviewed-on: #123
2026-03-30 12:15:14 +07:00
bagas d7ec5e852b Merge pull request 'refactor: move types package to internal' (#122) from refactor/move-types-to-internal into staging
SonarQube Scan / SonarQube Trigger (push) Successful in 3m32s
Tests / Run Tests (pull_request) Successful in 2m6s
Reviewed-on: #122
2026-03-30 11:53:16 +07:00
bagas 4af011b91d refactor: move types package to internal
Tests / Run Tests (pull_request) Successful in 2m7s
2026-03-30 11:50:24 +07:00
bagas dc0a4af27f Merge pull request 'refactor: move session package to internal' (#121) from refactor/move-session-to-internal into staging
SonarQube Scan / SonarQube Trigger (push) Successful in 3m48s
Reviewed-on: #121
2026-03-30 11:47:35 +07:00
bagas 032b6e5096 Merge pull request 'refactor: move server package to internal' (#120) from refactor/move-server-to-internal into staging
SonarQube Scan / SonarQube Trigger (push) Successful in 3m36s
Reviewed-on: #120
2026-03-30 11:38:52 +07:00
bagas ae71b46482 refactor: move session package to internal
Tests / Run Tests (pull_request) Successful in 2m4s
2026-03-30 11:37:59 +07:00
bagas 7ecc56aa3c refactor: move server package to internal
Tests / Run Tests (pull_request) Successful in 2m37s
2026-03-30 11:18:44 +07:00
34 changed files with 143 additions and 145 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ jobs:
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Log in to Docker Registry - name: Log in to Docker Registry
uses: docker/login-action@v3 uses: docker/login-action@v4
with: with:
registry: git.fossy.my.id registry: git.fossy.my.id
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
+1 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.26.0-alpine AS go_builder FROM golang:1.26.1-alpine AS go_builder
ARG VERSION=dev ARG VERSION=dev
ARG BUILD_DATE=unknown ARG BUILD_DATE=unknown
+1 -5
View File
@@ -3,10 +3,10 @@ module tunnel_pls
go 1.26.0 go 1.26.0
require ( require (
charm.land/bubbletea/v2 v2.0.0
git.fossy.my.id/bagas/tunnel-please-grpc v1.5.0 git.fossy.my.id/bagas/tunnel-please-grpc v1.5.0
github.com/caddyserver/certmagic v0.25.1 github.com/caddyserver/certmagic v0.25.1
github.com/charmbracelet/bubbles v1.0.0 github.com/charmbracelet/bubbles v1.0.0
github.com/charmbracelet/bubbletea v1.3.10
github.com/charmbracelet/lipgloss v1.1.0 github.com/charmbracelet/lipgloss v1.1.0
github.com/joho/godotenv v1.5.1 github.com/joho/godotenv v1.5.1
github.com/libdns/cloudflare v0.2.2 github.com/libdns/cloudflare v0.2.2
@@ -21,14 +21,10 @@ require (
github.com/atotto/clipboard v0.1.4 // indirect github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/caddyserver/zerossl v0.1.4 // indirect github.com/caddyserver/zerossl v0.1.4 // indirect
github.com/charmbracelet/bubbletea v1.3.10 // indirect
github.com/charmbracelet/colorprofile v0.4.1 // indirect github.com/charmbracelet/colorprofile v0.4.1 // indirect
github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8 // indirect
github.com/charmbracelet/x/ansi v0.11.6 // indirect github.com/charmbracelet/x/ansi v0.11.6 // indirect
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
github.com/charmbracelet/x/term v0.2.2 // indirect github.com/charmbracelet/x/term v0.2.2 // indirect
github.com/charmbracelet/x/termios v0.1.1 // indirect
github.com/charmbracelet/x/windows v0.2.2 // indirect
github.com/clipperhouse/displaywidth v0.9.0 // indirect github.com/clipperhouse/displaywidth v0.9.0 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.5.0 // indirect github.com/clipperhouse/uax29/v2 v2.5.0 // indirect
+2 -10
View File
@@ -1,5 +1,3 @@
charm.land/bubbletea/v2 v2.0.0 h1:p0d6CtWyJXJ9GfzMpUUqbP/XUUhhlk06+vCKWmox1wQ=
charm.land/bubbletea/v2 v2.0.0/go.mod h1:3LRff2U4WIYXy7MTxfbAQ+AdfM3D8Xuvz2wbsOD9OHQ=
git.fossy.my.id/bagas/tunnel-please-grpc v1.5.0 h1:3xszIhck4wo9CoeRq9vnkar4PhY7kz9QrR30qj2XszA= git.fossy.my.id/bagas/tunnel-please-grpc v1.5.0 h1:3xszIhck4wo9CoeRq9vnkar4PhY7kz9QrR30qj2XszA=
git.fossy.my.id/bagas/tunnel-please-grpc v1.5.0/go.mod h1:Weh6ZujgWmT8XxD3Qba7sJ6r5eyUMB9XSWynqdyOoLo= git.fossy.my.id/bagas/tunnel-please-grpc v1.5.0/go.mod h1:Weh6ZujgWmT8XxD3Qba7sJ6r5eyUMB9XSWynqdyOoLo=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
@@ -20,20 +18,14 @@ github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco
github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk= github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk=
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8 h1:eyFRbAmexyt43hVfeyBofiGSEmJ7krjLOYt/9CF5NKA=
github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8/go.mod h1:SQpCTRNBtzJkwku5ye4S3HEuthAlGy2n9VXZnWkEW98=
github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8= github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8=
github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ= github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ=
github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI= github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=
github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q= github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q=
github.com/charmbracelet/x/exp/golden v0.0.0-20241212170349-ad4b7ae0f25f h1:UytXHv0UxnsDFmL/7Z9Q5SBYPwSuRLXHbwx+6LycZ2w= github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ=
github.com/charmbracelet/x/exp/golden v0.0.0-20241212170349-ad4b7ae0f25f/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk= github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI= github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=
github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=
github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM=
github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k=
github.com/clipperhouse/displaywidth v0.9.0 h1:Qb4KOhYwRiN3viMv1v/3cTBlz3AcAZX3+y9OLhMtAtA= github.com/clipperhouse/displaywidth v0.9.0 h1:Qb4KOhYwRiN3viMv1v/3cTBlz3AcAZX3+y9OLhMtAtA=
github.com/clipperhouse/displaywidth v0.9.0/go.mod h1:aCAAqTlh4GIVkhQnJpbL0T/WfcrJXHcj8C0yjYcjOZA= github.com/clipperhouse/displaywidth v0.9.0/go.mod h1:aCAAqTlh4GIVkhQnJpbL0T/WfcrJXHcj8C0yjYcjOZA=
github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs=
+2 -2
View File
@@ -15,10 +15,10 @@ import (
"tunnel_pls/internal/port" "tunnel_pls/internal/port"
"tunnel_pls/internal/random" "tunnel_pls/internal/random"
"tunnel_pls/internal/registry" "tunnel_pls/internal/registry"
"tunnel_pls/internal/server"
"tunnel_pls/internal/transport" "tunnel_pls/internal/transport"
"tunnel_pls/internal/types"
"tunnel_pls/internal/version" "tunnel_pls/internal/version"
"tunnel_pls/server"
"tunnel_pls/types"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
) )
+2 -2
View File
@@ -14,8 +14,8 @@ import (
"tunnel_pls/internal/config" "tunnel_pls/internal/config"
"tunnel_pls/internal/port" "tunnel_pls/internal/port"
"tunnel_pls/internal/registry" "tunnel_pls/internal/registry"
"tunnel_pls/session/slug" "tunnel_pls/internal/session/slug"
"tunnel_pls/types" "tunnel_pls/internal/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
+3 -1
View File
@@ -1,6 +1,8 @@
package config package config
import "tunnel_pls/types" import (
"tunnel_pls/internal/types"
)
type Config interface { type Config interface {
Domain() string Domain() string
+1 -1
View File
@@ -3,7 +3,7 @@ package config
import ( import (
"os" "os"
"testing" "testing"
"tunnel_pls/types" "tunnel_pls/internal/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"os" "os"
"strconv" "strconv"
"strings" "strings"
"tunnel_pls/types" "tunnel_pls/internal/types"
"github.com/joho/godotenv" "github.com/joho/godotenv"
) )
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"time" "time"
"tunnel_pls/internal/config" "tunnel_pls/internal/config"
"tunnel_pls/internal/registry" "tunnel_pls/internal/registry"
"tunnel_pls/types" "tunnel_pls/internal/types"
proto "git.fossy.my.id/bagas/tunnel-please-grpc/gen" proto "git.fossy.my.id/bagas/tunnel-please-grpc/gen"
"google.golang.org/grpc" "google.golang.org/grpc"
+5 -5
View File
@@ -7,14 +7,14 @@ import (
"io" "io"
"testing" "testing"
"time" "time"
"tunnel_pls/internal/session/forwarder"
"tunnel_pls/internal/session/interaction"
"tunnel_pls/internal/session/lifecycle"
"tunnel_pls/internal/session/slug"
"tunnel_pls/internal/types"
"tunnel_pls/internal/port" "tunnel_pls/internal/port"
"tunnel_pls/internal/registry" "tunnel_pls/internal/registry"
"tunnel_pls/session/forwarder"
"tunnel_pls/session/interaction"
"tunnel_pls/session/lifecycle"
"tunnel_pls/session/slug"
"tunnel_pls/types"
proto "git.fossy.my.id/bagas/tunnel-please-grpc/gen" proto "git.fossy.my.id/bagas/tunnel-please-grpc/gen"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
+5 -5
View File
@@ -3,11 +3,11 @@ package registry
import ( import (
"fmt" "fmt"
"sync" "sync"
"tunnel_pls/session/forwarder" "tunnel_pls/internal/session/forwarder"
"tunnel_pls/session/interaction" "tunnel_pls/internal/session/interaction"
"tunnel_pls/session/lifecycle" "tunnel_pls/internal/session/lifecycle"
"tunnel_pls/session/slug" "tunnel_pls/internal/session/slug"
"tunnel_pls/types" "tunnel_pls/internal/types"
) )
type Key = types.SessionKey type Key = types.SessionKey
+5 -5
View File
@@ -5,11 +5,11 @@ import (
"testing" "testing"
"time" "time"
"tunnel_pls/internal/port" "tunnel_pls/internal/port"
"tunnel_pls/session/forwarder" "tunnel_pls/internal/session/forwarder"
"tunnel_pls/session/interaction" "tunnel_pls/internal/session/interaction"
"tunnel_pls/session/lifecycle" "tunnel_pls/internal/session/lifecycle"
"tunnel_pls/session/slug" "tunnel_pls/internal/session/slug"
"tunnel_pls/types" "tunnel_pls/internal/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
@@ -13,7 +13,7 @@ import (
"tunnel_pls/internal/port" "tunnel_pls/internal/port"
"tunnel_pls/internal/random" "tunnel_pls/internal/random"
"tunnel_pls/internal/registry" "tunnel_pls/internal/registry"
"tunnel_pls/session" "tunnel_pls/internal/session"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
) )
@@ -10,8 +10,8 @@ import (
"testing" "testing"
"time" "time"
"tunnel_pls/internal/registry" "tunnel_pls/internal/registry"
"tunnel_pls/session/slug" "tunnel_pls/internal/session/slug"
"tunnel_pls/types" "tunnel_pls/internal/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
@@ -10,8 +10,8 @@ import (
"strconv" "strconv"
"sync" "sync"
"tunnel_pls/internal/config" "tunnel_pls/internal/config"
"tunnel_pls/session/slug" "tunnel_pls/internal/session/slug"
"tunnel_pls/types" "tunnel_pls/internal/types"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
) )
@@ -10,8 +10,8 @@ import (
"sync/atomic" "sync/atomic"
"testing" "testing"
"time" "time"
"tunnel_pls/session/slug" "tunnel_pls/internal/session/slug"
"tunnel_pls/types" "tunnel_pls/internal/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
@@ -3,14 +3,14 @@ package interaction
import ( import (
"strings" "strings"
tea "charm.land/bubbletea/v2" "github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss"
) )
func (m *model) comingSoonUpdate(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) { func (m *model) comingSoonUpdate(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
_ = msg
m.showingComingSoon = false m.showingComingSoon = false
return m, nil return m, tea.Batch(tea.ClearScreen, textinput.Blink)
} }
func (m *model) comingSoonView() string { func (m *model) comingSoonView() string {
@@ -4,8 +4,9 @@ import (
"strings" "strings"
"time" "time"
tea "charm.land/bubbletea/v2"
"github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss"
) )
@@ -16,22 +17,24 @@ func (m *model) handleCommandSelection(item commandItem) (tea.Model, tea.Cmd) {
m.editingSlug = true m.editingSlug = true
m.slugInput.SetValue(m.interaction.slug.String()) m.slugInput.SetValue(m.interaction.slug.String())
m.slugInput.Focus() m.slugInput.Focus()
return m, nil return m, tea.Batch(tea.ClearScreen, textinput.Blink)
case "tunnel-type": case "tunnel-type":
m.showingCommands = false m.showingCommands = false
m.showingComingSoon = true m.showingComingSoon = true
return m, tickCmd(5 * time.Second) return m, tea.Batch(tickCmd(5*time.Second), tea.ClearScreen, textinput.Blink)
default: default:
m.showingCommands = false m.showingCommands = false
return m, nil return m, nil
} }
} }
func (m *model) commandsUpdate(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) { func (m *model) commandsUpdate(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
switch { switch {
case key.Matches(msg, m.keymap.quit), msg.String() == "esc": case key.Matches(msg, m.keymap.quit), msg.String() == "esc":
m.showingCommands = false m.showingCommands = false
return m, nil return m, tea.Batch(tea.ClearScreen, textinput.Blink)
case msg.String() == "enter": case msg.String() == "enter":
selectedItem := m.commandList.SelectedItem() selectedItem := m.commandList.SelectedItem()
if selectedItem != nil { if selectedItem != nil {
@@ -39,8 +42,8 @@ func (m *model) commandsUpdate(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
return m.handleCommandSelection(item) return m.handleCommandSelection(item)
} }
} }
m.commandList, _ = m.commandList.Update(msg) m.commandList, cmd = m.commandList.Update(msg)
return m, nil return m, cmd
} }
func (m *model) commandsView() string { func (m *model) commandsView() string {
@@ -4,19 +4,20 @@ import (
"fmt" "fmt"
"strings" "strings"
tea "charm.land/bubbletea/v2"
"github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss"
) )
func (m *model) dashboardUpdate(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) { func (m *model) dashboardUpdate(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
switch { switch {
case key.Matches(msg, m.keymap.quit): case key.Matches(msg, m.keymap.quit):
m.quitting = true m.quitting = true
return m, tea.Quit return m, tea.Batch(tea.ClearScreen, textinput.Blink, tea.Quit)
case key.Matches(msg, m.keymap.command): case key.Matches(msg, m.keymap.command):
m.showingCommands = true m.showingCommands = true
return m, nil return m, tea.Batch(tea.ClearScreen, textinput.Blink)
} }
return m, nil return m, nil
} }
@@ -6,14 +6,14 @@ import (
"sync" "sync"
"tunnel_pls/internal/config" "tunnel_pls/internal/config"
"tunnel_pls/internal/random" "tunnel_pls/internal/random"
"tunnel_pls/session/slug" "tunnel_pls/internal/session/slug"
"tunnel_pls/types" "tunnel_pls/internal/types"
tea "charm.land/bubbletea/v2"
"github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list" "github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss"
"github.com/muesli/termenv" "github.com/muesli/termenv"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
@@ -120,7 +120,7 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) { switch msg := msg.(type) {
case tickMsg: case tickMsg:
m.showingComingSoon = false m.showingComingSoon = false
return m, nil return m, tea.Batch(tea.ClearScreen, textinput.Blink)
case tea.WindowSizeMsg: case tea.WindowSizeMsg:
m.width = msg.Width m.width = msg.Width
@@ -137,9 +137,9 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case tea.QuitMsg: case tea.QuitMsg:
m.quitting = true m.quitting = true
return m, tea.Quit return m, tea.Batch(tea.ClearScreen, textinput.Blink, tea.Quit)
case tea.KeyPressMsg: case tea.KeyMsg:
if m.showingComingSoon { if m.showingComingSoon {
return m.comingSoonUpdate(msg) return m.comingSoonUpdate(msg)
} }
@@ -160,28 +160,28 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (i *interaction) Redraw() { func (i *interaction) Redraw() {
if i.program != nil { if i.program != nil {
i.program.Send(tea.WindowSizeMsg{}) i.program.Send(tea.ClearScreen())
} }
} }
func (m *model) View() tea.View { func (m *model) View() string {
var content string
if m.quitting { if m.quitting {
content = "" return ""
} else if m.showingComingSoon {
content = m.comingSoonView()
} else if m.editingSlug {
content = m.slugView()
} else if m.showingCommands {
content = m.commandsView()
} else {
content = m.dashboardView()
} }
v := tea.NewView(content) if m.showingComingSoon {
v.AltScreen = true return m.comingSoonView()
v.MouseMode = tea.MouseModeCellMotion }
return v
if m.editingSlug {
return m.slugView()
}
if m.showingCommands {
return m.commandsView()
}
return m.dashboardView()
} }
func (i *interaction) Start() { func (i *interaction) Start() {
@@ -249,6 +249,8 @@ func (i *interaction) Start() {
m, m,
tea.WithInput(i.channel), tea.WithInput(i.channel),
tea.WithOutput(i.channel), tea.WithOutput(i.channel),
tea.WithAltScreen(),
tea.WithMouseCellMotion(),
tea.WithoutSignals(), tea.WithoutSignals(),
tea.WithoutSignalHandler(), tea.WithoutSignalHandler(),
tea.WithFPS(30), tea.WithFPS(30),
@@ -7,12 +7,12 @@ import (
"net" "net"
"testing" "testing"
"time" "time"
"tunnel_pls/types" "tunnel_pls/internal/types"
tea "charm.land/bubbletea/v2"
"github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list" "github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
@@ -694,7 +694,7 @@ func TestInteraction_Integration(t *testing.T) {
func TestModel_Update_KeyMessages(t *testing.T) { func TestModel_Update_KeyMessages(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
key tea.KeyPressMsg key tea.KeyMsg
showingComingSoon bool showingComingSoon bool
editingSlug bool editingSlug bool
showingCommands bool showingCommands bool
@@ -702,25 +702,25 @@ func TestModel_Update_KeyMessages(t *testing.T) {
}{ }{
{ {
name: "key press while showing coming soon", name: "key press while showing coming soon",
key: tea.KeyPressMsg{Code: tea.KeyEnter}, key: tea.KeyMsg{Type: tea.KeyEnter},
showingComingSoon: true, showingComingSoon: true,
description: "should call comingSoonUpdate", description: "should call comingSoonUpdate",
}, },
{ {
name: "key press while editing slug", name: "key press while editing slug",
key: tea.KeyPressMsg{Code: tea.KeyEnter}, key: tea.KeyMsg{Type: tea.KeyEnter},
editingSlug: true, editingSlug: true,
description: "should call slugUpdate", description: "should call slugUpdate",
}, },
{ {
name: "key press while showing commands", name: "key press while showing commands",
key: tea.KeyPressMsg{Code: tea.KeyEnter}, key: tea.KeyMsg{Type: tea.KeyEnter},
showingCommands: true, showingCommands: true,
description: "should call commandsUpdate", description: "should call commandsUpdate",
}, },
{ {
name: "key press in dashboard view", name: "key press in dashboard view",
key: tea.KeyPressMsg{Code: 'c', Text: "c"}, key: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'c'}},
description: "should call dashboardUpdate", description: "should call dashboardUpdate",
}, },
} }
@@ -777,7 +777,7 @@ func TestModel_SlugUpdate(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
tunnelType types.TunnelType tunnelType types.TunnelType
keyMsg tea.KeyPressMsg keyMsg tea.KeyMsg
inputValue string inputValue string
setupMocks func(*MockSessionRegistry, *MockSlug, *MockRandom) setupMocks func(*MockSessionRegistry, *MockSlug, *MockRandom)
expectedEdit bool expectedEdit bool
@@ -787,21 +787,21 @@ func TestModel_SlugUpdate(t *testing.T) {
{ {
name: "escape key cancels editing", name: "escape key cancels editing",
tunnelType: types.TunnelTypeHTTP, tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyPressMsg{Code: tea.KeyEsc}, keyMsg: tea.KeyMsg{Type: tea.KeyEsc},
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {}, setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {},
expectedEdit: false, expectedEdit: false,
}, },
{ {
name: "ctrl+c cancels editing", name: "ctrl+c cancels editing",
tunnelType: types.TunnelTypeHTTP, tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyPressMsg{Code: 'c', Mod: tea.ModCtrl}, keyMsg: tea.KeyMsg{Type: tea.KeyCtrlC},
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {}, setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {},
expectedEdit: false, expectedEdit: false,
}, },
{ {
name: "enter key saves valid slug", name: "enter key saves valid slug",
tunnelType: types.TunnelTypeHTTP, tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyPressMsg{Code: tea.KeyEnter}, keyMsg: tea.KeyMsg{Type: tea.KeyEnter},
inputValue: "my-custom-slug", inputValue: "my-custom-slug",
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) { setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {
ms.On("String").Return("old-slug") ms.On("String").Return("old-slug")
@@ -816,7 +816,7 @@ func TestModel_SlugUpdate(t *testing.T) {
{ {
name: "enter key with error shows error message", name: "enter key with error shows error message",
tunnelType: types.TunnelTypeHTTP, tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyPressMsg{Code: tea.KeyEnter}, keyMsg: tea.KeyMsg{Type: tea.KeyEnter},
inputValue: "invalid", inputValue: "invalid",
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) { setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {
ms.On("String").Return("old-slug") ms.On("String").Return("old-slug")
@@ -831,7 +831,7 @@ func TestModel_SlugUpdate(t *testing.T) {
{ {
name: "ctrl+r generates random slug", name: "ctrl+r generates random slug",
tunnelType: types.TunnelTypeHTTP, tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyPressMsg{Code: 'r', Mod: tea.ModCtrl}, keyMsg: tea.KeyMsg{Type: tea.KeyCtrlR},
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) { setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {
mr.On("String", 20).Return("random-generated-slug", nil) mr.On("String", 20).Return("random-generated-slug", nil)
}, },
@@ -841,7 +841,7 @@ func TestModel_SlugUpdate(t *testing.T) {
{ {
name: "ctrl+r with error does nothing", name: "ctrl+r with error does nothing",
tunnelType: types.TunnelTypeHTTP, tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyPressMsg{Code: 'r', Mod: tea.ModCtrl}, keyMsg: tea.KeyMsg{Type: tea.KeyCtrlR},
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) { setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {
mr.On("String", 20).Return("", assert.AnError) mr.On("String", 20).Return("", assert.AnError)
}, },
@@ -850,14 +850,14 @@ func TestModel_SlugUpdate(t *testing.T) {
{ {
name: "regular key updates input", name: "regular key updates input",
tunnelType: types.TunnelTypeHTTP, tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyPressMsg{Code: 'a', Text: "a"}, keyMsg: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'a'}},
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {}, setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {},
expectedEdit: true, expectedEdit: true,
}, },
{ {
name: "tcp tunnel exits editing immediately", name: "tcp tunnel exits editing immediately",
tunnelType: types.TunnelTypeTCP, tunnelType: types.TunnelTypeTCP,
keyMsg: tea.KeyPressMsg{Code: 'a', Text: "a"}, keyMsg: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'a'}},
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {}, setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {},
expectedEdit: false, expectedEdit: false,
}, },
@@ -1006,19 +1006,19 @@ func TestModel_SlugView(t *testing.T) {
func TestModel_ComingSoonUpdate(t *testing.T) { func TestModel_ComingSoonUpdate(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
keyMsg tea.KeyPressMsg keyMsg tea.KeyMsg
}{ }{
{ {
name: "any key dismisses coming soon", name: "any key dismisses coming soon",
keyMsg: tea.KeyPressMsg{Code: tea.KeyEnter}, keyMsg: tea.KeyMsg{Type: tea.KeyEnter},
}, },
{ {
name: "escape key dismisses", name: "escape key dismisses",
keyMsg: tea.KeyPressMsg{Code: tea.KeyEsc}, keyMsg: tea.KeyMsg{Type: tea.KeyEsc},
}, },
{ {
name: "space key dismisses", name: "space key dismisses",
keyMsg: tea.KeyPressMsg{Code: ' ', Text: " "}, keyMsg: tea.KeyMsg{Type: tea.KeySpace},
}, },
} }
@@ -1097,7 +1097,7 @@ func TestModel_ComingSoonView(t *testing.T) {
func TestModel_CommandsUpdate(t *testing.T) { func TestModel_CommandsUpdate(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
keyMsg tea.KeyPressMsg keyMsg tea.KeyMsg
selectedItem list.Item selectedItem list.Item
expectCommands bool expectCommands bool
expectEditSlug bool expectEditSlug bool
@@ -1105,31 +1105,31 @@ func TestModel_CommandsUpdate(t *testing.T) {
}{ }{
{ {
name: "escape key closes commands", name: "escape key closes commands",
keyMsg: tea.KeyPressMsg{Code: tea.KeyEsc}, keyMsg: tea.KeyMsg{Type: tea.KeyEsc},
expectCommands: false, expectCommands: false,
}, },
{ {
name: "q key closes commands", name: "q key closes commands",
keyMsg: tea.KeyPressMsg{Code: 'q', Text: "q"}, keyMsg: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'q'}},
expectCommands: false, expectCommands: false,
}, },
{ {
name: "enter on slug command starts editing", name: "enter on slug command starts editing",
keyMsg: tea.KeyPressMsg{Code: tea.KeyEnter}, keyMsg: tea.KeyMsg{Type: tea.KeyEnter},
selectedItem: commandItem{name: "slug", desc: "Set custom subdomain"}, selectedItem: commandItem{name: "slug", desc: "Set custom subdomain"},
expectCommands: false, expectCommands: false,
expectEditSlug: true, expectEditSlug: true,
}, },
{ {
name: "enter on tunnel-type shows coming soon", name: "enter on tunnel-type shows coming soon",
keyMsg: tea.KeyPressMsg{Code: tea.KeyEnter}, keyMsg: tea.KeyMsg{Type: tea.KeyEnter},
selectedItem: commandItem{name: "tunnel-type", desc: "Change tunnel type"}, selectedItem: commandItem{name: "tunnel-type", desc: "Change tunnel type"},
expectCommands: false, expectCommands: false,
expectComingSoon: true, expectComingSoon: true,
}, },
{ {
name: "arrow key navigates list", name: "arrow key navigates list",
keyMsg: tea.KeyPressMsg{Code: tea.KeyDown}, keyMsg: tea.KeyMsg{Type: tea.KeyDown},
expectCommands: true, expectCommands: true,
}, },
} }
@@ -1261,28 +1261,28 @@ func TestModel_CommandsView(t *testing.T) {
func TestModel_DashboardUpdate(t *testing.T) { func TestModel_DashboardUpdate(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
keyMsg tea.KeyPressMsg keyMsg tea.KeyMsg
expectQuit bool expectQuit bool
expectCommands bool expectCommands bool
}{ }{
{ {
name: "q key quits", name: "q key quits",
keyMsg: tea.KeyPressMsg{Code: 'q', Text: "q"}, keyMsg: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'q'}},
expectQuit: true, expectQuit: true,
}, },
{ {
name: "ctrl+c quits", name: "ctrl+c quits",
keyMsg: tea.KeyPressMsg{Code: 'c', Mod: tea.ModCtrl}, keyMsg: tea.KeyMsg{Type: tea.KeyCtrlC},
expectQuit: true, expectQuit: true,
}, },
{ {
name: "c key opens commands", name: "c key opens commands",
keyMsg: tea.KeyPressMsg{Code: 'c', Text: "c"}, keyMsg: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'c'}},
expectCommands: true, expectCommands: true,
}, },
{ {
name: "other keys do nothing", name: "other keys do nothing",
keyMsg: tea.KeyPressMsg{Code: 'x', Text: "x"}, keyMsg: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'x'}},
}, },
} }
@@ -4,13 +4,13 @@ import (
"fmt" "fmt"
"time" "time"
"tunnel_pls/internal/random" "tunnel_pls/internal/random"
"tunnel_pls/types" "tunnel_pls/internal/types"
tea "charm.land/bubbletea/v2"
"github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list" "github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
) )
type commandItem struct { type commandItem struct {
@@ -77,7 +77,7 @@ type keymap struct {
type tickMsg time.Time type tickMsg time.Time
func (m *model) Init() tea.Cmd { func (m *model) Init() tea.Cmd {
return tea.RequestWindowSize return tea.Batch(textinput.Blink, tea.WindowSize())
} }
func getResponsiveWidth(screenWidth, padding, minWidth, maxWidth int) int { func getResponsiveWidth(screenWidth, padding, minWidth, maxWidth int) int {
@@ -3,26 +3,28 @@ package interaction
import ( import (
"fmt" "fmt"
"strings" "strings"
"tunnel_pls/types" "tunnel_pls/internal/types"
tea "charm.land/bubbletea/v2"
"github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss"
) )
func (m *model) slugUpdate(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) { func (m *model) slugUpdate(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
if m.tunnelType != types.TunnelTypeHTTP { if m.tunnelType != types.TunnelTypeHTTP {
m.editingSlug = false m.editingSlug = false
m.slugError = "" m.slugError = ""
return m, nil return m, tea.Batch(tea.ClearScreen, textinput.Blink)
} }
switch msg.String() { switch msg.String() {
case "esc", "ctrl+c": case "esc", "ctrl+c":
m.editingSlug = false m.editingSlug = false
m.slugError = "" m.slugError = ""
return m, nil return m, tea.Batch(tea.ClearScreen, textinput.Blink)
case "enter": case "enter":
inputValue := m.slugInput.Value() inputValue := m.slugInput.Value()
if err := m.interaction.sessionRegistry.Update(m.interaction.user, types.SessionKey{ if err := m.interaction.sessionRegistry.Update(m.interaction.user, types.SessionKey{
@@ -37,18 +39,18 @@ func (m *model) slugUpdate(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
} }
m.editingSlug = false m.editingSlug = false
m.slugError = "" m.slugError = ""
return m, nil return m, tea.Batch(tea.ClearScreen, textinput.Blink)
default: default:
if key.Matches(msg, m.keymap.random) { if key.Matches(msg, m.keymap.random) {
newSubdomain, err := m.randomizer.String(20) newSubdomain, err := m.randomizer.String(20)
if err != nil { if err != nil {
return m, nil return m, cmd
} }
m.slugInput.SetValue(newSubdomain) m.slugInput.SetValue(newSubdomain)
} }
m.slugError = "" m.slugError = ""
m.slugInput, _ = m.slugInput.Update(msg) m.slugInput, cmd = m.slugInput.Update(msg)
return m, nil return m, cmd
} }
} }
@@ -6,10 +6,10 @@ import (
"net" "net"
"sync" "sync"
"time" "time"
"tunnel_pls/internal/session/slug"
"tunnel_pls/internal/types"
portUtil "tunnel_pls/internal/port" portUtil "tunnel_pls/internal/port"
"tunnel_pls/session/slug"
"tunnel_pls/types"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
) )
@@ -6,7 +6,7 @@ import (
"io" "io"
"net" "net"
"testing" "testing"
"tunnel_pls/types" "tunnel_pls/internal/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
@@ -12,12 +12,12 @@ import (
portUtil "tunnel_pls/internal/port" portUtil "tunnel_pls/internal/port"
"tunnel_pls/internal/random" "tunnel_pls/internal/random"
"tunnel_pls/internal/registry" "tunnel_pls/internal/registry"
"tunnel_pls/internal/session/forwarder"
"tunnel_pls/internal/session/interaction"
"tunnel_pls/internal/session/lifecycle"
"tunnel_pls/internal/session/slug"
"tunnel_pls/internal/transport" "tunnel_pls/internal/transport"
"tunnel_pls/session/forwarder" "tunnel_pls/internal/types"
"tunnel_pls/session/interaction"
"tunnel_pls/session/lifecycle"
"tunnel_pls/session/slug"
"tunnel_pls/types"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
) )
@@ -15,8 +15,8 @@ import (
"time" "time"
"tunnel_pls/internal/config" "tunnel_pls/internal/config"
"tunnel_pls/internal/registry" "tunnel_pls/internal/registry"
"tunnel_pls/session/lifecycle" "tunnel_pls/internal/session/lifecycle"
"tunnel_pls/types" "tunnel_pls/internal/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
+1 -1
View File
@@ -16,7 +16,7 @@ import (
"tunnel_pls/internal/http/stream" "tunnel_pls/internal/http/stream"
"tunnel_pls/internal/middleware" "tunnel_pls/internal/middleware"
"tunnel_pls/internal/registry" "tunnel_pls/internal/registry"
"tunnel_pls/types" "tunnel_pls/internal/types"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
) )
+5 -5
View File
@@ -11,11 +11,11 @@ import (
"testing" "testing"
"time" "time"
"tunnel_pls/internal/registry" "tunnel_pls/internal/registry"
"tunnel_pls/session/forwarder" "tunnel_pls/internal/session/forwarder"
"tunnel_pls/session/interaction" "tunnel_pls/internal/session/interaction"
"tunnel_pls/session/lifecycle" "tunnel_pls/internal/session/lifecycle"
"tunnel_pls/session/slug" "tunnel_pls/internal/session/slug"
"tunnel_pls/types" "tunnel_pls/internal/types"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
+1 -1
View File
@@ -14,7 +14,7 @@ import (
"testing" "testing"
"time" "time"
"tunnel_pls/internal/config" "tunnel_pls/internal/config"
"tunnel_pls/types" "tunnel_pls/internal/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"