mirror of
https://github.com/xaionaro-go/streamctl.git
synced 2025-12-24 12:27:57 +08:00
Revert back the secret package
This commit is contained in:
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/cloudwego/eino-ext/components/model/openai"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/facebookincubator/go-belt/tool/logger"
|
||||
"github.com/xaionaro-go/secret"
|
||||
llmtypes "github.com/xaionaro-go/streamctl/pkg/llm/types"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
)
|
||||
|
||||
type ChatGPT struct {
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"github.com/pojntfx/weron/pkg/wrtcconn"
|
||||
"github.com/pojntfx/weron/pkg/wrtcip"
|
||||
"github.com/xaionaro-go/observability"
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/consts"
|
||||
p2pconsts "github.com/xaionaro-go/streamctl/pkg/p2p/implementations/weron/consts"
|
||||
"github.com/xaionaro-go/streamctl/pkg/p2p/types"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -23,8 +23,8 @@ import (
|
||||
"github.com/xaionaro-go/avpipeline/node"
|
||||
"github.com/xaionaro-go/avpipeline/packet"
|
||||
"github.com/xaionaro-go/observability"
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/screenshot"
|
||||
"github.com/xaionaro-go/secret"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
@@ -57,7 +57,7 @@ func (s *ScreenshoterWayland) Loop(
|
||||
logger.Debugf(ctx, "starting wf-recorder")
|
||||
args := []string{
|
||||
"wf-recorder",
|
||||
"-o", "DP-2",
|
||||
"-o", "DP-8",
|
||||
"-y",
|
||||
"-r", fmt.Sprintf("%f", 1.0/interval.Seconds()),
|
||||
"-c", "rawvideo",
|
||||
|
||||
61
pkg/secret/any.go
Normal file
61
pkg/secret/any.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package secret
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
|
||||
"github.com/xaionaro-go/secret"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
type Any[T any] struct {
|
||||
secret.Any[T]
|
||||
}
|
||||
|
||||
func New[T any](in T) Any[T] {
|
||||
return Any[T]{Any: secret.New(in)}
|
||||
}
|
||||
|
||||
func (s Any[T]) MarshalYAML() (_ret []byte, _err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
_err = fmt.Errorf("got a panic: %v", r)
|
||||
}
|
||||
}()
|
||||
|
||||
var v any = s.Get()
|
||||
if b, ok := v.([]byte); ok {
|
||||
v = base64.StdEncoding.EncodeToString(b)
|
||||
}
|
||||
b, err := yaml.Marshal(v)
|
||||
return b, err
|
||||
}
|
||||
|
||||
func (s *Any[T]) UnmarshalYAML(b []byte) (_err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
_err = fmt.Errorf("got a panic: %v", r)
|
||||
}
|
||||
}()
|
||||
|
||||
var v T
|
||||
if _, ok := any(v).([]byte); ok {
|
||||
var str string
|
||||
err := yaml.Unmarshal(b, &str)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to yaml.Unmarshal: %w", err)
|
||||
}
|
||||
b, err := base64.StdEncoding.DecodeString(str)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode '%s' as base64: %w", str, err)
|
||||
}
|
||||
s.Set(any(b).(T))
|
||||
} else {
|
||||
err := yaml.Unmarshal(b, &v)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to yaml.Unmarshal: %w", err)
|
||||
}
|
||||
s.Set(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
3
pkg/secret/bytes.go
Normal file
3
pkg/secret/bytes.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package secret
|
||||
|
||||
type Bytes = Any[[]byte]
|
||||
9
pkg/secret/oauth2_token.go
Normal file
9
pkg/secret/oauth2_token.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package secret
|
||||
|
||||
import (
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
// OAuth2Token stores an OAuth2 token in an encrypted state in memory, so that
|
||||
// you don't accidentally leak these secrets via logging or whatever.
|
||||
type OAuth2Token = Any[oauth2.Token]
|
||||
3
pkg/secret/string.go
Normal file
3
pkg/secret/string.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package secret
|
||||
|
||||
type String = Any[string]
|
||||
@@ -18,8 +18,8 @@ import (
|
||||
"github.com/scorfly/gokick"
|
||||
"github.com/xaionaro-go/kickcom"
|
||||
"github.com/xaionaro-go/observability"
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/oauthhandler"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamcontrol"
|
||||
"github.com/xaionaro-go/xsync"
|
||||
)
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/buildvars"
|
||||
"github.com/xaionaro-go/streamctl/pkg/oauthhandler"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
streamctl "github.com/xaionaro-go/streamctl/pkg/streamcontrol"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package kick
|
||||
|
||||
import (
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
)
|
||||
|
||||
type CustomData struct {
|
||||
|
||||
@@ -3,7 +3,7 @@ package types
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
streamctl "github.com/xaionaro-go/streamctl/pkg/streamcontrol"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/facebookincubator/go-belt/tool/logger"
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
twitch "github.com/xaionaro-go/streamctl/pkg/streamcontrol/twitch/types"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/facebookincubator/go-belt/tool/logger"
|
||||
"github.com/xaionaro-go/observability"
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
twitch "github.com/xaionaro-go/streamctl/pkg/streamcontrol/twitch/types"
|
||||
)
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"github.com/facebookincubator/go-belt/tool/logger/implementation/zap"
|
||||
"github.com/nicklaw5/helix/v2"
|
||||
"github.com/xaionaro-go/observability"
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/oauthhandler"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamcontrol/twitch"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamcontrol/twitch/auth"
|
||||
)
|
||||
|
||||
@@ -16,9 +16,9 @@ import (
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/nicklaw5/helix/v2"
|
||||
"github.com/xaionaro-go/observability"
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/buildvars"
|
||||
"github.com/xaionaro-go/streamctl/pkg/ringbuffer"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamcontrol"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamcontrol/twitch/auth"
|
||||
"github.com/xaionaro-go/xsync"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package twitch
|
||||
|
||||
import (
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/buildvars"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
streamctl "github.com/xaionaro-go/streamctl/pkg/streamcontrol"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/oauthhandler"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
streamctl "github.com/xaionaro-go/streamctl/pkg/streamcontrol"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
"github.com/go-yaml/yaml"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/xaionaro-go/observability"
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/oauthhandler"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamcontrol"
|
||||
"github.com/xaionaro-go/timeapiio"
|
||||
"github.com/xaionaro-go/xcontext"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
)
|
||||
|
||||
type GitRepoConfig struct {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/goombaio/namegenerator"
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
)
|
||||
|
||||
type P2PPrivateKey struct {
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/facebookincubator/go-belt/tool/logger"
|
||||
"github.com/xaionaro-go/secret"
|
||||
llms "github.com/xaionaro-go/streamctl/pkg/llm"
|
||||
llmtypes "github.com/xaionaro-go/streamctl/pkg/llm/types"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
"github.com/xaionaro-go/xcontext"
|
||||
"github.com/xaionaro-go/xsync"
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/xaionaro-go/lockmap"
|
||||
"github.com/xaionaro-go/observability"
|
||||
"github.com/xaionaro-go/recoder"
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamcontrol/youtube"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamd/memoize"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamserver/types"
|
||||
|
||||
@@ -2,7 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/xaionaro-go/recoder/xaionaro-go-rtmp/yutoppgortmp"
|
||||
"github.com/xaionaro-go/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/secret"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamtypes"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user