Skip to content

Commit 1959ce1

Browse files
committed
Multiple updates
1 parent 2ae50b9 commit 1959ce1

34 files changed

+771
-736
lines changed

cmd/streamd/main.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package main
22

33
import (
44
"context"
5+
"crypto/tls"
56
"log"
6-
"net"
77
"net/http"
88
_ "net/http/pprof"
99
"os"
@@ -19,11 +19,13 @@ import (
1919
"github.com/getsentry/sentry-go"
2020
grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
2121
"github.com/spf13/pflag"
22+
"github.com/xaionaro-go/eventbus"
2223
"github.com/xaionaro-go/grpcproxy/grpcproxyserver"
2324
"github.com/xaionaro-go/grpcproxy/protobuf/go/proxy_grpc"
2425
"github.com/xaionaro-go/obs-grpc-proxy/protobuf/go/obs_grpc"
2526
"github.com/xaionaro-go/observability"
2627
"github.com/xaionaro-go/streamctl/cmd/streamd/ui"
28+
"github.com/xaionaro-go/streamctl/pkg/cert"
2729
"github.com/xaionaro-go/streamctl/pkg/streamcontrol"
2830
"github.com/xaionaro-go/streamctl/pkg/streamd"
2931
"github.com/xaionaro-go/streamctl/pkg/streamd/config"
@@ -127,6 +129,8 @@ func main() {
127129
}
128130
defer belt.Flush(ctx)
129131

132+
eventbus.LoggingEnabled = true
133+
130134
configPathExpanded, err := xpath.Expand(*configPath)
131135
if err != nil {
132136
l.Fatalf("unable to get the path to the data file: %v", err)
@@ -181,7 +185,16 @@ func main() {
181185
}
182186
})
183187

184-
listener, err := net.Listen("tcp", *listenAddr)
188+
cert, err := cert.GenerateSelfSignedForServer()
189+
if err != nil {
190+
logger.Panicf(ctx, "unable to generate the certificate: %v", err)
191+
}
192+
193+
listener, err := tls.Listen("tcp", *listenAddr, &tls.Config{
194+
Certificates: []tls.Certificate{cert},
195+
NextProtos: []string{"h2"},
196+
})
197+
//listener, err := net.Listen("tcp", *listenAddr)
185198
if err != nil {
186199
log.Fatalf("failed to listen: %v", err)
187200
}

cmd/streampanel/FyneApp.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Website = "https://github.com/xaionaro/streamctl"
55
Name = "streampanel"
66
ID = "center.dx.streampanel"
77
Version = "0.1.0"
8-
Build = 432
8+
Build = 433

cmd/streampanel/runtime.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/facebookincubator/go-belt"
1717
"github.com/facebookincubator/go-belt/tool/logger"
1818
"github.com/prometheus/client_golang/prometheus/promhttp"
19+
"github.com/xaionaro-go/eventbus"
1920
"github.com/xaionaro-go/observability"
2021
)
2122

@@ -115,6 +116,8 @@ func initRuntime(
115116

116117
seppukuIfMemHugeLeak(ctx)
117118

119+
eventbus.LoggingEnabled = true
120+
118121
ctx, cancelFn := context.WithCancel(ctx)
119122
return ctx, func() {
120123
defer belt.Flush(ctx)

cmd/streampanel/streamd.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"bytes"
55
"context"
6+
"crypto/tls"
67
"encoding/gob"
78
"fmt"
89
"net"
@@ -20,6 +21,7 @@ import (
2021
"github.com/xaionaro-go/obs-grpc-proxy/protobuf/go/obs_grpc"
2122
"github.com/xaionaro-go/observability"
2223
"github.com/xaionaro-go/streamctl/cmd/streamd/ui"
24+
"github.com/xaionaro-go/streamctl/pkg/cert"
2325
"github.com/xaionaro-go/streamctl/pkg/mainprocess"
2426
"github.com/xaionaro-go/streamctl/pkg/streamcontrol"
2527
"github.com/xaionaro-go/streamctl/pkg/streamd"
@@ -257,7 +259,17 @@ func initGRPCServers(
257259
) (net.Listener, *grpc.Server, *server.GRPCServer, obs_grpc.OBSServer, proxy_grpc.NetworkProxyServer) {
258260
logger.Debugf(ctx, "initGRPCServers")
259261
defer logger.Debugf(ctx, "/initGRPCServers")
260-
listener, err := net.Listen("tcp", listenAddr)
262+
263+
cert, err := cert.GenerateSelfSignedForServer()
264+
if err != nil {
265+
logger.Panicf(ctx, "unable to generate the certificate: %v", err)
266+
}
267+
268+
logger.Debugf(ctx, "generated certificate %#+v", cert)
269+
listener, err := tls.Listen("tcp", listenAddr, &tls.Config{
270+
Certificates: []tls.Certificate{cert},
271+
NextProtos: []string{"h2"},
272+
})
261273
if err != nil {
262274
logger.Panicf(ctx, "failed to listen: %v", err)
263275
}

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ replace github.com/asticode/go-astiav v0.36.0 => github.com/xaionaro-go/astiav v
2727

2828
replace github.com/bluenviron/mediacommon/v2 v2.0.1-0.20250324151931-b8ce69d15d3d => github.com/xaionaro-go/mediacommon/v2 v2.0.0-20250420012906-03d6d69ac3b7
2929

30-
replace github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef => github.com/mysteriumnetwork/EventBus v0.0.0-20220414214953-84469ec2b111
31-
3230
require (
3331
github.com/facebookincubator/go-belt v0.0.0-20250308011339-62fb7027b11f
3432
github.com/go-git/go-billy/v5 v5.6.2
3533
github.com/goccy/go-yaml v1.17.1
3634
github.com/hashicorp/go-multierror v1.1.1
3735
github.com/nicklaw5/helix/v2 v2.30.1-0.20240715193454-0151ccccf980
3836
github.com/spf13/cobra v1.8.1
37+
github.com/xaionaro-go/eventbus v0.0.0-20250712213100-19c3828d84b4
3938
github.com/xaionaro-go/logrustash v0.0.0-20240804141650-d48034780a5f // indirect
4039
golang.org/x/oauth2 v0.30.0
4140
google.golang.org/api v0.239.0
@@ -256,7 +255,6 @@ require (
256255
github.com/adeithe/go-twitch v0.3.1
257256
github.com/andreykaipov/goobs v1.4.1
258257
github.com/anthonynsimon/bild v0.14.0
259-
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef
260258
github.com/asticode/go-astiav v0.36.0
261259
github.com/bamiaux/rez v0.0.0-20170731184118-29f4463c688b
262260
github.com/bluenviron/gortsplib/v4 v4.12.4-0.20250324174248-61372cfa6800
@@ -326,6 +324,8 @@ require (
326324
require (
327325
github.com/BurntSushi/xgbutil v0.0.0-20190907113008-ad855c713046
328326
github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250424061409-ccd60fbc7c1c
327+
github.com/coder/websocket v1.8.13
328+
github.com/joeyak/go-twitch-eventsub/v3 v3.0.0
329329
github.com/phuslu/goid v1.0.2 // indirect
330330
github.com/pion/datachannel v1.5.10 // indirect
331331
github.com/pion/dtls/v2 v2.2.12 // indirect

go.sum

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH
216216
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
217217
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
218218
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
219+
github.com/coder/websocket v1.8.13 h1:f3QZdXy7uGVz+4uCJy2nTZyM0yTBj8yANEHhqlXZ9FE=
220+
github.com/coder/websocket v1.8.13/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
219221
github.com/coreos/go-oidc/v3 v3.11.0 h1:Ia3MxdwpSw702YW0xgfmP1GVCMA9aEFWu12XUZ3/OtI=
220222
github.com/coreos/go-oidc/v3 v3.11.0/go.mod h1:gE3LgjOgFoHi9a4ce4/tJczr0Ai2/BoDhf0r5lltWI0=
221223
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
@@ -613,6 +615,8 @@ github.com/jfreymuth/oggvorbis v1.0.5 h1:u+Ck+R0eLSRhgq8WTmffYnrVtSztJcYrl588DM4
613615
github.com/jfreymuth/oggvorbis v1.0.5/go.mod h1:1U4pqWmghcoVsCJJ4fRBKv9peUJMBHixthRlBeD6uII=
614616
github.com/jfreymuth/vorbis v1.0.2 h1:m1xH6+ZI4thH927pgKD8JOH4eaGRm18rEE9/0WKjvNE=
615617
github.com/jfreymuth/vorbis v1.0.2/go.mod h1:DoftRo4AznKnShRl1GxiTFCseHr4zR9BN3TWXyuzrqQ=
618+
github.com/joeyak/go-twitch-eventsub/v3 v3.0.0 h1:6BDgmYJynNDyCP7P+wM9jPQnE3leJAi58nohDnzliJ4=
619+
github.com/joeyak/go-twitch-eventsub/v3 v3.0.0/go.mod h1:rpqOjYP1ftWDj3H4D8fA58AdOpkvK9YvODoduDpPCQU=
616620
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
617621
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
618622
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
@@ -741,8 +745,6 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
741745
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
742746
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
743747
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
744-
github.com/mysteriumnetwork/EventBus v0.0.0-20220414214953-84469ec2b111 h1:7s+VqlctjdVjy1z0slV2giUawTnv1A6vWj9oKKfgPhI=
745-
github.com/mysteriumnetwork/EventBus v0.0.0-20220414214953-84469ec2b111/go.mod h1:ef8wV5ITJhXSTG1sUkcHPAQF7lh83c7l875IvrYU7H0=
746748
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
747749
github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM=
748750
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
@@ -1088,6 +1090,8 @@ github.com/xaionaro-go/avpipeline v0.0.0-20250525204026-17104bc4baca h1:Cls4rEim
10881090
github.com/xaionaro-go/avpipeline v0.0.0-20250525204026-17104bc4baca/go.mod h1:LMh5Qi7cuntcktUezfA9toVCUCCsx9pjyGDWe9GLt9A=
10891091
github.com/xaionaro-go/datacounter v1.0.4 h1:+QMZLmu73R5WGkQfUPwlXF/JFN+Weo4iuDZkiL2wVm8=
10901092
github.com/xaionaro-go/datacounter v1.0.4/go.mod h1:Sf9vBevuV6w5iE6K3qJ9pWVKcyS60clWBUSQLjt5++c=
1093+
github.com/xaionaro-go/eventbus v0.0.0-20250712213100-19c3828d84b4 h1:rGojai/ewiNr7EqxfxFUxFLoMyjtAsiaExhOij8jCRs=
1094+
github.com/xaionaro-go/eventbus v0.0.0-20250712213100-19c3828d84b4/go.mod h1:zSbWHZpDvsRhjD3Sr3bruqqsWotjXvsIKmx6/THwXFw=
10911095
github.com/xaionaro-go/fyne/v2 v2.0.0-20250622004601-3a26ee69528a h1:awMQXlaweeiSZB4rSNfMmJGJriyn1ca/m/lglBi9uyA=
10921096
github.com/xaionaro-go/fyne/v2 v2.0.0-20250622004601-3a26ee69528a/go.mod h1:0GOXKqyvNwk3DLmsFu9v0oYM0ZcD1ysGnlHCerKoAmo=
10931097
github.com/xaionaro-go/go-rtmp v0.0.0-20241009130244-1e3160f27f42 h1:izCjREd+62HDF9FRYqUI7dgJNdUxAIysEuqed8lBcDY=

pkg/chatmessagesstorage/load.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func (s *ChatMessagesStorage) loadLocked(ctx context.Context) (_err error) {
3333
if err != nil {
3434
return fmt.Errorf("unable to parse file '%s': %w", s.FilePath, err)
3535
}
36+
logger.Debugf(ctx, "loaded %d messages", len(s.Messages))
3637
s.sortAndDeduplicateAndTruncate(ctx)
3738
return nil
3839
}

pkg/streamcontrol/kick/kick.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
http "github.com/Danny-Dasilva/fhttp"
1313
"github.com/davecgh/go-spew/spew"
14+
"github.com/facebookincubator/go-belt"
1415
"github.com/facebookincubator/go-belt/tool/logger"
1516
"github.com/google/uuid"
1617
"github.com/scorfly/gokick"
@@ -64,6 +65,7 @@ func New(
6465
cfg Config,
6566
saveCfgFn func(Config) error,
6667
) (*Kick, error) {
68+
ctx = belt.WithField(ctx, "controller", ID)
6769
if cfg.Config.Channel == "" {
6870
return nil, fmt.Errorf("channel is not set")
6971
}

pkg/streamcontrol/stream_control.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ type ChatMessage struct {
115115
Username string
116116
MessageID ChatMessageID
117117
Message string
118+
Paid Money
119+
}
120+
121+
type Currency int
122+
123+
const (
124+
CurrencyNone = Currency(iota)
125+
CurrencyUSD
126+
CurrencyOther
127+
)
128+
129+
type Money struct {
130+
Currency Currency
131+
Amount float64
118132
}
119133

120134
type StreamControllerCommons interface {

pkg/streamcontrol/twitch/chat_client.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)