proxy.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.status = proxyStats.status
  15. }
  16. }
  17. class TcpProxy extends BaseProxy {
  18. constructor(proxyStats) {
  19. super(proxyStats)
  20. this.type = "tcp"
  21. if (proxyStats.conf != null) {
  22. this.addr = proxyStats.conf.bind_addr + ":" + proxyStats.conf.remote_port
  23. this.port = proxyStats.conf.remote_port
  24. } else {
  25. this.addr = ""
  26. this.port = ""
  27. }
  28. }
  29. }
  30. class UdpProxy extends BaseProxy {
  31. constructor(proxyStats) {
  32. super(proxyStats)
  33. this.type = "udp"
  34. if (proxyStats.conf != null) {
  35. this.addr = proxyStats.conf.bind_addr + ":" + proxyStats.conf.remote_port
  36. this.port = proxyStats.conf.remote_port
  37. } else {
  38. this.addr = ""
  39. this.port = ""
  40. }
  41. }
  42. }
  43. class HttpProxy extends BaseProxy {
  44. constructor(proxyStats, port, subdomain_host) {
  45. super(proxyStats)
  46. this.type = "http"
  47. this.port = port
  48. if (proxyStats.conf != null) {
  49. this.custom_domains = proxyStats.conf.custom_domains
  50. this.host_header_rewrite = proxyStats.conf.host_header_rewrite
  51. this.locations = proxyStats.conf.locations
  52. if (proxyStats.conf.sub_domain != "") {
  53. this.subdomain = proxyStats.conf.sub_domain + "." + subdomain_host
  54. } else {
  55. this.subdomain = ""
  56. }
  57. } else {
  58. this.custom_domains = ""
  59. this.host_header_rewrite = ""
  60. this.subdomain = ""
  61. this.locations = ""
  62. }
  63. }
  64. }
  65. class HttpsProxy extends BaseProxy {
  66. constructor(proxyStats, port, subdomain_host) {
  67. super(proxyStats)
  68. this.type = "https"
  69. this.port = port
  70. if (proxyStats.conf != null) {
  71. this.custom_domains = proxyStats.conf.custom_domains
  72. if (proxyStats.conf.sub_domain != "") {
  73. this.subdomain = proxyStats.conf.sub_domain + "." + subdomain_host
  74. } else {
  75. this.subdomain = ""
  76. }
  77. } else {
  78. this.custom_domains = ""
  79. this.subdomain = ""
  80. }
  81. }
  82. }
  83. export {BaseProxy, TcpProxy, UdpProxy, HttpProxy, HttpsProxy}