Mã nguồn đã công bố
Tải mã nguồn dạng ZIP
CH-J SM Mobile
Duyệt thư mục và tệp của một bản phát hành ứng dụng cụ thể.
CH-J / SM Mobile
175 tệp
sm-mobile-20261016T185235Z-8e93ecc1b59a
Ngày thêm: · Ngày dựng:
1
#!/usr/bin/env python32
"""Real, unprivileged loopback-only OpenSSH fixture on macOS/Linux. No Docker required."""3
import argparse,base64,getpass,json,os,pathlib,shutil,socket,subprocess,tempfile,time4
root=pathlib.Path(__file__).resolve().parents[1]5
p=argparse.ArgumentParser()6
p.add_argument('--device',help='Flutter device id; omitted runs host network tests')7
p.add_argument('--android',action='store_true',help='Use emulator host address 10.0.2.2')8
p.add_argument('--integration',default='integration_test/device_test.dart',help='Integration test file for --device')9
p.add_argument('--define',action='append',default=[],help='Extra NAME=VALUE dart define for --device')10
args=p.parse_args()11
sshd=shutil.which('sshd') or '/usr/sbin/sshd'12
# StrictModes requires a non-world-writable parent, unlike /tmp on macOS.13
cache=pathlib.Path.home()/'.cache/sm-mobile-tests';cache.mkdir(parents=True,exist_ok=True);cache.chmod(0o700)14
with tempfile.TemporaryDirectory(prefix='openssh-',dir=cache) as temporary:15
fixture=pathlib.Path(temporary)16
for name,phrase in [('host_key',''),('client_key','isolated-test-passphrase')]:17
subprocess.run(['ssh-keygen','-q','-t','ed25519','-N',phrase,'-f',str(fixture/name)],check=True)18
shutil.copy(fixture/'client_key.pub',fixture/'authorized_keys')19
(fixture/'authorized_keys').chmod(0o600)20
(fixture/'remote').mkdir()21
(fixture/'sshd_config').write_text(f'''Port 2222922
ListenAddress 127.0.0.123
HostKey {fixture}/host_key24
PidFile {fixture}/pid25
AuthorizedKeysFile {fixture}/authorized_keys26
StrictModes yes27
PubkeyAuthentication yes28
PasswordAuthentication no29
KbdInteractiveAuthentication no30
UsePAM no31
AllowUsers {getpass.getuser()}32
Subsystem sftp internal-sftp33
LogLevel ERROR34
''')35
with (fixture/'server.log').open('w') as log:36
server=subprocess.Popen([sshd,'-D','-e','-f',str(fixture/'sshd_config')],stdout=log,stderr=log)37
try:38
time.sleep(.5)39
if server.poll() is not None: raise SystemExit((fixture/'server.log').read_text())40
with socket.create_connection(('127.0.0.1',22229),timeout=3): pass41
env={**os.environ,'SM_OPENSSH_TEST':'1','SM_TEST_KEY':str(fixture/'client_key'),'SM_TEST_REMOTE_DIR':str(fixture/'remote')}42
if args.device:43
fingerprint=subprocess.check_output(['ssh-keygen','-lf',str(fixture/'host_key.pub'),'-E','sha256'],text=True).split()[1]44
defines={'SM_TEST_KEY_B64':base64.b64encode((fixture/'client_key').read_bytes()).decode(),45
'SM_TEST_FINGERPRINT':fingerprint,'SM_TEST_USER':getpass.getuser(),'SM_TEST_HOST':'10.0.2.2' if args.android else '127.0.0.1'}46
defines.update(d.split('=',1) for d in args.define)47
(fixture/'defines.json').write_text(json.dumps(defines));(fixture/'defines.json').chmod(0o600)48
command=['flutter','test',args.integration,'-d',args.device,'--dart-define-from-file='+str(fixture/'defines.json')]49
else: command=['flutter','test','test/network/openssh_test.dart','test/network/sftp_editor_test.dart','test/network/adaptive_session_test.dart','--reporter','expanded']50
subprocess.run(command,cwd=root,env=env,check=True)51
finally:52
server.terminate()53
try: server.wait(timeout=5)54
except subprocess.TimeoutExpired: server.kill();server.wait()SHA-256
cdad20ba3f5d99081d8eaa45d6f531813715cb5d0a39f368c4d6386352bc4065CH-J Proprietary Software License 1.14 · Mã nguồn được cung cấp theo CH-J Proprietary Software License 1.14. Việc công khai mã nguồn không thay đổi các điều khoản giấy phép và không cấp thêm quyền nào.
SHA-256 của tệp nén
46e427a43e87af091004f36145590bda8fe90086dfb0f631afeb5029fb0b5655