forked from xmdhs/clash2sfa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (37 loc) · 766 Bytes
/
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
package main
import (
_ "embed"
"fmt"
"net/http"
"os"
"strconv"
"time"
"log/slog"
"github.com/samber/lo"
"github.com/xmdhs/clash2sfa/provide"
)
func main() {
port := ":8080"
if p := os.Getenv("port"); p != "" {
port = p
}
levels := os.Getenv("level")
leveln, err := strconv.Atoi(levels)
if err != nil {
leveln = -4
}
level := &slog.LevelVar{}
level.Set(slog.Level(leveln))
h := slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{
Level: level,
})
handler, _ := lo.Must2(provide.InitializeServer(h))
s := http.Server{
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
ReadHeaderTimeout: 10 * time.Second,
Addr: port,
Handler: handler,
}
fmt.Println(s.ListenAndServe())
}