Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions YQroute.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"lng":"120.13070956263502","lat":"30.27050553852012"},{"lng":"120.13063320666667","lat":"30.270372977572208"},{"lng":"120.13056134222587","lat":"30.270217023284346"},{"lng":"120.13052990153302","lat":"30.270135147183037"},{"lng":"120.13048947778508","lat":"30.27006496761273"},{"lng":"120.13045803709223","lat":"30.26998699025295"},{"lng":"120.13043108792692","lat":"30.26993240606388"},{"lng":"120.13037718959633","lat":"30.269819338717568"},{"lng":"120.13031879973818","lat":"30.269682877952008"},{"lng":"120.13027388446268","lat":"30.26959320363032"},{"lng":"120.13025142682493","lat":"30.269480135889374"},{"lng":"120.13025142682493","lat":"30.26942165252348"},{"lng":"120.13026490140759","lat":"30.269359270227735"},{"lng":"120.13027837599023","lat":"30.269304685686116"},{"lng":"120.13031430821063","lat":"30.269257898911754"},{"lng":"120.13036820654122","lat":"30.269199415412135"},{"lng":"120.13043557945447","lat":"30.269152628587094"},{"lng":"120.13054786764322","lat":"30.269117538453532"},{"lng":"120.13065566430441","lat":"30.26909804392941"},{"lng":"120.13074998638297","lat":"30.269101942834556"},{"lng":"120.13084879998907","lat":"30.26912923516613"},{"lng":"120.13097456276046","lat":"30.269246202214642"},{"lng":"120.13108235942165","lat":"30.26948793366883"},{"lng":"120.13117668150021","lat":"30.269706271239713"},{"lng":"120.131248545941","lat":"30.269901215084936"},{"lng":"120.131248545941","lat":"30.269901215084936"},{"lng":"120.13133388496445","lat":"30.270061068746227"},{"lng":"120.13141473246036","lat":"30.270232618724396"},{"lng":"120.1314012578777","lat":"30.270404168399743"},{"lng":"120.1314012578777","lat":"30.270404168399743"},{"lng":"120.13135185107465","lat":"30.27050553852012"},{"lng":"120.13135185107465","lat":"30.27050553852012"},{"lng":"120.1312844781614","lat":"30.27058351546384"},{"lng":"120.13120812219306","lat":"30.270622503912236"},{"lng":"120.1311227831696","lat":"30.270649795816816"},{"lng":"120.1311227831696","lat":"30.270649795816816"},{"lng":"120.13104193567371","lat":"30.270657593502428"},{"lng":"120.13104193567371","lat":"30.270657593502428"},{"lng":"120.13095659665026","lat":"30.27064589697377"},{"lng":"120.13095659665026","lat":"30.27064589697377"},{"lng":"120.13088024068192","lat":"30.270638099287222"},{"lng":"120.13088024068192","lat":"30.270638099287222"},{"lng":"120.13079041013091","lat":"30.270599110845076"},{"lng":"120.13079041013091","lat":"30.270599110845076"}
1 change: 1 addition & 0 deletions ZJGroute_East.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"lng":"120.08964801777392","lat":"30.31198043310912"},{"lng":"120.08942344139643","lat":"30.31184403157866"},{"lng":"120.08936056001073","lat":"30.31165696631077"},{"lng":"120.08938750917603","lat":"30.31140754539256"},{"lng":"120.08945039056174","lat":"30.31121268485407"},{"lng":"120.08949530583723","lat":"30.310986646139167"},{"lng":"120.08952225500254","lat":"30.310838551523187"},{"lng":"120.08957615333313","lat":"30.31065927879089"},{"lng":"120.08966598388413","lat":"30.310503389189215"},{"lng":"120.08982767887592","lat":"30.310402060813825"},{"lng":"120.09007920441871","lat":"30.310417649801536"},{"lng":"120.09033072996151","lat":"30.31060082021961"},{"lng":"120.09031276385132","lat":"30.310850243211604"},{"lng":"120.09026335704826","lat":"30.311119151656598"},{"lng":"120.09023640788295","lat":"30.311310115172233"},{"lng":"120.09017801802482","lat":"30.311606302738646"},{"lng":"120.09011064511157","lat":"30.311812854059056"},{"lng":"120.08991301789936","lat":"30.311968741556882"}
1 change: 1 addition & 0 deletions ZJGroute_West.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"lng":"120.08845086732593","lat":"30.310177948123332"},{"lng":"120.08860357926262","lat":"30.310158461840157"},{"lng":"120.08868891828608","lat":"30.31021302342319"},{"lng":"120.08881917258502","lat":"30.310290968488587"},{"lng":"120.08888205397072","lat":"30.31042737220237"},{"lng":"120.08890002008091","lat":"30.310602748124037"},{"lng":"120.08886408786051","lat":"30.310836582193172"},{"lng":"120.08881468105747","lat":"30.31100806015239"},{"lng":"120.08875629119932","lat":"30.31120292110182"},{"lng":"120.08874281661667","lat":"30.311393884452592"},{"lng":"120.08867095217587","lat":"30.311588744627155"},{"lng":"120.08857663009732","lat":"30.311717352128007"},{"lng":"120.08844188427084","lat":"30.31176411844969"},{"lng":"120.08827120622394","lat":"30.31177191283444"},{"lng":"120.08816340956274","lat":"30.311725146516526"},{"lng":"120.08802866373624","lat":"30.311678380176055"},{"lng":"120.0879163755475","lat":"30.311588744627155"},{"lng":"120.0879163755475","lat":"30.311452342546055"},{"lng":"120.08793883318525","lat":"30.311292557007146"},{"lng":"120.0879433247128","lat":"30.311113285113688"},{"lng":"120.0879792569332","lat":"30.31089114339489"},{"lng":"120.08805561290154","lat":"30.310626131556315"},{"lng":"120.08810951123213","lat":"30.310329940997807"},{"lng":"120.08819934178314","lat":"30.310201331657986"},{"lng":"120.08832959608209","lat":"30.31018574263551"}
24 changes: 18 additions & 6 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import yaml
import os

YAML_FILE = os.path.join(os.path.dirname(__file__), 'config.yaml')
class Config:
def __init__(self):
with open("config.yaml", 'r') as f:
config = yaml.safe_load(f)
for i in config:
setattr(self, i, config[i])

def __init__(self,yaml_path=None):
yaml_path=yaml_path or os.path.join(os.path.dirname(__file__),'config.yaml')
with open(yaml_path,encoding='utf-8') as f:
y = yaml.safe_load(f) or {}
for k,v in y.items():
setattr(self, k, v)
if not hasattr(self,'routeConfig'):
self.routeConfig = None
if not hasattr(self, 'pace_default'):
self.pace_default = '530'
def save_pace_default(self, pace_str):
with open(YAML_FILE, encoding='utf-8') as f:
y = yaml.safe_load(f) or {}
y['pace_default'] = pace_str
with open(YAML_FILE, 'w', encoding='utf-8') as f:
yaml.safe_dump(y, f, allow_unicode=True)

config = Config()
7 changes: 4 additions & 3 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
imageDir: DeveloperDiskImage
libimobiledeviceDir: libimobiledevice
pace_default: '530'
routeConfig: ZJGroute_East.txt
v: 3.3
routeConfig: "HNroute.txt"
libimobiledeviceDir: "libimobiledevice"
imageDir: "DeveloperDiskImage"
30 changes: 29 additions & 1 deletion init/route.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
import config
import os

from util import route

ROUTE_FILES = [
'ZJGRoute_East.txt',
'ZJGRoute_West.txt',
'YQRoute.txt',
'HNRoute.txt'
]
def choose_route_file():
"""让用户从预置路线里选"""
print('===== 当前可用路线 =====')
for idx, f in enumerate(ROUTE_FILES, 1):
print(f'{idx}: {f}')
while True:
try:
sel = int(input('请选择路线编号(输入数字后回车): '))
if 1 <= sel <= len(ROUTE_FILES):
chosen = ROUTE_FILES[sel-1]
if not os.path.isfile(chosen):
print(f'路线文件 {chosen} 不存在,请确认路径')
continue
config.config.routeConfig = chosen
print(f'已选择路线: {chosen}')
return
except ValueError:
pass
print('不合法的选择,请重试')


def get_route():
with open(config.config.routeConfig) as myFile:
with open(config.config.routeConfig,encoding='utf-8') as myFile:
loc = route.parse_route(myFile.read())
return loc
32 changes: 31 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,31 @@
logging.getLogger('urllib3.connectionpool').setLevel(logging.DEBUG if debug else logging.WARNING)



# ===== 配速:首次交互 + 记住上次 =====
def ask_pace(default_pace_str):
while True:
pace_str = input(f"请输入配速(分钟秒钟,如 530 表示 5′30″/km)"
f" [直接回车={default_pace_str}]: ").strip()
if not pace_str: # 回车
pace_str = default_pace_str
if len(pace_str) < 3:
print("格式错误,重试!")
continue
try:
minutes = int(pace_str[:-2])
seconds = int(pace_str[-2:])
if not (0 <= seconds < 60):
raise ValueError
total_min = minutes + seconds / 60
if total_min <= 0:
raise ValueError
v = 1000 / (total_min * 60)
print(f"→ 已设置 {minutes}′{seconds:02d}″/km ≈ {v:.2f} m/s")
return v, pace_str # 返回速度 + 字符串(留给下次当默认值)
except ValueError:
print("输入无效,示例:530")
# ==========================

async def main():
logger = logging.getLogger(__name__)
coloredlogs.install(level=logging.INFO)
Expand All @@ -40,6 +64,12 @@ async def main():

init.init()
logger.info("init done")
# ===== 新增:交互选路线 =====
route.choose_route_file() # 把用户选择写进 config.config.routeConfig
# ===========================

config.config.v, new_pace = ask_pace(config.config.pace_default) # 来自上次运行的默认值
config.config.save_pace_default(new_pace) #存储本次使用的配速

logger.info("trying to start tunnel")
original_sigint_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
Expand Down
235 changes: 235 additions & 0 deletions venv/Lib/site-packages/Crypto/Cipher/AES.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
# -*- coding: utf-8 -*-
#
# Cipher/AES.py : AES
#
# ===================================================================
# The contents of this file are dedicated to the public domain. To
# the extent that dedication to the public domain is not available,
# everyone is granted a worldwide, perpetual, royalty-free,
# non-exclusive license to exercise all rights associated with the
# contents of this file for any purpose whatsoever.
# No rights are reserved.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# ===================================================================

import sys

from Crypto.Cipher import _create_cipher
from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
VoidPointer, SmartPointer,
c_size_t, c_uint8_ptr)

from Crypto.Util import _cpu_features
from Crypto.Random import get_random_bytes

MODE_ECB = 1 #: Electronic Code Book (:ref:`ecb_mode`)
MODE_CBC = 2 #: Cipher-Block Chaining (:ref:`cbc_mode`)
MODE_CFB = 3 #: Cipher Feedback (:ref:`cfb_mode`)
MODE_OFB = 5 #: Output Feedback (:ref:`ofb_mode`)
MODE_CTR = 6 #: Counter mode (:ref:`ctr_mode`)
MODE_OPENPGP = 7 #: OpenPGP mode (:ref:`openpgp_mode`)
MODE_CCM = 8 #: Counter with CBC-MAC (:ref:`ccm_mode`)
MODE_EAX = 9 #: :ref:`eax_mode`
MODE_SIV = 10 #: Synthetic Initialization Vector (:ref:`siv_mode`)
MODE_GCM = 11 #: Galois Counter Mode (:ref:`gcm_mode`)
MODE_OCB = 12 #: Offset Code Book (:ref:`ocb_mode`)
MODE_KW = 13 #: Key Wrap (:ref:`kw_mode`)
MODE_KWP = 14 #: Key Wrap with Padding (:ref:`kwp_mode`)

_cproto = """
int AES_start_operation(const uint8_t key[],
size_t key_len,
void **pResult);
int AES_encrypt(const void *state,
const uint8_t *in,
uint8_t *out,
size_t data_len);
int AES_decrypt(const void *state,
const uint8_t *in,
uint8_t *out,
size_t data_len);
int AES_stop_operation(void *state);
"""


# Load portable AES
_raw_aes_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_aes",
_cproto)

# Try to load AES with AES NI instructions
try:
_raw_aesni_lib = None
if _cpu_features.have_aes_ni():
_raw_aesni_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_aesni",
_cproto.replace("AES",
"AESNI"))
# _raw_aesni may not have been compiled in
except OSError:
pass


def _create_base_cipher(dict_parameters):
"""This method instantiates and returns a handle to a low-level
base cipher. It will absorb named parameters in the process."""

use_aesni = dict_parameters.pop("use_aesni", True)

try:
key = dict_parameters.pop("key")
except KeyError:
raise TypeError("Missing 'key' parameter")

if len(key) not in key_size:
raise ValueError("Incorrect AES key length (%d bytes)" % len(key))

if use_aesni and _raw_aesni_lib:
start_operation = _raw_aesni_lib.AESNI_start_operation
stop_operation = _raw_aesni_lib.AESNI_stop_operation
else:
start_operation = _raw_aes_lib.AES_start_operation
stop_operation = _raw_aes_lib.AES_stop_operation

cipher = VoidPointer()
result = start_operation(c_uint8_ptr(key),
c_size_t(len(key)),
cipher.address_of())
if result:
raise ValueError("Error %X while instantiating the AES cipher"
% result)
return SmartPointer(cipher.get(), stop_operation)


def _derive_Poly1305_key_pair(key, nonce):
"""Derive a tuple (r, s, nonce) for a Poly1305 MAC.
If nonce is ``None``, a new 16-byte nonce is generated.
"""

if len(key) != 32:
raise ValueError("Poly1305 with AES requires a 32-byte key")

if nonce is None:
nonce = get_random_bytes(16)
elif len(nonce) != 16:
raise ValueError("Poly1305 with AES requires a 16-byte nonce")

s = new(key[:16], MODE_ECB).encrypt(nonce)
return key[16:], s, nonce


def new(key, mode, *args, **kwargs):
"""Create a new AES cipher.
Args:
key(bytes/bytearray/memoryview):
The secret key to use in the symmetric cipher.
It must be 16 (*AES-128)*, 24 (*AES-192*) or 32 (*AES-256*) bytes long.
For ``MODE_SIV`` only, it doubles to 32, 48, or 64 bytes.
mode (a ``MODE_*`` constant):
The chaining mode to use for encryption or decryption.
If in doubt, use ``MODE_EAX``.
Keyword Args:
iv (bytes/bytearray/memoryview):
(Only applicable for ``MODE_CBC``, ``MODE_CFB``, ``MODE_OFB``,
and ``MODE_OPENPGP`` modes).
The initialization vector to use for encryption or decryption.
For ``MODE_CBC``, ``MODE_CFB``, and ``MODE_OFB`` it must be 16 bytes long.
For ``MODE_OPENPGP`` mode only,
it must be 16 bytes long for encryption
and 18 bytes for decryption (in the latter case, it is
actually the *encrypted* IV which was prefixed to the ciphertext).
If not provided, a random byte string is generated (you must then
read its value with the :attr:`iv` attribute).
nonce (bytes/bytearray/memoryview):
(Only applicable for ``MODE_CCM``, ``MODE_EAX``, ``MODE_GCM``,
``MODE_SIV``, ``MODE_OCB``, and ``MODE_CTR``).
A value that must never be reused for any other encryption done
with this key (except possibly for ``MODE_SIV``, see below).
For ``MODE_EAX``, ``MODE_GCM`` and ``MODE_SIV`` there are no
restrictions on its length (recommended: **16** bytes).
For ``MODE_CCM``, its length must be in the range **[7..13]**.
Bear in mind that with CCM there is a trade-off between nonce
length and maximum message size. Recommendation: **11** bytes.
For ``MODE_OCB``, its length must be in the range **[1..15]**
(recommended: **15**).
For ``MODE_CTR``, its length must be in the range **[0..15]**
(recommended: **8**).
For ``MODE_SIV``, the nonce is optional, if it is not specified,
then no nonce is being used, which renders the encryption
deterministic.
If not provided, for modes other than ``MODE_SIV``, a random
byte string of the recommended length is used (you must then
read its value with the :attr:`nonce` attribute).
segment_size (integer):
(Only ``MODE_CFB``).The number of **bits** the plaintext and ciphertext
are segmented in. It must be a multiple of 8.
If not specified, it will be assumed to be 8.
mac_len (integer):
(Only ``MODE_EAX``, ``MODE_GCM``, ``MODE_OCB``, ``MODE_CCM``)
Length of the authentication tag, in bytes.
It must be even and in the range **[4..16]**.
The recommended value (and the default, if not specified) is **16**.
msg_len (integer):
(Only ``MODE_CCM``). Length of the message to (de)cipher.
If not specified, ``encrypt`` must be called with the entire message.
Similarly, ``decrypt`` can only be called once.
assoc_len (integer):
(Only ``MODE_CCM``). Length of the associated data.
If not specified, all associated data is buffered internally,
which may represent a problem for very large messages.
initial_value (integer or bytes/bytearray/memoryview):
(Only ``MODE_CTR``).
The initial value for the counter. If not present, the cipher will
start counting from 0. The value is incremented by one for each block.
The counter number is encoded in big endian mode.
counter (object):
(Only ``MODE_CTR``).
Instance of ``Crypto.Util.Counter``, which allows full customization
of the counter block. This parameter is incompatible to both ``nonce``
and ``initial_value``.
use_aesni: (boolean):
Use Intel AES-NI hardware extensions (default: use if available).
Returns:
an AES object, of the applicable mode.
"""

kwargs["add_aes_modes"] = True
return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)


# Size of a data block (in bytes)
block_size = 16
# Size of a key (in bytes)
key_size = (16, 24, 32)
Loading