mirror of
https://github.com/hikaricai/p2p_tun.git
synced 2024-04-21 12:41:48 +00:00
44 lines
1.1 KiB
Go
Executable File
44 lines
1.1 KiB
Go
Executable File
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
)
|
|
|
|
// Config for server
|
|
type Config struct {
|
|
Listen string `json:"listen"`
|
|
Passwd string `json:"passwd"`
|
|
Crypt string `json:"crypt"`
|
|
Mode string `json:"mode"`
|
|
MTU int `json:"mtu"`
|
|
SndWnd int `json:"sndwnd"`
|
|
RcvWnd int `json:"rcvwnd"`
|
|
DataShard int `json:"datashard"`
|
|
ParityShard int `json:"parityshard"`
|
|
DSCP int `json:"dscp"`
|
|
NoComp bool `json:"nocomp"`
|
|
AckNodelay bool `json:"acknodelay"`
|
|
NoDelay int `json:"nodelay"`
|
|
Interval int `json:"interval"`
|
|
Resend int `json:"resend"`
|
|
NoCongestion int `json:"nc"`
|
|
SockBuf int `json:"sockbuf"`
|
|
KeepAlive int `json:"keepalive"`
|
|
Log string `json:"log"`
|
|
SnmpLog string `json:"snmplog"`
|
|
SnmpPeriod int `json:"snmpperiod"`
|
|
Pprof bool `json:"pprof"`
|
|
Quiet bool `json:"quiet"`
|
|
}
|
|
|
|
func parseJSONConfig(config *Config, path string) error {
|
|
file, err := os.Open(path) // For read access.
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer file.Close()
|
|
|
|
return json.NewDecoder(file).Decode(config)
|
|
}
|