mirror of
https://github.com/fumiama/terasu-cloudflared.git
synced 2026-06-18 01:26:23 +08:00
TUN-4699: Make quick tunnels the default in cloudflared
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -51,7 +52,7 @@ func RunQuickTunnel(sc *subcommandContext) error {
|
||||
TunnelName: data.Result.Name,
|
||||
}
|
||||
|
||||
for _, line := range connection.AsciiBox([]string{
|
||||
for _, line := range AsciiBox([]string{
|
||||
"Your Quick Tunnel has been created! Visit it at:",
|
||||
data.Result.Hostname,
|
||||
}, 2) {
|
||||
@@ -61,10 +62,9 @@ func RunQuickTunnel(sc *subcommandContext) error {
|
||||
return StartServer(
|
||||
sc.c,
|
||||
version,
|
||||
&connection.NamedTunnelConfig{Credentials: credentials},
|
||||
&connection.NamedTunnelConfig{Credentials: credentials, QuickTunnelUrl: data.Result.Hostname},
|
||||
sc.log,
|
||||
sc.isUIEnabled,
|
||||
data.Result.Hostname,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -86,3 +86,26 @@ type QuickTunnel struct {
|
||||
AccountTag string `json:"account_tag"`
|
||||
Secret []byte `json:"secret"`
|
||||
}
|
||||
|
||||
// Print out the given lines in a nice ASCII box.
|
||||
func AsciiBox(lines []string, padding int) (box []string) {
|
||||
maxLen := maxLen(lines)
|
||||
spacer := strings.Repeat(" ", padding)
|
||||
border := "+" + strings.Repeat("-", maxLen+(padding*2)) + "+"
|
||||
box = append(box, border)
|
||||
for _, line := range lines {
|
||||
box = append(box, "|"+spacer+line+strings.Repeat(" ", maxLen-len(line))+spacer+"|")
|
||||
}
|
||||
box = append(box, border)
|
||||
return
|
||||
}
|
||||
|
||||
func maxLen(lines []string) int {
|
||||
max := 0
|
||||
for _, line := range lines {
|
||||
if len(line) > max {
|
||||
max = len(line)
|
||||
}
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user