config.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package base
  2. const (
  3. cfgStr = iota
  4. cfgInt
  5. cfgBool
  6. defaultJwt = "abcdef.0123456789.abcdef"
  7. defaultPwd = "$2a$10$UQ7C.EoPifDeJh6d8.31TeSPQU7hM/NOM2nixmBucJpAuXDQNqNke"
  8. )
  9. type config struct {
  10. Typ int
  11. Name string
  12. Short string
  13. Usage string
  14. ValStr string
  15. ValInt int
  16. ValBool bool
  17. }
  18. var configs = []config{
  19. {Typ: cfgStr, Name: "conf", Usage: "config file", ValStr: "./conf/server.toml", Short: "c"},
  20. {Typ: cfgStr, Name: "profile", Usage: "profile.xml file", ValStr: "./conf/profile.xml"},
  21. {Typ: cfgStr, Name: "server_addr", Usage: "服务监听地址", ValStr: ":443"},
  22. {Typ: cfgBool, Name: "server_dtls", Usage: "开启DTLS", ValBool: false},
  23. {Typ: cfgStr, Name: "server_dtls_addr", Usage: "DTLS监听地址", ValStr: ":4433"},
  24. {Typ: cfgStr, Name: "admin_addr", Usage: "后台服务监听地址", ValStr: ":8800"},
  25. {Typ: cfgBool, Name: "proxy_protocol", Usage: "TCP代理协议", ValBool: false},
  26. {Typ: cfgStr, Name: "db_type", Usage: "数据库类型 [sqlite3 mysql postgres]", ValStr: "sqlite3"},
  27. {Typ: cfgStr, Name: "db_source", Usage: "数据库source", ValStr: "./conf/anylink.db"},
  28. {Typ: cfgStr, Name: "cert_file", Usage: "证书文件", ValStr: "./conf/vpn_cert.pem"},
  29. {Typ: cfgStr, Name: "cert_key", Usage: "证书密钥", ValStr: "./conf/vpn_cert.key"},
  30. {Typ: cfgStr, Name: "files_path", Usage: "外部下载文件路径", ValStr: "./conf/files"},
  31. {Typ: cfgStr, Name: "log_path", Usage: "日志文件路径,默认标准输出", ValStr: ""},
  32. {Typ: cfgStr, Name: "log_level", Usage: "日志等级 [debug info warn error]", ValStr: "info"},
  33. {Typ: cfgBool, Name: "pprof", Usage: "开启pprof", ValBool: false},
  34. {Typ: cfgStr, Name: "issuer", Usage: "系统名称", ValStr: "XX公司VPN"},
  35. {Typ: cfgStr, Name: "admin_user", Usage: "管理用户名", ValStr: "admin"},
  36. {Typ: cfgStr, Name: "admin_pass", Usage: "管理用户密码", ValStr: defaultPwd},
  37. {Typ: cfgStr, Name: "jwt_secret", Usage: "JWT密钥", ValStr: defaultJwt},
  38. {Typ: cfgStr, Name: "link_mode", Usage: "虚拟网络类型[tun tap macvtap ipvtap]", ValStr: "tun"},
  39. {Typ: cfgStr, Name: "ipv4_master", Usage: "ipv4主网卡名称", ValStr: "eth0"},
  40. {Typ: cfgStr, Name: "ipv4_cidr", Usage: "ip地址网段", ValStr: "192.168.10.0/24"},
  41. {Typ: cfgStr, Name: "ipv4_gateway", Usage: "ipv4_gateway", ValStr: "192.168.10.1"},
  42. {Typ: cfgStr, Name: "ipv4_start", Usage: "IPV4开始地址", ValStr: "192.168.10.100"},
  43. {Typ: cfgStr, Name: "ipv4_end", Usage: "IPV4结束", ValStr: "192.168.10.200"},
  44. {Typ: cfgStr, Name: "default_group", Usage: "默认用户组", ValStr: "one"},
  45. {Typ: cfgInt, Name: "ip_lease", Usage: "IP租期(秒)", ValInt: 1209600},
  46. {Typ: cfgInt, Name: "max_client", Usage: "最大用户连接", ValInt: 100},
  47. {Typ: cfgInt, Name: "max_user_client", Usage: "最大单用户连接", ValInt: 3},
  48. {Typ: cfgInt, Name: "cstp_keepalive", Usage: "keepalive时间(秒)", ValInt: 20},
  49. {Typ: cfgInt, Name: "cstp_dpd", Usage: "死链接检测时间(秒)", ValInt: 30},
  50. {Typ: cfgInt, Name: "mobile_keepalive", Usage: "移动端keepalive接检测时间(秒)", ValInt: 50},
  51. {Typ: cfgInt, Name: "mobile_dpd", Usage: "移动端死链接检测时间(秒)", ValInt: 60},
  52. {Typ: cfgInt, Name: "session_timeout", Usage: "session过期时间(秒)", ValInt: 3600},
  53. // {Typ: cfgInt, Name: "auth_timeout", Usage: "auth_timeout", ValInt: 0},
  54. {Typ: cfgInt, Name: "audit_interval", Usage: "审计去重间隔(秒),-1关闭", ValInt: -1},
  55. }
  56. var envs = map[string]string{}