-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
48 lines (45 loc) · 1.05 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 (
"fmt"
"fyne.io/fyne"
"fyne.io/fyne/app"
oslog "log"
"os"
"tunProxy/client"
"tunProxy/gui"
"tunProxy/log"
"tunProxy/utils"
)
func start() {
log.InitLogger()
fd, err0 := os.OpenFile("./log.txt", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
if err0 != nil {
log.WriteLog(log.WARNING, err0.Error())
}
defer fd.Close()
os.Stdout = fd
os.Stderr = fd
oslog.SetOutput(fd)
oslog.Println(gui.APP_NAME + " launch")
if err := os.Setenv("FYNE_FONT", "msyh.ttc"); err != nil {
log.WriteLog(log.WARNING, err.Error())
}
app := app.New()
window := app.NewWindow(gui.APP_NAME)
window.Resize(fyne.NewSize(gui.WIDTH, gui.HEIGHT))
window.SetFixedSize(true)
config := &utils.Config{}
err := config.Load(utils.CONFIG_PATH)
if err != nil {
gui.ErrorDialog(&app, &window, fmt.Sprintf("无法加载配置 : \n%v", err.Error()))
window.ShowAndRun()
}
tunClient := client.NewTunClient()
tunClient.ClientAddr = config.ClientAddr
tunClient.Listen()
gui.InitWindow(&app, &window, config, tunClient)
window.ShowAndRun()
}
func main() {
start()
}