proxy.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. class BaseProxy {
  2. constructor(proxyStats) {
  3. this.name = proxyStats.name
  4. if (proxyStats.conf != null) {
  5. this.encryption = proxyStats.conf.use_encryption
  6. this.compression = proxyStats.conf.use_compression
  7. } else {
  8. this.encryption = ""
  9. this.compression = ""
  10. }
  11. this.conns = proxyStats.cur_conns
  12. this.traffic_in = proxyStats.today_traffic_in
  13. this.traffic_out = proxyStats.today_traffic_out
  14. this.last_start_time = proxyStats.last_start_time
  15. this.last_close_time = proxyStats.last_close_time
  16. this.status = proxyStats.status
  17. }
  18. }
  19. class TcpProxy extends BaseProxy {
  20. constructor(proxyStats) {
  21. super(proxyStats)
  22. this.type = "tcp"
  23. if (proxyStats.conf != null) {
  24. this.addr = proxyStats.conf.bind_addr + ":" + proxyStats.conf.remote_port
  25. this.port = proxyStats.conf.remote_port
  26. } else {
  27. this.addr = ""
  28. this.port = ""
  29. }
  30. }
  31. }
  32. class UdpProxy extends BaseProxy {
  33. constructor(proxyStats) {
  34. super(proxyStats)
  35. this.type = "udp"
  36. if (proxyStats.conf != null) {
  37. this.addr = proxyStats.conf.bind_addr + ":" + proxyStats.conf.remote_port
  38. this.port = proxyStats.conf.remote_port
  39. } else {
  40. this.addr = ""
  41. this.port = ""
  42. }
  43. }
  44. }
  45. class HttpProxy extends BaseProxy {
  46. constructor(proxyStats, port, subdomain_host) {
  47. super(proxyStats)
  48. this.type = "http"
  49. this.port = port
  50. if (proxyStats.conf != null) {
  51. this.custom_domains = proxyStats.conf.custom_domains
  52. this.host_header_rewrite = proxyStats.conf.host_header_rewrite
  53. this.locations = proxyStats.conf.locations
  54. if (proxyStats.conf.sub_domain != "") {
  55. this.subdomain = proxyStats.conf.sub_domain + "." + subdomain_host
  56. } else {
  57. this.subdomain = ""
  58. }
  59. } else {
  60. this.custom_domains = ""
  61. this.host_header_rewrite = ""
  62. this.subdomain = ""
  63. this.locations = ""
  64. }
  65. }
  66. }
  67. class HttpsProxy extends BaseProxy {
  68. constructor(proxyStats, port, subdomain_host) {
  69. super(proxyStats)
  70. this.type = "https"
  71. this.port = port
  72. if (proxyStats.conf != null) {
  73. this.custom_domains = proxyStats.conf.custom_domains
  74. if (proxyStats.conf.sub_domain != "") {
  75. this.subdomain = proxyStats.conf.sub_domain + "." + subdomain_host
  76. } else {
  77. this.subdomain = ""
  78. }
  79. } else {
  80. this.custom_domains = ""
  81. this.subdomain = ""
  82. }
  83. }
  84. }
  85. export {BaseProxy, TcpProxy, UdpProxy, HttpProxy, HttpsProxy}