config.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package main
  2. import (
  3. "encoding/json"
  4. "os"
  5. )
  6. // Config for client
  7. type Config struct {
  8. LocalAddr string `json:"localaddr"`
  9. RemoteAddr string `json:"remoteaddr"`
  10. Key string `json:"key"`
  11. Mode string `json:"mode"`
  12. Conn int `json:"conn"`
  13. AutoExpire int `json:"autoexpire"`
  14. ScavengeTTL int `json:"scavengettl"`
  15. MTU int `json:"mtu"`
  16. SndWnd int `json:"sndwnd"`
  17. RcvWnd int `json:"rcvwnd"`
  18. DataShard int `json:"datashard"`
  19. ParityShard int `json:"parityshard"`
  20. DSCP int `json:"dscp"`
  21. NoComp bool `json:"nocomp"`
  22. AckNodelay bool `json:"acknodelay"`
  23. NoDelay int `json:"nodelay"`
  24. Interval int `json:"interval"`
  25. Resend int `json:"resend"`
  26. NoCongestion int `json:"nc"`
  27. SockBuf int `json:"sockbuf"`
  28. SmuxVer int `json:"smuxver"`
  29. SmuxBuf int `json:"smuxbuf"`
  30. StreamBuf int `json:"streambuf"`
  31. KeepAlive int `json:"keepalive"`
  32. Log string `json:"log"`
  33. SnsiLog string `json:"snsilog"`
  34. SnsiPeriod int `json:"snsiperiod"`
  35. Quiet bool `json:"quiet"`
  36. TCP bool `json:"tcp"`
  37. }
  38. func parseJSONConfig(config *Config, path string) error {
  39. file, err := os.Open(path) // For read access.
  40. if err != nil {
  41. return err
  42. }
  43. defer file.Close()
  44. return json.NewDecoder(file).Decode(config)
  45. }