Compare commits
1 Commits
v0.0.12
...
feature/ht
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8960aa3bc |
@@ -77,6 +77,21 @@ func (s *Service) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) ListenAndServe() error {
|
||||
|
||||
if s.ctx.HTTPAddr == "" {
|
||||
s.ctx.HTTPAddr = DefalutHTTPAddr
|
||||
}
|
||||
|
||||
s.server = &http.Server{
|
||||
Addr: s.ctx.HTTPAddr,
|
||||
Handler: s.router,
|
||||
}
|
||||
|
||||
log.Info().Msg("Starting HTTP server on " + s.ctx.HTTPAddr)
|
||||
return s.server.ListenAndServe()
|
||||
}
|
||||
|
||||
func (s *Service) Stop() error {
|
||||
|
||||
if s.server == nil {
|
||||
|
||||
@@ -306,3 +306,44 @@ func (m *Manager) CommandDecrypt(dataDir string, workDir string, key string, pla
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Manager) CommandHTTPServer(addr string, dataDir string, workDir string, platform string, version int) error {
|
||||
|
||||
if addr == "" {
|
||||
addr = "127.0.0.1:5030"
|
||||
}
|
||||
|
||||
if workDir == "" {
|
||||
return fmt.Errorf("workDir is required")
|
||||
}
|
||||
|
||||
if platform == "" {
|
||||
return fmt.Errorf("platform is required")
|
||||
}
|
||||
|
||||
if version == 0 {
|
||||
return fmt.Errorf("version is required")
|
||||
}
|
||||
|
||||
m.ctx.HTTPAddr = addr
|
||||
m.ctx.DataDir = dataDir
|
||||
m.ctx.WorkDir = workDir
|
||||
m.ctx.Platform = platform
|
||||
m.ctx.Version = version
|
||||
|
||||
// 如果是 4.0 版本,更新下 xorkey
|
||||
if m.ctx.Version == 4 && m.ctx.DataDir != "" {
|
||||
go dat2img.ScanAndSetXorKey(m.ctx.DataDir)
|
||||
}
|
||||
|
||||
// 按依赖顺序启动服务
|
||||
if err := m.db.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := m.mcp.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return m.http.ListenAndServe()
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
const (
|
||||
V3ProcessName = "WeChat"
|
||||
V4ProcessName = "Weixin"
|
||||
V3DBFile = "Msg\\Misc.db"
|
||||
V4DBFile = "db_storage\\message\\message_0.db"
|
||||
V3DBFile = `Msg\Misc.db`
|
||||
V4DBFile = `db_storage\session\session.db`
|
||||
)
|
||||
|
||||
// Detector 实现 Windows 平台的进程检测器
|
||||
|
||||
Reference in New Issue
Block a user