mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 20:50:00 +00:00
TUN-5915: New cloudflared command to allow to retrieve the token credentials for a Tunnel
This commit is contained in:
@@ -2,6 +2,7 @@ package connection
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
@@ -11,6 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
|
||||
"github.com/cloudflare/cloudflared/websocket"
|
||||
@@ -65,6 +67,15 @@ func (t TunnelToken) Credentials() Credentials {
|
||||
}
|
||||
}
|
||||
|
||||
func (t TunnelToken) Encode() (string, error) {
|
||||
val, err := json.Marshal(t)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "could not JSON encode token")
|
||||
}
|
||||
|
||||
return base64.StdEncoding.EncodeToString(val), nil
|
||||
}
|
||||
|
||||
type ClassicTunnelProperties struct {
|
||||
Hostname string
|
||||
OriginCert []byte
|
||||
|
Reference in New Issue
Block a user