mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-09-27 01:15:52 +08:00
feat: update core files for cluster support
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
global:
|
||||
loglevel: debug
|
||||
enablelogin: true
|
||||
enablelogin: false
|
||||
# db:
|
||||
# dbtype: mysql
|
||||
# dsn: root:Monibuca#!4@tcp(sh-cynosdbmysql-grp-kxt43lv6.sql.tencentcdb.com:28520)/lkm7s_v5?parseTime=true
|
||||
|
18
plugin.go
18
plugin.go
@@ -570,6 +570,12 @@ func (p *Plugin) PublishWithConfig(ctx context.Context, streamPath string, conf
|
||||
}
|
||||
}
|
||||
err = p.Server.Streams.AddTask(publisher, ctx).WaitStarted()
|
||||
if err == nil {
|
||||
publisher.OnDispose(func() {
|
||||
p.sendPublishEndWebhook(publisher)
|
||||
})
|
||||
p.sendPublishWebhook(publisher)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -605,6 +611,12 @@ func (p *Plugin) SubscribeWithConfig(ctx context.Context, streamPath string, con
|
||||
err = subscriber.StopReason()
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
subscriber.OnDispose(func() {
|
||||
p.sendSubscribeEndWebhook(subscriber)
|
||||
})
|
||||
p.sendSubscribeWebhook(subscriber)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -778,14 +790,14 @@ func (p *Plugin) sendPublishEndWebhook(pub *Publisher) {
|
||||
p.SendWebhook(config.HookOnPublishEnd, p.config.Hook[config.HookOnPublishEnd], webhookData)
|
||||
}
|
||||
|
||||
func (p *Plugin) sendSubscribeWebhook(pub *Publisher, sub *Subscriber) {
|
||||
func (p *Plugin) sendSubscribeWebhook(sub *Subscriber) {
|
||||
if p.config.Hook == nil {
|
||||
return
|
||||
}
|
||||
webhookData := map[string]interface{}{
|
||||
"event": "subscribe",
|
||||
"streamPath": pub.StreamPath,
|
||||
"publishId": pub.ID,
|
||||
"streamPath": sub.StreamPath,
|
||||
"publishId": sub.Publisher.ID,
|
||||
"subscriberId": sub.ID,
|
||||
"remoteAddr": sub.RemoteAddr,
|
||||
"type": sub.Type,
|
||||
|
@@ -31,7 +31,7 @@ func (p *PushJob) Init(pusher IPusher, plugin *Plugin, streamPath string, conf c
|
||||
p.Connection.Init(plugin, streamPath, conf.URL, conf.Proxy, http.Header(conf.Header))
|
||||
p.pusher = pusher
|
||||
if subConf == nil {
|
||||
p.SubConf = plugin.GetCommonConf().Subscribe
|
||||
p.SubConf = plugin.config.Subscribe
|
||||
} else {
|
||||
p.SubConf = *subConf
|
||||
}
|
||||
|
@@ -405,6 +405,7 @@ func (s *Server) Start() (err error) {
|
||||
}
|
||||
if s.DB != nil {
|
||||
s.DB.AutoMigrate(&PullProxy{})
|
||||
s.DB.AutoMigrate(&PushProxy{})
|
||||
}
|
||||
for _, d := range s.PullProxy {
|
||||
if d.ID != 0 {
|
||||
@@ -540,6 +541,7 @@ func (s *Server) Login(ctx context.Context, req *pb.LoginRequest) (res *pb.Login
|
||||
res = &pb.LoginResponse{}
|
||||
if !s.ServerConfig.EnableLogin {
|
||||
res.Data = &pb.LoginSuccess{
|
||||
Token: "monibuca",
|
||||
UserInfo: &pb.UserInfo{
|
||||
Username: "anonymous",
|
||||
ExpiresAt: time.Now().Add(24 * time.Hour).Unix(),
|
||||
|
Reference in New Issue
Block a user