mirror of
https://github.com/ayflying/p2p.git
synced 2026-03-05 01:39:23 +00:00
增加分布式更新方法
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
)
|
||||
|
||||
@@ -28,6 +29,12 @@ type (
|
||||
// FindFromDHT 从 DHT 查找数据(从网络节点获取)
|
||||
FindFromDHT(ctx context.Context, key string) (string, error)
|
||||
GatewayStart(ctx context.Context, group *ghttp.RouterGroup) (err error)
|
||||
// 发送错误消息
|
||||
SendError(conn *websocket.Conn, errMsg string)
|
||||
// SendAll 发送消息给所有客户端
|
||||
SendAll(typ string, data any) (err error)
|
||||
// Send 发送消息给指定客户端
|
||||
Send(conn *websocket.Conn, typ string, data any) (err error)
|
||||
// 只获取IPv4公网IP(过滤IPv6结果)
|
||||
GetIPv4PublicIP() (string, error)
|
||||
}
|
||||
|
||||
36
internal/service/system.go
Normal file
36
internal/service/system.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// ================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// You can delete these comments if you wish manually maintain this interface file.
|
||||
// ================================================================================
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type (
|
||||
ISystem interface {
|
||||
Init()
|
||||
Update(ctx context.Context) (err error)
|
||||
// RestartSelf 实现 Windows 平台下的程序自重启
|
||||
RestartSelf() error
|
||||
// RenameRunningFile 重命名正在运行的程序文件(如 p2p.exe → p2p.exe~)
|
||||
RenameRunningFile(exePath string) (string, error)
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
localSystem ISystem
|
||||
)
|
||||
|
||||
func System() ISystem {
|
||||
if localSystem == nil {
|
||||
panic("implement not found for interface ISystem, forgot register?")
|
||||
}
|
||||
return localSystem
|
||||
}
|
||||
|
||||
func RegisterSystem(i ISystem) {
|
||||
localSystem = i
|
||||
}
|
||||
Reference in New Issue
Block a user