xtlsapi-ipblacklist 3.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. xtlsapi_ipblacklist-3.3.2/Containerfile +5 -0
  2. xtlsapi_ipblacklist-3.3.2/HISTORY.md +0 -0
  3. xtlsapi_ipblacklist-3.3.2/LICENSE +24 -0
  4. xtlsapi_ipblacklist-3.3.2/MANIFEST.in +5 -0
  5. xtlsapi_ipblacklist-3.3.2/PKG-INFO +58 -0
  6. xtlsapi_ipblacklist-3.3.2/README.md +44 -0
  7. xtlsapi_ipblacklist-3.3.2/pyproject.toml +20 -0
  8. xtlsapi_ipblacklist-3.3.2/setup.cfg +4 -0
  9. xtlsapi_ipblacklist-3.3.2/setup.py +50 -0
  10. xtlsapi_ipblacklist-3.3.2/tests/__init__.py +0 -0
  11. xtlsapi_ipblacklist-3.3.2/tests/conftest.py +14 -0
  12. xtlsapi_ipblacklist-3.3.2/tests/test_base.py +5 -0
  13. xtlsapi_ipblacklist-3.3.2/tests/test_block_ips.py +9 -0
  14. xtlsapi_ipblacklist-3.3.2/tests/test_stats_online_ip_list.py +14 -0
  15. xtlsapi_ipblacklist-3.3.2/xtlsapi/VERSION +1 -0
  16. xtlsapi_ipblacklist-3.3.2/xtlsapi/__init__.py +4 -0
  17. xtlsapi_ipblacklist-3.3.2/xtlsapi/__main__.py +6 -0
  18. xtlsapi_ipblacklist-3.3.2/xtlsapi/__pycache__/__init__.cpython-313.pyc +0 -0
  19. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/__init__.py +8 -0
  20. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/_base.py +12 -0
  21. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/handler/__init__.py +6 -0
  22. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/handler/add_client.py +66 -0
  23. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/handler/remove_client.py +27 -0
  24. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/logger/__init__.py +5 -0
  25. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/logger/restart_logger.py +17 -0
  26. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/router/__init__.py +7 -0
  27. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/router/block_ips.py +60 -0
  28. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/stats/__init__.py +22 -0
  29. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/stats/get_client_download_traffic.py +17 -0
  30. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/stats/get_client_upload_traffic.py +15 -0
  31. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/stats/get_inbound_download_traffic.py +16 -0
  32. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/stats/get_inbound_upload_traffic.py +16 -0
  33. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/stats/get_stats_online_ip_list.py +28 -0
  34. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/stats/get_statsonline.py +18 -0
  35. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/stats/get_statsquery.py +17 -0
  36. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/stats/get_total_download_traffic.py +17 -0
  37. xtlsapi_ipblacklist-3.3.2/xtlsapi/api_services/stats/get_total_upload_traffic.py +16 -0
  38. xtlsapi_ipblacklist-3.3.2/xtlsapi/base.py +17 -0
  39. xtlsapi_ipblacklist-3.3.2/xtlsapi/cli.py +28 -0
  40. xtlsapi_ipblacklist-3.3.2/xtlsapi/client/SingboxClient.py +11 -0
  41. xtlsapi_ipblacklist-3.3.2/xtlsapi/client/XrayClient.py +11 -0
  42. xtlsapi_ipblacklist-3.3.2/xtlsapi/client/__init__.py +1 -0
  43. xtlsapi_ipblacklist-3.3.2/xtlsapi/client/__pycache__/XrayClient.cpython-313.pyc +0 -0
  44. xtlsapi_ipblacklist-3.3.2/xtlsapi/client/__pycache__/__init__.cpython-313.pyc +0 -0
  45. xtlsapi_ipblacklist-3.3.2/xtlsapi/exceptions/__init__.py +4 -0
  46. xtlsapi_ipblacklist-3.3.2/xtlsapi/exceptions/_base.py +3 -0
  47. xtlsapi_ipblacklist-3.3.2/xtlsapi/exceptions/email_already_exists.py +7 -0
  48. xtlsapi_ipblacklist-3.3.2/xtlsapi/exceptions/email_not_found.py +7 -0
  49. xtlsapi_ipblacklist-3.3.2/xtlsapi/exceptions/inbound_not_found.py +7 -0
  50. xtlsapi_ipblacklist-3.3.2/xtlsapi/ext/__init__.py +0 -0
  51. xtlsapi_ipblacklist-3.3.2/xtlsapi/ext/utils.py +49 -0
  52. xtlsapi_ipblacklist-3.3.2/xtlsapi/generate_from_xray_proto.py +81 -0
  53. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api/__init__.py +0 -0
  54. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api/build.sh +6 -0
  55. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api/extensions.proto +39 -0
  56. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api/extensions_pb2.py +31 -0
  57. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api/extensions_pb2_grpc.py +4 -0
  58. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api/stats.proto +63 -0
  59. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api/stats_old.proto +53 -0
  60. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api/stats_pb2.py +45 -0
  61. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api/stats_pb2_grpc.py +132 -0
  62. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api_services/__init__.py +6 -0
  63. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api_services/_base.py +7 -0
  64. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api_services/stats/__init__.py +18 -0
  65. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api_services/stats/get_client_download_traffic.py +17 -0
  66. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api_services/stats/get_client_upload_traffic.py +15 -0
  67. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api_services/stats/get_inbound_download_traffic.py +16 -0
  68. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api_services/stats/get_inbound_upload_traffic.py +16 -0
  69. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api_services/stats/get_statsquery.py +17 -0
  70. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api_services/stats/get_total_download_traffic.py +17 -0
  71. xtlsapi_ipblacklist-3.3.2/xtlsapi/singbox_api_services/stats/get_total_upload_traffic.py +16 -0
  72. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/__init__.py +0 -0
  73. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/a.sh +4 -0
  74. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/__init__.py +0 -0
  75. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/commander/__init__.py +0 -0
  76. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/commander/config_pb2.py +40 -0
  77. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/commander/config_pb2_grpc.py +24 -0
  78. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/dispatcher/__init__.py +0 -0
  79. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/dispatcher/config_pb2.py +39 -0
  80. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/dispatcher/config_pb2_grpc.py +24 -0
  81. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/dns/__init__.py +0 -0
  82. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/dns/config_pb2.py +51 -0
  83. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/dns/config_pb2_grpc.py +24 -0
  84. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/dns/fakedns/__init__.py +0 -0
  85. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/dns/fakedns/fakedns_pb2.py +39 -0
  86. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/dns/fakedns/fakedns_pb2_grpc.py +24 -0
  87. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/log/__init__.py +0 -0
  88. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/log/command/__init__.py +0 -0
  89. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/log/command/config_pb2.py +43 -0
  90. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/log/command/config_pb2_grpc.py +97 -0
  91. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/log/config_pb2.py +40 -0
  92. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/log/config_pb2_grpc.py +24 -0
  93. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/metrics/__init__.py +0 -0
  94. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/metrics/config_pb2.py +37 -0
  95. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/metrics/config_pb2_grpc.py +24 -0
  96. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/observatory/__init__.py +0 -0
  97. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/observatory/burst/config_pb2.py +39 -0
  98. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/observatory/burst/config_pb2_grpc.py +24 -0
  99. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/observatory/command/__init__.py +0 -0
  100. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/observatory/command/command_pb2.py +44 -0
  101. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/observatory/command/command_pb2_grpc.py +97 -0
  102. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/observatory/config_pb2.py +47 -0
  103. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/observatory/config_pb2_grpc.py +24 -0
  104. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/policy/__init__.py +0 -0
  105. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/policy/config_pb2.py +55 -0
  106. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/policy/config_pb2_grpc.py +24 -0
  107. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/proxyman/__init__.py +0 -0
  108. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/proxyman/command/__init__.py +0 -0
  109. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/proxyman/command/command_pb2.py +76 -0
  110. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/proxyman/command/command_pb2_grpc.py +398 -0
  111. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/proxyman/config_pb2.py +61 -0
  112. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/proxyman/config_pb2_grpc.py +24 -0
  113. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/reverse/__init__.py +0 -0
  114. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/reverse/config_pb2.py +45 -0
  115. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/reverse/config_pb2_grpc.py +24 -0
  116. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/router/__init__.py +0 -0
  117. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/router/command/__init__.py +0 -0
  118. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/router/command/command_pb2.py +73 -0
  119. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/router/command/command_pb2_grpc.py +312 -0
  120. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/router/config_pb2.py +70 -0
  121. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/router/config_pb2_grpc.py +24 -0
  122. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/stats/__init__.py +0 -0
  123. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/stats/command/__init__.py +0 -0
  124. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/stats/command/command.proto +62 -0
  125. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/stats/command/command_pb2.py +59 -0
  126. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/stats/command/command_pb2_grpc.py +269 -0
  127. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/stats/config_pb2.py +39 -0
  128. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/app/stats/config_pb2_grpc.py +24 -0
  129. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/__init__.py +0 -0
  130. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/log/__init__.py +0 -0
  131. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/log/log_pb2.py +37 -0
  132. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/log/log_pb2_grpc.py +24 -0
  133. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/net/__init__.py +0 -0
  134. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/net/address_pb2.py +37 -0
  135. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/net/address_pb2_grpc.py +24 -0
  136. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/net/destination_pb2.py +39 -0
  137. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/net/destination_pb2_grpc.py +24 -0
  138. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/net/network_pb2.py +39 -0
  139. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/net/network_pb2_grpc.py +24 -0
  140. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/net/port_pb2.py +39 -0
  141. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/net/port_pb2_grpc.py +24 -0
  142. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/protocol/__init__.py +0 -0
  143. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/protocol/headers_pb2.py +39 -0
  144. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/protocol/headers_pb2_grpc.py +24 -0
  145. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/protocol/server_spec_pb2.py +39 -0
  146. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/protocol/server_spec_pb2_grpc.py +24 -0
  147. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/protocol/user_pb2.py +38 -0
  148. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/protocol/user_pb2_grpc.py +24 -0
  149. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/serial/__init__.py +0 -0
  150. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/serial/typed_message_pb2.py +37 -0
  151. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/common/serial/typed_message_pb2_grpc.py +24 -0
  152. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/core/__init__.py +0 -0
  153. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/core/config_pb2.py +42 -0
  154. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/core/config_pb2_grpc.py +24 -0
  155. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/__init__.py +0 -0
  156. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/blackhole/__init__.py +0 -0
  157. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/blackhole/config_pb2.py +42 -0
  158. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/blackhole/config_pb2_grpc.py +24 -0
  159. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/dns/__init__.py +0 -0
  160. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/dns/config_pb2.py +38 -0
  161. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/dns/config_pb2_grpc.py +24 -0
  162. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/dokodemo/__init__.py +0 -0
  163. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/dokodemo/config_pb2.py +39 -0
  164. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/dokodemo/config_pb2_grpc.py +24 -0
  165. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/freedom/__init__.py +0 -0
  166. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/freedom/config_pb2.py +46 -0
  167. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/freedom/config_pb2_grpc.py +24 -0
  168. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/http/__init__.py +0 -0
  169. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/http/config_pb2.py +48 -0
  170. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/http/config_pb2_grpc.py +24 -0
  171. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/loopback/__init__.py +0 -0
  172. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/loopback/config_pb2.py +37 -0
  173. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/loopback/config_pb2_grpc.py +24 -0
  174. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/mtproto/__init__.py +0 -0
  175. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/mtproto/config_pb2.py +32 -0
  176. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/mtproto/config_pb2_grpc.py +4 -0
  177. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/shadowsocks/__init__.py +0 -0
  178. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/shadowsocks/config_pb2.py +46 -0
  179. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/shadowsocks/config_pb2_grpc.py +24 -0
  180. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/shadowsocks_2022/__init__.py +0 -0
  181. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/shadowsocks_2022/config_pb2.py +50 -0
  182. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/shadowsocks_2022/config_pb2_grpc.py +24 -0
  183. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/socks/__init__.py +0 -0
  184. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/socks/config_pb2.py +49 -0
  185. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/socks/config_pb2_grpc.py +24 -0
  186. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/trojan/__init__.py +0 -0
  187. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/trojan/config_pb2.py +45 -0
  188. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/trojan/config_pb2_grpc.py +24 -0
  189. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vless/__init__.py +0 -0
  190. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vless/account_pb2.py +37 -0
  191. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vless/account_pb2_grpc.py +24 -0
  192. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vless/encoding/__init__.py +0 -0
  193. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vless/encoding/addons_pb2.py +37 -0
  194. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vless/encoding/addons_pb2_grpc.py +24 -0
  195. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vless/inbound/__init__.py +0 -0
  196. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vless/inbound/config_pb2.py +40 -0
  197. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vless/inbound/config_pb2_grpc.py +24 -0
  198. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vless/outbound/__init__.py +0 -0
  199. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vless/outbound/config_pb2.py +38 -0
  200. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vless/outbound/config_pb2_grpc.py +24 -0
  201. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vmess/__init__.py +0 -0
  202. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vmess/account_pb2.py +38 -0
  203. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vmess/account_pb2_grpc.py +24 -0
  204. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vmess/inbound/__init__.py +0 -0
  205. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vmess/inbound/config_pb2.py +42 -0
  206. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vmess/inbound/config_pb2_grpc.py +24 -0
  207. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vmess/outbound/__init__.py +0 -0
  208. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vmess/outbound/config_pb2.py +38 -0
  209. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/vmess/outbound/config_pb2_grpc.py +24 -0
  210. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/wireguard/__init__.py +0 -0
  211. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/wireguard/config_pb2.py +41 -0
  212. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/proxy/wireguard/config_pb2_grpc.py +24 -0
  213. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/__init__.py +0 -0
  214. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/global/__init__.py +0 -0
  215. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/global/config_pb2.py +30 -0
  216. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/global/config_pb2_grpc.py +4 -0
  217. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/__init__.py +0 -0
  218. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/config_pb2.py +51 -0
  219. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/config_pb2_grpc.py +24 -0
  220. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/domainsocket/__init__.py +0 -0
  221. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/domainsocket/config_pb2.py +27 -0
  222. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/domainsocket/config_pb2_grpc.py +4 -0
  223. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/grpc/__init__.py +0 -0
  224. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/grpc/config_pb2.py +37 -0
  225. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/grpc/config_pb2_grpc.py +24 -0
  226. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/grpc/encoding/__init__.py +0 -0
  227. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/grpc/encoding/stream_pb2.py +41 -0
  228. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/grpc/encoding/stream_pb2_grpc.py +140 -0
  229. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/__init__.py +0 -0
  230. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/dns/config_pb2.py +37 -0
  231. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/dns/config_pb2_grpc.py +24 -0
  232. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/http/__init__.py +0 -0
  233. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/http/config_pb2.py +49 -0
  234. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/http/config_pb2_grpc.py +24 -0
  235. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/noop/__init__.py +0 -0
  236. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/noop/config_pb2.py +39 -0
  237. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/noop/config_pb2_grpc.py +24 -0
  238. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/srtp/__init__.py +0 -0
  239. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/srtp/config_pb2.py +37 -0
  240. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/srtp/config_pb2_grpc.py +24 -0
  241. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/tls/__init__.py +0 -0
  242. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/tls/config_pb2.py +37 -0
  243. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/tls/config_pb2_grpc.py +24 -0
  244. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/utp/__init__.py +0 -0
  245. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/utp/config_pb2.py +37 -0
  246. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/utp/config_pb2_grpc.py +24 -0
  247. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/wechat/__init__.py +0 -0
  248. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/wechat/config_pb2.py +37 -0
  249. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/wechat/config_pb2_grpc.py +24 -0
  250. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/wireguard/__init__.py +0 -0
  251. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/wireguard/config_pb2.py +37 -0
  252. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/headers/wireguard/config_pb2_grpc.py +24 -0
  253. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/http/__init__.py +0 -0
  254. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/http/config_pb2.py +38 -0
  255. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/http/config_pb2_grpc.py +24 -0
  256. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/httpupgrade/config_pb2.py +41 -0
  257. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/httpupgrade/config_pb2_grpc.py +24 -0
  258. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/kcp/__init__.py +0 -0
  259. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/kcp/config_pb2.py +54 -0
  260. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/kcp/config_pb2_grpc.py +24 -0
  261. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/quic/__init__.py +0 -0
  262. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/quic/config_pb2.py +29 -0
  263. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/quic/config_pb2_grpc.py +4 -0
  264. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/reality/config_pb2.py +37 -0
  265. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/reality/config_pb2_grpc.py +24 -0
  266. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/splithttp/config_pb2.py +46 -0
  267. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/splithttp/config_pb2_grpc.py +24 -0
  268. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/tcp/__init__.py +0 -0
  269. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/tcp/config_pb2.py +38 -0
  270. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/tcp/config_pb2_grpc.py +24 -0
  271. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/tls/__init__.py +0 -0
  272. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/tls/config_pb2.py +41 -0
  273. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/tls/config_pb2_grpc.py +24 -0
  274. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/udp/__init__.py +0 -0
  275. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/udp/config_pb2.py +37 -0
  276. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/udp/config_pb2_grpc.py +24 -0
  277. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/websocket/__init__.py +0 -0
  278. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/websocket/config_pb2.py +41 -0
  279. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/websocket/config_pb2_grpc.py +24 -0
  280. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/xtls/__init__.py +0 -0
  281. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/xtls/config_pb2.py +30 -0
  282. xtlsapi_ipblacklist-3.3.2/xtlsapi/xray_api/transport/internet/xtls/config_pb2_grpc.py +4 -0
  283. xtlsapi_ipblacklist-3.3.2/xtlsapi_ipblacklist.egg-info/PKG-INFO +58 -0
  284. xtlsapi_ipblacklist-3.3.2/xtlsapi_ipblacklist.egg-info/SOURCES.txt +285 -0
  285. xtlsapi_ipblacklist-3.3.2/xtlsapi_ipblacklist.egg-info/dependency_links.txt +1 -0
  286. xtlsapi_ipblacklist-3.3.2/xtlsapi_ipblacklist.egg-info/requires.txt +3 -0
  287. xtlsapi_ipblacklist-3.3.2/xtlsapi_ipblacklist.egg-info/top_level.txt +6 -0
@@ -0,0 +1,5 @@
1
+ FROM python:3.7-alpine
2
+ COPY . /app
3
+ WORKDIR /app
4
+ RUN pip install .
5
+ CMD ["xtlsapi"]
File without changes
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org>
@@ -0,0 +1,5 @@
1
+ include LICENSE
2
+ include HISTORY.md
3
+ include Containerfile
4
+ graft tests
5
+ graft xtlsapi
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.4
2
+ Name: xtlsapi-ipblacklist
3
+ Version: 3.3.2
4
+ Summary: Fork of the xtlsapi library with an ip blacklist feature
5
+ Home-page: https://github.com/hiddify/xtlsapi/
6
+ Author: klirii
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: grpcio
10
+ Requires-Dist: grpcio-tools<2.0.0
11
+ Requires-Dist: protobuf==5.29.0
12
+ Dynamic: home-page
13
+ Dynamic: license-file
14
+
15
+
16
+ # xtlsapi
17
+
18
+ [![codecov](https://codecov.io/gh/hiddify/xtlsapi/branch/main/graph/badge.svg?token=xtlsapi_token_here)](https://codecov.io/gh/hiddify/xtlsapi)
19
+ [![CI](https://github.com/hiddify/xtlsapi/actions/workflows/main.yml/badge.svg)](https://github.com/hiddify/xtlsapi/actions/workflows/main.yml)
20
+
21
+
22
+ Python library to communicate with xray core
23
+
24
+ ## Install it from PyPI
25
+
26
+ ```bash
27
+ pip install xtlsapi
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ```py
33
+ from xtlsapi import XrayClient, utils, exceptions
34
+
35
+ xray_client = XrayClient('1.2.3.4', 1234)
36
+ user_id = utils.generate_random_user_id()
37
+ user_email = utils.generate_random_email()
38
+ inbound_tag = 'inbound-tag'
39
+
40
+ # Get stats
41
+ print(utils.human_readable_bytes(xray_client.get_client_download_traffic('user-email@mail.com')))
42
+ print(utils.human_readable_bytes(xray_client.get_client_upload_traffic('user-email@mail.com')))
43
+ print(utils.human_readable_bytes(xray_client.get_inbound_download_traffic(inbound_tag)))
44
+ print(utils.human_readable_bytes(xray_client.get_inbound_upload_traffic(inbound_tag)))
45
+
46
+ # Add & Remove client
47
+ user = xray_client.add_client(inbound_tag, user_id, user_email)
48
+ if user:
49
+ print(user)
50
+ xray_client.remove_client(inbound_tag, user_email)
51
+
52
+ # restart logger
53
+ xray_client.restart_logger()
54
+ ```
55
+
56
+ ## Development
57
+
58
+ Read the [CONTRIBUTING.md](CONTRIBUTING.md) file.
@@ -0,0 +1,44 @@
1
+
2
+ # xtlsapi
3
+
4
+ [![codecov](https://codecov.io/gh/hiddify/xtlsapi/branch/main/graph/badge.svg?token=xtlsapi_token_here)](https://codecov.io/gh/hiddify/xtlsapi)
5
+ [![CI](https://github.com/hiddify/xtlsapi/actions/workflows/main.yml/badge.svg)](https://github.com/hiddify/xtlsapi/actions/workflows/main.yml)
6
+
7
+
8
+ Python library to communicate with xray core
9
+
10
+ ## Install it from PyPI
11
+
12
+ ```bash
13
+ pip install xtlsapi
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```py
19
+ from xtlsapi import XrayClient, utils, exceptions
20
+
21
+ xray_client = XrayClient('1.2.3.4', 1234)
22
+ user_id = utils.generate_random_user_id()
23
+ user_email = utils.generate_random_email()
24
+ inbound_tag = 'inbound-tag'
25
+
26
+ # Get stats
27
+ print(utils.human_readable_bytes(xray_client.get_client_download_traffic('user-email@mail.com')))
28
+ print(utils.human_readable_bytes(xray_client.get_client_upload_traffic('user-email@mail.com')))
29
+ print(utils.human_readable_bytes(xray_client.get_inbound_download_traffic(inbound_tag)))
30
+ print(utils.human_readable_bytes(xray_client.get_inbound_upload_traffic(inbound_tag)))
31
+
32
+ # Add & Remove client
33
+ user = xray_client.add_client(inbound_tag, user_id, user_email)
34
+ if user:
35
+ print(user)
36
+ xray_client.remove_client(inbound_tag, user_email)
37
+
38
+ # restart logger
39
+ xray_client.restart_logger()
40
+ ```
41
+
42
+ ## Development
43
+
44
+ Read the [CONTRIBUTING.md](CONTRIBUTING.md) file.
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "xtlsapi-ipblacklist"
7
+ version = "3.3.2"
8
+ description = "Fork of the xtlsapi library with an ip blacklist feature"
9
+ authors = [
10
+ { name="klirii" }
11
+ ]
12
+ readme = "README.md"
13
+ dependencies = [
14
+ "grpcio",
15
+ "grpcio-tools<2.0.0",
16
+ "protobuf==5.29.0"
17
+ ]
18
+
19
+ [tool.setuptools.packages.find]
20
+ where = ["."]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,50 @@
1
+ """Python setup.py for xtlsapi package"""
2
+ import io
3
+ import os
4
+ from setuptools import find_packages, setup
5
+
6
+
7
+ def read(*paths, **kwargs):
8
+ """Read the contents of a text file safely.
9
+ >>> read("xtlsapi", "VERSION")
10
+ '0.1.0'
11
+ >>> read("README.md")
12
+ ...
13
+ """
14
+
15
+ content = ""
16
+ with io.open(
17
+ os.path.join(os.path.dirname(__file__), *paths),
18
+ encoding=kwargs.get("encoding", "utf8"),
19
+ ) as open_file:
20
+ content = open_file.read().strip()
21
+ return content
22
+
23
+
24
+ def read_requirements(path):
25
+ return [
26
+ line.strip()
27
+ for line in read(path).split("\n")
28
+ if not line.startswith(('"', "#", "-", "git+"))
29
+ ]
30
+
31
+
32
+ setup(
33
+ name="xtlsapi",
34
+ version=read("xtlsapi", "VERSION"),
35
+ description="Awesome xtlsapi created by hiddify",
36
+ url="https://github.com/hiddify/xtlsapi/",
37
+ long_description=read("README.md"),
38
+ long_description_content_type="text/markdown",
39
+ author="hiddify",
40
+ packages=find_packages(exclude=["tests", ".github"]),
41
+ install_requires=[
42
+ "grpcio",
43
+ "grpcio-tools<2.0.0",
44
+ "protobuf==5.29.0",
45
+ ],
46
+ entry_points={
47
+ "console_scripts": ["xtlsapi = xtlsapi.__main__:main"]
48
+ },
49
+ # extras_require={"test": read_requirements("requirements-test.txt")},
50
+ )
File without changes
@@ -0,0 +1,14 @@
1
+ import sys
2
+ import pytest
3
+
4
+
5
+ # each test runs on cwd to its temp dir
6
+ @pytest.fixture(autouse=True)
7
+ def go_to_tmpdir(request):
8
+ # Get the fixture dynamically by its name.
9
+ tmpdir = request.getfixturevalue("tmpdir")
10
+ # ensure local test created packages can be imported
11
+ sys.path.insert(0, str(tmpdir))
12
+ # Chdir only for the duration of the test.
13
+ with tmpdir.as_cwd():
14
+ yield
@@ -0,0 +1,5 @@
1
+ from xtlsapi.base import NAME
2
+
3
+
4
+ def test_base():
5
+ assert NAME == "xtlsapi"
@@ -0,0 +1,9 @@
1
+ import pytest
2
+ from unittest.mock import patch
3
+ from xtlsapi import XrayClient
4
+
5
+ def test_stats_online_ip_list():
6
+ xray = XrayClient("127.0.0.1", 53357)
7
+ with patch.object(xray, 'stats_online_ip_list', return_value={'212.58.119.246': 1763418412}):
8
+ result = xray.stats_online_ip_list("1")
9
+ assert result == {'212.58.119.246': 1763418412}
@@ -0,0 +1,14 @@
1
+ import pytest
2
+ from unittest.mock import patch
3
+ from xtlsapi import XrayClient
4
+ from xtlsapi.xray_api.app.router.command import command_pb2
5
+
6
+
7
+ def test_stats_online_ip_list():
8
+ xray = XrayClient("127.0.0.1", 53357)
9
+ with patch.object(xray, 'block_ips', return_value=command_pb2.AddRuleResponse()):
10
+ xray.block_ips(
11
+ ips=["103.23.202.74"],
12
+ inbound_tag="vless-in"
13
+ )
14
+ assert xray
@@ -0,0 +1 @@
1
+ 3.3.0
@@ -0,0 +1,4 @@
1
+ from xtlsapi.client.XrayClient import XrayClient
2
+ from xtlsapi.client.SingboxClient import SingboxClient
3
+ import xtlsapi.exceptions
4
+ from xtlsapi.ext import utils
@@ -0,0 +1,6 @@
1
+ """Entry point for xtlsapi."""
2
+
3
+ from .cli import main # pragma: no cover
4
+
5
+ if __name__ == "__main__": # pragma: no cover
6
+ main()
@@ -0,0 +1,8 @@
1
+ from .stats import StatsAPIService
2
+ from .handler import HandlerAPIService
3
+ from .logger import LoggerAPIService
4
+ from .router import RouterAPIService
5
+
6
+
7
+ class APIService(StatsAPIService, HandlerAPIService, LoggerAPIService, RouterAPIService):
8
+ pass
@@ -0,0 +1,12 @@
1
+ from xtlsapi.xray_api.app.log.command import config_pb2_grpc as logger_pb2_grpc
2
+ from xtlsapi.xray_api.app.stats.command import command_pb2_grpc as stats_pb2_grpc
3
+ from xtlsapi.xray_api.app.proxyman.command import command_pb2_grpc as handler_pb2_grpc
4
+ from xtlsapi.xray_api.app.router.command import command_pb2_grpc as router_pb2_grpc
5
+
6
+
7
+ class BaseService:
8
+ def __init__(self):
9
+ self.stats_stub = stats_pb2_grpc.StatsServiceStub(self._channel)
10
+ self.logger_stub = logger_pb2_grpc.LoggerServiceStub(self._channel)
11
+ self.handler_stub = handler_pb2_grpc.HandlerServiceStub(self._channel)
12
+ self.routing_stub = router_pb2_grpc.RoutingServiceStub(self._channel)
@@ -0,0 +1,6 @@
1
+ from .add_client import AddClient
2
+ from .remove_client import RemoveClient
3
+
4
+
5
+ class HandlerAPIService(AddClient, RemoveClient):
6
+ pass
@@ -0,0 +1,66 @@
1
+ from grpc._channel import _InactiveRpcError
2
+
3
+ from xtlsapi.xray_api.common.protocol import user_pb2
4
+ from xtlsapi.xray_api.app.proxyman.command import command_pb2
5
+ from xtlsapi.ext import utils
6
+ from .._base import BaseService
7
+ from xtlsapi import exceptions
8
+
9
+
10
+ class AddClient(BaseService):
11
+ def add_client(self, inbound_tag, user_id_or_password, email,protocol='vless', level=None, alter_id=None,flow=None,cipher=None):
12
+ try:
13
+ if protocol=='vmess':
14
+ from xtlsapi.xray_api.proxy.vmess import account_pb2
15
+ account=account_pb2.Account(id=user_id_or_password)
16
+ elif protocol=='vless':
17
+ from xtlsapi.xray_api.proxy.vless import account_pb2
18
+ account=account_pb2.Account(id=user_id_or_password,flow=flow,encryption="none")
19
+ elif protocol=='trojan':
20
+ from xtlsapi.xray_api.proxy.trojan import config_pb2
21
+ account=config_pb2.Account(password=user_id_or_password,flow=flow)
22
+ elif protocol=='shadowsocks':
23
+ from xtlsapi.xray_api.proxy.shadowsocks import config_pb2
24
+ cipher_map={'aes_128_gcm':config_pb2.CipherType.AES_128_GCM,
25
+ 'aes_256_gcm':config_pb2.CipherType.AES_256_GCM,
26
+ 'chacha20_poly1305':config_pb2.CipherType.CHACHA20_POLY1305,
27
+ 'xchacha20_poly1305':config_pb2.CipherType.XCHACHA20_POLY1305,
28
+ None:config_pb2.CipherType.NONE
29
+ }
30
+ account=config_pb2.Account(password=user_id_or_password,cipher_type=cipher_map.get(cipher,cipher_map[None]))
31
+ # elif protocol=='shadowsocks_2022':
32
+ # from xtlsapi.xray_api.proxy.shadowsocks import config_pb2
33
+ # cipher_map={'aes_128_gcm':config_pb2.CipherType.AES_128_GCM,
34
+ # 'aes_256_gcm':config_pb2.CipherType.AES_256_GCM,
35
+ # 'chacha20_poly1305':config_pb2.CipherType.CHACHA20_POLY1305,
36
+ # 'xchacha20_poly1305':config_pb2.CipherType.XCHACHA20_POLY1305,
37
+ # None:config_pb2.CipherType.NONE
38
+ # }
39
+ # account=config_pb2.Account(password=user_id_or_password,cipher_type=cipher_map.get(cipher,cipher_map[None])
40
+ # raise Exception("not implemented ")
41
+ else:
42
+ raise Exception("not implemented "+protocol )
43
+
44
+ self.handler_stub.AlterInbound(
45
+ command_pb2.AlterInboundRequest(
46
+ tag=inbound_tag,
47
+ operation=utils.to_typed_message(
48
+ command_pb2.AddUserOperation(
49
+ user=user_pb2.User(
50
+ email=email,
51
+ level=level,
52
+ account=utils.to_typed_message(account),
53
+ )
54
+ )
55
+ ),
56
+ )
57
+ )
58
+ return user_id_or_password
59
+ except _InactiveRpcError as e:
60
+ details = e.details()
61
+ if details.endswith(f"User {email} already exists."):
62
+ raise exceptions.EmailAlreadyExists(details, email)
63
+ elif details.endswith(f"handler not found: {inbound_tag}"):
64
+ raise exceptions.InboundNotFound(details, inbound_tag)
65
+ else:
66
+ raise exceptions.XRayException(details)
@@ -0,0 +1,27 @@
1
+ from grpc._channel import _InactiveRpcError
2
+ from xtlsapi.ext import utils
3
+ from xtlsapi import exceptions
4
+ from xtlsapi.xray_api.app.proxyman.command import command_pb2
5
+
6
+ from .._base import BaseService
7
+
8
+
9
+ class RemoveClient(BaseService):
10
+ def remove_client(self, inbound_tag, email):
11
+ try:
12
+ self.handler_stub.AlterInbound(
13
+ command_pb2.AlterInboundRequest(
14
+ tag=inbound_tag,
15
+ operation=utils.to_typed_message(
16
+ command_pb2.RemoveUserOperation(email=email)
17
+ ),
18
+ )
19
+ )
20
+ except _InactiveRpcError as e:
21
+ details = e.details()
22
+ if details.endswith(f"User {email} not found."):
23
+ raise exceptions.EmailNotFound(details, email)
24
+ elif details.endswith(f"handler not found: {inbound_tag}"):
25
+ raise exceptions.InboundNotFound(details, inbound_tag)
26
+ else:
27
+ raise exceptions.XRayException(details)
@@ -0,0 +1,5 @@
1
+ from .restart_logger import RestartLogger
2
+
3
+
4
+ class LoggerAPIService(RestartLogger):
5
+ pass
@@ -0,0 +1,17 @@
1
+ from grpc._channel import _InactiveRpcError
2
+
3
+ from xtlsapi import exceptions
4
+ from xtlsapi.xray_api.app.log.command import config_pb2
5
+
6
+ from .._base import BaseService
7
+
8
+
9
+ class RestartLogger(BaseService):
10
+ def restart_logger(self):
11
+ try:
12
+ self.logger_stub.RestartLogger(
13
+ config_pb2.RestartLoggerRequest()
14
+ )
15
+ except _InactiveRpcError as e:
16
+ details = e.details()
17
+ raise exceptions.XRayException(details)
@@ -0,0 +1,7 @@
1
+ from .block_ips import RouterBlockIps
2
+
3
+
4
+ class RouterAPIService(
5
+ RouterBlockIps,
6
+ ):
7
+ pass
@@ -0,0 +1,60 @@
1
+ import grpc
2
+ import ipaddress
3
+
4
+ from xtlsapi.api_services._base import BaseService
5
+ from xtlsapi.xray_api.app.router.command import command_pb2
6
+ from xtlsapi.xray_api.common.serial import typed_message_pb2
7
+ from xtlsapi.xray_api.app.router import config_pb2
8
+
9
+
10
+ class RouterBlockIps(BaseService):
11
+
12
+ def block_ips(
13
+ self,
14
+ ips: list[str],
15
+ inbound_tag: str,
16
+ rule_tag: str = "sourceIpBlock",
17
+ outbound_tag: str = "blocked",
18
+ ):
19
+ try:
20
+ self.routing_stub.RemoveRule(
21
+ command_pb2.RemoveRuleRequest(ruleTag=rule_tag)
22
+ )
23
+
24
+ if not ips:
25
+ return None
26
+
27
+ rule = config_pb2.RoutingRule()
28
+ rule.rule_tag = rule_tag
29
+ rule.inbound_tag.extend([inbound_tag] if inbound_tag else [])
30
+ rule.tag = outbound_tag
31
+
32
+ for ip in ips:
33
+ net = ipaddress.ip_network(ip, strict=False)
34
+
35
+ cidr = config_pb2.CIDR()
36
+ cidr.ip = net.network_address.packed
37
+ cidr.prefix = net.prefixlen
38
+
39
+ geo = config_pb2.GeoIP()
40
+ geo.cidr.append(cidr)
41
+
42
+ rule.source_geoip.append(geo)
43
+
44
+ config = config_pb2.Config()
45
+ config.rule.append(rule)
46
+
47
+ typed_msg = typed_message_pb2.TypedMessage(
48
+ type="xray.app.router.Config",
49
+ value=config.SerializeToString(),
50
+ )
51
+
52
+ return self.routing_stub.AddRule(
53
+ command_pb2.AddRuleRequest(
54
+ config=typed_msg,
55
+ shouldAppend=True,
56
+ )
57
+ )
58
+
59
+ except grpc.RpcError as e:
60
+ raise e
@@ -0,0 +1,22 @@
1
+ from .get_client_upload_traffic import GetClientUploadTraffic
2
+ from .get_client_download_traffic import GetClientDownloadTraffic
3
+ from .get_inbound_upload_traffic import GetInboundUploadTraffic
4
+ from .get_inbound_download_traffic import GetInboundDownloadTraffic
5
+ from .get_total_upload_traffic import GetTotalUploadTraffic
6
+ from .get_total_download_traffic import GetTotalDownloadTraffic
7
+ from .get_statsquery import StatsQuery
8
+ from .get_statsonline import StatsOnline
9
+ from .get_stats_online_ip_list import StatsOnlineIpList
10
+
11
+ class StatsAPIService(
12
+ GetClientUploadTraffic,
13
+ GetClientDownloadTraffic,
14
+ GetInboundUploadTraffic,
15
+ GetInboundDownloadTraffic,
16
+ GetTotalUploadTraffic,
17
+ GetTotalDownloadTraffic,
18
+ StatsQuery,
19
+ StatsOnline,
20
+ StatsOnlineIpList
21
+ ):
22
+ pass
@@ -0,0 +1,17 @@
1
+ import grpc
2
+ from xtlsapi.xray_api.app.stats.command import command_pb2
3
+
4
+ from .._base import BaseService
5
+
6
+
7
+ class GetClientDownloadTraffic(BaseService):
8
+ def get_client_download_traffic(self, email, reset=False):
9
+ try:
10
+ return self.stats_stub.GetStats(
11
+ command_pb2.GetStatsRequest(
12
+ name=f"user>>>{email}>>>traffic>>>downlink", reset=reset
13
+ )
14
+ ).stat.value
15
+ except grpc.RpcError:
16
+ # raise
17
+ return None
@@ -0,0 +1,15 @@
1
+ import grpc
2
+ from xtlsapi.xray_api.app.stats.command import command_pb2
3
+ from .._base import BaseService
4
+
5
+
6
+ class GetClientUploadTraffic(BaseService):
7
+ def get_client_upload_traffic(self, email, reset=False):
8
+ try:
9
+ return self.stats_stub.GetStats(
10
+ command_pb2.GetStatsRequest(
11
+ name=f"user>>>{email}>>>traffic>>>uplink", reset=reset
12
+ )
13
+ ).stat.value
14
+ except grpc.RpcError:
15
+ return None
@@ -0,0 +1,16 @@
1
+ import grpc
2
+ from xtlsapi.xray_api.app.stats.command import command_pb2
3
+ from .._base import BaseService
4
+
5
+
6
+ class GetInboundDownloadTraffic(BaseService):
7
+ def get_inbound_download_traffic(self, tag, reset=False):
8
+ try:
9
+ return self.stats_stub.GetStats(
10
+ command_pb2.GetStatsRequest(
11
+ name=f"inbound>>>{tag}>>>traffic>>>downlink", reset=reset
12
+ )
13
+ ).stat.value
14
+ except grpc.RpcError:
15
+ # raise
16
+ return None
@@ -0,0 +1,16 @@
1
+ import grpc
2
+ from xtlsapi.xray_api.app.stats.command import command_pb2
3
+ from .._base import BaseService
4
+
5
+
6
+ class GetInboundUploadTraffic(BaseService):
7
+ def get_inbound_upload_traffic(self, tag, reset=False):
8
+ try:
9
+ return self.stats_stub.GetStats(
10
+ command_pb2.GetStatsRequest(
11
+ name=f"inbound>>>{tag}>>>traffic>>>uplink", reset=reset
12
+ )
13
+ ).stat.value
14
+ except grpc.RpcError:
15
+ # raise
16
+ return None
@@ -0,0 +1,28 @@
1
+ import grpc
2
+ from xtlsapi.xray_api.app.stats.command import command_pb2
3
+
4
+ from .._base import BaseService
5
+
6
+
7
+ class StatsOnlineIpList(BaseService):
8
+ def stats_online_ip_list(self, user, reset=False) -> dict:
9
+ """
10
+ Returns a dictionary of online IPs for the given user.
11
+
12
+ Args:
13
+ user: The email of the user to query.
14
+
15
+ Returns:
16
+ A dictionary mapping IP addresses to last cleanup time of expired ip's.
17
+ """
18
+
19
+ try:
20
+ return self.stats_stub.GetStatsOnlineIpList(
21
+ command_pb2.GetStatsRequest(
22
+ name=f"user>>>{user}>>>online",
23
+ reset=reset
24
+ )
25
+ ).ips
26
+ except grpc.RpcError:
27
+ raise
28
+ return None
@@ -0,0 +1,18 @@
1
+ import grpc
2
+ from xtlsapi.xray_api.app.stats.command import command_pb2
3
+
4
+ from .._base import BaseService
5
+
6
+
7
+ class StatsOnline(BaseService):
8
+ def stats_online(self, user,reset=False):
9
+ try:
10
+ return self.stats_stub.GetStatsOnline(
11
+ command_pb2.GetStatsRequest(
12
+ name=f"user>>>{user}>>>online",
13
+ reset=reset
14
+ )
15
+ ).stat.value
16
+ except grpc.RpcError:
17
+ raise
18
+ return None