-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconf.go
More file actions
58 lines (50 loc) · 1.71 KB
/
conf.go
File metadata and controls
58 lines (50 loc) · 1.71 KB
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
49
50
51
52
53
54
55
56
57
58
package main
import (
"encoding/json"
"log"
"os"
)
type Quic struct {
HandshakeIdleTimeout byte `json:"HandshakeIdleTimeout"`
MaxIdleTimeout byte `json:"MaxIdleTimeout"`
InitialStreamReceiveWindow uint64 `json:"InitialStreamReceiveWindow"`
MaxStreamReceiveWindow uint64 `json:"MaxStreamReceiveWindow"`
InitialConnectionReceiveWindow uint64 `json:"InitialConnectionReceiveWindow"`
MaxConnectionReceiveWindow uint64 `json:"MaxConnectionReceiveWindow"`
MaxIncomingStreams int64 `json:"MaxIncomingStreams"`
MaxIncomingUniStreams int64 `json:"MaxIncomingUniStreams"`
DisablePathMTUDiscovery bool `json:"DisablePathMTUDiscovery"`
Allow0RTT bool `json:"Allow0RTT"`
}
type Destination struct {
Name string `json:"Name"`
Addr string `json:"Addr"`
Scheme string `json:"Scheme"`
Path string `json:"Path"`
H3RespHeaders map[string][]string `json:"H3RespHeaders"`
H1ReqHeaders map[string][]string `json:"H1ReqHeaders"`
}
type FL struct {
Enable bool `json:"Enable"`
Level string `json:"Level"`
}
type Conf struct {
H3Addr string `json:"H3Addr"`
TLS TlsConf `json:"TLS"`
Destinations []Destination `json:"Destinations"`
QUIC Quic `json:"QUIC"`
Trace bool `json:"Trace"`
FileLog FL `json:"FileLog"`
}
func LoadConfig() Conf {
cfile, cfile_err := os.ReadFile("conf.json")
if cfile_err != nil {
log.Fatalln(cfile_err.Error())
}
conf := Conf{}
conf_err := json.Unmarshal(cfile, &conf)
if conf_err != nil {
log.Fatalln(conf_err.Error())
}
return conf
}