Skip to content

Commit a259a55

Browse files
committed
new: add statsonline
1 parent df36926 commit a259a55

File tree

138 files changed

+3213
-641
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+3213
-641
lines changed

xtlsapi/api_services/stats/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .get_total_upload_traffic import GetTotalUploadTraffic
66
from .get_total_download_traffic import GetTotalDownloadTraffic
77
from .get_statsquery import StatsQuery
8+
from .get_statsonline import StatsOnline
89

910
class StatsAPIService(
1011
GetClientUploadTraffic,
@@ -13,6 +14,7 @@ class StatsAPIService(
1314
GetInboundDownloadTraffic,
1415
GetTotalUploadTraffic,
1516
GetTotalDownloadTraffic,
16-
StatsQuery
17+
StatsQuery,
18+
StatsOnline
1719
):
1820
pass
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

xtlsapi/generate_from_xray_proto.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from pathlib import Path
55

66
package_name="xtlsapi.xray_api"
7-
out="/opt/xtlsapi/xtlsapi/xray_api/"
7+
out="/workspaces/xtlsapi/xtlsapi/xray_api/"
88
#out="xtlsapi/xray_api"
9-
xray_src="/opt/Xray-core/"
9+
xray_src="/workspaces/xtlsapi/Xray-core/"
1010
# create the output directory
1111
Path(out).mkdir(parents=True, exist_ok=True)
1212

@@ -36,7 +36,7 @@
3636
output = stream.read()
3737
if output != '':
3838
print(''.join(['protoc error/info for file ', filename, ' - ', output]))
39-
39+
4040
# get the python files in the base directory
4141
base_pys = set()
4242

xtlsapi/xray_api/app/commander/config_pb2.py

Lines changed: 19 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
4+
import warnings
45

6+
7+
GRPC_GENERATED_VERSION = '1.67.1'
8+
GRPC_VERSION = grpc.__version__
9+
_version_not_supported = False
10+
11+
try:
12+
from grpc._utilities import first_version_is_lower
13+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
14+
except ImportError:
15+
_version_not_supported = True
16+
17+
if _version_not_supported:
18+
raise RuntimeError(
19+
f'The grpc package installed is at version {GRPC_VERSION},'
20+
+ f' but the generated code in app/commander/config_pb2_grpc.py depends on'
21+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
22+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
23+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
24+
)

xtlsapi/xray_api/app/dispatcher/config_pb2.py

Lines changed: 15 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
4+
import warnings
45

6+
7+
GRPC_GENERATED_VERSION = '1.67.1'
8+
GRPC_VERSION = grpc.__version__
9+
_version_not_supported = False
10+
11+
try:
12+
from grpc._utilities import first_version_is_lower
13+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
14+
except ImportError:
15+
_version_not_supported = True
16+
17+
if _version_not_supported:
18+
raise RuntimeError(
19+
f'The grpc package installed is at version {GRPC_VERSION},'
20+
+ f' but the generated code in app/dispatcher/config_pb2_grpc.py depends on'
21+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
22+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
23+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
24+
)

xtlsapi/xray_api/app/dns/config_pb2.py

Lines changed: 30 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
4+
import warnings
45

6+
7+
GRPC_GENERATED_VERSION = '1.67.1'
8+
GRPC_VERSION = grpc.__version__
9+
_version_not_supported = False
10+
11+
try:
12+
from grpc._utilities import first_version_is_lower
13+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
14+
except ImportError:
15+
_version_not_supported = True
16+
17+
if _version_not_supported:
18+
raise RuntimeError(
19+
f'The grpc package installed is at version {GRPC_VERSION},'
20+
+ f' but the generated code in app/dns/config_pb2_grpc.py depends on'
21+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
22+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
23+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
24+
)

xtlsapi/xray_api/app/dns/fakedns/fakedns_pb2.py

Lines changed: 15 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)