-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
49 lines (40 loc) · 1.02 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import "C"
import (
"fmt"
"github.com/alist-org/alist/v3/cmd"
"github.com/alist-org/alist/v3/cmd/flags"
"github.com/alist-org/alist/v3/diy"
"strings"
"time"
)
func main() {}
var AlistCommit = "小幸运内置Alist"
//export OutServerInit
func OutServerInit(port int, dir *C.char) {
fmt.Println("正式启动 端口 ", port)
flags.DataDir = C.GoString(dir)
diy.SetVersion(AlistCommit)
diy.SetConfAndPort(port)
cmd.OutAlistInit()
}
//export OutServerTestInit
func OutServerTestInit(port int, dir *C.char) {
fmt.Println("测试服务启动 .. 你有5秒时间启动服务器 ")
time.Sleep(5 * time.Second)
}
//export SetAlistPassword
func SetAlistPassword(pass *C.char) *C.char {
fmt.Println("调用了函数 设置密码 " + C.GoString(pass))
//for !diy.GetStoragesLoaded() {
// time.Sleep(1 * time.Second)
//}
p := strings.Split(C.GoString(pass), "|---|")
flags.DataDir = p[0]
//diy.SetConfAndPort(randomInt())
s := diy.SetPassword(p[1])
if s == "" {
s = diy.GetAdmin()
}
return C.CString(s)
}