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