v2kit 0.2__tar.gz → 0.3__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.
- {v2kit-0.2 → v2kit-0.3}/AUTHORS.md +1 -1
- {v2kit-0.2 → v2kit-0.3}/CHANGELOG.md +12 -1
- {v2kit-0.2 → v2kit-0.3}/PKG-INFO +18 -5
- {v2kit-0.2 → v2kit-0.3}/README.md +4 -2
- {v2kit-0.2 → v2kit-0.3}/SECURITY.md +2 -2
- v2kit-0.2/dev-requirements.txt → v2kit-0.3/requirements-dev.txt +2 -0
- {v2kit-0.2 → v2kit-0.3}/setup.py +6 -17
- {v2kit-0.2 → v2kit-0.3}/tests/test_errors.py +35 -1
- {v2kit-0.2 → v2kit-0.3}/tests/test_functions.py +23 -13
- v2kit-0.3/tests/test_shadowsocks.py +17 -0
- v2kit-0.3/tests/test_socks.py +69 -0
- v2kit-0.3/tests/test_trojan.py +17 -0
- v2kit-0.3/tests/test_vless.py +58 -0
- v2kit-0.3/tests/test_vmess.py +32 -0
- {v2kit-0.2 → v2kit-0.3}/v2kit/__init__.py +5 -2
- {v2kit-0.2 → v2kit-0.3}/v2kit/functions.py +10 -1
- v2kit-0.3/v2kit/models/__init__.py +9 -0
- v2kit-0.3/v2kit/models/base.py +108 -0
- v2kit-0.3/v2kit/models/shadowsocks.py +168 -0
- v2kit-0.3/v2kit/models/socks.py +172 -0
- v2kit-0.3/v2kit/models/trojan.py +140 -0
- v2kit-0.3/v2kit/models/vless.py +141 -0
- v2kit-0.3/v2kit/models/vmess.py +217 -0
- {v2kit-0.2 → v2kit-0.3}/v2kit/params.py +2 -1
- {v2kit-0.2 → v2kit-0.3}/v2kit/parsers.py +24 -3
- {v2kit-0.2 → v2kit-0.3}/v2kit/utils.py +2 -3
- {v2kit-0.2 → v2kit-0.3}/v2kit/validators.py +12 -0
- {v2kit-0.2 → v2kit-0.3}/v2kit.egg-info/PKG-INFO +18 -5
- {v2kit-0.2 → v2kit-0.3}/v2kit.egg-info/SOURCES.txt +14 -5
- v2kit-0.2/requirements.txt +0 -1
- v2kit-0.2/tests/test_models.py +0 -114
- v2kit-0.2/v2kit/models.py +0 -735
- {v2kit-0.2 → v2kit-0.3}/LICENSE +0 -0
- {v2kit-0.2 → v2kit-0.3}/MANIFEST.in +0 -0
- {v2kit-0.2 → v2kit-0.3}/setup.cfg +0 -0
- {v2kit-0.2 → v2kit-0.3}/v2kit/__main__.py +0 -0
- {v2kit-0.2 → v2kit-0.3}/v2kit/errors.py +0 -0
- {v2kit-0.2 → v2kit-0.3}/v2kit.egg-info/dependency_links.txt +0 -0
- {v2kit-0.2 → v2kit-0.3}/v2kit.egg-info/top_level.txt +0 -0
|
@@ -5,6 +5,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
|
+
## [0.3] - 2026-06-16
|
|
9
|
+
### Added
|
|
10
|
+
- Logo
|
|
11
|
+
- `SocksConfig` class
|
|
12
|
+
- `is_socks` function
|
|
13
|
+
### Changed
|
|
14
|
+
- `README.md` updated
|
|
15
|
+
- Test system modified
|
|
16
|
+
- Dependencies structure modified
|
|
17
|
+
- All config models moved to `models` folder
|
|
8
18
|
## [0.2] - 2026-06-04
|
|
9
19
|
### Added
|
|
10
20
|
- `VMESSConfig` class
|
|
@@ -33,7 +43,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
33
43
|
- `encode_subscription` function
|
|
34
44
|
- `decode_subscription` function
|
|
35
45
|
|
|
36
|
-
[Unreleased]: https://github.com/sepandhaghighi/v2kit/compare/v0.
|
|
46
|
+
[Unreleased]: https://github.com/sepandhaghighi/v2kit/compare/v0.3...dev
|
|
47
|
+
[0.3]: https://github.com/sepandhaghighi/v2kit/compare/v0.2...v0.3
|
|
37
48
|
[0.2]: https://github.com/sepandhaghighi/v2kit/compare/v0.1...v0.2
|
|
38
49
|
[0.1]: https://github.com/sepandhaghighi/v2kit/compare/bb5a2cb...v0.1
|
|
39
50
|
|
{v2kit-0.2 → v2kit-0.3}/PKG-INFO
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: v2kit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3
|
|
4
4
|
Summary: V2Kit: A Lightweight Toolkit for V2Ray Config Manipulation
|
|
5
5
|
Home-page: https://github.com/sepandhaghighi/v2kit
|
|
6
|
-
Download-URL: https://github.com/sepandhaghighi/v2kit/tarball/v0.
|
|
6
|
+
Download-URL: https://github.com/sepandhaghighi/v2kit/tarball/v0.3
|
|
7
7
|
Author: Sepand Haghighi
|
|
8
8
|
Author-email: me@sepand.tech
|
|
9
9
|
License: MIT
|
|
@@ -44,6 +44,7 @@ Dynamic: summary
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div align="center">
|
|
47
|
+
<img src="https://github.com/sepandhaghighi/v2kit/raw/main/otherfiles/logo.png" width="350">
|
|
47
48
|
<h1>V2Kit: A Lightweight Toolkit for V2Ray Config Manipulation</h1>
|
|
48
49
|
<br/>
|
|
49
50
|
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/built%20with-Python3-green.svg" alt="built with Python3"></a>
|
|
@@ -95,13 +96,13 @@ V2Kit is a lightweight and extensible Python toolkit for working with V2Ray prox
|
|
|
95
96
|
## Installation
|
|
96
97
|
|
|
97
98
|
### Source Code
|
|
98
|
-
- Download [Version 0.
|
|
99
|
+
- Download [Version 0.3](https://github.com/sepandhaghighi/v2kit/archive/v0.3.zip) or [Latest Source](https://github.com/sepandhaghighi/v2kit/archive/dev.zip)
|
|
99
100
|
- `pip install .`
|
|
100
101
|
|
|
101
102
|
### PyPI
|
|
102
103
|
|
|
103
104
|
- Check [Python Packaging User Guide](https://packaging.python.org/installing/)
|
|
104
|
-
- `pip install v2kit==0.
|
|
105
|
+
- `pip install v2kit==0.3`
|
|
105
106
|
|
|
106
107
|
## Supported Protocols
|
|
107
108
|
|
|
@@ -113,6 +114,7 @@ V2Kit currently supports the following protocols:
|
|
|
113
114
|
| VLESS | ✅ | ✅ | ✅ | ✅ |
|
|
114
115
|
| Trojan | ✅ | ✅ | ✅ | ✅ |
|
|
115
116
|
| Shadowsocks | ✅ | ✅ | ✅ | ✅ |
|
|
117
|
+
| SOCKS | ✅ | ✅ | ✅ | ✅ |
|
|
116
118
|
|
|
117
119
|
|
|
118
120
|
## Usage
|
|
@@ -208,6 +210,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
|
208
210
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
209
211
|
|
|
210
212
|
## [Unreleased]
|
|
213
|
+
## [0.3] - 2026-06-16
|
|
214
|
+
### Added
|
|
215
|
+
- Logo
|
|
216
|
+
- `SocksConfig` class
|
|
217
|
+
- `is_socks` function
|
|
218
|
+
### Changed
|
|
219
|
+
- `README.md` updated
|
|
220
|
+
- Test system modified
|
|
221
|
+
- Dependencies structure modified
|
|
222
|
+
- All config models moved to `models` folder
|
|
211
223
|
## [0.2] - 2026-06-04
|
|
212
224
|
### Added
|
|
213
225
|
- `VMESSConfig` class
|
|
@@ -236,7 +248,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
236
248
|
- `encode_subscription` function
|
|
237
249
|
- `decode_subscription` function
|
|
238
250
|
|
|
239
|
-
[Unreleased]: https://github.com/sepandhaghighi/v2kit/compare/v0.
|
|
251
|
+
[Unreleased]: https://github.com/sepandhaghighi/v2kit/compare/v0.3...dev
|
|
252
|
+
[0.3]: https://github.com/sepandhaghighi/v2kit/compare/v0.2...v0.3
|
|
240
253
|
[0.2]: https://github.com/sepandhaghighi/v2kit/compare/v0.1...v0.2
|
|
241
254
|
[0.1]: https://github.com/sepandhaghighi/v2kit/compare/bb5a2cb...v0.1
|
|
242
255
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
+
<img src="https://github.com/sepandhaghighi/v2kit/raw/main/otherfiles/logo.png" width="350">
|
|
2
3
|
<h1>V2Kit: A Lightweight Toolkit for V2Ray Config Manipulation</h1>
|
|
3
4
|
<br/>
|
|
4
5
|
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/built%20with-Python3-green.svg" alt="built with Python3"></a>
|
|
@@ -50,13 +51,13 @@ V2Kit is a lightweight and extensible Python toolkit for working with V2Ray prox
|
|
|
50
51
|
## Installation
|
|
51
52
|
|
|
52
53
|
### Source Code
|
|
53
|
-
- Download [Version 0.
|
|
54
|
+
- Download [Version 0.3](https://github.com/sepandhaghighi/v2kit/archive/v0.3.zip) or [Latest Source](https://github.com/sepandhaghighi/v2kit/archive/dev.zip)
|
|
54
55
|
- `pip install .`
|
|
55
56
|
|
|
56
57
|
### PyPI
|
|
57
58
|
|
|
58
59
|
- Check [Python Packaging User Guide](https://packaging.python.org/installing/)
|
|
59
|
-
- `pip install v2kit==0.
|
|
60
|
+
- `pip install v2kit==0.3`
|
|
60
61
|
|
|
61
62
|
## Supported Protocols
|
|
62
63
|
|
|
@@ -68,6 +69,7 @@ V2Kit currently supports the following protocols:
|
|
|
68
69
|
| VLESS | ✅ | ✅ | ✅ | ✅ |
|
|
69
70
|
| Trojan | ✅ | ✅ | ✅ | ✅ |
|
|
70
71
|
| Shadowsocks | ✅ | ✅ | ✅ | ✅ |
|
|
72
|
+
| SOCKS | ✅ | ✅ | ✅ | ✅ |
|
|
71
73
|
|
|
72
74
|
|
|
73
75
|
## Usage
|
{v2kit-0.2 → v2kit-0.3}/setup.py
RENAMED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
"""Setup module."""
|
|
3
|
-
from
|
|
4
|
-
try:
|
|
5
|
-
from setuptools import setup
|
|
6
|
-
except ImportError:
|
|
7
|
-
from distutils.core import setup
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def get_requires() -> List[str]:
|
|
11
|
-
"""Read requirements.txt."""
|
|
12
|
-
requirements = open("requirements.txt", "r").read()
|
|
13
|
-
return list(filter(lambda x: x != "", requirements.split()))
|
|
14
|
-
|
|
3
|
+
from setuptools import setup
|
|
15
4
|
|
|
16
5
|
def read_description() -> str:
|
|
17
6
|
"""Read README.md and CHANGELOG.md."""
|
|
@@ -32,8 +21,8 @@ def read_description() -> str:
|
|
|
32
21
|
|
|
33
22
|
setup(
|
|
34
23
|
name='v2kit',
|
|
35
|
-
packages=['v2kit'],
|
|
36
|
-
version='0.
|
|
24
|
+
packages=['v2kit', 'v2kit.models'],
|
|
25
|
+
version='0.3',
|
|
37
26
|
description='V2Kit: A Lightweight Toolkit for V2Ray Config Manipulation',
|
|
38
27
|
long_description=read_description(),
|
|
39
28
|
long_description_content_type='text/markdown',
|
|
@@ -41,11 +30,11 @@ setup(
|
|
|
41
30
|
author='Sepand Haghighi',
|
|
42
31
|
author_email='me@sepand.tech',
|
|
43
32
|
url='https://github.com/sepandhaghighi/v2kit',
|
|
44
|
-
download_url='https://github.com/sepandhaghighi/v2kit/tarball/v0.
|
|
45
|
-
keywords=
|
|
33
|
+
download_url='https://github.com/sepandhaghighi/v2kit/tarball/v0.3',
|
|
34
|
+
keywords='v2ray v2ray-config v2ray-tools vmess vless trojan shadowsocks proxy subscription network',
|
|
46
35
|
project_urls={
|
|
47
36
|
'Source': 'https://github.com/sepandhaghighi/v2kit'},
|
|
48
|
-
install_requires=
|
|
37
|
+
install_requires=[],
|
|
49
38
|
python_requires='>=3.8',
|
|
50
39
|
classifiers=[
|
|
51
40
|
'Development Status :: 3 - Alpha',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
3
|
import pytest
|
|
4
|
-
from v2kit import VMESSConfig, VLESSConfig, TrojanConfig, ShadowsocksConfig
|
|
4
|
+
from v2kit import VMESSConfig, VLESSConfig, TrojanConfig, ShadowsocksConfig, SocksConfig
|
|
5
5
|
from v2kit import relabel, encode_subscription, decode_subscription, parse
|
|
6
6
|
from v2kit import V2kitError, V2kitValidationError, V2kitParseError
|
|
7
7
|
from v2kit.validators import _validate_uri
|
|
@@ -166,3 +166,37 @@ def test_shadowsocks_empty_encryption():
|
|
|
166
166
|
address="example.com",
|
|
167
167
|
port=8388,
|
|
168
168
|
)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def test_socks_invalid_port():
|
|
172
|
+
with pytest.raises(V2kitValidationError):
|
|
173
|
+
SocksConfig(
|
|
174
|
+
address="example.com",
|
|
175
|
+
port=70000,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def test_socks_empty_address():
|
|
180
|
+
with pytest.raises(V2kitValidationError):
|
|
181
|
+
SocksConfig(
|
|
182
|
+
address="",
|
|
183
|
+
port=1080,
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def test_socks_invalid_username():
|
|
188
|
+
with pytest.raises(V2kitValidationError):
|
|
189
|
+
SocksConfig(
|
|
190
|
+
address="example.com",
|
|
191
|
+
port=1080,
|
|
192
|
+
username="",
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def test_socks_invalid_password():
|
|
197
|
+
with pytest.raises(V2kitValidationError):
|
|
198
|
+
SocksConfig(
|
|
199
|
+
address="example.com",
|
|
200
|
+
port=1080,
|
|
201
|
+
password="",
|
|
202
|
+
)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
|
-
from v2kit import is_vmess, is_vless, is_trojan, is_shadowsocks, parse
|
|
4
|
+
from v2kit import is_vmess, is_vless, is_trojan, is_shadowsocks, is_socks, parse
|
|
5
5
|
from v2kit import relabel, encode_subscription, decode_subscription
|
|
6
|
-
from v2kit import VMESSConfig, VLESSConfig, TrojanConfig, ShadowsocksConfig
|
|
6
|
+
from v2kit import VMESSConfig, VLESSConfig, TrojanConfig, ShadowsocksConfig, SocksConfig
|
|
7
7
|
from v2kit.utils import _encode_base64
|
|
8
8
|
|
|
9
9
|
|
|
@@ -29,19 +29,13 @@ def create_vmess(label="test"):
|
|
|
29
29
|
|
|
30
30
|
VMESS_CONFIG = create_vmess()
|
|
31
31
|
|
|
32
|
-
VLESS_CONFIG =
|
|
33
|
-
"vless://1c4b4bca-e3ff-4ca8-a062-6f399ad3cf45@example.com:443"
|
|
34
|
-
"?security=tls#vless-test"
|
|
35
|
-
)
|
|
32
|
+
VLESS_CONFIG = "vless://1c4b4bca-e3ff-4ca8-a062-6f399ad3cf45@example.com:443?security=tls#vless-test"
|
|
36
33
|
|
|
37
|
-
TROJAN_CONFIG =
|
|
38
|
-
"trojan://password@example.com:443"
|
|
39
|
-
"?security=tls#trojan-test"
|
|
40
|
-
)
|
|
34
|
+
TROJAN_CONFIG = "trojan://password@example.com:443?security=tls#trojan-test"
|
|
41
35
|
|
|
42
|
-
SHADOWSOCKS_CONFIG =
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
SHADOWSOCKS_CONFIG = "ss://YWVzLTI1Ni1nY206cGFzc3dvcmQ=@example.com:8388#ss-test"
|
|
37
|
+
|
|
38
|
+
SOCKS_CONFIG = "socks://user:password@example.com:1080#socks-test"
|
|
45
39
|
|
|
46
40
|
|
|
47
41
|
def test_is_vmess():
|
|
@@ -80,6 +74,14 @@ def test_is_shadowsocks_invalid():
|
|
|
80
74
|
assert is_shadowsocks("invalid") is False
|
|
81
75
|
|
|
82
76
|
|
|
77
|
+
def test_is_socks():
|
|
78
|
+
assert is_socks(SOCKS_CONFIG) is True
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_is_socks_invalid():
|
|
82
|
+
assert is_socks("invalid") is False
|
|
83
|
+
|
|
84
|
+
|
|
83
85
|
def test_relabel_vmess():
|
|
84
86
|
result = relabel(VMESS_CONFIG, "new-label")
|
|
85
87
|
|
|
@@ -142,6 +144,7 @@ def test_encode_decode_subscription_roundtrip():
|
|
|
142
144
|
VLESS_CONFIG,
|
|
143
145
|
TROJAN_CONFIG,
|
|
144
146
|
SHADOWSOCKS_CONFIG,
|
|
147
|
+
SOCKS_CONFIG,
|
|
145
148
|
]
|
|
146
149
|
|
|
147
150
|
encoded = encode_subscription(configs)
|
|
@@ -206,3 +209,10 @@ def test_parse_shadowsocks():
|
|
|
206
209
|
parse(SHADOWSOCKS_CONFIG),
|
|
207
210
|
ShadowsocksConfig,
|
|
208
211
|
)
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def test_parse_socks():
|
|
215
|
+
assert isinstance(
|
|
216
|
+
parse(SOCKS_CONFIG),
|
|
217
|
+
SocksConfig,
|
|
218
|
+
)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from v2kit import parse
|
|
3
|
+
from v2kit import ShadowsocksConfig
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_to_uri_roundtrip():
|
|
7
|
+
config = ShadowsocksConfig(
|
|
8
|
+
encryption="aes-256-gcm",
|
|
9
|
+
password="password",
|
|
10
|
+
address="example.com",
|
|
11
|
+
port=8388,
|
|
12
|
+
label="test",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
parsed = parse(config.to_uri())
|
|
16
|
+
|
|
17
|
+
assert parsed == config
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from v2kit import parse
|
|
3
|
+
from v2kit import SocksConfig
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_update_methods():
|
|
7
|
+
config = SocksConfig(
|
|
8
|
+
address="example.com",
|
|
9
|
+
port=1080,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
config.update_username("user")
|
|
13
|
+
config.update_password("password")
|
|
14
|
+
|
|
15
|
+
assert config.username == "user"
|
|
16
|
+
assert config.password == "password"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def test_to_uri_roundtrip():
|
|
20
|
+
config = SocksConfig(
|
|
21
|
+
address="example.com",
|
|
22
|
+
port=1080,
|
|
23
|
+
username="user",
|
|
24
|
+
password="password",
|
|
25
|
+
label="test",
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
parsed = parse(config.to_uri())
|
|
29
|
+
|
|
30
|
+
assert parsed == config
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_config_equality():
|
|
34
|
+
config1 = SocksConfig(
|
|
35
|
+
address="example.com",
|
|
36
|
+
port=1080,
|
|
37
|
+
username="user",
|
|
38
|
+
password="password",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
config2 = SocksConfig(
|
|
42
|
+
address="example.com",
|
|
43
|
+
port=1080,
|
|
44
|
+
username="user",
|
|
45
|
+
password="password",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
assert config1 == config2
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_to_uri_without_auth():
|
|
52
|
+
config = SocksConfig(
|
|
53
|
+
address="example.com",
|
|
54
|
+
port=1080,
|
|
55
|
+
label="test",
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
assert config.to_uri() == "socks://example.com:1080#test"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def test_to_uri_username_only():
|
|
62
|
+
config = SocksConfig(
|
|
63
|
+
address="example.com",
|
|
64
|
+
port=1080,
|
|
65
|
+
username="user",
|
|
66
|
+
label="test",
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
assert config.to_uri() == "socks://user@example.com:1080#test"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from v2kit import parse
|
|
4
|
+
from v2kit import TrojanConfig
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_to_uri_roundtrip():
|
|
8
|
+
config = TrojanConfig(
|
|
9
|
+
password="password",
|
|
10
|
+
address="example.com",
|
|
11
|
+
port=443,
|
|
12
|
+
label="test",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
parsed = parse(config.to_uri())
|
|
16
|
+
|
|
17
|
+
assert parsed == config
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from v2kit import parse
|
|
4
|
+
from v2kit import VLESSConfig
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_to_uri_roundtrip():
|
|
8
|
+
config = VLESSConfig(
|
|
9
|
+
uuid="1c4b4bca-e3ff-4ca8-a062-6f399ad3cf45",
|
|
10
|
+
address="example.com",
|
|
11
|
+
port=443,
|
|
12
|
+
label="test",
|
|
13
|
+
extra={"security": "tls"},
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
parsed = parse(config.to_uri())
|
|
17
|
+
|
|
18
|
+
assert parsed == config
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_config_equality():
|
|
22
|
+
config1 = VLESSConfig(
|
|
23
|
+
uuid="1c4b4bca-e3ff-4ca8-a062-6f399ad3cf45",
|
|
24
|
+
address="example.com",
|
|
25
|
+
port=443,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
config2 = VLESSConfig(
|
|
29
|
+
uuid="1c4b4bca-e3ff-4ca8-a062-6f399ad3cf45",
|
|
30
|
+
address="example.com",
|
|
31
|
+
port=443,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
assert config1 == config2
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_config_repr():
|
|
38
|
+
config = VLESSConfig(
|
|
39
|
+
uuid="1c4b4bca-e3ff-4ca8-a062-6f399ad3cf45",
|
|
40
|
+
address="example.com",
|
|
41
|
+
port=443,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
assert "VLESSConfig" in repr(config)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_update_extra():
|
|
48
|
+
config = VLESSConfig(
|
|
49
|
+
uuid="1c4b4bca-e3ff-4ca8-a062-6f399ad3cf45",
|
|
50
|
+
address="example.com",
|
|
51
|
+
port=443,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
config.update_extra(
|
|
55
|
+
{"security": "tls"}
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
assert config.extra["security"] == "tls"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from v2kit import parse
|
|
3
|
+
from v2kit import VMESSConfig
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_to_uri_roundtrip():
|
|
7
|
+
config = VMESSConfig(
|
|
8
|
+
uuid="1c4b4bca-e3ff-4ca8-a062-6f399ad3cf45",
|
|
9
|
+
address="example.com",
|
|
10
|
+
port=443,
|
|
11
|
+
label="test",
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
parsed = parse(config.to_uri())
|
|
15
|
+
|
|
16
|
+
assert parsed == config
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def test_update_methods():
|
|
20
|
+
config = VMESSConfig(
|
|
21
|
+
uuid="1c4b4bca-e3ff-4ca8-a062-6f399ad3cf45",
|
|
22
|
+
address="example.com",
|
|
23
|
+
port=443,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
config.update_network("ws")
|
|
27
|
+
config.update_tls("tls")
|
|
28
|
+
config.update_alter_id(1)
|
|
29
|
+
|
|
30
|
+
assert config.network == "ws"
|
|
31
|
+
assert config.tls == "tls"
|
|
32
|
+
assert config.alter_id == 1
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"""v2kit modules."""
|
|
3
3
|
from .params import V2KIT_VERSION, Protocol
|
|
4
4
|
from .errors import V2kitError, V2kitValidationError, V2kitParseError
|
|
5
|
-
from .functions import is_vmess, is_vless, is_trojan, is_shadowsocks
|
|
5
|
+
from .functions import is_vmess, is_vless, is_trojan, is_shadowsocks, is_socks
|
|
6
6
|
from .functions import relabel
|
|
7
7
|
from .functions import encode_subscription, decode_subscription
|
|
8
8
|
from .parsers import parse
|
|
@@ -11,6 +11,7 @@ from .models import (
|
|
|
11
11
|
VLESSConfig,
|
|
12
12
|
TrojanConfig,
|
|
13
13
|
ShadowsocksConfig,
|
|
14
|
+
SocksConfig,
|
|
14
15
|
)
|
|
15
16
|
__version__ = V2KIT_VERSION
|
|
16
17
|
|
|
@@ -22,6 +23,7 @@ __all__ = [
|
|
|
22
23
|
"is_vless",
|
|
23
24
|
"is_trojan",
|
|
24
25
|
"is_shadowsocks",
|
|
26
|
+
"is_socks",
|
|
25
27
|
"relabel",
|
|
26
28
|
"encode_subscription",
|
|
27
29
|
"decode_subscription",
|
|
@@ -30,4 +32,5 @@ __all__ = [
|
|
|
30
32
|
"VMESSConfig",
|
|
31
33
|
"VLESSConfig",
|
|
32
34
|
"TrojanConfig",
|
|
33
|
-
"ShadowsocksConfig"
|
|
35
|
+
"ShadowsocksConfig",
|
|
36
|
+
"SocksConfig"]
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from typing import Iterable, List, Union
|
|
4
4
|
from .errors import V2kitValidationError
|
|
5
5
|
from .params import Protocol, INVALID_ITEMS_MESSAGE
|
|
6
|
-
from .utils import
|
|
6
|
+
from .utils import _is_protocol
|
|
7
7
|
from .utils import _encode_base64, _decode_base64
|
|
8
8
|
from .validators import _validate_non_empty_string
|
|
9
9
|
from .parsers import parse
|
|
@@ -46,6 +46,15 @@ def is_shadowsocks(uri: str) -> bool:
|
|
|
46
46
|
return _is_protocol(uri, Protocol.SHADOWSOCKS)
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
def is_socks(uri: str) -> bool:
|
|
50
|
+
"""
|
|
51
|
+
Check whether URI is SOCKS.
|
|
52
|
+
|
|
53
|
+
:param uri: V2Ray URI.
|
|
54
|
+
"""
|
|
55
|
+
return _is_protocol(uri, Protocol.SOCKS)
|
|
56
|
+
|
|
57
|
+
|
|
49
58
|
def relabel(uri: str, label: str) -> str:
|
|
50
59
|
"""
|
|
51
60
|
Relabel any supported URI.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""models module."""
|
|
2
|
+
from .base import BaseConfig
|
|
3
|
+
from .socks import SocksConfig
|
|
4
|
+
from .shadowsocks import ShadowsocksConfig
|
|
5
|
+
from .vless import VLESSConfig
|
|
6
|
+
from .vmess import VMESSConfig
|
|
7
|
+
from .trojan import TrojanConfig
|
|
8
|
+
|
|
9
|
+
__all__ = ["BaseConfig", "SocksConfig", "ShadowsocksConfig", "VLESSConfig", "VMESSConfig", "TrojanConfig"]
|