1
0

proxy_server.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package main
  2. import (
  3. "flag"
  4. "github.com/astaxie/beego"
  5. "github.com/cnlh/easyProxy/server"
  6. "github.com/cnlh/easyProxy/utils"
  7. _ "github.com/cnlh/easyProxy/web/routers"
  8. "log"
  9. )
  10. var (
  11. TcpPort = flag.Int("tcpport", 0, "客户端与服务端通信端口")
  12. httpPort = flag.Int("httpport", 8024, "对外监听的端口")
  13. rpMode = flag.String("mode", "webServer", "启动模式")
  14. tunnelTarget = flag.String("target", "10.1.50.203:80", "远程目标")
  15. VerifyKey = flag.String("vkey", "", "验证密钥")
  16. u = flag.String("u", "", "验证用户名(socks5和web)")
  17. p = flag.String("p", "", "验证密码(socks5和web)")
  18. compress = flag.String("compress", "", "数据压缩方式(snappy)")
  19. crypt = flag.String("crypt", "false", "是否加密(true|false)")
  20. mux = flag.String("mux", "false", "是否TCP多路复用(true|false)")
  21. )
  22. func main() {
  23. flag.Parse()
  24. server.VerifyKey = *VerifyKey
  25. cnf := &utils.ServerConfig{
  26. TcpPort: *httpPort,
  27. Mode: *rpMode,
  28. Target: *tunnelTarget,
  29. VerifyKey: *VerifyKey,
  30. U: *u,
  31. P: *p,
  32. Compress: *compress,
  33. Start: 0,
  34. IsRun: 0,
  35. ClientStatus: 0,
  36. Crypt: utils.GetBoolByStr(*crypt),
  37. Mux: utils.GetBoolByStr(*mux),
  38. CompressEncode: 0,
  39. CompressDecode: 0,
  40. }
  41. if *TcpPort == 0 {
  42. p, err := beego.AppConfig.Int("tcpport")
  43. if err == nil && *rpMode == "webServer" {
  44. *TcpPort = p
  45. } else {
  46. *TcpPort = 8284
  47. }
  48. }
  49. log.Println("服务端启动,监听tcp服务端端口:", *TcpPort)
  50. cnf.CompressDecode, cnf.CompressEncode = utils.GetCompressType(cnf.Compress)
  51. server.StartNewServer(*TcpPort, cnf)
  52. }