Skip to content

Commit f9af632

Browse files
committed
setuptools: Structure module to be compliant with setuptools installation routine
1 parent ee1030e commit f9af632

25 files changed

+112
-32
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,12 @@ __pycache__
66
.vscode/
77
.idea/
88
venv/
9+
.venv/
10+
.env/
911

1012
appconfig*
13+
14+
# Python build artifacts
15+
*.egg-info/
16+
build/
17+
dist/

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ source venv/bin/activate
1010
```
1111

1212
And install the dependencies
13+
1314
```sh
1415
pip install -r requirements.txt
1516
```
@@ -18,8 +19,8 @@ pip install -r requirements.txt
1819

1920
You can invoke 3 different parts of the script
2021

21-
```
22+
```sh
2223
python -m main smartglass
2324
python -m main xhome
2425
python -m main xcloud
25-
```
26+
```

requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ ms_cv
33
pydantic
44
httpx
55
aiortc
6-
construct
6+
construct
7+
dpkt

setup.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
3+
from setuptools import setup, find_packages
4+
5+
setup(
6+
name='xcloud',
7+
version='0.1.0',
8+
description='XCloud Gamestreaming library for python',
9+
author='tuxuser',
10+
author_email='noreply@openxbox.org',
11+
url='https://github.com/OpenXbox/xcloud-python',
12+
packages=find_packages(),
13+
entry_points={'console_scripts': ['xcloud-pcap-reader=xcloud.scripts.pcap_reader:main']},
14+
install_requires=[
15+
"ecdsa",
16+
"ms_cv",
17+
"pydantic",
18+
"httpx",
19+
"aiortc",
20+
"construct",
21+
"dpkt"
22+
]
23+
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

auth/models.py renamed to xcloud/auth/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pydantic import BaseModel
22
from typing import Dict, List, Optional
3-
from auth.constants import XalAppId, XalTitleId, XalRedirectUri,\
3+
from .constants import XalAppId, XalTitleId, XalRedirectUri,\
44
XalQueryDisplay, XalDeviceType, XalUserAgents
55

66

auth/request_signer.py renamed to xcloud/auth/request_signer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import hashlib
88
import struct
99
from datetime import datetime
10-
11-
from auth import filetimes
1210
from ecdsa import SigningKey, NIST256p
1311

12+
from . import filetimes
13+
1414

1515
class RequestSigner:
1616

auth/signed_session.py renamed to xcloud/auth/signed_session.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import asyncio
88
import httpx
9-
from auth.request_signer import RequestSigner
9+
from .request_signer import RequestSigner
1010

1111

1212
class SignedSession(httpx.AsyncClient):

auth/xal_auth.py renamed to xcloud/auth/xal_auth.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
from typing import Optional, Tuple
1414

1515
import ms_cv
16-
from auth.signed_session import SignedSession
17-
from auth.request_signer import RequestSigner
18-
from auth.models import SisuAuthenticationResponse, SisuAuthorizationResponse, \
16+
from .signed_session import SignedSession
17+
from .request_signer import RequestSigner
18+
from .models import SisuAuthenticationResponse, SisuAuthorizationResponse, \
1919
WindowsLiveTokenResponse, XADResponse, XalClientParameters, XSTSResponse, \
2020
XCloudTokenResponse
21-
from auth.constants import XalDeviceType
21+
from .constants import XalDeviceType
2222

2323
log = logging.getLogger('auth')
2424

common.py renamed to xcloud/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Optional
22

33
from pydantic import BaseModel, UUID4
4-
from auth.models import SisuAuthorizationResponse, WindowsLiveTokenResponse,\
4+
from .auth.models import SisuAuthorizationResponse, WindowsLiveTokenResponse,\
55
XalClientParameters
66

77

ice.py renamed to xcloud/ice.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List
1+
from typing import List, Tuple
22

33

44
from aiortc import (
@@ -78,7 +78,9 @@ async def generate_local_config(self) -> dict:
7878
return ice_config
7979

8080
@staticmethod
81-
def parse_remote_config(ice_config: dict) -> (List[RTCIceCandidate], RTCIceParameters):
81+
def parse_remote_config(
82+
ice_config: dict
83+
) -> Tuple[List[RTCIceCandidate], RTCIceParameters]:
8284
candidate_nodes: dict = ice_config.get('Candidates')
8385
if not candidate_nodes:
8486
raise Exception(

main.py renamed to xcloud/main.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import time
55
import asyncio
66

7-
from common import AppConfiguration
7+
from .common import AppConfiguration
88

9-
from auth.constants import IOS_XBOXBETA_APP_PARAMS, ANDROID_GAMEPASS_BETA_PARAMS
10-
from auth.models import XalClientParameters, XSTSResponse
11-
from auth.xal_auth import XalAuthenticator
12-
from auth.request_signer import RequestSigner
9+
from .auth.constants import IOS_XBOXBETA_APP_PARAMS, ANDROID_GAMEPASS_BETA_PARAMS
10+
from .auth.models import XalClientParameters, XSTSResponse
11+
from .auth.xal_auth import XalAuthenticator
12+
from .auth.request_signer import RequestSigner
1313

14-
from smartglass_api import SmartglassApi
15-
from xcloud_api import XCloudApi
16-
from xhomestreaming_api import XHomeStreamingApi
14+
from .smartglass_api import SmartglassApi
15+
from .xcloud_api import XCloudApi
16+
from .xhomestreaming_api import XHomeStreamingApi
1717

1818
APP_CONFIG_XBOXBETA_FILE = "appconfig.xboxbeta.json"
1919
APP_CONFIG_XBOXGAMEPASS_FILE = "appconfig.xboxgamepass.json"

xcloud/protocol/__init__.py

Whitespace-only changes.

protocol/packets.py renamed to xcloud/protocol/packets.py

+26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1+
from enum import Enum
12
from construct import Struct, this, Int32ul, Int64ul, PrefixedArray, Bytes, Array
23

4+
"""
5+
Payload types
6+
"""
7+
class PayloadType(Enum):
8+
MuxDCTChannelRangeDefault = 0x23
9+
MuxDCTChannelRangeEnd = 0x3f
10+
BaseLinkControl = 0x60
11+
MuxDCTControl = 0x61
12+
FECControl = 0x62
13+
SecurityLayerCtrl = 0x63
14+
URCPControl = 0x64
15+
UDPKeepAlive = 0x65
16+
UDPConnectionProbing = 0x66
17+
URCPDummyPacket = 0x68
18+
MockUDPDctCtrl = 0x7f
19+
320
"""
421
Video Channel
522
"""
@@ -83,3 +100,12 @@ class QosControlFlags:
83100
# TBD
84101
)
85102

103+
"""
104+
Control Protocol
105+
"""
106+
class ControlProtocolMessageOpCode(Enum):
107+
Auth = 0x1
108+
AuthComplete = 0x2
109+
Config = 0x3
110+
ControllerChange = 0x4
111+
Config2 = 0x6

xcloud/scripts/__init__.py

Whitespace-only changes.

xcloud/scripts/pcap_reader.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""
2+
PCAP Parser for XCloud network traffic
3+
"""
4+
import argparse
5+
6+
def parse_file(filepath: str) -> None:
7+
print(f"hello -> {filepath}")
8+
9+
def main():
10+
parser = argparse.ArgumentParser(
11+
"XCloud PCAP parser",
12+
description="PCAP Parser for XCloud network traffic"
13+
)
14+
parser.add_argument("filepath", help="Path to PCAP/NG file")
15+
args = parser.parse_args()
16+
17+
parse_file(args.filepath)
18+
19+
if __name__ == "__main__":
20+
main()

smartglass_api.py renamed to xcloud/smartglass_api.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
from typing import Optional, Union, List
55

66
import ms_cv
7-
from auth.models import SisuAuthorizationResponse, XSTSResponse
8-
from auth.signed_session import SignedSession
9-
from auth.request_signer import RequestSigner
7+
from .auth.models import SisuAuthorizationResponse, XSTSResponse
8+
from .auth.signed_session import SignedSession
9+
from .auth.request_signer import RequestSigner
1010

11-
from smartglass_models import SmartglassConsoleList, \
11+
from .smartglass_models import SmartglassConsoleList, \
1212
SmartglassConsoleStatus, CommandResponse, VolumeDirection, InputKeyType,\
1313
MediaCommand, InstalledPackagesList, StorageDevicesList,\
1414
OperationStatusResponse
File renamed without changes.
File renamed without changes.

xcloud_api.py renamed to xcloud/xcloud_api.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import httpx
66
import ms_cv
77

8-
from auth.models import XSTSResponse, XCloudTokenResponse
9-
from streaming_models import StreamLoginResponse, StreamSessionResponse, \
8+
from .auth.models import XSTSResponse, XCloudTokenResponse
9+
from .streaming_models import StreamLoginResponse, StreamSessionResponse, \
1010
StreamStateResponse, StreamConfig, StreamSetupState
11-
from xcloud_models import TitlesResponse, TitleWaitTimeResponse, CloudGameTitle
11+
from .xcloud_models import TitlesResponse, TitleWaitTimeResponse, CloudGameTitle
1212

1313
USER_AGENT_ANDROID = '{"conn":{"cell":{"carrier":"congstar","mcc":"262","mnc":"01","networkDetail":"{\"ci\":\"unknown\",\"pci\":\"unknown\",\"rat\":\"unknown\",\"signalStrengthDbm\":\"-2147483648\",\"pilotPowerSignalQuality\":\"-2147483648\",\"snr\":\"-2147483648\"}","roaming":"NotRoaming","strengthPct":100},"type":"Wifi","wifi":{"freq":5300,"strengthDbm":-60,"strengthPct":88}},"dev":{"hw":{"make":"Google","model":"Pixel 3a"},"os":{"name":"Android","ver":"11-RP1A.200720.009-30"}}}'
1414

File renamed without changes.

xhomestreaming_api.py renamed to xcloud/xhomestreaming_api.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import ms_cv
77

88
import httpx
9-
from auth.models import XSTSResponse
10-
from ice import ICEHandler
9+
from .auth.models import XSTSResponse
10+
from .ice import ICEHandler
1111

12-
from streaming_models import StreamLoginResponse, StreamSessionResponse, \
12+
from .streaming_models import StreamLoginResponse, StreamSessionResponse, \
1313
StreamStateResponse, StreamConfig, StreamICEConfig
1414

1515
USER_AGENT_IOS = '{"conn":{"cell":{"carrier":"","mcc":"","mnc":"","networkDetail":"","roaming":"Unknown","strengthPct":-1},"type":"Wifi","wifi":{"freq":-2147483648,"strengthDbm":-2147483648,"strengthPct":-1}},"dev":{"hw":{"make":"Apple","model":"iPad6,11"},"os":{"name":"iOS","ver":"14.0.1 (Build 18A393)"}}}'

0 commit comments

Comments
 (0)